import { useEffect } from "react"; import { Badge, Button, Form, Input, Modal, Table, message } from "antd"; import dayjs from "dayjs"; import PageLayout from "@cqsjjb/jjb-react-admin-component/PageLayout"; import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction"; import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper"; import SearchForm from "~/components/SearchForm"; import { AntdTableFuncControl } from "@cqsjjb/jjb-common-decorator/antd"; import { Connect } from "@cqsjjb/jjb-dva-runtime"; import { tools } from "@cqsjjb/jjb-common-lib"; import { NS_COURSEWARE } from "~/enumerate/namespace"; import { CLASS_STATUS_MAP, CLASS_STATUS_OPTIONS, COURSEWARE_TRAINING_TYPE_MAP, COURSEWARE_TRAINING_TYPE_OPTIONS, } from "~/enumerate/constant"; const { router } = tools; /** 涉及学员人员数 / 完成人员数:学员统计接口未接入,暂用假数据 */ const MOCK_STUDENT_COUNT = 10; const MOCK_COMPLETED_COUNT = 5; /** 班级总人次:同上,暂用假数据 */ const MOCK_TOTAL_PERSON_TIMES = 93; /** 搜索表单值 → 查询参数:培训时间范围拆为后端字段(yyyy-MM-dd) */ const buildQuery = (value) => { const { trainingDateRange, ...rest } = value || {}; return { ...rest, ...(trainingDateRange?.[0] ? { startDateBegin: trainingDateRange[0].format("YYYY-MM-DD") } : {}), ...(trainingDateRange?.[1] ? { endDateEnd: trainingDateRange[1].format("YYYY-MM-DD") } : {}), current: 1, size: 10, }; }; /** 教育培训 — 班级管理 */ function ClassManagePage(props) { const [searchForm] = Form.useForm(); const { courseware } = props; const { classList, classTotal: total, classLoading: loading } = courseware || {}; const handleSearch = () => { props.classPage(router.query); }; useEffect(() => { const { startDateBegin, endDateEnd, ...rest } = router.query; searchForm.setFieldsValue({ ...rest, ...(startDateBegin && endDateEnd ? { trainingDateRange: [dayjs(startDateBegin), dayjs(endDateEnd)] } : {}), }); handleSearch(); }, []); const onDelete = (record) => { Modal.confirm({ title: "提示", content: "数据将会删除,您是否确认删除?", okText: "是", cancelText: "否", onOk: () => { message.info(`班级「${record.className}」删除接口待接入`); }, }); }; const columns = [ { title: "序号", width: 70, fixed: "left", render: (_, __, index) => { const current = Number(router.query.current) || 1; const size = Number(router.query.size) || 10; return (current - 1) * size + index + 1; }, }, { title: "参训单位", dataIndex: "unitName", width: 180, ellipsis: true, render: (v) => v || "-", }, { title: "班级名称", dataIndex: "className", width: 180, ellipsis: true, }, { title: "班级编码", dataIndex: "classCode", width: 180, }, { title: "培训类型", dataIndex: "trainingType", width: 160, ellipsis: true, render: (v) => COURSEWARE_TRAINING_TYPE_MAP[v] ?? (v || "-"), }, { title: "培训开始时间", dataIndex: "startDate", width: 120, render: (v) => v || "-", }, { title: "结束时间", dataIndex: "endDate", width: 120, render: (v) => v || "-", }, { title: "涉及学员人员数", dataIndex: "studentCount", width: 120, render: () => MOCK_STUDENT_COUNT, }, { title: "完成人员数", dataIndex: "completedCount", width: 100, render: () => MOCK_COMPLETED_COUNT, }, { title: "班级状态", dataIndex: "status", width: 100, render: (v) => { const item = CLASS_STATUS_MAP[v]; return item ? : "-"; }, }, { title: "操作", width: 240, fixed: "right", render: (_, record) => ( {record.status === 2 && ( )} ), }, ]; return ( , , , , , ]} onReset={(value) => { router.query = buildQuery(value); handleSearch(); }} onFinish={(value) => { router.query = buildQuery(value); handleSearch(); }} /> `共 ${t} 条`, current: Number(router.query.current) || 1, pageSize: Number(router.query.size) || 10, onChange: (page, pageSize) => { router.query = { ...router.query, current: page, size: pageSize }; handleSearch(); }, }} /> ); } export default Connect( [NS_COURSEWARE], true, )(AntdTableFuncControl(ClassManagePage));