crud.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. import type { CreateCrudOptionsRet } from '@fast-crud/fast-crud';
  2. import { dict } from '@fast-crud/fast-crud';
  3. import { queryAttendance, queryClassAll, queryClassRoomList } from './api';
  4. function curd(): CreateCrudOptionsRet {
  5. return {
  6. crudOptions: {
  7. request: {
  8. pageRequest: async ({ page, query }) => {
  9. const { total, data } = await queryAttendance(page.offset + 1, page.limit, query);
  10. return { records: data, total, currentPage: page.offset, pageSize: page.limit };
  11. }
  12. },
  13. toolbar: {
  14. show: true
  15. },
  16. actionbar: {
  17. show: false
  18. },
  19. rowHandle: {
  20. show: false,
  21. buttons: {
  22. remove: {
  23. show: false
  24. },
  25. add: {
  26. show: false
  27. },
  28. edit: {
  29. show: false
  30. },
  31. view: {
  32. show: false
  33. }
  34. }
  35. },
  36. columns: {
  37. id: {
  38. title: '排课ID',
  39. type: 'text',
  40. search: {
  41. show: true
  42. },
  43. column: {
  44. show: true
  45. }
  46. },
  47. checkinDate: {
  48. title: '签到日期',
  49. type: 'text',
  50. search: {
  51. show: false
  52. },
  53. column: {
  54. show: false
  55. }
  56. },
  57. morning: {
  58. title: '上午',
  59. type: 'dict-select',
  60. dict: dict({
  61. data: [
  62. // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效
  63. { value: 'a', label: '正常' },
  64. { value: 'b', label: '迟到/早退' },
  65. { value: 'c', label: '旷课' },
  66. { value: 'd', label: '请假' },
  67. { value: 'e', label: '无效' }
  68. ]
  69. }),
  70. search: {
  71. show: false
  72. },
  73. column: {
  74. resizable: true,
  75. align: 'center',
  76. fixed: 'left'
  77. }
  78. },
  79. afternoon: {
  80. title: '下午',
  81. type: 'dict-select',
  82. dict: dict({
  83. data: [
  84. // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效
  85. { value: 'a', label: '正常' },
  86. { value: 'b', label: '迟到/早退' },
  87. { value: 'c', label: '旷课' },
  88. { value: 'd', label: '请假' },
  89. { value: 'e', label: '无效' }
  90. ]
  91. }),
  92. search: {
  93. show: false
  94. },
  95. column: {
  96. resizable: true,
  97. align: 'center',
  98. fixed: 'left'
  99. }
  100. },
  101. month: {
  102. title: '月份',
  103. type: 'text',
  104. search: {
  105. show: true
  106. },
  107. column: {
  108. resizable: true,
  109. width: 20,
  110. align: 'center',
  111. fixed: 'left'
  112. }
  113. },
  114. studentId: {
  115. title: '学生ID',
  116. type: 'text',
  117. search: {
  118. show: true
  119. },
  120. column: {
  121. resizable: true,
  122. align: 'center',
  123. fixed: 'left'
  124. }
  125. },
  126. type: {
  127. title: '类型',
  128. type: 'text',
  129. search: {
  130. show: false
  131. },
  132. column: {
  133. resizable: true,
  134. align: 'center',
  135. fixed: 'left'
  136. }
  137. },
  138. className: {
  139. title: '班级',
  140. search: {
  141. show: true
  142. },
  143. column: {
  144. resizable: true,
  145. align: 'center',
  146. fixed: 'left'
  147. },
  148. type: 'dict-select',
  149. dict: dict({
  150. async getData() {
  151. const result = await queryClassAll();
  152. return result.data?.map(r => {
  153. return {
  154. label: r.name,
  155. value: r.id
  156. };
  157. }) as any[];
  158. }
  159. })
  160. },
  161. startTime: {
  162. title: '开始时间',
  163. type: 'easDateTime',
  164. search: {
  165. show: true
  166. },
  167. column: {
  168. resizable: true,
  169. align: 'center',
  170. fixed: 'left'
  171. }
  172. },
  173. endTime: {
  174. title: '结束时间',
  175. type: 'easDateTime',
  176. search: {
  177. show: true
  178. },
  179. column: {
  180. resizable: true,
  181. align: 'center',
  182. fixed: 'left'
  183. }
  184. },
  185. categoryName: {
  186. title: '类别名称',
  187. type: 'text',
  188. search: {
  189. show: false
  190. },
  191. column: {
  192. resizable: true,
  193. align: 'center',
  194. fixed: 'left'
  195. }
  196. },
  197. subjectsName: {
  198. title: '科目名称',
  199. type: 'text',
  200. search: {
  201. show: false
  202. },
  203. column: {
  204. resizable: true,
  205. align: 'center',
  206. fixed: 'left'
  207. }
  208. },
  209. studentName: {
  210. title: '姓名',
  211. type: 'text',
  212. search: {
  213. show: true
  214. },
  215. column: {
  216. resizable: true,
  217. align: 'center',
  218. fixed: 'left'
  219. }
  220. },
  221. teacherName: {
  222. title: '教师姓名',
  223. type: 'text',
  224. search: {
  225. show: false
  226. },
  227. column: {
  228. resizable: true,
  229. align: 'center',
  230. fixed: 'left'
  231. }
  232. },
  233. roomName: {
  234. search: {
  235. show: true
  236. },
  237. title: '教室',
  238. type: 'dict-select',
  239. dict: dict({
  240. async getData() {
  241. const result = await queryClassRoomList(1, 100, {});
  242. return result.data?.map(r => {
  243. return {
  244. label: r.name,
  245. value: r.id
  246. };
  247. }) as any[];
  248. }
  249. })
  250. }
  251. }
  252. }
  253. };
  254. }
  255. export default curd;