diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index fb4cb0e..b848fb3 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -1,5 +1,4 @@ /** 模拟考试 | 资质考试选题 */ - import { InputNumber, Space, Form, Input} from 'antd'; //import styles from '../style.less'; import { forwardRef, useImperativeHandle, useRef, useState } from 'react'; @@ -24,18 +23,15 @@ export type TableListItem = { }; // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 -const ScoreSetter = (props: any, ref: any) => { - const [flag, setFlag] = useState([]) // 分数变更标记 +const ScoreSetter = (props: any, ref: any) => { const {questionTypeValues, passScore: passScoreValue } = props + + const [flag, setFlag] = useState([]) // 分数变更标记 const [typeScore, setTypeScore] = useState(questionTypeValues.map((item: { code: number; score: number; score_harf: number; })=>({question_type:item.code, score: item.score, score_harf: item.score_harf}))) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},] //const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 - //const [selectedRowsState, setSelectedRows] = useState([]); - //const [addType, setAddType] = useState({name: '', value: 0}); //const [sumScore, setSumScore] = useState(); const [passScore, setPassScore] = useState(passScoreValue); // 设置通过分数线 - - //let sumScore = 0 // 总分 - //console.log('init........', typeScore) + const formRef = useRef(); /** 列表项定义 */ @@ -82,24 +78,22 @@ const ScoreSetter = (props: any, ref: any) => { { (record?.code === 1) && <> - 错选、漏选得: - { - // - const _data = []; - typeScore?.forEach((item: { score_harf: any; }, key: number)=>{ - _data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)}) - }) - setTypeScore(_data) - }} /> - + 错选、漏选得: + { + const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{ + return {...item, score_harf: ((index === key) ? value : item?.score_harf)} + }) + setTypeScore(harf) + }} /> + } , @@ -117,9 +111,6 @@ const ScoreSetter = (props: any, ref: any) => { width: 80, defaultValue:()=>{ return 123}, render: (_text: any, _: any, index: number) => { - //console.log('typeScore---', typeScore) - //console.log('questionTypeValues',questionTypeValues) - //console.log('==score==',typeScore) return <> {flag?.indexOf(index) === -1 ? questionTypeValues[index]?.score * questionTypeValues[index].count :