From 2589f5f3e2a288e0280a7d2ee24cd3a0b9bb7246 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 21 Mar 2022 23:07:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=BB=84=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../normal/components/AutoSelector.tsx | 33 +++++++++---------- .../examinationrules/normal/step/index.tsx | 17 ++++++---- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx b/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx index ed5730c..e49a6ca 100644 --- a/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx +++ b/admin/src/pages/examinationrules/normal/components/AutoSelector.tsx @@ -56,7 +56,7 @@ const AutoSelector = (props: any, ref: any) => { console.log('props subject_id', props) const { subjectId, questionType } = props; console.log('questionType', questionType) - const [typeChapterCount, setTypeChapterCount] = useState([]) ; // 题型分数数组 [{"question_type":0,"chapter_list": [{ "chapter_id":3, "count":1 }]}] + const [rows, setRows] = useState([]) ; // 章节 //const [dataSource, setDataSource] = useState(() => defaultData); @@ -83,7 +83,7 @@ const AutoSelector = (props: any, ref: any) => { console.log('onchange==', val) const values = formRef?.current.getFieldsValue() console.log('values', values) - const {questionType} = values; + const { questionType } = values; const avg = val / questionType[idx].length // 平均数 const rem = val % questionType[idx].length // 余数 const _questionType = questionType[idx].map((item, key)=>{return key < rem ? Math.ceil(avg) : Math.floor(avg)}) @@ -96,20 +96,7 @@ const AutoSelector = (props: any, ref: any) => { //key: 'code', dataIndex: `type${item?.code}`, render: ( _dom, record, index) => { - return { - console.log('record', record) - //{chapter_id: record?.chapter_id, count:0} - /* - console.log('typeChapterCount',typeChapterCount) - const data = typeChapterCount?.map((item, key)=>{ - data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)}) - }) - setTypeChapterCount(data) - console.log('setTypeChapterCount---',typeChapterCount) - */ - }} - />; + return ; }, }) }) @@ -119,7 +106,18 @@ const AutoSelector = (props: any, ref: any) => { useImperativeHandle(ref, () => ({ // 构造ref的获取数据方法 getData: () => { // 组卷数据 - return []; + console.log('useImperativeHandle') + const values = formRef.current.getFieldsValue() + console.log(values) + const data = values?.questionType.map((item, key)=>{ + return { + question_type:key, + chapter_list: item.map((val,idx)=>( + {chapter_id:rows[idx]?.chapter_id, count: val} + )) + } + }) // 题型分数数组 [{"question_type":0,"chapter_list": [{ "chapter_id":3, "count":1 }]}] + return data; }, })); @@ -144,6 +142,7 @@ const AutoSelector = (props: any, ref: any) => { page_number: 1, page_size: 1000, }); + setRows(data?.list) console.log('data--',data) /* const _data = []; diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 557cc41..0f1e0bc 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -663,15 +663,18 @@ export default () => { visible={autoModalVisible} onVisibleChange={handleAutoModalVisible} onFinish={async () => { - // 需要处理 - //console.log('111') - const values = autoRef?.current?.getData() - console.log('values ', values ) + const values = autoRef?.current.getData() + console.log('data-v', values) //const values = [{"question_type":0,"chapter_list": [{ "chapter_id":76, "count":1 },{ "chapter_id":77, "count":1 }]}] - //const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)}) + const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)}) //console.log('paper', paper) - //setUuidPaper(paper?.paper_uuid) - // message.success('提交成功'); + setUuidPaper(paper?.paper_uuid) + run({ + paper_uuid: paper?.paper_uuid, + page_size: 1000, + page_number: 1 + }); // 获取当前选题列表 + message.success('提交成功'); handleAutoModalVisible(false) return true; }}