|
|
|
@ -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<any>([]) // 分数变更标记
|
|
|
|
|
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<API.RuleListItem[]>([]);
|
|
|
|
|
//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<any>();
|
|
|
|
|
|
|
|
|
|
/** 列表项定义 */
|
|
|
|
@ -82,24 +78,22 @@ const ScoreSetter = (props: any, ref: any) => {
|
|
|
|
|
<span>分</span>
|
|
|
|
|
{ (record?.code === 1) &&
|
|
|
|
|
<>
|
|
|
|
|
<span>错选、漏选得:</span>
|
|
|
|
|
<Form.Item style={{margin:0}} name={`score_harf`}
|
|
|
|
|
rules={[
|
|
|
|
|
/*
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入分值!',
|
|
|
|
|
},*/
|
|
|
|
|
]}
|
|
|
|
|
><InputNumber min={0} max={99} maxLength={2} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
|
|
|
|
|
//
|
|
|
|
|
const _data = [];
|
|
|
|
|
typeScore?.forEach((item: { score_harf: any; }, key: number)=>{
|
|
|
|
|
_data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)})
|
|
|
|
|
})
|
|
|
|
|
setTypeScore(_data)
|
|
|
|
|
}} /></Form.Item>
|
|
|
|
|
<span>分</span>
|
|
|
|
|
<span>错选、漏选得:</span>
|
|
|
|
|
<Form.Item style={{margin:0}} name={`score_harf`}
|
|
|
|
|
rules={[
|
|
|
|
|
/*
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: '请输入分值!',
|
|
|
|
|
},*/
|
|
|
|
|
]}
|
|
|
|
|
><InputNumber min={0} max={99} maxLength={2} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
|
|
|
|
|
const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{
|
|
|
|
|
return {...item, score_harf: ((index === key) ? value : item?.score_harf)}
|
|
|
|
|
})
|
|
|
|
|
setTypeScore(harf)
|
|
|
|
|
}} /></Form.Item>
|
|
|
|
|
<span>分</span>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
</Space>,
|
|
|
|
@ -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 :
|
|
|
|
|