自动组卷

master
zhengpengju 3 years ago
parent 0778ce36b8
commit 2589f5f3e2

@ -56,7 +56,7 @@ const AutoSelector = (props: any, ref: any) => {
console.log('props subject_id', props)
const { subjectId, questionType } = props;
console.log('questionType', questionType)
const [typeChapterCount, setTypeChapterCount] = useState([]) ; // 题型分数数组 [{"question_type":0,"chapter_list": [{ "chapter_id":3, "count":1 }]}]
const [rows, setRows] = useState([]) ; // 章节
//const [dataSource, setDataSource] = useState<DataSourceType[]>(() => defaultData);
@ -96,20 +96,7 @@ const AutoSelector = (props: any, ref: any) => {
//key: 'code',
dataIndex: `type${item?.code}`,
render: ( _dom, record, index) => {
return <Form.Item style={{margin:0}} name={['questionType', idx, index]}><Input min={0} max={3} defaultValue={0} type='text'
onChange={(value)=>{
console.log('record', record)
//{chapter_id: record?.chapter_id, count:0}
/*
console.log('typeChapterCount',typeChapterCount)
const data = typeChapterCount?.map((item, key)=>{
data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)})
})
setTypeChapterCount(data)
console.log('setTypeChapterCount---',typeChapterCount)
*/
}}
/></Form.Item>;
return <Form.Item style={{margin:0}} name={['questionType', idx, index]}><Input min={0} max={3} defaultValue={0} type='text' /></Form.Item>;
},
})
})
@ -119,7 +106,18 @@ const AutoSelector = (props: any, ref: any) => {
useImperativeHandle(ref, () => ({
// 构造ref的获取数据方法
getData: () => { // 组卷数据
return [];
console.log('useImperativeHandle')
const values = formRef.current.getFieldsValue()
console.log(values)
const data = values?.questionType.map((item, key)=>{
return {
question_type:key,
chapter_list: item.map((val,idx)=>(
{chapter_id:rows[idx]?.chapter_id, count: val}
))
}
}) // 题型分数数组 [{"question_type":0,"chapter_list": [{ "chapter_id":3, "count":1 }]}]
return data;
},
}));
@ -144,6 +142,7 @@ const AutoSelector = (props: any, ref: any) => {
page_number: 1,
page_size: 1000,
});
setRows(data?.list)
console.log('data--',data)
/*
const _data = [];

@ -663,15 +663,18 @@ export default () => {
visible={autoModalVisible}
onVisibleChange={handleAutoModalVisible}
onFinish={async () => {
// 需要处理
//console.log('111')
const values = autoRef?.current?.getData()
console.log('values ', values )
const values = autoRef?.current.getData()
console.log('data-v', values)
//const values = [{"question_type":0,"chapter_list": [{ "chapter_id":76, "count":1 },{ "chapter_id":77, "count":1 }]}]
//const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)})
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('提交成功');
setUuidPaper(paper?.paper_uuid)
run({
paper_uuid: paper?.paper_uuid,
page_size: 1000,
page_number: 1
}); // 获取当前选题列表
message.success('提交成功');
handleAutoModalVisible(false)
return true;
}}

Loading…
Cancel
Save