From b1ebe5ded9926985446a89378cf746fbd40efa01 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 28 Mar 2022 15:46:06 +0800 Subject: [PATCH] fix score setter --- admin/src/pages/course/option/index.tsx | 10 +++++-- .../components/ScoreSetter.tsx | 28 ++++++++++++++----- .../examinationrules/normal/step/index.tsx | 7 +++-- admin/src/pages/questionbank/index.tsx | 5 ++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index 78ebaac..6ea760c 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -275,6 +275,7 @@ const CourseList: React.FC = () => { message.error('视频编码格式不正确(视频采用AVC,音频采用AAC)') return false; } + console.log('filename', file?.name) // 获取文件名 SetUploadFileName(file?.name); // 获取最后一个.的位置 @@ -609,9 +610,12 @@ const CourseList: React.FC = () => { //return false; await handleAdd({ ...values, - //course_id: currentRow?.course_id, - attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, - attachment_filesize: values?.attachment_json?.file?.size, // 字节 + ////course_id: currentRow?.course_id, + //attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, + //attachment_filesize: values?.attachment_json?.file?.size, // 字节 + + attachment_json: `{"img":"", "name": "${values?.attachment_json[0]?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`, + attachment_filesize: values?.attachment_json[0]?.size, // 字节 }); handleCreateModalVisible(false); // 隐藏创建窗口 actionRef.current?.reloadAndRest?.(); diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index 39c65ca..3f2f6f3 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -61,7 +61,7 @@ const ScoreSetter = (props: any, ref: any) => { e.currentTarget.value = val.slice(0,3) } }} - defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0} + defaultValue={questionTypeValues ? questionTypeValues[index]?.score || 0 : 0} placeholder="请输入" size="small" onChange={(e)=>{ @@ -87,7 +87,7 @@ const ScoreSetter = (props: any, ref: any) => { message: '请输入分值!', },*/ ]} - >{ + >{ const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{ return {...item, score_harf: ((index === key) ? value : item?.score_harf)} }) @@ -102,7 +102,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}, + render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count || 0 : '0'}, }, { title: '总分值', @@ -112,8 +112,8 @@ const ScoreSetter = (props: any, ref: any) => { render: (_text: any, _: any, index: number) => { return <> {flag?.indexOf(index) === -1 ? - questionTypeValues[index]?.score * questionTypeValues[index].count : - (typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * questionTypeValues[index]?.count).toFixed(1) : '0' + (questionTypeValues[index]?.score || 0) * (questionTypeValues[index]?.count || 0) : + (typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * (questionTypeValues[index]?.count || 0)).toFixed(1) : '0' } }, @@ -154,20 +154,23 @@ const ScoreSetter = (props: any, ref: any) => { > { - return 共计 {sumQuestion} 题,总计 { + return 共计 {sumQuestion || 0} 题,总计 { + typeScore?.length > 0 && typeScore?.map((item: any, key: number)=>{return item?.score * questionTypeValues[key].count})?.reduce((total: number, item: number)=>(total + item)) || 0 } 分 通过分数线 - { + { setPassScore(value) }} />}} //formMapRef={formMapRef} rowKey={'code'} request={async ()=>{ + console.log('questionTypeValues1111', questionTypeValues) const result = await queryQuestionType() // 从字典获取题型数据 [{code: 0, name:"单选题"},] setTypeScore(questionTypeValues?.map((item: { score: any; score_harf: any; }, key: number)=>{ return {question_type: result.list[key]?.code, score: item?.score, score_harf: (item?.score_harf || 0)} })) + return {data:questionTypeValues?.map((item: any, key: number)=>({ ...item, code: result.list[key]?.code, @@ -175,6 +178,17 @@ const ScoreSetter = (props: any, ref: any) => { name: result.list[key]?.name, count: result.list[key]?.count }))} + + /* + return {data:result?.list?.map((item: any)=>({ + ...item, + code: item?.code, + question_type: item?.code, + name: item?.name, + count: item?.count || 0 + }))} + */ + }} bordered cardProps={{bodyStyle:{padding:0}}} diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 1f5c1e1..7e804ac 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -642,7 +642,8 @@ export default () => { //const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId) //console.log('q::', questionTypeScore) - console.log('typeQuestionCount', typeQuestionCount); + console.log('typeQuestionCount---------------', typeQuestionCount); + setPassScore(ruleData?.pass_score) handleScoreModalVisible(true) }}>批量设置分值 @@ -798,8 +799,8 @@ export default () => { handleScoreModalVisible(false) return true; }} - >{console.log('q1',questionTypeValues)}{console.log('q2',scoreData)} - + > + 0 ? questionTypeValues : questionType?.map((item,key)=>({...item, count: typeQuestionCount[key]}))} passScore={passScore} /> diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index 269853e..0f7dd37 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -34,6 +34,7 @@ console.log('first'); * @param fields */ const handleAdd = async (fields: TableListItem) => { + console.log('handleadd...') const hide = message.loading('正在添加'); try { await saveQuestion({ ...fields }); @@ -292,7 +293,7 @@ const QuestionBank = () => { hideInForm: false, hideInSearch: true, formItemProps: { - rules: [ + rules: [ { required: true, message: '请填写试题解析', @@ -784,8 +785,6 @@ const QuestionBank = () => { onFinish={async (values: any) => { //console.log('formRef.current', formRef.current.getFieldsValue(['answertrue'])) console.log(values); - return - // 表单处理 console.log('columns:', columns); console.log('values:', values);