From 35c2fe430ba5499be3b245c8c0d6c83e9087753d Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Thu, 3 Mar 2022 16:23:12 +0800 Subject: [PATCH 1/6] fix bug --- admin/src/pages/dashboard/analysis/index.tsx | 2 +- admin/src/pages/demo/index.tsx | 65 +++++++++++++- .../attestation/step/index.tsx | 17 +++- .../components/QuestionSelector.tsx | 1 + .../components/ScoreSetter.tsx | 31 ++++--- .../examinationrules/normal/step/index.tsx | 87 +++++++++++++++---- admin/src/pages/examinationrules/service.ts | 30 ++++++- admin/src/pages/history/analysis/index.tsx | 15 ---- admin/src/pages/questionbank/index.tsx | 10 ++- 9 files changed, 202 insertions(+), 56 deletions(-) diff --git a/admin/src/pages/dashboard/analysis/index.tsx b/admin/src/pages/dashboard/analysis/index.tsx index 651e1cf..9360997 100644 --- a/admin/src/pages/dashboard/analysis/index.tsx +++ b/admin/src/pages/dashboard/analysis/index.tsx @@ -59,7 +59,7 @@ const Analysis: FC = () => { - {/** 课程浏览量/月柱形图 */} + {/** 课程浏览量/月柱形图 需要处理 */} { + // 秒 + let second = parseInt(value) + // 分 + let minute = 0 + // 小时 + let hour = 0 + // 天 + // let day = 0 + // 如果秒数大于60,将秒数转换成整数 + if (second > 60) { + // 获取分钟,除以60取整数,得到整数分钟 + minute = parseInt(second / 60) + // 获取秒数,秒数取佘,得到整数秒数 + second = parseInt(second % 60) + // 如果分钟大于60,将分钟转换成小时 + if (minute > 60) { + // 获取小时,获取分钟除以60,得到整数小时 + hour = parseInt(minute / 60) + // 获取小时后取佘的分,获取分钟除以60取佘的分 + minute = parseInt(minute % 60) + // 如果小时大于24,将小时转换成天 + // if (hour > 23) { + // // 获取天数,获取小时除以24,得到整天数 + // day = parseInt(hour / 24) + // // 获取天数后取余的小时,获取小时除以24取余的小时 + // hour = parseInt(hour % 24) + // } + } + } + + let result = '' + parseInt(second) + ' 秒 ' + if (minute > 0) { + result = '' + parseInt(minute) + ' 分 ' + result + } + if (hour > 0) { + result = '' + parseInt(hour) + ' 小时 ' + result + } + // if (day > 0) { + // result = '' + parseInt(day) + '天' + result + // } + console.log('result:', result) + return result +} export default () => { const uuid = uuidv4() console.log('uuid', uuidv4()); @@ -131,12 +175,24 @@ export default () => { const [selectedCourse, setSelectedCourse] = useState(0); const [menu, setMenu] = useState(); + + const [timeData, setTimeData] = useState(0); + + useEffect(() => { + let secondValue = 3000; // 秒 截至时间 - 服务器当前时间 + setTimeData(secondValue) + const timer = setInterval(() => { // + setTimeData((secondValue > 1) ? secondValue-- : 0); + }, 1000); + return ()=>{ + clearInterval(timer) // 清理计算器 + } + },[]) + /** 获取课程数据 */ const { data: listData } = useRequest(() => { return queryCourseList(); }); - - useEffect(() => { console.log('listData', listData) setInterval(() => { @@ -261,6 +317,9 @@ export default () => { D {}}>rrrrr + + +
{formatSeconds(timeData)}
) }; diff --git a/admin/src/pages/examinationrules/attestation/step/index.tsx b/admin/src/pages/examinationrules/attestation/step/index.tsx index 336a353..65a4cb9 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.tsx +++ b/admin/src/pages/examinationrules/attestation/step/index.tsx @@ -322,7 +322,6 @@ export default () => { }} >
- {`试卷`} { page_number: value.current, page_size: value.pageSize } - ); - + ); const _questionTypeCountData = []; _data.question_list[0]?.question_type_count.forEach((item)=>{ @@ -486,6 +484,19 @@ export default () => { console.log('批量设置分值v::::', values); const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)}) console.log('paper', paper) + // 总分及通过分 + let _sumScore = 0; + values?.forEach((item)=>{ + console.log('item--',item) + _sumScore += item?.score + }) + console.log('_sumScore', _sumScore) + /* + // 需要处理 + console.log('passSocre',passSocre) + console.log('sumScore',sumScore) + const {success} = await updateScore({rules_id:Number(params?.id), pass_socre: passSocre, sum_score: _sumScore})*/ + setSumScore(_sumScore) // setUuidPaper(paper?.paper_uuid) // message.success('提交成功'); handleScoreModalVisible(false) diff --git a/admin/src/pages/examinationrules/components/QuestionSelector.tsx b/admin/src/pages/examinationrules/components/QuestionSelector.tsx index dc588c9..b2c5bc1 100644 --- a/admin/src/pages/examinationrules/components/QuestionSelector.tsx +++ b/admin/src/pages/examinationrules/components/QuestionSelector.tsx @@ -112,6 +112,7 @@ const QuestionSelector = (props: any, ref: any) => { return selectedRowsState; }, })); + return ( <> { const {questionTypeValues} = props - console.log('questionTypeValues', questionTypeValues) + console.log('questionTypeValues:::', questionTypeValues) const match = useRouteMatch(); console.log('match', match); @@ -47,8 +47,9 @@ const ScoreSetter = (props: any, ref: any) => { const [dataSource, setDataSource] = useState([]); //const [selectedRowsState, setSelectedRows] = useState([]); //const [addType, setAddType] = useState({name: '', value: 0}); - - let sumScore = 0 // 总分 + const [sumScore, setSumScore] = useState(0); + + //let sumScore = 0 // 总分 const formRef = useRef(); @@ -70,7 +71,7 @@ const ScoreSetter = (props: any, ref: any) => { render: (text, record, index) => 每题 - { + { console.log('row', index) console.log('v1',value) const _data = []; @@ -88,8 +89,8 @@ const ScoreSetter = (props: any, ref: any) => { { (record?.code === 1) && <> - 错选、漏选得:: - { + 错选、漏选得: + { // const _data = []; console.log('typeScore',typeScore) @@ -107,7 +108,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index].count : '0'}, + render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}, /* editable: (text, record, index) => { return true; @@ -119,8 +120,6 @@ const ScoreSetter = (props: any, ref: any) => { //key: 'age', width: 80, render: (text, _, index) => { - //console.log('===',typeScore ? typeScore[index].score * questionTypeValues[index].count : '0') - sumScore = sumScore + ((typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : 0) return <> {(typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : '0'} @@ -170,6 +169,18 @@ const ScoreSetter = (props: any, ref: any) => { //return ()=>{} }, [data]); + /** 计算总分 */ + useEffect(() => { + console.log('typeScore', typeScore) + let _sum = 0; + typeScore?.forEach((item, index)=>{ + _sum += item.score * questionTypeValues[index]?.count; + }) + + setSumScore(_sum) + //return ()=>{} + }, [typeScore]); + // 暴露组件的方法 接受外部获取的ref useImperativeHandle(ref, () => ({ // 构造ref的获取数据方法 @@ -185,7 +196,7 @@ const ScoreSetter = (props: any, ref: any) => { { return 共计 {sumQuestion} 题, 总计 {sumScore} 分 通过分数线 - + }} //formMapRef={formMapRef} //rowKey={'code'} diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 07e9ae2..33c3379 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -16,7 +16,7 @@ import { Button, Checkbox, Col, Divider, Dropdown, Form, Input, List, Menu, mess import { PageContainer } from '@ant-design/pro-layout'; import ProDescriptions from '@ant-design/pro-descriptions'; import styles from './index.less' -import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList, saveQuestionTypeScore } from '../../service'; +import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList, saveQuestionTypeScore, queryRulesPaper, updateScore } from '../../service'; import { queryCourseView } from '@/pages/course/option/service'; import { queryQuestionList, queryQuestionById, queryQuestionType } from '@/pages/questionbank/service'; import { PlusOutlined, DownOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EyeInvisibleOutlined, EyeOutlined, EditOutlined, ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons'; @@ -85,13 +85,6 @@ const handleAppend = async (rules_id: number, rows: any[]) => { } }; -const waitTime = (time: number = 100) => { - return new Promise((resolve) => { - setTimeout(() => { - resolve(true); - }, time); - }); -}; const labels = ['A','B','C','D','E','F','G','H','I','J','K'] // 模拟考试规则维护 export default () => { @@ -103,10 +96,15 @@ export default () => { const [subjectId, setSubjectId] = useState(0); // 关联主题id const [subjectName, setSubjectName] = useState(''); // 关联主题name + const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] + const [uuidPaper, setUuidPaper] = useState(0); const [createType, setCreateType] = useState(1); // 组卷类型 const [rulesName, setRulesName] = useState(''); // 组卷类型 + const [sumScore, setSumScore] = useState(0); // 总分 + const [passSocre, setPassSocre] = useState(0); // 通过分数线 + const [typeQuestionCount, setTypeQuestionCount] = useState([0, 0, 0]); // 临时卷 各题型数量 const formRef = useRef(); @@ -141,7 +139,38 @@ export default () => { /** 组卷,查询试题临时表(当前选题列表) */ const { data: questions, run } = useRequest(async (params) => { console.log('questions', questions) - return queryTempQuestionList(params); + const _data = await queryTempQuestionList(params); + return _data; + },{ + manual: true, + formatResult: (result) => { + return result?.table_List; + }}); + + /** 从临时表中计算各题型数量 */ + useEffect(() => { + let _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序 + console.log('questions-info', questions) + questions?.forEach((item)=>{ + _data[Number(item?.question_type)] += 1 + }) + + setTypeQuestionCount(_data); + return ()=>{ + /** 退出当前页面清空Map */ + //parsingMap.clear(); + } + }, [questions]); + // + const { data: paperData, run: runPaper } = useRequest(async (params) => { + console.log('paperData', paperData) + /** + * rules_id: params?.id, + page_number: value.current, + page_size: value.pageSize + */ + + return queryRulesPaper(params); },{ manual: true, formatResult: (result) => { @@ -275,6 +304,7 @@ export default () => { onFinish={async () => { console.log(formRef.current?.getFieldsValue()); setCurrentStep(2) // 设置步骤号 + runPaper({rules_id: params?.id }) return true; }} > @@ -359,7 +389,7 @@ export default () => { { questionType.map((item)=>{ - return {item?.name} 共 { '-' } 题 { '-' } 分 + return {item?.name} 共 { typeQuestionCount[Number(item.code)] } 题 { '-' } 分 } )} @@ -378,6 +408,14 @@ export default () => { }}>选择试题 @@ -468,14 +481,11 @@ export default () => { { {/** 需要从试卷 或 临时试卷 中读取 */} return - 共 0 道题, 100 分 + 共 0 道题, {paperInfo?.sum_score} 分 单选: 0 道题 单选: 0 道题 单选: 0 道题 - 通过线 {0} 分 - - + 通过线 {paperInfo?.pass_score} 分 + }} /> - - } @@ -515,11 +525,13 @@ export default () => { width="60%" visible={autoModalVisible} onVisibleChange={ handleAutoModalVisible } - footer={null} - onFinish={async () => { - const values = autoRef?.current?.getData() - const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)}) - console.log('paper', paper) + onFinish={async () => { + // 需要处理 + //console.log('111') + //const values = autoRef?.current?.getData() + //console.log('2222') + //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('提交成功'); handleAutoModalVisible(false) @@ -534,10 +546,11 @@ export default () => { width="60%" visible={scoreModalVisible} onVisibleChange={handleScoreModalVisible} - footer={null} onFinish={async () => { console.log('typeQuestionCount', typeQuestionCount) - const values = setterRef.current?.getData() + const values = setterRef.current?.getData() // 获取题型分值数据 + const passSocre = setterRef.current?.getValue() // 获取通过分数线 + console.log('批量设置分值v::::2', values); // 题型分数 const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)}) @@ -547,10 +560,10 @@ export default () => { console.log('item--',item) _sumScore += item?.score }) - console.log('_sumScore', _sumScore) + //console.log('_sumScore', _sumScore) - console.log('passSocre',passSocre) - console.log('sumScore',sumScore) + //console.log('passScore',passScore) + console.log('sumScore',sumScore) const {success} = await updateScore({rules_id:Number(params?.id), pass_socre: passSocre, sum_score: _sumScore}) setSumScore(_sumScore) console.log('paper', paper) diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index fffe18a..5950ce0 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -430,7 +430,7 @@ const QuestionBank = () => { console.log('item', item); return ( - {`${(record?.question_type === 2) ? ['T','F'][key] : labels[key]}. ${item?.answer}`} + {`${(record?.question_type === 2) ? ['A','B'][key] : labels[key]}. ${item?.answer}`} ) }} /> @@ -450,7 +450,7 @@ const QuestionBank = () => { answer = labels?.filter((x, idx, self)=>`${answertrue[idx]}` === `1`).toString() break; case 2: // 判断 - answer = ['T', 'F']?.filter((x, idx, self)=>`${answertrue[idx]}` === `1`).toString() + answer = ['A', 'B']?.filter((x, idx, self)=>`${answertrue[idx]}` === `1`).toString() break; } console.log('expandedDescRowKeys', expandedDescRowKeys) From c7f3d5f85c5ea5104a2927ec0aeb5721547d2ed8 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Thu, 3 Mar 2022 19:22:00 +0800 Subject: [PATCH 4/6] fix --- admin/src/pages/examinationrules/normal/step/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index d73f6f0..7d98cbe 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -389,7 +389,6 @@ export default () => { -
@@ -479,7 +478,7 @@ export default () => { (`${text} 分钟`)} /> { - {/** 需要从试卷 或 临时试卷 中读取 */} + {/** 需要从试卷 或 临时试卷 中读取 需要处理 */} return 共 0 道题, {paperInfo?.sum_score} 分 单选: 0 道题 单选: 0 道题 单选: 0 道题 From ff601e6e44b090088f7fdaac1b65b7ebb1e0fa25 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Fri, 4 Mar 2022 08:02:12 +0800 Subject: [PATCH 5/6] fix bug --- admin/src/pages/questionbank/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index 5950ce0..824e8b5 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -199,13 +199,16 @@ const QuestionBank = () => { renderFormItem: (item, { defaultRender, ...rest }, form) => { // 需要处理 关联长度变化及编辑回显 console.log('edit answertrue11', item) + console.log('form::::::',form.getFieldValue('answertrue')) // 0 单选 1 多选 2 判断 return (addType?.value !== 1 ) ? - { + form.setFieldsValue({answertrue: 'B'}) + }} /> : { initialValue={[]} options={['A', 'B', 'C', 'D']} /> - + }, /* formItemProps: { From 436ce95de28924bf9732eb64190386c8e523f4ac Mon Sep 17 00:00:00 2001 From: wangxi <123456> Date: Fri, 4 Mar 2022 10:35:57 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E7=94=9F=E6=B6=AF=E8=80=83=E8=AF=95?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E5=88=A0=E9=99=A4mock=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../analysis/components/IntroduceRow.tsx | 1 + admin/src/pages/history/analysis/index.tsx | 51 +++++++++++-------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/admin/src/pages/history/analysis/components/IntroduceRow.tsx b/admin/src/pages/history/analysis/components/IntroduceRow.tsx index 150901a..04eead9 100644 --- a/admin/src/pages/history/analysis/components/IntroduceRow.tsx +++ b/admin/src/pages/history/analysis/components/IntroduceRow.tsx @@ -211,6 +211,7 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat onChange={(id) => { area_id=id; handleSearch(''); + run() }} > diff --git a/admin/src/pages/history/analysis/index.tsx b/admin/src/pages/history/analysis/index.tsx index 7c8ab00..2f73357 100644 --- a/admin/src/pages/history/analysis/index.tsx +++ b/admin/src/pages/history/analysis/index.tsx @@ -42,7 +42,7 @@ const Analysis: FC = () => { getTimeDistance('year'), ); - const { loading, data } = useRequest(fakeChartData); + // const { loading, data } = useRequest(fakeChartData); const selectDate = (type: TimeType) => { setRangePickerValue(getTimeDistance(type)); @@ -73,46 +73,55 @@ const Analysis: FC = () => { }; let salesPieData; - if (salesType === 'all') { - salesPieData = data?.salesTypeData; - } else { - salesPieData = salesType === 'online' ? data?.salesTypeDataOnline : data?.salesTypeDataOffline; - } - - const handleChangeSalesType = (e: RadioChangeEvent) => { - setSalesType(e.target.value); - }; - - const handleTabChange = (key: string) => { - setCurrentTabKey(key); - }; - - const activeKey = currentTabKey || (data?.offlineData[0] && data?.offlineData[0].name) || ''; + // if (salesType === 'all') { + // salesPieData = data?.salesTypeData; + // } else { + // salesPieData = salesType === 'online' ? data?.salesTypeDataOnline : data?.salesTypeDataOffline; + // } + // + // const handleChangeSalesType = (e: RadioChangeEvent) => { + // setSalesType(e.target.value); + // }; + // + // const handleTabChange = (key: string) => { + // setCurrentTabKey(key); + // }; + // + // const activeKey = currentTabKey || (data?.offlineData[0] && data?.offlineData[0].name) || ''; return ( <> }> - + - + - +