From 4c1d2152a5527d86611a25217106eba22ccd0e99 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Thu, 17 Feb 2022 07:59:45 +0800 Subject: [PATCH] fix delete --- admin/src/pages/course/option/index.tsx | 16 +++++++---- admin/src/pages/course/subject/index.tsx | 21 ++++++++------ admin/src/pages/course/subject/service.ts | 11 ++++++++ admin/src/pages/examination/option/index.tsx | 17 ++++++++++- admin/src/pages/examination/service.ts | 10 +++++-- .../pages/examinationrules/normal/index.tsx | 16 ++++++++--- admin/src/pages/training/option/index.tsx | 28 +++++++++++++------ admin/src/pages/training/option/service.ts | 4 ++- 8 files changed, 92 insertions(+), 31 deletions(-) diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index fa313e5..d73c16a 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -70,11 +70,15 @@ const handleRemove = async (selectedRows: TableListItem[]) => { if (!selectedRows) return true; console.log('key', selectedRows); try { - await removeCourse({ + const {code, msg} = await removeCourse({ key: selectedRows.map((row) => row.key), }); hide(); - message.success('删除成功,即将刷新'); + if(code === 2000 ){ + message.success('删除成功,即将刷新'); + }else{ + message.warning(msg); + } return true; } catch (error) { console.log('error', error) @@ -84,7 +88,6 @@ const handleRemove = async (selectedRows: TableListItem[]) => { } }; - const CourseList: React.FC = () => { /** 新建窗口的弹窗 */ @@ -333,7 +336,7 @@ const CourseList: React.FC = () => { , { + onClick={ () => { handleRemove([{ key: record?.course_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) setSelectedRows([]); actionRef.current?.reloadAndRest?.(); @@ -442,9 +445,12 @@ const CourseList: React.FC = () => { { - playerRef.current?.pause(); + //playerRef?.current?.ended(); + playerRef?.current?.dispose(); + //videoRef.current.play() console.log('playerRef:', playerRef.current) setCurrentRow(undefined); // 设置当前行 diff --git a/admin/src/pages/course/subject/index.tsx b/admin/src/pages/course/subject/index.tsx index aaf5596..b241e89 100644 --- a/admin/src/pages/course/subject/index.tsx +++ b/admin/src/pages/course/subject/index.tsx @@ -121,7 +121,7 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) = }; /** - * 删除节点 + * 删除主题 * * @param selectedRows */ @@ -130,11 +130,15 @@ const handleRemove = async (selectedRows: TableListItem[]) => { if (!selectedRows) return true; try { - await removeSubject({ + const {code, msg} = await removeSubject({ key: selectedRows.map((row) => row.key), }); hide(); - message.success('删除成功,即将刷新'); + if(code === 2000 ){ + message.success('删除成功,即将刷新'); + }else{ + message.warning(msg); + } return true; } catch (error) { hide(); @@ -282,11 +286,12 @@ const TableList: React.FC = () => { 复制 , { - // handleCopyItem({}); - }} - > + key="remove" + onClick={ () => { + handleRemove([{ key: record?.subject_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + }}> 删除 , ], diff --git a/admin/src/pages/course/subject/service.ts b/admin/src/pages/course/subject/service.ts index e4a392c..5b4d863 100644 --- a/admin/src/pages/course/subject/service.ts +++ b/admin/src/pages/course/subject/service.ts @@ -147,3 +147,14 @@ export async function saveChapter(data: Record, options?: Record) { + console.log('data:::', data); + return request>('/dsideal_yy/ypt/careerTraining/subject/deleteSubject', { + data: { subject_id: data?.key[0] }, // 当前接口不支持批量操作 + method: 'POST', + requestType: 'form', + ...(options || {}), + }); +} \ No newline at end of file diff --git a/admin/src/pages/examination/option/index.tsx b/admin/src/pages/examination/option/index.tsx index f507956..87b19ea 100644 --- a/admin/src/pages/examination/option/index.tsx +++ b/admin/src/pages/examination/option/index.tsx @@ -317,7 +317,13 @@ const ExaminationList: React.FC = () => { > 编辑 , - + { + handleRemove([{ key: record?.examination_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + }}> 删除 , { labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} onFinish={async (values) => { + console.log('values', values); + //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; + //console.log('url', url) + await handleUpdate({ + ...values, + examination_id: currentRow?.examination_id, + }); + handleUpdateModalVisible(false); // 隐藏编辑窗口 + actionRef.current?.reloadAndRest?.(); console.log(values); }} submitter={{ diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index 8a5f0c3..e6577bf 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -81,14 +81,17 @@ export async function updateExamination(data: Record, options?: Rec }); } -/** 删除考试 POST /dsideal_yy/ypt/careerTraining/course/delete */ +/** 删除考试 */ export async function removeExamination(data: { key: number[] }, options?: Record) { - return request>('/dsideal_yy/ypt/careerTraining/course/delete', { - data, + console.log('data:::', data); + return request>('/dsideal_yy/zygh/training/examination/delExamination', { + data: { examination_id: data?.key[0] }, // 当前接口不支持批量操作 method: 'POST', + requestType: 'form', ...(options || {}), }); } + /** saveRegistration */ export async function saveRegistration(data: { key: number[] }, options?: Record) { return request>('/dsideal_yy/ypt/careerTraining/course/delete', { @@ -97,6 +100,7 @@ export async function saveRegistration(data: { key: number[] }, options?: Record ...(options || {}), }); } + /** removeRegistration */ export async function removeRegistration(data: { key: number[] }, options?: Record) { return request>('/dsideal_yy/ypt/careerTraining/course/delete', { diff --git a/admin/src/pages/examinationrules/normal/index.tsx b/admin/src/pages/examinationrules/normal/index.tsx index 15a8642..321a370 100644 --- a/admin/src/pages/examinationrules/normal/index.tsx +++ b/admin/src/pages/examinationrules/normal/index.tsx @@ -41,7 +41,7 @@ const handleAdd = async (fields: TableListItem) => { * * @param fields */ -/* + const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => { const hide = message.loading('正在配置'); @@ -51,15 +51,14 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) = ...fields, }); hide(); - message.success('配置成功'); + message.success('操作成功'); return true; } catch (error) { hide(); - message.error('配置失败请重试!'); + message.error('操作失败请重试!'); return false; } }; -*/ /** * 删除考试 @@ -394,6 +393,15 @@ const ExaminationRules: React.FC = () => { labelCol={{ span: 8 }} wrapperCol={{ span: 12 }} onFinish={async (values) => { + console.log('currentRow', currentRow) + //const url = values?.upload[0]?.url?.replace('/dsideal_yy/html/','') || values?.upload[0]?.response?.url; + //console.log('url', url) + await handleUpdate({ + ...values, + examination_id: currentRow?.examination_id, + }); + handleUpdateModalVisible(false); // 隐藏编辑窗口 + actionRef.current?.reloadAndRest?.(); console.log(values); }} submitter={{ diff --git a/admin/src/pages/training/option/index.tsx b/admin/src/pages/training/option/index.tsx index f38c5fe..5a69301 100644 --- a/admin/src/pages/training/option/index.tsx +++ b/admin/src/pages/training/option/index.tsx @@ -57,29 +57,33 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) = }; /** - * 删除培训 - * + * 删除培训(接口不支持批量) + * 参数为记录数组 * @param selectedRows */ -const handleRemove = async (selectedRows: TableListItem[]) => { + const handleRemove = async (selectedRows: TableListItem[]) => { const hide = message.loading('正在删除'); if (!selectedRows) return true; - + console.log('key', selectedRows); try { - await removeTrain({ + const {code, msg} = await removeTrain({ key: selectedRows.map((row) => row.key), }); hide(); - message.success('删除成功,即将刷新'); + if(code === 2000 ){ + message.success('删除成功,即将刷新'); + }else{ + message.warning(msg); + } return true; } catch (error) { + console.log('error', error) hide(); message.error('删除失败,请重试'); return false; } }; - interface OrgTreeForOaItem { id?: number; pId?: number; @@ -300,9 +304,15 @@ const TableList: React.FC = () => { > 编辑 , - + { + handleRemove([{ key: record?.train_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + }}> 删除 - , + , ], }, ]; diff --git a/admin/src/pages/training/option/service.ts b/admin/src/pages/training/option/service.ts index 7ccf12c..56f5612 100644 --- a/admin/src/pages/training/option/service.ts +++ b/admin/src/pages/training/option/service.ts @@ -41,9 +41,11 @@ export async function saveTrain(data: Record, options?: Record) { + console.log('data:::', data); return request>('/dsideal_yy/ypt/careerTraining/train/delete', { - data, + data: { train_id: data?.key[0] }, // 当前接口不支持批量操作 method: 'POST', + requestType: 'form', ...(options || {}), }); }