From ed5e78a2bf79f43db6e9c6caa4d943505f11a8f8 Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Tue, 8 Mar 2022 13:37:10 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/examination/option/index.tsx | 12 +- .../examinationrules/normal/step/index.tsx | 282 ++++++++++-------- .../analysis/components/AchievementRow.tsx | 2 +- web/config/config.ts | 2 +- web/src/global.less | 8 + .../mockExamination/chapterErrorListPaper.tsx | 30 +- .../mockExamination/chapterListPaper.tsx | 66 ++-- web/src/pages/mockExamination/paper/index.tsx | 151 +++++++--- .../pages/mockExamination/paper/success.tsx | 6 +- 9 files changed, 333 insertions(+), 226 deletions(-) diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index dba752f..0b050e3 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -58,7 +58,7 @@ const handleRemove = async (selectedRows: TableListItem[], currentRow) => { try { await removeExamination({ key: selectedRows.map((row) => row.key), - },currentRow); + }, currentRow); hide(); message.success('删除成功,即将刷新'); return true; @@ -258,7 +258,7 @@ const ExaminationList: React.FC = () => { hideInSearch: true, hideInForm: true, render: (dom, entity) => { - return entity.pass_count + "人/" + entity.apply_person_count + "人"; + return entity.apply_person_count + "人"; }, }, { @@ -318,7 +318,7 @@ const ExaminationList: React.FC = () => { , { + onClick={() => { handleRemove([{ key: record?.examination_id }], record); // 调用批量删除函数(如果接口不支持批量需要在service中处理) setSelectedRows([]); actionRef.current?.reloadAndRest?.(); @@ -590,7 +590,7 @@ const ExaminationList: React.FC = () => { wrapperCol={{ span: 12 }} onFinish={async (values) => { console.log('values', values); - //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; + //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; //console.log('url', url) const params = { ...values, @@ -601,14 +601,14 @@ const ExaminationList: React.FC = () => { examination_start_time: values?.examination_time[0], examination_end_time: values?.examination_time[1] } - + delete params.apply_time delete params.course_time delete params.examination_time await handleUpdate({ ...params, examination_id: currentRow?.examination_id, - }); + }); handleUpdateModalVisible(false); // 隐藏编辑窗口 actionRef.current?.reloadAndRest?.(); console.log(values); diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 7d98cbe..8087c1d 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -1,6 +1,7 @@ import React, { useEffect, useRef, useState } from 'react'; import { history, useParams, useRequest } from 'umi'; -import { ModalForm, ProFormInstance } from '@ant-design/pro-form'; +import type { ProFormInstance } from '@ant-design/pro-form'; +import { ModalForm } from '@ant-design/pro-form'; import { ProFormRadio } from '@ant-design/pro-form'; import ProForm, { StepsForm, @@ -41,11 +42,11 @@ const handleAppend = async (rules_id: number, rows: any[]) => { const hide = message.loading('正在添加'); try { const questions: { question_id: any; }[] = []; - rows?.forEach((item)=>{ - questions.push({question_id: item?.id}) + rows?.forEach((item) => { + questions.push({ question_id: item?.id }) }) - const _data = await manualPaper({ - question_count: questions?.length || 0, + const _data = await manualPaper({ + question_count: questions?.length || 0, questions: JSON.stringify(questions), rules_id: Number(rules_id) }); @@ -64,15 +65,15 @@ const handleAppend = async (rules_id: number, rows: any[]) => { * * @param values */ - const handleUpdatePaper = async ( rules_id: number, paper_uuid: number, paper_id: number) => { +const handleUpdatePaper = async (rules_id: number, paper_uuid: number, paper_id: number) => { const hide = message.loading('正在保存'); try { const _data = { - rules_id: Number(rules_id), - paper_uuid: paper_uuid, + rules_id: Number(rules_id), + paper_uuid: paper_uuid, paper_id: paper_id } - if(paper_id === 0){ + if (paper_id === 0) { delete _data.paper_id; } await updatePaper(_data); @@ -86,13 +87,13 @@ const handleAppend = async (rules_id: number, rows: any[]) => { } }; -const labels = ['A','B','C','D','E','F','G','H','I','J','K'] +const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'] // 模拟考试规则维护 export default () => { - + const [selectorModalVisible, handleSelectorModalVisible] = useState(false); const [scoreModalVisible, handleScoreModalVisible] = useState(false); - const [autoModalVisible, handleAutoModalVisible] = useState(false); + const [autoModalVisible, handleAutoModalVisible] = useState(false); const [subjectId, setSubjectId] = useState(0); // 关联主题id const [subjectName, setSubjectName] = useState(''); // 关联主题name @@ -104,63 +105,64 @@ export default () => { const [rulesName, setRulesName] = useState(''); // 组卷类型 const [sumScore, setSumScore] = useState(0); // 总分 const [passScore, setPassScore] = useState(0); // 通过分数线 - + const [typeQuestionCount, setTypeQuestionCount] = useState([0, 0, 0]); // 临时卷 各题型数量 const formRef = useRef(); const selectorRef = useRef(); const setterRef = useRef(); - const autoRef = useRef(); + const autoRef = useRef(); + + const [currentStep, setCurrentStep] = useState(0); - const [currentStep, setCurrentStep] = useState(0); - const params = useParams(); - + const [questionType, setQuestionType] = useState([]); // 题型 const [scoreValues, SetscoreValues] = useState([]); // 分值 [{"question_type": "0","score": "3","score_harf": "0"},] const [paperInfo, setPaperInfo] = useState({}) - + /** 获取题型 */ const { data: questionTypeData } = useRequest(() => { return queryQuestionType(); - },{ + }, { formatResult: (result) => { - return result.list; + return result.list; } }); useEffect(() => { setQuestionType(questionTypeData || []); - return ()=>{ - /** 退出当前页面清空Map */ - //parsingMap.clear(); + return () => { + /** 退出当前页面清空Map */ + //parsingMap.clear(); } }, [questionTypeData]); - + /** 组卷,查询试题临时表(当前选题列表) */ const { data: questions, run } = useRequest(async (params) => { console.log('questions', questions) const _data = await queryTempQuestionList(params); return _data; - },{ + }, { manual: true, formatResult: (result) => { - return result?.table_List; - }}); + return result?.table_List; + } + }); /** 从临时表中计算各题型数量 */ useEffect(() => { - let _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序 + const _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序 console.log('questions-info', questions) - questions?.forEach((item)=>{ + questions?.forEach((item) => { _data[Number(item?.question_type)] += 1 }) - + setTypeQuestionCount(_data); - return ()=>{ - /** 退出当前页面清空Map */ - //parsingMap.clear(); + return () => { + /** 退出当前页面清空Map */ + //parsingMap.clear(); } }, [questions]); // @@ -172,19 +174,20 @@ export default () => { page_size: value.pageSize */ return queryRulesPaper(params); - },{ + }, { manual: true, formatResult: (result) => { - return result?.question_list; - }}); + return result?.question_list; + } + }); useEffect(() => { console.log('paperData2', paperData) - if(paperData?.length > 0){ + if (paperData?.length > 0) { console.log('paperData[0]', paperData[0]) setPaperInfo(paperData[0]) } - console.log('PaperInfo', paperInfo) + console.log('PaperInfo', paperInfo) }, [paperData]); console.log(params, 'params'); @@ -194,10 +197,11 @@ export default () => { //console.log(JSON.stringify(params), "878"); const { data } = useRequest(async () => { return queryRulesView(params); - },{ + }, { formatResult: (result) => { - return result?.bean; - }}); + return result?.bean; + } + }); ruleData = data } console.log(ruleData, 'ruleData'); @@ -261,9 +265,15 @@ export default () => { initialValue={ruleData?.rules_name} // tooltip="最长为 6 位汉字,需要与考生身份证一致" placeholder="请输入名称" - rules={[{ required: true, message: '请输入考试名称' }]} - // value="锦书" - // disabled + rules={[ + { required: true, message: '请输入考试名称' }, + { + pattern: /^[^\s]*$/, + message: '禁止输入空格' + } + ]} + // value="锦书" + // disabled /> { return querySubjectList().then(({ data }) => { console.log(data, 'querySubjectList') return data.list.map((item) => { - if(item?.subject_id === ruleData?.subject_id){ + if (item?.subject_id === ruleData?.subject_id) { setSubjectName(item?.subject_name) // 设置关联主题名称 console.log('label::', item?.subject_name) } @@ -284,7 +294,7 @@ export default () => { }); }); }} - onChange={(value)=>{ + onChange={(value) => { console.log('on change', value) }} rules={[{ required: true, message: '请选择主题' }]} @@ -294,7 +304,15 @@ export default () => { )} @@ -314,26 +332,26 @@ export default () => { onFinish={async () => { console.log(formRef.current?.getFieldsValue()); setCurrentStep(2) // 设置步骤号 - runPaper({rules_id: params?.id }) + runPaper({ rules_id: params?.id }) return true; }} >
{rulesName} {/** 一旦录入另一项将禁用,清空组卷后可选另一项 */} - { + { setCreateType(Number(e?.target?.value)) console.log('value', e?.target?.value) //handleAutoModalVisible(true); // 显示系统组卷窗口 }} style={{ marginBottom: 16, }}> - 手动组卷 - 系统组卷 + 手动组卷 + 系统组卷 - + { headerBordered > - { questions && questions.map((item, idx)=>( - item && -
- - {idx+1}. {item?.question_stem} - - {(item?.question_type === 0) && // 单选题 -
- {item?.answers && item?.answers.map((anster, k)=>( -
- {anster?.is_true === '0' && {labels[k]} } - {anster?.is_true === '1' && {labels[k]} } - {anster?.answer} -
- ))} -
- } - {(item?.question_type === 1) && // 多选题 -
- {item?.answers && item?.answers.map((anster, k)=>( -
- {anster?.is_true === '0' && {labels[k]} } - {anster?.is_true === '1' && {labels[k]} } - {anster?.answer} -
- ))} + {questions && questions.map((item, idx) => ( + item && +
+ + {idx + 1}. {item?.question_stem} + + {(item?.question_type === 0) && // 单选题 +
+ {item?.answers && item?.answers.map((anster, k) => ( +
+ {anster?.is_true === '0' && {labels[k]} } + {anster?.is_true === '1' && {labels[k]} } + {anster?.answer} +
+ ))} +
+ } + {(item?.question_type === 1) && // 多选题 +
+ {item?.answers && item?.answers.map((anster, k) => ( +
+ {anster?.is_true === '0' && {labels[k]} } + {anster?.is_true === '1' && {labels[k]} } + {anster?.answer} +
+ ))} +
+ } + {(item?.question_type === 2) && // 判断选题 +
+ {item?.answers && item?.answers.map((anster, k) => ( +
+ {anster?.is_true === '0' && {labels[k]} } + {anster?.is_true === '1' && {labels[k]} } + {anster?.answer} +
+ ))} +
+ } +
+
- } - {(item?.question_type === 2) && // 判断选题 -
- {item?.answers && item?.answers.map((anster, k)=>( -
- {anster?.is_true === '0' && {labels[k]} } - {anster?.is_true === '1' && {labels[k]} } - {anster?.answer} -
- ))} -
- } -
-
-
- ))} - - + ))} + +
试卷信息与设置 - 共 { '-' } 题 { '-' } 分 + 共 {'-'} 题 {'-'} 分 - { questionType.map((item)=>{ - return {item?.name} 共 { typeQuestionCount[Number(item.code)] } 题 { '-' } 分 + {questionType.map((item) => { + return {item?.name} 共 {typeQuestionCount[Number(item.code)]} 题 {'-'} 分 } - )} + )} - - - {/* {console.log(questionNow.answerId, 'answerId', questionNow.answerId)} */} - + {questionNow.question_type === 0 ? @@ -365,15 +461,12 @@ const CardList = () => { {questionNow?.answers?.map((item, index) => { return { + onChange={(e) => { const qArr = [] // 默认输出答案0,0,0,0 - questionNow?.answers?.map(() => { - qArr.push("0") - + questionNow?.answers?.map((qitem) => { + qitem.id === e.target.value ? qArr.push("1") : qArr.push("0") }) - // 修改用户答案 - qArr[index] = item.is_true const questionList = questionTypeList const questionAnswer = qArr.join(",") @@ -429,14 +522,12 @@ const CardList = () => { {questionNow?.answers?.map((item, index) => { return { + onChange={(e) => { const qArr = [] // 默认输出答案0,0,0,0 - questionNow?.answers?.map(() => { - qArr.push("0") + questionNow?.answers?.map((qitem) => { + qitem.id === e.target.value ? qArr.push("1") : qArr.push("0") }) - // 修改用户答案 - qArr[index] = item.is_true const questionList = questionTypeList const questionAnswer = qArr.join(",") @@ -535,27 +626,7 @@ const CardList = () => { diff --git a/web/src/pages/mockExamination/paper/success.tsx b/web/src/pages/mockExamination/paper/success.tsx index 31a833e..4aeca0e 100644 --- a/web/src/pages/mockExamination/paper/success.tsx +++ b/web/src/pages/mockExamination/paper/success.tsx @@ -59,8 +59,8 @@ const Result = () => { return (
-
{ history.push('/dashboard/workplace') }}>首页 / 资质考试 / 标题
-
标题
+
{ history.push('/dashboard/workplace') }}>首页 / 综合模拟考试 / {params.rules_name}
+
{params.rules_name}
考试用时:
@@ -72,7 +72,7 @@ const Result = () => {
是否通过:
- {params.score >= params.pass_score ? "是" : "否"} + {params.score >= params.pass_score ? "通过" : "未通过"}