import ExamPlanController from "@/services/apis/ExamPlanController"; import ExamSampleController from "@/services/apis/ExamSampleController"; import { DrawerForm, ProFormCheckbox, ProFormDependency, ProFormDigit, ProFormItem, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-components"; import { useRequest } from "ahooks"; import { App, Space, Typography } from "antd"; import { useState } from "react"; /** 添加修改抽样方案 */ const ExamSampleEditModal: React.FC<{ /** 抽样方案 */ data: Partial; /** 保存成功回调 */ onFinish: () => void; /** 关闭回调 */ onClose: () => void; }> = ({ data, onFinish, onClose }) => { const [open, setOpen] = useState(true); const handleClose = () => { setOpen(false); setTimeout(onClose, 300); }; const { message } = App.useApp(); const [isEnabledOnlyOneClassStudentMin, setIsEnabledOnlyOneClassStudentMin] = useState(data.config?.isEnabledOnlyOneClassStudentMin); const [isEnabledGradeNoSampleStudentMin, setIsEnabledGradeNoSampleStudentMin] = useState(data.config?.isEnabledGradeNoSampleStudentMin); const [isEnabledClassStudentMin, setIsEnabledClassStudentMin] = useState(data.config?.isEnabledClassStudentMin); const { data: refPlanList } = useRequest(async () => { return await ExamPlanController.getSampleRefPlanList({ id: data.examPlanId }) }); const { config, ...restData } = data; return ( title="监测抽样方案参数配置" width={800} open={open} drawerProps={{ maskClosable: false, onClose: handleClose, }} initialValues={{ config: { percent: 40, startPosition: 1, interval: 2, isRandomSampling: false, isExcludeSpecialStudent: true, specialStudentMustApproved: true, ...config, }, ...restData }} onFinish={async (values) => { try { const { config, ...restValues } = values; let p: API.AddExamSampleInput = { ...restValues, examPlanId: data.examPlanId ?? 0, config: { ...data.config, ...config, }, }; if ((data.id ?? 0) > 0) { const up = { id: data.id ?? 0, ...p } as API.UpdateExamSampleInput; await ExamSampleController.update(up); } else { await ExamSampleController.add(p); } message.success('操作成功!'); onFinish(); handleClose(); return true; } catch { message.error('操作失败!'); return false; } }} > {(data.id ?? 0) > 0 && <> 方案全称} name="fullName" required rules={[{ required: true, message: '请输入方案全称' }]} /> 方案名称} name="name" required rules={[{ required: true, message: '请输入方案名称' }]} /> 方案简称} name="shortName" required rules={[{ required: true, message: '请输入方案简称' }]} /> } 抽样参照成绩所在监测计划} name="examScoreRefExamPlanId" rules={[{ required: true, message: '请选择' }]} fieldProps={{ options: refPlanList?.map(t => ({ label: t.name, value: t.id })) ?? [], }} /> 抽样比例} name={['config', 'percent']} fieldProps={{ addonAfter: '%' }} rules={[{ required: true, message: '请输入抽样比例' }]} /> 抽样方式} name={['config', 'isRandomSampling']} fieldProps={{ options: [ { label: '随机抽样', value: true }, { label: 等距抽样(班级无成绩时将采用随机抽样), value: false } ], }} rules={[{ required: true, message: '请选择抽样方式' }]} /> 位置间距} required>
全抽配置} tooltip="以下全抽规则序号越小优先级越高">
setIsEnabledOnlyOneClassStudentMin(e.target.checked), }} >1. 年级仅有一个班,且该班学生人数小于等于
setIsEnabledGradeNoSampleStudentMin(e.target.checked), }} >2. 年级多于一个班,且年级未抽样部分学生人数小于
setIsEnabledClassStudentMin(e.target.checked), }} >3. 班级学生人数小于等于
特殊学生}> 不参与抽样 {({ config }) => ( 必须审核通过{config?.specialStudentMustApproved ? '(勾选仅审核已通过不参与抽样)' : '(未勾选待审核和审核已通过均不参与抽样)'} )} 排序设置}> 监测顺序号在年级内随机打乱 (默认在班内按前期成绩排序) 备注说明} name="remark" /> ); } export default ExamSampleEditModal;