|
|
|
@ -46,6 +46,25 @@ console.log('first');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 编辑试题
|
|
|
|
|
*
|
|
|
|
|
* @param fields
|
|
|
|
|
*/
|
|
|
|
|
const handleUpdate = async (fields: TableListItem) => {
|
|
|
|
|
const hide = message.loading('正在保存');
|
|
|
|
|
try {
|
|
|
|
|
await saveQuestion({ ...fields});
|
|
|
|
|
hide();
|
|
|
|
|
message.success('保存成功');
|
|
|
|
|
return true;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hide();
|
|
|
|
|
message.error('保存失败请重试!');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除试题
|
|
|
|
|
*
|
|
|
|
@ -642,22 +661,26 @@ const QuestionBank = () => {
|
|
|
|
|
}}
|
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
// 表单处理
|
|
|
|
|
console.log('columns:', columns);
|
|
|
|
|
console.log('columns:', columns);
|
|
|
|
|
console.log('values:', values);
|
|
|
|
|
const opts = [];
|
|
|
|
|
values?.answers?.forEach((item)=>{
|
|
|
|
|
opts.push({answer:item, is_true:0})
|
|
|
|
|
values?.answers?.forEach((item,key)=>{
|
|
|
|
|
const is_true = values?.answertrue.indexOf(labels[key]) >-1 ? 1 : 0;
|
|
|
|
|
opts.push({answer:item, is_true: is_true||0}) // 循环选项
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
const success = await handleAdd({
|
|
|
|
|
|
|
|
|
|
const success = await handleUpdate({
|
|
|
|
|
...currentRow,
|
|
|
|
|
...values,
|
|
|
|
|
type: type, // 必填,0-常规题,1-资质考试题
|
|
|
|
|
answers: JSON.stringify(opts),
|
|
|
|
|
question_type: addType.value,
|
|
|
|
|
//question_type: currentRow?.question_type, // 题型
|
|
|
|
|
// subject_id: params?.id || 0,
|
|
|
|
|
});
|
|
|
|
|
console.log('123')
|
|
|
|
|
console.log('123', success)
|
|
|
|
|
if(success){
|
|
|
|
|
handleCreateModalVisible(false);
|
|
|
|
|
handleUpdateModalVisible(false);
|
|
|
|
|
actionRef.current?.reloadAndRest?.();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|