|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
/** 模拟考试 | 资质考试选题 */
|
|
|
|
|
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
|
|
|
|
|
import { Button, InputNumber, message, Space } from 'antd';
|
|
|
|
|
import { Button, InputNumber, message, Space, Form} from 'antd';
|
|
|
|
|
//import { FooterToolbar, PageContainer } from '@ant-design/pro-layout';
|
|
|
|
|
//import { useRequest } from 'umi';
|
|
|
|
|
//import { queryFakeList } from './service';
|
|
|
|
@ -17,6 +17,8 @@ import { queryQuestionList, queryQuestionType } from '@/pages/questionbank/servi
|
|
|
|
|
//import ProForm, { ProFormSelect } from '@ant-design/pro-form';
|
|
|
|
|
import { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table';
|
|
|
|
|
import ProTable from '@ant-design/pro-table';
|
|
|
|
|
import ProForm from '@ant-design/pro-form';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type TableListItem = {
|
|
|
|
|
id: string;
|
|
|
|
@ -32,15 +34,29 @@ export type TableListItem = {
|
|
|
|
|
|
|
|
|
|
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
|
|
|
|
|
const ScoreSetter = (props: any, ref: any) => {
|
|
|
|
|
const match = useRouteMatch();
|
|
|
|
|
console.log('match', match);
|
|
|
|
|
|
|
|
|
|
const [typeScore, setTypeScore] = useState([]) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},]
|
|
|
|
|
//const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
|
|
|
|
|
const [dataSource, setDataSource] = useState([]);
|
|
|
|
|
//const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
|
|
|
|
|
//const [addType, setAddType] = useState({name: '', value: 0});
|
|
|
|
|
|
|
|
|
|
//const actionRef = useRef<ActionType>();
|
|
|
|
|
const [sumScore, setSumScore] = useState(0); // 总分
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const formRef = useRef();
|
|
|
|
|
const formEntityRef = useRef();
|
|
|
|
|
|
|
|
|
|
//const actionRef = useRef<ActionType>();
|
|
|
|
|
|
|
|
|
|
/** 列表项定义 */
|
|
|
|
|
const columns: any = [
|
|
|
|
|
{
|
|
|
|
|
title: '题型',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
key: 'code',
|
|
|
|
|
//key: 'code',
|
|
|
|
|
width: 100,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
@ -48,15 +64,32 @@ const ScoreSetter = (props: any, ref: any) => {
|
|
|
|
|
dataIndex: 'score',
|
|
|
|
|
key: 'code',
|
|
|
|
|
width: 400,
|
|
|
|
|
render: (text, record) =>
|
|
|
|
|
render: (text, record, index) =>
|
|
|
|
|
<Space direction='horizontal'>
|
|
|
|
|
<span>每题</span>
|
|
|
|
|
<InputNumber type="number" placeholder="请输入" size="small" />
|
|
|
|
|
<Form.Item style={{margin:0}} name={`score[${index}]`}><InputNumber type="number" placeholder="请输入" size="small" onChange={(value)=>{
|
|
|
|
|
console.log('row', index)
|
|
|
|
|
console.log('v1',value)
|
|
|
|
|
const _data = [];
|
|
|
|
|
console.log('typeScore1',typeScore)
|
|
|
|
|
typeScore?.forEach((item, key)=>{
|
|
|
|
|
_data.push({...item, score: ((index === key) ? value : item?.score)})
|
|
|
|
|
})
|
|
|
|
|
setTypeScore(_data)
|
|
|
|
|
}}/></Form.Item>
|
|
|
|
|
<span>分</span>
|
|
|
|
|
{ (record?.code === 1) &&
|
|
|
|
|
<>
|
|
|
|
|
<span>错选、漏选得 </span>
|
|
|
|
|
<InputNumber type="number" placeholder="请输入" size="small" name='score_harf' />
|
|
|
|
|
<span>错选、漏选得:: </span>
|
|
|
|
|
<Form.Item style={{margin:0}} name={`score_harf`}><InputNumber type="number" placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
|
|
|
|
|
//
|
|
|
|
|
const _data = [];
|
|
|
|
|
console.log('typeScore',typeScore)
|
|
|
|
|
typeScore?.forEach((item, key)=>{
|
|
|
|
|
_data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)})
|
|
|
|
|
})
|
|
|
|
|
setTypeScore(_data)
|
|
|
|
|
}} /></Form.Item>
|
|
|
|
|
<span>分</span>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
@ -79,63 +112,69 @@ const ScoreSetter = (props: any, ref: any) => {
|
|
|
|
|
width: 80,
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
const match = useRouteMatch();
|
|
|
|
|
console.log('match', match);
|
|
|
|
|
|
|
|
|
|
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
|
|
|
|
|
const [questionType, setQuestionType] = useState([]);
|
|
|
|
|
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
|
|
|
|
|
const [addType, setAddType] = useState({name: '', value: 0});
|
|
|
|
|
/*
|
|
|
|
|
const labels = ['A','B','C','D','E']
|
|
|
|
|
//const labels = ['A','B','C','D','E']
|
|
|
|
|
|
|
|
|
|
// 获取题型
|
|
|
|
|
const { data } = useRequest(() => {
|
|
|
|
|
return queryQuestionType();
|
|
|
|
|
},{
|
|
|
|
|
formatResult: (result) => {
|
|
|
|
|
return result.list;
|
|
|
|
|
const _data = [];
|
|
|
|
|
if(result.list){
|
|
|
|
|
result.list.forEach((item)=>{
|
|
|
|
|
_data.push({
|
|
|
|
|
name: item?.name,
|
|
|
|
|
code: item?.code,
|
|
|
|
|
count: 0,
|
|
|
|
|
score_sum: 0,
|
|
|
|
|
harf: 0
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
console.log('_data',_data)
|
|
|
|
|
return _data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setQuestionType(data || []);
|
|
|
|
|
return ()=>{
|
|
|
|
|
}
|
|
|
|
|
setDataSource(data);
|
|
|
|
|
console.log('data', data)
|
|
|
|
|
const _typeScore = [];
|
|
|
|
|
data?.forEach((item)=>{
|
|
|
|
|
_typeScore.push({question_type: item?.code, score: item?.count, score_harf: 0})
|
|
|
|
|
})
|
|
|
|
|
setTypeScore(_typeScore) // 初始值
|
|
|
|
|
//return ()=>{}
|
|
|
|
|
}, [data]);
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 暴露组件的方法 接受外部获取的ref
|
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
|
|
|
// 构造ref的获取数据方法
|
|
|
|
|
getSelectedRows: () => {
|
|
|
|
|
return selectedRowsState;
|
|
|
|
|
getData: () => {
|
|
|
|
|
return typeScore;
|
|
|
|
|
},
|
|
|
|
|
}));
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Form
|
|
|
|
|
ref={formRef}
|
|
|
|
|
>
|
|
|
|
|
<EditableProTable
|
|
|
|
|
title={()=>{return <Space>共计 0 题, 总计 0 分 通过分数线 0 分</Space>}}
|
|
|
|
|
title={()=>{return <Space>共计 0 题, 总计 {sumScore} 分 通过分数线
|
|
|
|
|
<Form.Item style={{margin:0}} name='win' initialValue={0}><InputNumber /></Form.Item>
|
|
|
|
|
分</Space>}}
|
|
|
|
|
//formMapRef={formMapRef}
|
|
|
|
|
//rowKey={'code'}
|
|
|
|
|
bordered
|
|
|
|
|
cardProps={{bodyStyle:{padding:0}}}
|
|
|
|
|
recordCreatorProps={false}
|
|
|
|
|
search={false}
|
|
|
|
|
options={false}
|
|
|
|
|
request={async ()=>{
|
|
|
|
|
const { list } = await queryQuestionType()
|
|
|
|
|
console.log('list', list);
|
|
|
|
|
const _data = []
|
|
|
|
|
list.forEach((item)=>{
|
|
|
|
|
_data.push({
|
|
|
|
|
name: item?.name,
|
|
|
|
|
code: item?.code,
|
|
|
|
|
count: 0,
|
|
|
|
|
score_sum: 0,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
return {data: _data}
|
|
|
|
|
}}
|
|
|
|
|
columns={columns} />
|
|
|
|
|
</>
|
|
|
|
|
value={dataSource}
|
|
|
|
|
columns={columns}
|
|
|
|
|
/>
|
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
// forwardRef这个组件能够将其接受的 ref 属性转发到其组件树下
|
|
|
|
|