From de3dcb59ef48036eeed97fb11f4ee2531e6d44b6 Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Thu, 11 Sep 2025 18:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A3=E4=BC=A0=E7=89=A9=E6=96=99=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E8=B0=83=E8=AF=95=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/dataManage/pro-materials.js | 2 +- src/components/UploadFileFormData/index.vue | 5 ++ .../components/addAndEditForm.vue | 77 ++++++++++++++++--- src/views/dataManage/pro-materials/index.vue | 2 +- 4 files changed, 75 insertions(+), 11 deletions(-) diff --git a/src/api/dataManage/pro-materials.js b/src/api/dataManage/pro-materials.js index 8d8552e..d3836ef 100644 --- a/src/api/dataManage/pro-materials.js +++ b/src/api/dataManage/pro-materials.js @@ -22,7 +22,7 @@ export function addProMaterialsAPI(data) { // 编辑产品中心 export function editProductCenterAPI(data) { return request_formdata({ - url: '//material/edit', + url: '/material/edit', method: 'POST', data, }) diff --git a/src/components/UploadFileFormData/index.vue b/src/components/UploadFileFormData/index.vue index 9848e27..272d282 100644 --- a/src/components/UploadFileFormData/index.vue +++ b/src/components/UploadFileFormData/index.vue @@ -107,6 +107,10 @@ export default { // } // } this.$emit('update:fileList', fileList) + + if (file.id) { + this.$emit('onSelectDeleteFileId', file.id) + } }, // 预览 @@ -195,6 +199,7 @@ export default { // ) // return false // } + // 判断文件大小 const isLt = file.size / 1024 / 1024 < this.fileSize if (!isLt) { diff --git a/src/views/dataManage/pro-materials/components/addAndEditForm.vue b/src/views/dataManage/pro-materials/components/addAndEditForm.vue index 386fc47..a21990a 100644 --- a/src/views/dataManage/pro-materials/components/addAndEditForm.vue +++ b/src/views/dataManage/pro-materials/components/addAndEditForm.vue @@ -49,6 +49,7 @@ :file-type="[]" :file-list.sync="addAndEditForm.file" :is-uploaded="addAndEditForm.file.length >= 1" + @onSelectDeleteFileId="handleSelectDeleteFileId" /> @@ -61,6 +62,7 @@ :file-type="['png', 'jpg', 'jpeg']" :file-list.sync="addAndEditForm.cover" :is-uploaded="addAndEditForm.cover.length >= 1" + @onSelectDeleteFileId="handleSelectDeleteFileId" /> @@ -155,6 +157,7 @@ export default { return { currentTab: '1', // 当前激活的Tab名称 productList: [], + deleteFileId: [], // 基本信息表单 addAndEditForm: { name: '', // 名称 @@ -208,7 +211,6 @@ export default { handleCancel() { // 重置基本信息表单 this.$refs.addAndEditForm?.resetFields() - this.$emit('closeDialog', false) }, // 保存操作:校验所有表单 @@ -234,7 +236,10 @@ export default { typeId, // 类型 version, // 版本 typeName, // 类型名称 - productName, // 归属产品 + productName: productName.substring( + 0, + productName.length - 1, + ), // 归属产品 description, productId: productId.join(','), } @@ -255,19 +260,30 @@ export default { } }) + if (this.formType === 2) { + params.id = this.detailsId + if (this.deleteFileId.length > 0) { + params.delIds = this.deleteFileId.join(',') + } + } + formData.append('fileMsg', JSON.stringify(fileMsg)) formData.append('params', JSON.stringify(params)) - const res = await addProMaterialsAPI(formData) + const API = + this.formType === 2 + ? editProductCenterAPI + : addProMaterialsAPI + + const res = await API(formData) console.log(res, 'res') if (res.code === 200) { - this.$message.success('保存成功') + this.$modal.msgSuccess( + this.formType === 2 ? '编辑成功' : '新增成功', + ) this.$emit('closeDialog', true) } - - // this.$message.success('保存成功') - // this.$emit('closeDialog', true) } catch (error) { // 校验失败,提示用户 // this.$message.error('请完善所有必填项后再保存') @@ -295,7 +311,8 @@ export default { { value.forEach((item) => { this.addAndEditForm.productName += - this.productList.find((j) => item == j.value).label + this.productList.find((j) => item == j.id).name + + ',' }) } } @@ -305,7 +322,49 @@ export default { async getProductCenterDetail() { const res = await getProductCenterDetailAPI(this.detailsId) - console.log(res, '宣传物料详情') + const { + name, + typeId, + files, + version, + typeName, + productIds, + description, + productName, + } = res.data + + this.addAndEditForm = { + name, + typeId: typeId + '', + version, + typeName, + productId: productIds.map((e) => e * 1), + description, + productName, + file: files + .filter((e) => e.typeId === 1) + .map((item) => ({ + id: item.id, + url: item.filePath, + name: item.originalName, + })), + cover: files + .filter((e) => e.typeId === 2) + .map((item) => ({ + id: item.id, + url: item.filePath, + name: item.originalName, + })), + } + // this.addAndEditForm.productId.forEach((item) => { + // this.addAndEditForm.productName += + // this.productList.find((j) => item == j.id).name + ',' + // }) + }, + + // 删除文件ID + handleSelectDeleteFileId(id) { + this.deleteFileId.push(id) }, }, diff --git a/src/views/dataManage/pro-materials/index.vue b/src/views/dataManage/pro-materials/index.vue index 8daa74a..e43f8f2 100644 --- a/src/views/dataManage/pro-materials/index.vue +++ b/src/views/dataManage/pro-materials/index.vue @@ -199,7 +199,7 @@ export default { label: '描述', }, { - prop: 'createUser', + prop: 'createUserName', label: '创建人', }, {