import { useEffect, useState } from "react";
import { Badge, Button, Form, Table, message } from "antd";
import ControlWrapper from "@cqsjjb/jjb-react-admin-component/ControlWrapper";
import SearchForm from "~/components/SearchForm";
import TableAction from "@cqsjjb/jjb-react-admin-component/TableAction";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { NS_COURSEWARE } from "~/enumerate/namespace";
import {
CLASS_STUDENT_EXAM_STATUS_OPTIONS,
CLASS_STUDENT_FACE_AUTH_MAP,
CLASS_STUDENT_STUDY_STATUS_MAP,
CLASS_STUDENT_EXAM_STATUS_MAP,
CLASS_STUDENT_STUDY_STATUS_OPTIONS,
} from "~/enumerate/constant";
/** 搜索表单值 → 查询参数:入班时间范围拆为起止字段(yyyy-MM-dd,接口暂未支持,先行透传) */
const buildQuery = (value) => {
const { entryTimeRange, ...rest } = value || {};
return {
...rest,
...(entryTimeRange?.[0]
? { entryTimeStart: entryTimeRange[0].format("YYYY-MM-DD") }
: {}),
...(entryTimeRange?.[1]
? { entryTimeEnd: entryTimeRange[1].format("YYYY-MM-DD") }
: {}),
current: 1,
size: 10,
};
};
/** 班级详情 — 学员 Tab:班级学员查询 */
function ClassStudentTab(props) {
const { classId } = props;
const [searchForm] = Form.useForm();
const [query, setQuery] = useState({ current: 1, size: 10 });
const {
classStudentList: dataSource,
classStudentTotal: total,
classStudentLoading: loading,
} = props.courseware || {};
const handleSearch = (params = query) => {
props.classStudentPage({ ...params, classId });
};
useEffect(() => {
if (!classId) return;
handleSearch(query);
}, [classId]);
const columns = [
{
title: "序号",
width: 70,
fixed: "left",
render: (_, __, index) => (query.current - 1) * query.size + index + 1,
},
{ title: "姓名", dataIndex: "studentName", width: 100 },
{
title: "参训单位",
dataIndex: "unitName",
width: 160,
ellipsis: true,
render: (v) => v || "-",
},
{ title: "部门", dataIndex: "department", width: 120, render: (v) => v || "-" },
{ title: "手机号", dataIndex: "phone", width: 130, render: (v) => v || "-" },
{ title: "档案编号", dataIndex: "fileNumber", width: 220, ellipsis: true },
{
title: "人脸认证",
dataIndex: "faceAuth",
width: 100,
render: (v) => {
const item = CLASS_STUDENT_FACE_AUTH_MAP[v];
return item ? : "-";
},
},
{
title: "要求学时",
dataIndex: "requiredHours",
width: 100,
render: (v) => (v == null ? "-" : v),
},
{
title: "已完成学时",
dataIndex: "completedHours",
width: 110,
render: (v) => (v == null ? "-" : v),
},
{
title: "学习状态",
dataIndex: "studyStatus",
width: 100,
render: (v) => CLASS_STUDENT_STUDY_STATUS_MAP[v] ?? "-",
},
{
title: "考试状态",
dataIndex: "examStatus",
width: 100,
render: (v) => CLASS_STUDENT_EXAM_STATUS_MAP[v] ?? "-",
},
{
title: "操作人",
dataIndex: "createName",
width: 100,
},
{
title: "操作",
width: 160,
fixed: "right",
render: () => (
),
},
];
return (
<>
,
,
,
,
]}
onReset={(value) => {
const next = buildQuery(value);
setQuery(next);
handleSearch(next);
}}
onFinish={(value) => {
const next = buildQuery(value);
setQuery(next);
handleSearch(next);
}}
/>
`共 ${t} 条`,
current: query.current,
pageSize: query.size,
onChange: (page, pageSize) => {
const next = { ...query, current: page, size: pageSize };
setQuery(next);
handleSearch(next);
},
}}
/>
>
);
}
export default Connect([NS_COURSEWARE], true)(ClassStudentTab);