master
zhengpengju 3 years ago
parent d52dede4a6
commit 557845bddc

@ -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>
}
)}
</>
);
};

@ -16,7 +16,7 @@ import { Button, Checkbox, Col, Divider, Input, List, Menu, message, Radio, Row,
import { PageContainer } from '@ant-design/pro-layout';
import ProDescriptions from '@ant-design/pro-descriptions';
import styles from './index.less'
import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper, saveQuestionTypeScore } from '../../service';
import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper, saveQuestionTypeScore, autoPaperOfficial } from '../../service';
import { queryQuestionType } from '@/pages/questionbank/service';
import ProTable, { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table';
import { TableListPagination } from '@/pages/ListTableList2/data';
@ -400,8 +400,18 @@ export default () => {
title="系统组卷"
visible={autoModalVisible}
onVisibleChange={handleAutoModalVisible}
onFinish={async () => {
const values = autoRef.current?.getData();
console.log('系统组卷::::', values);
const {code, data: paper, msg} = await autoPaperOfficial({rules_id:Number(params?.id), question_count: values?.questionCount.toString(), question_type_count: values?.questionTypeCount.toString()})
console.log('paper', paper)
// setUuidPaper(paper?.paper_uuid)
// message.success('提交成功');
handleAutoModalVisible(false)
return true;
}}
>
<AutoSelector ref={autoRef} />
<AutoSelector ref={autoRef} questionType={questionType} />
</ModalForm>
<ModalForm
title={`批量设置分值`}
@ -413,7 +423,6 @@ export default () => {
onFinish={async () => {
const values = setterRef.current?.getData()
console.log('批量设置分值v::::', values);
const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)})
console.log('paper', paper)
// setUuidPaper(paper?.paper_uuid)

@ -47,7 +47,7 @@ const ScoreSetter = (props: any, ref: any) => {
const formRef = useRef();
const formEntityRef = useRef();
//const actionRef = useRef<ActionType>();

@ -3,7 +3,7 @@
*/
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, InputNumber, message } from 'antd';
import { Button, Form, InputNumber, message } from 'antd';
//import { FooterToolbar, PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
@ -63,9 +63,7 @@ const AutoSelector = (props: any, ref: any) => {
console.log('props subject_id', props)
const { subjectId, questionType } = props;
console.log('questionType', questionType)
const [editableKeys, setEditableRowKeys] = useState<React.Key[]>(() =>
defaultData.map((item) => item.id),
);
const [typeScore, setTypeScore] = useState([]) ; // 题型分数数组 [{"question_type":0,"chapter_list": [{ "chapter_id":3, "count":1 }]}]
//const [dataSource, setDataSource] = useState<DataSourceType[]>(() => defaultData);
@ -84,11 +82,21 @@ const AutoSelector = (props: any, ref: any) => {
/* 动态设置题型列 */
questionType?.forEach((item)=>{
columns.push({
title: <>{item?.name} <InputNumber value={0} style={{marginLeft:5}} /></>,
title: <>{item?.name} <Form.Item style={{margin:0}} name={`type${item?.code}`}><InputNumber defaultValue={0} style={{marginLeft:5}} /></Form.Item></>,
//key: 'code',
dataIndex: `type${item?.code}`,
render: ( item, { defaultRender, ...rest }, form) => {
return <InputNumber value={0} />;
return <Form.Item style={{margin:0}} ><InputNumber defaultValue={1}
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>;
},
})
})
@ -140,6 +148,7 @@ const AutoSelector = (props: any, ref: any) => {
// setDataSource
}}
toolBarRender={false}
/*
editable={{
type: 'multiple',
editableKeys,
@ -147,10 +156,12 @@ const AutoSelector = (props: any, ref: any) => {
return [defaultDoms.delete];
},
onValuesChange: (record, recordList) => {
console.log('rrrr',record, recordList)
// setDataSource(recordList);
},
onChange: setEditableRowKeys,
}}
*/
/>
</>
);

@ -139,3 +139,20 @@ export async function manualPaper(
},
});
}
/**
* 25
* @param params
* @returns
*/
export async function autoPaper(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
return request('/dsideal_yy/zygh/training/rules/autoPaper', {
method: 'POST',
requestType: 'form',
data: {
...params,
},
});
}

@ -22,7 +22,7 @@ import { queryQuestionList, queryQuestionById, queryQuestionType } from '@/pages
import { PlusOutlined, DownOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EyeInvisibleOutlined, EyeOutlined, EditOutlined } from '@ant-design/icons';
import ProList from '@ant-design/pro-list';
import { manualPaper, updatePaper } from '../service';
import { autoPaper, manualPaper, updatePaper } from '../service';
import ProTable, { EditableProTable } from '@ant-design/pro-table';
import QuestionSelector from '../../components/QuestionSelector';
@ -326,12 +326,13 @@ export default () => {
<div style={{ background: '#ffffff', padding: 24 }}>
<Space direction="vertical" style={{ width: '100%' }}>
<strong></strong>
<Typography> { } { } </Typography>
<Typography> { 0 } { 0 } </Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Space direction="vertical">
<Typography> { } { } </Typography>
<Typography> { } { } </Typography>
<Typography> { } { } </Typography>
{ questionType.map((item)=>{
return <Typography>{item?.name} { 0 } { 0 } </Typography>
}
)}
</Space>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
@ -437,12 +438,10 @@ export default () => {
visible={autoModalVisible}
onVisibleChange={ handleAutoModalVisible }
footer={null}
onFinish={async (values) => {
console.log('v::::', values.name);
//const rows = selectorRef?.current?.getSelectedRows()
//console.log('rows::::', rows);
//const {code, data: paper, msg} = await handleAppend(Number(params?.id), rows)
//console.log('paper', paper)
onFinish={async () => {
const values = autoRef?.current?.getData()
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('提交成功');
handleAutoModalVisible(false)

@ -199,4 +199,14 @@ export async function saveQuestionTypeScore(data: Record<string, any>, options?:
requestType: "form",
...(options || {}),
});
}
}
/** 22 组卷,资质考试组卷 */
export async function autoPaperOfficial(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/zygh/training/rules/autoPaperOfficial', {
data,
method: 'POST',
requestType: "form",
...(options || {}),
});
}

Loading…
Cancel
Save