|
|
|
@ -38,84 +38,27 @@ export type TableListItem = {
|
|
|
|
|
// 资质考试自动组卷
|
|
|
|
|
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
|
|
|
|
|
const AutoSelector = (props: any, ref: any) => {
|
|
|
|
|
const { questionType } = props;
|
|
|
|
|
|
|
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
|
|
/** 列表项定义 */
|
|
|
|
|
const columns: ProColumns<TableListItem>[] | ProColumns<TableListItem>[] = [
|
|
|
|
|
{
|
|
|
|
|
title: '序号',
|
|
|
|
|
key: 'index',
|
|
|
|
|
valueType: 'indexBorder',
|
|
|
|
|
render: (text: React.ReactNode, _: any, index: number) => {
|
|
|
|
|
if (actionRef && actionRef?.current && actionRef?.current?.pageInfo) {
|
|
|
|
|
return `${(actionRef?.current?.pageInfo?.current - 1) * actionRef.current.pageInfo?.pageSize + (index + 1)
|
|
|
|
|
}`;
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
width: 48,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '类型',
|
|
|
|
|
dataIndex: 'question_type',
|
|
|
|
|
valueType: 'select',
|
|
|
|
|
hideInTable: false,
|
|
|
|
|
hideInForm: true,
|
|
|
|
|
hideInSearch: false,
|
|
|
|
|
width: 100,
|
|
|
|
|
request: async () => {
|
|
|
|
|
const { list: Items } = await queryQuestionType();
|
|
|
|
|
const types = []
|
|
|
|
|
for (let i = 0; i < Items.length; i++) {
|
|
|
|
|
types.push({text: Items[i]?.name, label: Items[i]?.name, value: Items[i]?.code })
|
|
|
|
|
}
|
|
|
|
|
return types;
|
|
|
|
|
},
|
|
|
|
|
render: (text: React.ReactNode, _: any, index: number) => {
|
|
|
|
|
return text;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '题干',
|
|
|
|
|
dataIndex: 'question_stem',
|
|
|
|
|
valueType: 'text',
|
|
|
|
|
hideInTable: false,
|
|
|
|
|
hideInForm: true,
|
|
|
|
|
hideInSearch: false,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
// const actionRef = useRef<ActionType>();
|
|
|
|
|
const [questionCount, setQuestionCount] = useState([0,0]) // 题库抽取数量
|
|
|
|
|
const [questionTypeCount, setQuestionTypeCount] = useState(questionType.map(()=>(0))) // 题型抽取数量
|
|
|
|
|
|
|
|
|
|
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 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 { data } = useRequest(() => {
|
|
|
|
|
return queryQuestionType();
|
|
|
|
|
},{
|
|
|
|
|
formatResult: (result) => {
|
|
|
|
|
return result.list;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setQuestionType(data || []);
|
|
|
|
|
return ()=>{
|
|
|
|
|
}
|
|
|
|
|
}, [data]);
|
|
|
|
|
|
|
|
|
|
// 暴露组件的方法 接受外部获取的ref
|
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
|
|
|
// 构造ref的获取数据方法
|
|
|
|
|
getSelectedRows: () => {
|
|
|
|
|
return selectedRowsState;
|
|
|
|
|
getData: () => { // 组卷
|
|
|
|
|
return {questionCount, questionTypeCount};
|
|
|
|
|
},
|
|
|
|
|
}));
|
|
|
|
|
return (
|
|
|
|
@ -123,26 +66,31 @@ const AutoSelector = (props: any, ref: any) => {
|
|
|
|
|
<Row><Col style={{padding:10}}>题库选择</Col></Row>
|
|
|
|
|
<Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={5}>{`常规题库 ( ${0} 道题)`}</Col>
|
|
|
|
|
<Col offset={1} span={10}>抽取比例: <InputNumber value={0} style={{textAlign:'center'}} /> %</Col>
|
|
|
|
|
<Col offset={1} span={10}>抽取比例: <InputNumber defaultValue={0} style={{textAlign:'center'}} onChange={(value)=>{
|
|
|
|
|
setQuestionCount([value,questionCount[1]])
|
|
|
|
|
}} /> %</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={5}>{`资质考试题库 ( ${0} 道题)`}</Col>
|
|
|
|
|
<Col offset={1} span={10}>抽取比例: <InputNumber value={0} style={{textAlign:'center'}} /> %</Col>
|
|
|
|
|
<Col offset={1} span={10}>抽取比例: <InputNumber defaultValue={0} style={{textAlign:'center'}} onChange={(value)=>{
|
|
|
|
|
setQuestionCount([questionCount[0], value])
|
|
|
|
|
}} /> %</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
<Row><Col style={{padding:10}}>题型选择</Col></Row>
|
|
|
|
|
<Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={2}>{`单选`}</Col>
|
|
|
|
|
<Col offset={1} span={10}><InputNumber value={0} style={{textAlign:'center'}}/> 题</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={2}>{`多选`}</Col>
|
|
|
|
|
<Col offset={1} span={10}><InputNumber value={0} style={{textAlign:'center'}}/> 题</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={2}>{`判断`}</Col>
|
|
|
|
|
<Col offset={1} span={10}><InputNumber value={0} style={{textAlign:'center'}}/> 题</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
{ questionType && questionType.map((item, index)=>{
|
|
|
|
|
return <Row style={{padding:5}}>
|
|
|
|
|
<Col offset={1} span={2}>{`${item?.name}`}</Col>
|
|
|
|
|
<Col offset={1} span={10}><InputNumber defaultValue={0} style={{textAlign:'center'}} onChange={(value)=>{
|
|
|
|
|
const _data = [];
|
|
|
|
|
questionTypeCount.forEach((val, key) => {
|
|
|
|
|
_data.push(index === key ? value : val)
|
|
|
|
|
});
|
|
|
|
|
setQuestionTypeCount(_data)
|
|
|
|
|
}} /> 题</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
}
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|