宣传物料管理页面调试完成
This commit is contained in:
parent
2b3e1ea66d
commit
de3dcb59ef
|
|
@ -22,7 +22,7 @@ export function addProMaterialsAPI(data) {
|
|||
// 编辑产品中心
|
||||
export function editProductCenterAPI(data) {
|
||||
return request_formdata({
|
||||
url: '//material/edit',
|
||||
url: '/material/edit',
|
||||
method: 'POST',
|
||||
data,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
:file-type="[]"
|
||||
:file-list.sync="addAndEditForm.file"
|
||||
:is-uploaded="addAndEditForm.file.length >= 1"
|
||||
@onSelectDeleteFileId="handleSelectDeleteFileId"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
|
@ -61,6 +62,7 @@
|
|||
:file-type="['png', 'jpg', 'jpeg']"
|
||||
:file-list.sync="addAndEditForm.cover"
|
||||
:is-uploaded="addAndEditForm.cover.length >= 1"
|
||||
@onSelectDeleteFileId="handleSelectDeleteFileId"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
|
@ -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)
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ export default {
|
|||
label: '描述',
|
||||
},
|
||||
{
|
||||
prop: 'createUser',
|
||||
prop: 'createUserName',
|
||||
label: '创建人',
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue