index.tsx 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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: 4
  28. },
  29. tableList: [
  30. {
  31. studentName: '胡小小',
  32. phone: '17625367893',
  33. sex: '0',
  34. className: '一年级3班',
  35. classType: 'normal',
  36. studentType: 'member'
  37. },
  38. {
  39. studentName: '丁曼蓉',
  40. phone: '14677789334',
  41. sex: '1',
  42. className: '一年级3班',
  43. classType: 'normal',
  44. studentType: ''
  45. },
  46. {
  47. studentName: '李书意',
  48. phone: '13467857893',
  49. sex: '1',
  50. className: '一年级3班',
  51. classType: 'graduate',
  52. studentType: 'member'
  53. },
  54. {
  55. studentName: '夏小满',
  56. phone: '13925367893',
  57. sex: '0',
  58. className: '一年级3班',
  59. classType: 'none',
  60. studentType: ''
  61. }
  62. ] as any
  63. });
  64. const search = () => {
  65. console.log('search', state);
  66. };
  67. const onReset = () => {
  68. console.log('search');
  69. };
  70. const getList = () => {
  71. console.log('getList');
  72. };
  73. const columns = () => {
  74. return [
  75. {
  76. title: '姓名',
  77. key: 'studentName'
  78. },
  79. {
  80. title: '手机号',
  81. key: 'phone'
  82. },
  83. {
  84. title: '性别',
  85. key: 'sex',
  86. render(row: any) {
  87. return <>{row.sex == '0' ? '女' : '男'}</>;
  88. }
  89. },
  90. {
  91. title: '班级',
  92. key: 'className',
  93. render(row: any) {
  94. return (
  95. <>
  96. <div>
  97. {row.classType == 'none' ? (
  98. <p style={{ color: '#EA4132' }}>{'未在班级'}</p>
  99. ) : null}
  100. {row.classType == 'graduate' ? (
  101. <p style={{ color: '#AAAAAA' }}>{'毕业'}</p>
  102. ) : null}
  103. {row.classType == 'normal' ? <p>{row.className}</p> : null}
  104. </div>
  105. </>
  106. );
  107. }
  108. },
  109. {
  110. title: '学生类型',
  111. key: 'studentType',
  112. render(row: any) {
  113. return <>{row.studentType == 'member' ? '会员' : '普通'}</>;
  114. }
  115. },
  116. {
  117. title: '操作',
  118. key: 'id',
  119. render(row: any) {
  120. return (
  121. <NButton text type="primary">
  122. 详情
  123. </NButton>
  124. );
  125. }
  126. }
  127. ];
  128. };
  129. return () => (
  130. <div class={styles.listWrap}>
  131. <div class={styles.searchList}>
  132. <NForm label-placement="left" inline>
  133. <NFormItem>
  134. <SearchInput
  135. class={styles.searchInput}
  136. searchWord={state.searchWord}
  137. onChangeValue={(val: string) =>
  138. (state.searchWord = val)
  139. }></SearchInput>
  140. </NFormItem>
  141. <NFormItem>
  142. <CSelect
  143. {...({
  144. options: [
  145. {
  146. label:
  147. "Everybody's Got Something to Hide Except Me and My Monkey",
  148. value: 'song0'
  149. },
  150. {
  151. label: 'Drive My Car',
  152. value: 'song1'
  153. }
  154. ],
  155. placeholder: '学生声部',
  156. clearable: true
  157. } as any)}
  158. v-model:value={state.orchestraType}></CSelect>
  159. </NFormItem>
  160. <NFormItem>
  161. <CSelect
  162. {...({
  163. options: [
  164. {
  165. label:
  166. "Everybody's Got Something to Hide Except Me and My Monkey",
  167. value: 'song0'
  168. },
  169. {
  170. label: 'Drive My Car',
  171. value: 'song1'
  172. }
  173. ],
  174. placeholder: '年级班级',
  175. clearable: true
  176. } as any)}
  177. v-model:value={state.orchestraType}></CSelect>
  178. </NFormItem>
  179. <NFormItem>
  180. <CSelect
  181. {...({
  182. options: [
  183. {
  184. label:
  185. "Everybody's Got Something to Hide Except Me and My Monkey",
  186. value: 'song0'
  187. },
  188. {
  189. label: 'Drive My Car',
  190. value: 'song1'
  191. }
  192. ],
  193. placeholder: '学生类型',
  194. clearable: true
  195. } as any)}
  196. v-model:value={state.orchestraType}></CSelect>
  197. </NFormItem>
  198. <NFormItem>
  199. <NSpace justify="end">
  200. <NButton type="primary" ghost class="resetBtn" onClick={search}>
  201. 搜索
  202. </NButton>
  203. <NButton type="primary" class="searchBtn" onClick={onReset}>
  204. 重置
  205. </NButton>
  206. </NSpace>
  207. </NFormItem>
  208. </NForm>
  209. </div>
  210. <NButton
  211. class={styles.addBtn}
  212. type="primary"
  213. v-slots={{
  214. icon: () => (
  215. <>
  216. <NImage class={styles.addBtnIcon} src={add}></NImage>
  217. </>
  218. )
  219. }}>
  220. 新增学生
  221. </NButton>
  222. <div class={styles.tableWrap}>
  223. <NDataTable
  224. class={styles.classTable}
  225. loading={state.loading}
  226. columns={columns()}
  227. data={state.tableList}></NDataTable>
  228. <Pagination
  229. v-model:page={state.pagination.page}
  230. v-model:pageSize={state.pagination.rows}
  231. v-model:pageTotal={state.pagination.pageTotal}
  232. onList={getList}
  233. sync
  234. saveKey="orchestraRegistration-key"
  235. />
  236. </div>
  237. </div>
  238. );
  239. }
  240. });