diff --git a/admin/src/pages/questionbank/index.tsx b/admin/src/pages/questionbank/index.tsx index f836dc6..8b00535 100644 --- a/admin/src/pages/questionbank/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -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(false); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + const [selectedRowsState, setSelectedRows] = useState([]); const [expandedDescRowKeys, setExpandedDescRowKeys] = useState([]); // 展开解析设置 const [addType, setAddType] = useState({name: '', value: 0}); - - /** 获取题型 */ const { data } = useRequest(() => { return queryQuestionType(); @@ -277,9 +303,10 @@ const QuestionBank = () => { 新建 , + /* , + */, , @@ -455,7 +482,10 @@ const QuestionBank = () => { - + { + handleUpdateModalVisible(true) + return false; + }} target="_blank" rel="noopener noreferrer" key="link"> 编辑 @@ -543,6 +573,57 @@ const QuestionBank = () => { columns={columns} /> + { + handleUpdateModalVisible(false); + }} + footer={null} + > + + 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) => ( + + + {doms} + + + ), + }} + // action = '' + title="编辑" + columns={columns} + /> + ); }; diff --git a/admin/src/pages/questionbank/service.ts b/admin/src/pages/questionbank/service.ts index 39b5de0..f727b20 100644 --- a/admin/src/pages/questionbank/service.ts +++ b/admin/src/pages/questionbank/service.ts @@ -47,7 +47,6 @@ export async function saveQuestion(data: Record, options?: Record) { + console.log('data:::', data); + return request>('/dsideal_yy/zygh/training/delQuestion', { + data: { ids: data?.key[0] }, // 当前接口支持批量操作 + method: 'POST', + requestType: 'form', + ...(options || {}), + }); +} \ No newline at end of file