From 6e95ec7abac1898728544e160b6d4fd63a292a9a Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 24 Jan 2022 11:30:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=A7=86=E9=A2=91=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/pages/course/option/index.tsx | 30 ++++++++++++++++-------- admin/src/pages/course/option/service.ts | 5 ++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index 1734d9b..4c34fa4 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -26,7 +26,7 @@ const uuid = uuidv4(); const handleAdd = async (fields: TableListItem) => { const hide = message.loading('正在添加'); try { - await saveCourse({ ...fields, attachment_filesize:0, attachment_json: `{"img":"", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}` }); + await saveCourse({ ...fields, attachment_filesize:0, }); hide(); message.success('添加成功'); return true; @@ -61,14 +61,14 @@ const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) = }; /** - * 删除课程 - * + * 删除课程(接口不支持批量) + * 参数为记录数组 * @param selectedRows */ const handleRemove = async (selectedRows: TableListItem[]) => { const hide = message.loading('正在删除'); if (!selectedRows) return true; - + console.log('key', selectedRows); try { await removeCourse({ key: selectedRows.map((row) => row.key), @@ -77,6 +77,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => { message.success('删除成功,即将刷新'); return true; } catch (error) { + console.log('error', error) hide(); message.error('删除失败,请重试'); return false; @@ -236,14 +237,15 @@ const CourseList: React.FC = () => { }, { title: '视频', - dataIndex: 'attachment_filesize', + dataIndex: 'attachment_json', sorter: false, hideInTable: true, hideInForm: false, hideInSearch: true, - renderFormItem: () => ( + renderFormItem: (item, { defaultRender, ...rest }, form) => ( { console.log('file', file) // 获取文件名 @@ -329,7 +331,9 @@ const CourseList: React.FC = () => { { - handleRemove(record); + handleRemove([{key: record?.course_id}]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); }}> 删除 , @@ -479,7 +483,7 @@ const CourseList: React.FC = () => { } }} onReady={(play: any) => { - console.log('play====', play); + //console.log('play====', play); playerRef.current = play play.play(); play.on("timeupdate", function (event) { @@ -548,8 +552,14 @@ const CourseList: React.FC = () => { onFinish={async (values: any) => { // 表单处理 //console.log('columns:', columns); - //console.log('values:', values); - await handleAdd(values); + console.log('values:', values); + console.log('uploadFileName',uploadFileName) + //return false; + // values.attachment_json.response.file.response.url + await handleAdd({ + ...values, + attachment_json: `{"img":"", "name": "${values.attachment_json.file.name}", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}` + }); handleCreateModalVisible(false); actionRef.current?.reloadAndRest?.(); }} diff --git a/admin/src/pages/course/option/service.ts b/admin/src/pages/course/option/service.ts index 8eb5468..2619b74 100644 --- a/admin/src/pages/course/option/service.ts +++ b/admin/src/pages/course/option/service.ts @@ -39,9 +39,10 @@ export async function saveCourse(data: Record, options?: Record) { +export async function removeCourse(data: { key: number[] }, options?: Record) { + console.log('data:::', data); return request>('/dsideal_yy/ypt/careerTraining/course/delete', { - data, + data: {course_id: data?.key[0]}, // 当前接口不支持批量操作 method: 'POST', requestType: 'form', ...(options || {}),