crud.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import type { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  2. import { dict } from '@fast-crud/fast-crud';
  3. import { updateAttendance, getStudentList } from './api';
  4. function curd({ context }: CreateCrudOptionsProps): CreateCrudOptionsRet {
  5. return {
  6. crudOptions: {
  7. container: {
  8. is: 'fs-layout-card'
  9. },
  10. search: {
  11. show: false
  12. },
  13. pagination: {
  14. show: false
  15. },
  16. request: {
  17. pageRequest: async ({ page, query }) => {
  18. const queryBody = {
  19. id: context?.route.query.scheduleId ?? 9999999
  20. };
  21. const { data } = await getStudentList(Object.assign(queryBody, query));
  22. return { records: data, total: 0, currentPage: page.offset, pageSize: page.limit };
  23. },
  24. addRequest: () => {
  25. return Promise.resolve();
  26. },
  27. editRequest: ({ form }) => {
  28. form.scheduleId = form.id;
  29. updateAttendance(form);
  30. }
  31. },
  32. toolbar: {
  33. show: true
  34. },
  35. actionbar: {
  36. show: false
  37. },
  38. rowHandle: {
  39. buttons: {
  40. remove: {
  41. show: false
  42. }
  43. }
  44. },
  45. columns: {
  46. startTime: {
  47. title: '上课时间',
  48. type: 'easDateTime',
  49. sortable: true,
  50. column: {
  51. width: 160
  52. }
  53. },
  54. endTime: {
  55. title: '下课时间',
  56. type: 'easDateTime',
  57. sortable: true,
  58. column: {
  59. width: 160
  60. }
  61. },
  62. id: {
  63. title: '排课ID',
  64. type: 'text',
  65. column: {
  66. show: false
  67. }
  68. },
  69. checkinDate: {
  70. title: '签到日期',
  71. type: 'easDateTime',
  72. sortable: true,
  73. column: {
  74. show: false
  75. }
  76. },
  77. morning: {
  78. title: '上午出勤状态',
  79. type: 'dict-select',
  80. dict: dict({
  81. data: [
  82. // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效
  83. { value: 'a', label: '正常' },
  84. { value: 'b', label: '迟到/早退' },
  85. { value: 'c', label: '旷课' },
  86. { value: 'd', label: '请假' },
  87. { value: 'e', label: '无效' }
  88. ]
  89. }),
  90. column: {
  91. resizable: true
  92. }
  93. },
  94. afternoon: {
  95. title: '下午出勤状态',
  96. type: 'dict-select',
  97. dict: dict({
  98. data: [
  99. // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效
  100. { value: 'a', label: '正常' },
  101. { value: 'b', label: '迟到/早退' },
  102. { value: 'c', label: '旷课' },
  103. { value: 'd', label: '请假' },
  104. { value: 'e', label: '无效' }
  105. ]
  106. }),
  107. column: {
  108. resizable: true
  109. }
  110. },
  111. studentName: {
  112. title: '学生姓名',
  113. type: 'text',
  114. sortable: true
  115. },
  116. type: {
  117. title: '类别',
  118. type: 'text',
  119. sortable: true,
  120. form: {
  121. show: false
  122. }
  123. },
  124. studentNumber: {
  125. title: '学生学号',
  126. type: 'text',
  127. sortable: true,
  128. column: {
  129. width: 280
  130. }
  131. },
  132. teacherName: {
  133. title: '授课老师',
  134. type: 'text',
  135. sortable: true,
  136. width: 60,
  137. search: {
  138. show: false
  139. },
  140. form: {
  141. show: false
  142. }
  143. },
  144. categoryName: {
  145. title: '类别',
  146. type: 'text',
  147. sortable: true,
  148. width: 100,
  149. form: {
  150. show: false
  151. }
  152. },
  153. subjectsName: {
  154. title: '系列',
  155. type: 'text',
  156. sortable: true,
  157. width: 100,
  158. form: {
  159. show: false
  160. }
  161. },
  162. roomName: {
  163. title: '教室',
  164. type: 'text',
  165. form: {
  166. show: false
  167. }
  168. }
  169. }
  170. }
  171. };
  172. }
  173. export default curd;