index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import { defineComponent, reactive } from 'vue';
  2. import styles from './index.module.less';
  3. import {
  4. NButton,
  5. NDataTable,
  6. NForm,
  7. NFormItem,
  8. NImage,
  9. NSelect,
  10. NSpace
  11. } from 'naive-ui';
  12. import SearchInput from '@/components/searchInput';
  13. import CSelect from '@/components/CSelect';
  14. import Pagination from '@/components/pagination';
  15. import add from './images/add.png';
  16. export default defineComponent({
  17. name: 'student-studentList',
  18. setup(props, { emit }) {
  19. const state = reactive({
  20. searchWord: '',
  21. orchestraType: null,
  22. courseTypeCode: null,
  23. loading: false,
  24. pagination: {
  25. page: 1,
  26. rows: 10,
  27. pageTotal: 0
  28. },
  29. tableList: [] as any
  30. });
  31. const search = () => {
  32. console.log('search', state);
  33. };
  34. const onReset = () => {
  35. console.log('search');
  36. };
  37. const getList = () => {
  38. console.log('getList');
  39. };
  40. const columns = () => {
  41. return [
  42. {
  43. title: '姓名',
  44. key: 'id'
  45. },
  46. {
  47. title: '手机号',
  48. key: 'id'
  49. },
  50. {
  51. title: '性别',
  52. key: 'id'
  53. },
  54. {
  55. title: '乐器',
  56. key: 'id'
  57. },
  58. {
  59. title: '班级',
  60. key: 'id'
  61. },
  62. {
  63. title: '学生类型',
  64. key: 'id'
  65. },
  66. {
  67. title: '操作',
  68. key: 'id'
  69. }
  70. ];
  71. };
  72. return () => (
  73. <div class={styles.listWrap}>
  74. <div class={styles.searchList}>
  75. <NForm label-placement="left" inline>
  76. <NFormItem>
  77. <SearchInput
  78. class={styles.searchInput}
  79. searchWord={state.searchWord}
  80. onChangeValue={(val: string) =>
  81. (state.searchWord = val)
  82. }></SearchInput>
  83. </NFormItem>
  84. <NFormItem>
  85. <CSelect
  86. {...({
  87. options: [
  88. {
  89. label:
  90. "Everybody's Got Something to Hide Except Me and My Monkey",
  91. value: 'song0'
  92. },
  93. {
  94. label: 'Drive My Car',
  95. value: 'song1'
  96. }
  97. ],
  98. placeholder: '学生声部',
  99. clearable: true
  100. } as any)}
  101. v-model:value={state.orchestraType}></CSelect>
  102. </NFormItem>
  103. <NFormItem>
  104. <CSelect
  105. {...({
  106. options: [
  107. {
  108. label:
  109. "Everybody's Got Something to Hide Except Me and My Monkey",
  110. value: 'song0'
  111. },
  112. {
  113. label: 'Drive My Car',
  114. value: 'song1'
  115. }
  116. ],
  117. placeholder: '年级班级',
  118. clearable: true
  119. } as any)}
  120. v-model:value={state.orchestraType}></CSelect>
  121. </NFormItem>
  122. <NFormItem>
  123. <CSelect
  124. {...({
  125. options: [
  126. {
  127. label:
  128. "Everybody's Got Something to Hide Except Me and My Monkey",
  129. value: 'song0'
  130. },
  131. {
  132. label: 'Drive My Car',
  133. value: 'song1'
  134. }
  135. ],
  136. placeholder: '学生类型',
  137. clearable: true
  138. } as any)}
  139. v-model:value={state.orchestraType}></CSelect>
  140. </NFormItem>
  141. <NFormItem>
  142. <NSpace justify="end">
  143. <NButton type="primary" ghost class="resetBtn" onClick={search}>
  144. 搜索
  145. </NButton>
  146. <NButton type="primary" class="searchBtn" onClick={onReset}>
  147. 重置
  148. </NButton>
  149. </NSpace>
  150. </NFormItem>
  151. </NForm>
  152. </div>
  153. <NButton
  154. class={styles.addBtn}
  155. type="primary"
  156. v-slots={{
  157. icon: () => (
  158. <>
  159. <NImage class={styles.addBtnIcon} src={add}></NImage>
  160. </>
  161. )
  162. }}>
  163. 新增学生
  164. </NButton>
  165. <div class={styles.tableWrap}>
  166. <NDataTable
  167. class={styles.classTable}
  168. loading={state.loading}
  169. columns={columns()}
  170. data={state.tableList}></NDataTable>
  171. <Pagination
  172. v-model:page={state.pagination.page}
  173. v-model:pageSize={state.pagination.rows}
  174. v-model:pageTotal={state.pagination.pageTotal}
  175. onList={getList}
  176. sync
  177. saveKey="orchestraRegistration-key"
  178. />
  179. </div>
  180. </div>
  181. );
  182. }
  183. });