From 19a4f9be39280c1826931f9f76a1311f99c815aa Mon Sep 17 00:00:00 2001 From: xialiang <1818147@qq.com> Date: Tue, 22 Mar 2022 10:12:03 +0800 Subject: [PATCH] xxx --- .../examinationrules/attestation/index.tsx | 2 +- .../attestation/step/index.tsx | 304 ++++++++++-------- 2 files changed, 164 insertions(+), 142 deletions(-) diff --git a/admin/src/pages/examinationrules/attestation/index.tsx b/admin/src/pages/examinationrules/attestation/index.tsx index 6a552df..ad81e92 100644 --- a/admin/src/pages/examinationrules/attestation/index.tsx +++ b/admin/src/pages/examinationrules/attestation/index.tsx @@ -207,7 +207,7 @@ const ExaminationRules: React.FC = () => { valueType: 'option', width: 100, render: (_dom: any, record: React.SetStateAction) => { - console.log(record, 'record') + // console.log(record, 'record') return [ // { - const questionNumber = [1,1,1]; + const questionNumber = [1, 1, 1]; const params = useParams(); - const formRef = useRef(); + const formRef = useRef(); const actionRef = useRef(); const setterRef = useRef(); const autoRef = useRef(); - const [currentStep, setCurrentStep] = useState(0); + const [currentStep, setCurrentStep] = useState(0); const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] const [questionType, setQuestionType] = useState([]); // 题型 @@ -56,11 +58,13 @@ export default () => { const { data: questions, run } = useRequest(async (params) => { console.log('questions', questions) return queryPaperQuestionList(params); - },{ + }, { manual: true, formatResult: (result) => { - return result?.question_list; - }}); + + return result?.question_list; + } + }); @@ -127,9 +131,9 @@ export default () => { hideInTable: false, hideInForm: true, hideInSearch: true, - render: (dom, record,index) => { + render: (dom, record, index) => { return <> - {record.question_type_count.map((item)=>{return {`${item.type_name} ${item.count} 题`}})} + {record.question_type_count.map((item) => { return {`${item.type_name} ${item.count} 题`} })} }, }, @@ -170,7 +174,7 @@ export default () => { valueType: 'text', hideInSearch: true, hideInForm: false, - renderText: (val: string) => `${val || '-'}`, + renderText: (val: string) => `${val || '0'}`, }, { title: '通过线', @@ -179,7 +183,7 @@ export default () => { valueType: 'text', hideInSearch: true, hideInForm: false, - renderText: (val: string) => `${val || '-'}`, + renderText: (val: string) => `${val || '0'}`, }, { title: '操作', @@ -187,7 +191,7 @@ export default () => { valueType: 'option', width: 220, render: (_dom: any, record: React.SetStateAction) => { - console.log(record, 'record') + // console.log(record, 'record') return [ , , ] }, @@ -255,20 +259,20 @@ export default () => { /** 获取题型 */ 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]); - + return ( @@ -302,7 +306,7 @@ export default () => { } console.log(fileds, 'fileds', params); // return false - const {data} = await saveRules({ + const { data } = await saveRules({ ...fileds, b_use: 0, rules_type: 1, @@ -323,14 +327,14 @@ export default () => { name="rules_name" label="考试名称" width="lg" - fieldProps={{ + fieldProps={{ type: 'text', allowClear: false, width: 'large', - onInput:(e)=>{ + onInput: (e) => { const val = `${e.currentTarget?.value}`; - if(val.length > 50) { - e.currentTarget.value = val.slice(0,50) + if (val.length > 50) { + e.currentTarget.value = val.slice(0, 50) } } //style:{width: '100%'} @@ -362,70 +366,70 @@ export default () => { label="关联主题" disabled={params?.id} /> - - 关联主题选择并提交将后将不支持修改。 + + 关联主题选择并提交将后将不支持修改。 { + onInput: (e) => { const val = `${e.currentTarget?.value}`; console.log('val', val) console.log('val.charAt(0)', val.charAt(0)) - if(val.charAt(0) === ''){ + if (val.charAt(0) === '') { console.log('vvv', val) e.currentTarget.value = '0' } - if(val.length > 3) { - e.currentTarget.value = val.slice(0,3) + if (val.length > 3) { + e.currentTarget.value = val.slice(0, 3) } }, //style: {marginRight:3} }} // tooltip="限制考试时长的情况下,用户考试中离开,倒计时不会停止。" /> - - 限制考试时长的情况下,用户考试中离开,倒计时不会停止。 + + 限制考试时长的情况下,用户考试中离开,倒计时不会停止。 { + onInput: (e) => { const val = `${e.currentTarget?.value}`; console.log('val', val) console.log('val.charAt(0)', val.charAt(0)) - if(val.charAt(0) === ''){ + if (val.charAt(0) === '') { console.log('vvv', val) e.currentTarget.value = '' } - if(val.length > 3) { - e.currentTarget.value = val.slice(0,3) + if (val.length > 3) { + e.currentTarget.value = val.slice(0, 3) } }, //style:{width: '100%'} }} // tooltip="限制考试时长的情况下,用户考试中离开,倒计时不会停止。" /> - - 试卷数量与学生重复考试次数一致 + + 试卷数量与学生重复考试次数一致 {console.log('###', ruleData)} - - - 试卷有效期指超过试卷有效期重新生成试卷 - + + + 试卷有效期指超过试卷有效期重新生成试卷 + )} @@ -457,17 +461,17 @@ export default () => { options={false} search={false} toolBarRender={() => ( - + + - + )} request={async (value) => { console.log('queryRulesPaper::') /** 获取试卷 */ const _data = await queryRulesPaper( { - rules_id: params?.id || rulesId, - page_number: value.current, - page_size: value.pageSize + rules_id: params?.id || rulesId, + page_number: value.current, + page_size: value.pageSize } - ); + ); + + const _questionType = []; const _questionTypeCountData = []; - _data.question_list[0]?.question_type_count.forEach((item)=>{ + _data.question_list[0]?.question_type_count.forEach((item) => { _questionTypeCountData.push(item.count) + _questionType.push({ typeName: item.type_name, code: item.question_type }) }) console.log('_questionTypeCountData', _questionTypeCountData) - const _questionType = []; console.log('_data.question_type_score', _data.question_type_score) - if(_data?.question_type_score.length > 0){ - _data.question_type_score?.forEach((item, index)=>{ - _questionType.push({count: _questionTypeCountData[index], score: item.score, score_harf: item.score_harf}) + if (_data?.question_type_score.length > 0) { + _data.question_type_score?.forEach((item, index) => { + _questionType[index] = { ..._questionType[index], count: _questionTypeCountData[index], score: item.score, score_harf: item.score_harf } }) - }else{ - _questionTypeCountData?.forEach((item, index)=>{ - _questionType.push({count: _questionTypeCountData[index], score:0, score_harf: 0}) + } else { + _questionTypeCountData?.forEach((item, index) => { + _questionType[index] = { ..._questionType[index], count: _questionTypeCountData[index], score: 0, score_harf: 0 } }) } - console.log('_questionType', _questionType) + + // question_type_count + + + + console.log('_questionType 1', _questionType) setQuestionTypeValues(_questionType) + + + + + + + return { current: _data?.pageNumber, data: _data?.question_list, @@ -546,7 +564,7 @@ export default () => { //actionRef={actionRef} title={false} request={async () => { - const result = await queryRulesView({id: rulesId}) + const result = await queryRulesView({ id: rulesId }) console.log('queryRulesView', result) const subjectInfo = await getSubjectInfo({ subject_id: result.bean.subject_id }) console.log('subjectInfo', subjectInfo) @@ -558,22 +576,22 @@ export default () => { - (`${text} 分钟`)} /> + (`${text} 分钟`)} /> { {/** 从试卷中读取 临时卷必须保存后才进入此页 */ } return - 共 {paperInfo?.question_type_count?.map(item=>item.count)?.reduce((prev, curr)=>prev + curr)} 道题, {paperInfo?.sum_score || '-'} 分 - {paperInfo?.question_type_count?.map(item=>({`${item?.type_name} ${item?.count} 道题 `}))} + 共 {paperInfo?.question_type_count?.map(item => item.count)?.reduce((prev, curr) => prev + curr)} 道题, {paperInfo?.sum_score || '-'} 分 + {paperInfo?.question_type_count?.map(item => ({`${item?.type_name} ${item?.count} 道题 `}))} 通过线 {paperInfo?.pass_score || '-'} 分 }} /> - { - return
{entity?.paper_count} 试卷数量是学生重复考试次数
+ { + return
{entity?.paper_count} 试卷数量是学生重复考试次数
}} /> - { - return
{/*entity?.start_time.substring(0,10)*/} {entity?.end_time.substring(0,10)} 超过试卷有效期将重新生成试卷
+ { + return
{/*entity?.start_time.substring(0,10)*/} {entity?.end_time.substring(0, 10)} 超过试卷有效期将重新生成试卷
}} /> @@ -588,9 +606,9 @@ export default () => { visible={autoModalVisible} onVisibleChange={handleAutoModalVisible} onFinish={async () => { - const values = autoRef.current?.getData(); + const values = autoRef.current?.getData(); console.log('系统组卷::::', values); - const {code, data: paper, msg} = await autoPaperOfficial({rules_id:Number(params?.id || rulesId), question_count: values?.questionCount.toString(), question_type_count: values?.questionTypeCount.toString()}) + const { code, data: paper, msg } = await autoPaperOfficial({ rules_id: Number(params?.id || rulesId), question_count: values?.questionCount.toString(), question_type_count: values?.questionTypeCount.toString() }) console.log('paper', paper) // setUuidPaper(paper?.paper_uuid) // message.success('提交成功'); @@ -599,7 +617,7 @@ export default () => { return true; }} > - + { const values = setterRef.current?.getData() // 获取题型分值数据 const passSocre = setterRef.current?.getValue() // 获取通过分数线 console.log('批量设置分值v::::', values); - const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id || rulesId), type_score: JSON.stringify(values)}) + const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id || rulesId), type_score: JSON.stringify(values) }) console.log('paper', paper) // 总分及通过分 let _sumScore = 0; - values?.forEach((item: { score: number; })=>{ - console.log('item--',item) + values?.forEach((item: { score: number; }) => { + console.log('item--', item) _sumScore += item?.score }) console.log('_sumScore', _sumScore) // 需要处理 - console.log('passSocre',passSocre) + console.log('passSocre', passSocre) //console.log('sumScore',sumScore) - const {success} = await updateScore({rules_id:Number(params?.id || rulesId), pass_socre: passSocre, sum_score: _sumScore}) + const { success } = await updateScore({ rules_id: Number(params?.id || rulesId), pass_socre: passSocre, sum_score: _sumScore }) //setSumScore(_sumScore) // setUuidPaper(paper?.paper_uuid) // message.success('提交成功'); + actionRef.current?.reloadAndRest?.(); handleScoreModalVisible(false) return true; }} > - + { return true; }} > - {questionType && questionType?.map((typeItem, index)=>{ - //console.log('questionType:::', questionType) + {questionTypeValues && questionTypeValues?.map((typeItem, index) => { + console.log('questionType:::', typeItem) return <> {questions?.length === 0 &&
暂无数据
} -
{numberType[index]}. {typeItem?.name}
-
- { questions && questions.map((item, idx)=>( - (typeItem?.code === item?.question_type) && -
- - {questionNumber[item?.question_type]++}. {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} -
- ))} -
- } -
- ))} + {/* 题型 */} +
{numberType[index]}. {typeItem?.typeName} ({typeItem?.count}题)
+ {/* 试题列表 */} +
+ {questions && questions.map((item, idx) => ( + (typeItem?.code === item?.question_type) && +
+ + {questionNumber[item?.question_type]++}. ({typeItem?.typeName},分值{typeItem?.score}){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} +
+ ))} +
+ } +
+ ))}
})} - +