crud.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import type { CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  2. import { dict } from '@fast-crud/fast-crud';
  3. import { queryClassStudent, submitGroupStudentUpdate, submitGroupStudentDelete } from './api';
  4. function curd(): CreateCrudOptionsRet {
  5. return {
  6. crudOptions: {
  7. container: {
  8. is: 'fs-layout-card'
  9. },
  10. pagination: {
  11. show: false
  12. },
  13. request: {
  14. pageRequest: async ({ page, query }) => {
  15. query.groupId = 1;
  16. const { data } = await queryClassStudent(query);
  17. return { records: data, total: 0, currentPage: page.offset, pageSize: page.limit };
  18. },
  19. addRequest: () => {},
  20. editRequest: ({ form }) => {
  21. return submitGroupStudentUpdate(form);
  22. },
  23. delRequest: ({ row }) => {
  24. return submitGroupStudentDelete(Number(row.id));
  25. }
  26. },
  27. toolbar: {
  28. show: true
  29. },
  30. actionbar: {
  31. show: false
  32. },
  33. columns: {
  34. id: {
  35. title: 'ID',
  36. type: 'number',
  37. search: { show: false },
  38. show: false
  39. },
  40. studentId: {
  41. title: '学生ID',
  42. type: 'number',
  43. search: { show: true },
  44. column: {
  45. editable: {
  46. disabled: true
  47. }
  48. }
  49. },
  50. studentName: {
  51. title: '学生姓名',
  52. type: 'text',
  53. search: { show: true },
  54. column: {
  55. editable: {
  56. disabled: false
  57. }
  58. }
  59. },
  60. avatar: {
  61. title: '头像',
  62. type: 'image'
  63. },
  64. studentNumber: {
  65. title: '学生学号',
  66. type: 'text',
  67. search: { show: true }
  68. },
  69. managerName: {
  70. title: '班主任姓名',
  71. type: 'text'
  72. },
  73. phone: {
  74. title: '手机号码',
  75. type: 'text',
  76. search: { show: true }
  77. },
  78. email: {
  79. title: '电子邮箱',
  80. type: 'text',
  81. search: { show: true }
  82. },
  83. gender: {
  84. title: '性别',
  85. type: 'dict-select',
  86. dict: dict({
  87. data: [
  88. { value: 'M', label: '男' },
  89. { value: 'F', label: '女' }
  90. ]
  91. }),
  92. column: {
  93. resizable: true,
  94. width: 50
  95. },
  96. search: { show: true }
  97. },
  98. enrollmentDate: {
  99. title: '入学日期',
  100. type: 'easDate'
  101. },
  102. type: {
  103. title: '类别',
  104. type: 'dict-select',
  105. dict: dict({
  106. data: [
  107. { value: '正式', label: '正式' },
  108. { value: '旁听', label: '旁听' },
  109. { value: '留级', label: '留级' },
  110. { value: '休学', label: '休学' },
  111. { value: '暂停', label: '暂停' },
  112. { value: '其他', label: '其他' }
  113. ]
  114. }),
  115. column: {
  116. resizable: true,
  117. width: 60
  118. },
  119. search: { show: true }
  120. },
  121. admissionsName: {
  122. title: '招生负责人',
  123. type: 'text'
  124. }
  125. }
  126. }
  127. };
  128. }
  129. export default curd;