import type { CreateCrudOptionsProps, CreateCrudOptionsRet } from '@fast-crud/fast-crud'; import { dict } from '@fast-crud/fast-crud'; import { updateAttendance, getStudentList } from './api'; function curd({ context }: CreateCrudOptionsProps): CreateCrudOptionsRet { return { crudOptions: { container: { is: 'fs-layout-card' }, search: { show: false }, pagination: { show: false }, request: { pageRequest: async ({ page, query }) => { const queryBody = { id: context?.route.query.scheduleId ?? 9999999 }; const { data } = await getStudentList(Object.assign(queryBody, query)); return { records: data, total: 0, currentPage: page.offset, pageSize: page.limit }; }, addRequest: () => { return Promise.resolve(); }, editRequest: ({ form }) => { form.scheduleId = form.id; updateAttendance(form); } }, toolbar: { show: true }, actionbar: { show: false }, rowHandle: { buttons: { remove: { show: false } } }, columns: { startTime: { title: '上课时间', type: 'easDateTime', sortable: true, column: { width: 160 } }, endTime: { title: '下课时间', type: 'easDateTime', sortable: true, column: { width: 160 } }, id: { title: '排课ID', type: 'text', column: { show: false } }, checkinDate: { title: '签到日期', type: 'easDateTime', sortable: true, column: { show: false } }, morning: { title: '上午出勤状态', type: 'dict-select', dict: dict({ data: [ // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效 { value: 'a', label: '正常' }, { value: 'b', label: '迟到/早退' }, { value: 'c', label: '旷课' }, { value: 'd', label: '请假' }, { value: 'e', label: '无效' } ] }), column: { resizable: true } }, afternoon: { title: '下午出勤状态', type: 'dict-select', dict: dict({ data: [ // a 表示正常出勤, b 表示迟到、早退, c 表示旷课, d 表示请假, e表示无效 { value: 'a', label: '正常' }, { value: 'b', label: '迟到/早退' }, { value: 'c', label: '旷课' }, { value: 'd', label: '请假' }, { value: 'e', label: '无效' } ] }), column: { resizable: true } }, studentName: { title: '学生姓名', type: 'text', sortable: true }, type: { title: '类别', type: 'text', sortable: true, form: { show: false } }, studentNumber: { title: '学生学号', type: 'text', sortable: true, column: { width: 280 } }, teacherName: { title: '授课老师', type: 'text', sortable: true, width: 60, search: { show: false }, form: { show: false } }, categoryName: { title: '类别', type: 'text', sortable: true, width: 100, form: { show: false } }, subjectsName: { title: '系列', type: 'text', sortable: true, width: 100, form: { show: false } }, roomName: { title: '教室', type: 'text', form: { show: false } } } } }; } export default curd;