crud.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import type { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  2. import { dict } from '@fast-crud/fast-crud';
  3. import importStudent from '@/public/学员导入.xlsx';
  4. import { addRequest, delRequest, editRequest, pageRequest } from './api';
  5. function curd({ context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  6. return {
  7. crudOptions: {
  8. container: {
  9. is: 'fs-layout-card'
  10. },
  11. request: {
  12. pageRequest: async ({ page, query }) => {
  13. const { total, data } = await pageRequest(page.offset + 1, page.limit, query);
  14. return { records: data, total, currentPage: page.offset, pageSize: page.limit };
  15. },
  16. addRequest: ({ form }) => {
  17. return addRequest(form);
  18. },
  19. editRequest: ({ form }) => {
  20. editRequest(form);
  21. },
  22. delRequest: ({ row }) => {
  23. return delRequest(row.id);
  24. }
  25. },
  26. toolbar: {
  27. show: true
  28. },
  29. actionbar: {
  30. show: true,
  31. buttons: {
  32. add: {
  33. text: '新增学员',
  34. title: '使用表单新增学员',
  35. circle: false,
  36. tooltip: {
  37. slots: {
  38. default() {
  39. return '使用表单新增学员';
  40. }
  41. }
  42. }
  43. },
  44. importAdd: {
  45. text: 'Excel文件导入',
  46. title: '上传Excel文件批量导入学员',
  47. icon: '',
  48. iconRight: '',
  49. circle: false,
  50. style: {},
  51. disabled: false,
  52. tooltip: {
  53. slots: {
  54. default() {
  55. return '上传Excel文件,支持xlsx 格式';
  56. }
  57. }
  58. },
  59. show: true,
  60. click: () => {
  61. context?.openModal();
  62. },
  63. order: 1
  64. },
  65. exportAdd: {
  66. text: '下载导入模板',
  67. circle: false,
  68. disabled: false,
  69. tooltip: {
  70. slots: {
  71. default() {
  72. return '下载导入学员的 Excel 模板';
  73. }
  74. }
  75. },
  76. show: true,
  77. click: () => {
  78. window.location.href = importStudent;
  79. },
  80. order: 1
  81. }
  82. }
  83. },
  84. columns: {
  85. id: {
  86. search: { show: false },
  87. form: { show: false },
  88. column: {
  89. show: false
  90. }
  91. },
  92. studentName: {
  93. title: '姓名',
  94. type: 'text',
  95. search: { show: true },
  96. column: {
  97. resizable: true,
  98. width: 60,
  99. align: 'center',
  100. fixed: 'left'
  101. }
  102. },
  103. phone: {
  104. title: '手机',
  105. type: 'text',
  106. search: { show: true },
  107. column: {
  108. resizable: true,
  109. align: 'center',
  110. fixed: 'left'
  111. }
  112. },
  113. studentIdnumber: {
  114. title: '身份证号',
  115. type: 'text',
  116. search: { show: true },
  117. column: {
  118. resizable: true,
  119. align: 'center',
  120. fixed: 'left'
  121. }
  122. },
  123. university: {
  124. title: '学校',
  125. type: 'text',
  126. search: { show: true },
  127. column: {
  128. resizable: true,
  129. align: 'center',
  130. fixed: 'left'
  131. }
  132. },
  133. address: {
  134. title: '住址',
  135. type: 'text',
  136. search: { show: true },
  137. column: {
  138. resizable: true,
  139. align: 'center',
  140. fixed: 'left'
  141. }
  142. },
  143. email: {
  144. title: '邮箱',
  145. type: 'text',
  146. search: { show: true },
  147. column: {
  148. resizable: true,
  149. align: 'center',
  150. fixed: 'left'
  151. }
  152. },
  153. birthdate: {
  154. title: '生日',
  155. type: 'easDate',
  156. search: { show: true },
  157. column: {
  158. resizable: true,
  159. align: 'center'
  160. }
  161. },
  162. studentNumber: {
  163. title: '学生档案号',
  164. type: 'text',
  165. search: { show: true },
  166. column: {
  167. resizable: true,
  168. align: 'center'
  169. },
  170. form: {
  171. show: false
  172. }
  173. },
  174. enrollmentDate: {
  175. title: '入学时间',
  176. type: 'easDate',
  177. search: { show: true },
  178. column: {
  179. resizable: true,
  180. width: 100
  181. }
  182. },
  183. graduationDate: {
  184. title: '毕业时间',
  185. type: 'easDate',
  186. search: { show: true },
  187. column: {
  188. resizable: true,
  189. width: 100
  190. }
  191. },
  192. graduation: {
  193. title: '是否结业',
  194. type: 'dict-select',
  195. dict: dict({
  196. data: [
  197. { value: 'Y', label: '已结业' },
  198. { value: 'N', label: '在学习' }
  199. ]
  200. }),
  201. column: {
  202. resizable: true,
  203. width: 40
  204. }
  205. },
  206. gender: {
  207. title: '性别',
  208. type: 'dict-select',
  209. dict: dict({
  210. data: [
  211. { value: 'M', label: '男' },
  212. { value: 'F', label: '女' }
  213. ]
  214. }),
  215. column: {
  216. resizable: true,
  217. width: 40
  218. }
  219. }
  220. }
  221. }
  222. };
  223. }
  224. export default curd;