|
|
|
@ -46,6 +46,33 @@ console.log('first');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除试题
|
|
|
|
|
*
|
|
|
|
|
* @param selectedRows
|
|
|
|
|
*/
|
|
|
|
|
const handleRemove = async (selectedRows: TableListItem[]) => {
|
|
|
|
|
const hide = message.loading('正在删除');
|
|
|
|
|
if (!selectedRows) return true;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const {code, msg} = await removeQuestion({
|
|
|
|
|
key: selectedRows.map((row) => row.key),
|
|
|
|
|
});
|
|
|
|
|
hide();
|
|
|
|
|
if(code === 2000 ){
|
|
|
|
|
message.success('删除成功,即将刷新');
|
|
|
|
|
}else{
|
|
|
|
|
message.warning(msg);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hide();
|
|
|
|
|
message.error('删除失败,请重试');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const QuestionBank = () => {
|
|
|
|
|
const match = useRouteMatch();
|
|
|
|
|
console.log('match', match);
|
|
|
|
@ -208,19 +235,18 @@ const QuestionBank = () => {
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
]
|
|
|
|
|
const [questionType, setQuestionType] = useState([]);
|
|
|
|
|
|
|
|
|
|
const [parsing, setParsing] = useState();
|
|
|
|
|
|
|
|
|
|
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
|
|
|
|
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
|
|
|
|
|
|
|
|
|
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
|
|
|
|
|
const [expandedDescRowKeys, setExpandedDescRowKeys] = useState<readonly ReactText[]>([]); // 展开解析设置
|
|
|
|
|
const [addType, setAddType] = useState({name: '', value: 0});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 获取题型 */
|
|
|
|
|
const { data } = useRequest(() => {
|
|
|
|
|
return queryQuestionType();
|
|
|
|
@ -277,9 +303,10 @@ const QuestionBank = () => {
|
|
|
|
|
<PlusOutlined /> 新建 <DownOutlined />
|
|
|
|
|
</Button>
|
|
|
|
|
</Dropdown>,
|
|
|
|
|
/*
|
|
|
|
|
<Button key="remove" type="default" danger>
|
|
|
|
|
<DeleteOutlined /> 批量删除
|
|
|
|
|
</Button>,
|
|
|
|
|
</Button>*/,
|
|
|
|
|
<Button key="download" onClick={()=>{window.location.href='/dsideal_yy/zygh/training/exportQuestionTemplate'}} >
|
|
|
|
|
<DownloadOutlined /> 下载模板
|
|
|
|
|
</Button>,
|
|
|
|
@ -455,7 +482,10 @@ const QuestionBank = () => {
|
|
|
|
|
</Col>
|
|
|
|
|
<Col flex={1} style={{textAlign:'right'}}>
|
|
|
|
|
<Space direction="horizontal" size="middle">
|
|
|
|
|
<a href={record.html_url} target="_blank" rel="noopener noreferrer" key="link">
|
|
|
|
|
<a onClick={()=>{
|
|
|
|
|
handleUpdateModalVisible(true)
|
|
|
|
|
return false;
|
|
|
|
|
}} target="_blank" rel="noopener noreferrer" key="link">
|
|
|
|
|
<EditOutlined /> 编辑
|
|
|
|
|
</a>
|
|
|
|
|
<a href={record.html_url} target="_blank" rel="noopener noreferrer" key="warning" >
|
|
|
|
@ -543,6 +573,57 @@ const QuestionBank = () => {
|
|
|
|
|
columns={columns}
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
<Modal
|
|
|
|
|
title={`编辑${addType?.name }`}
|
|
|
|
|
//
|
|
|
|
|
width="60%"
|
|
|
|
|
visible={updateModalVisible}
|
|
|
|
|
destroyOnClose
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
handleUpdateModalVisible(false);
|
|
|
|
|
}}
|
|
|
|
|
footer={null}
|
|
|
|
|
>
|
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
|
layout="horizontal"
|
|
|
|
|
layoutType="Form"
|
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
|
wrapperCol={{ span: 12 }}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
// 表单处理
|
|
|
|
|
console.log('columns:', columns);
|
|
|
|
|
console.log('values:', values);
|
|
|
|
|
const opts = [];
|
|
|
|
|
values?.answers?.forEach((item)=>{
|
|
|
|
|
opts.push({answer:item, is_true:0})
|
|
|
|
|
})
|
|
|
|
|
const success = await handleAdd({
|
|
|
|
|
...values,
|
|
|
|
|
type: type, // 必填,0-常规题,1-资质考试题
|
|
|
|
|
answers: JSON.stringify(opts),
|
|
|
|
|
question_type: addType.value,
|
|
|
|
|
// subject_id: params?.id || 0,
|
|
|
|
|
});
|
|
|
|
|
console.log('123')
|
|
|
|
|
if(success){
|
|
|
|
|
handleCreateModalVisible(false);
|
|
|
|
|
actionRef.current?.reloadAndRest?.();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
submitter={{
|
|
|
|
|
render: (props, doms) => (
|
|
|
|
|
<Row>
|
|
|
|
|
<Col span={12} offset={8}>
|
|
|
|
|
<Space>{doms}</Space>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
),
|
|
|
|
|
}}
|
|
|
|
|
// action = ''
|
|
|
|
|
title="编辑"
|
|
|
|
|
columns={columns}
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
</PageContainer>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|