修改试题删除

master
zhengpengju 3 years ago
parent 557845bddc
commit fb58594f05

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

@ -47,7 +47,6 @@ export async function saveQuestion(data: Record<string, any>, options?: Record<s
});
}
/**
*
* @param params
@ -73,3 +72,14 @@ export async function queryQuestionById(params: {
params,
});
}
/** 删除试题 */
export async function removeQuestion(data: { key: number[] }, options?: Record<string, any>) {
console.log('data:::', data);
return request<Record<string, any>>('/dsideal_yy/zygh/training/delQuestion', {
data: { ids: data?.key[0] }, // 当前接口支持批量操作
method: 'POST',
requestType: 'form',
...(options || {}),
});
}
Loading…
Cancel
Save