宣传物料管理页面调试完成

This commit is contained in:
BianLzhaoMin 2025-09-11 18:28:33 +08:00
parent 2b3e1ea66d
commit de3dcb59ef
4 changed files with 75 additions and 11 deletions

View File

@ -22,7 +22,7 @@ export function addProMaterialsAPI(data) {
// 编辑产品中心 // 编辑产品中心
export function editProductCenterAPI(data) { export function editProductCenterAPI(data) {
return request_formdata({ return request_formdata({
url: '//material/edit', url: '/material/edit',
method: 'POST', method: 'POST',
data, data,
}) })

View File

@ -107,6 +107,10 @@ export default {
// } // }
// } // }
this.$emit('update:fileList', fileList) this.$emit('update:fileList', fileList)
if (file.id) {
this.$emit('onSelectDeleteFileId', file.id)
}
}, },
// //
@ -195,6 +199,7 @@ export default {
// ) // )
// return false // return false
// } // }
// //
const isLt = file.size / 1024 / 1024 < this.fileSize const isLt = file.size / 1024 / 1024 < this.fileSize
if (!isLt) { if (!isLt) {

View File

@ -49,6 +49,7 @@
:file-type="[]" :file-type="[]"
:file-list.sync="addAndEditForm.file" :file-list.sync="addAndEditForm.file"
:is-uploaded="addAndEditForm.file.length >= 1" :is-uploaded="addAndEditForm.file.length >= 1"
@onSelectDeleteFileId="handleSelectDeleteFileId"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -61,6 +62,7 @@
:file-type="['png', 'jpg', 'jpeg']" :file-type="['png', 'jpg', 'jpeg']"
:file-list.sync="addAndEditForm.cover" :file-list.sync="addAndEditForm.cover"
:is-uploaded="addAndEditForm.cover.length >= 1" :is-uploaded="addAndEditForm.cover.length >= 1"
@onSelectDeleteFileId="handleSelectDeleteFileId"
/> />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -155,6 +157,7 @@ export default {
return { return {
currentTab: '1', // Tab currentTab: '1', // Tab
productList: [], productList: [],
deleteFileId: [],
// //
addAndEditForm: { addAndEditForm: {
name: '', // name: '', //
@ -208,7 +211,6 @@ export default {
handleCancel() { handleCancel() {
// //
this.$refs.addAndEditForm?.resetFields() this.$refs.addAndEditForm?.resetFields()
this.$emit('closeDialog', false) this.$emit('closeDialog', false)
}, },
// //
@ -234,7 +236,10 @@ export default {
typeId, // typeId, //
version, // version, //
typeName, // typeName, //
productName, // productName: productName.substring(
0,
productName.length - 1,
), //
description, description,
productId: productId.join(','), 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('fileMsg', JSON.stringify(fileMsg))
formData.append('params', JSON.stringify(params)) 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') console.log(res, 'res')
if (res.code === 200) { if (res.code === 200) {
this.$message.success('保存成功') this.$modal.msgSuccess(
this.formType === 2 ? '编辑成功' : '新增成功',
)
this.$emit('closeDialog', true) this.$emit('closeDialog', true)
} }
// this.$message.success('')
// this.$emit('closeDialog', true)
} catch (error) { } catch (error) {
// //
// this.$message.error('') // this.$message.error('')
@ -295,7 +311,8 @@ export default {
{ {
value.forEach((item) => { value.forEach((item) => {
this.addAndEditForm.productName += 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() { async getProductCenterDetail() {
const res = await getProductCenterDetailAPI(this.detailsId) 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)
}, },
}, },

View File

@ -199,7 +199,7 @@ export default {
label: '描述', label: '描述',
}, },
{ {
prop: 'createUser', prop: 'createUserName',
label: '创建人', label: '创建人',
}, },
{ {