This commit is contained in:
余同学 2024-08-16 18:00:30 +08:00
parent 13a802f527
commit 948f724245
4 changed files with 131 additions and 33 deletions

View File

@ -111,15 +111,34 @@ export default {
this.init(cloneDeep(e.row)); this.init(cloneDeep(e.row));
} }
return { return {
add: () => { add: (data) => {
this.modalConfig.title = "添加属性"; this.modalConfig.title = "添加属性";
this.$nextTick(() => { if (data.length == 0) {
this.modalData = {}; this.ruleForm = {
this.$refs.ruleForm.resetFields(); name: "",
}); value: [],
};
} else {
this.ruleForm = {
name: data[0].name,
value: data[0].value.split(","),
};
}
this.isAdd = true; this.isAdd = true;
}, },
update: () => { update: (data) => {
console.log(data);
if (data.length == 0) {
this.ruleForm = {
name: "",
value: [],
};
} else {
this.ruleForm = {
name: data[0].name,
value: data[0].value.split(","),
};
}
this.isAdd = false; this.isAdd = false;
}, },
}; };

View File

@ -204,7 +204,7 @@ export default {
.catch(() => { .catch(() => {
this.$message({ this.$message({
type: "info", type: "info",
message: "已取消删除", message: "已取消",
}); });
}); });
}, },

View File

@ -64,7 +64,7 @@ export default {
// //
singleStock: "", singleStock: "",
// //
otherAttribute: '[{"name":"颜色","value":"黄色;屎黄色"}]', otherAttribute: [], //[{"name":"","value":""}]
// //
discountActivity: { discountActivity: {
// "endTime": "2024-08-31 00:00:00", // "endTime": "2024-08-31 00:00:00",
@ -146,6 +146,8 @@ export default {
fullscreen: true, fullscreen: true,
}, },
fileList: [], // fileList: [], //
fileListOne: [], //
fileListTwo: [], //
place: "", // place: "", //
passCheck: [], // passCheck: [], //
}; };
@ -178,7 +180,7 @@ export default {
description: "", description: "",
merchantId: "", merchantId: "",
name: "", name: "",
otherAttribute: "", otherAttribute: [],
productAttributeList: [], productAttributeList: [],
productCategoryId: "", productCategoryId: "",
productIntroducePhoto: "", productIntroducePhoto: "",
@ -220,20 +222,67 @@ export default {
url: item.url, url: item.url,
}; };
}); });
if (row.productIntroducePhoto) {
this.fileListOne = [
{
name: "",
url: row.productIntroducePhoto,
},
];
} else {
this.fileListOne = [];
}
if (row.productVideo) {
this.fileListTwo = [
{
name: "",
url: row.productVideo,
},
];
} else {
this.fileListTwo = [];
}
this.place = row.productPlace.split("-"); this.place = row.productPlace.split("-");
this.modalData = row; this.modalData = row;
this.$set(this.modalData, "singleStock", row.stockNum);
if (row.minSalePrice == row.maxSalePrice) {
this.$set(this.modalData, "singlePrice", row.maxSalePrice);
} else {
this.$set(
this.modalData,
"singlePrice",
row.minSalePrice + "~" + row.maxSalePrice
);
}
if (!row.productAttributeList) {
this.$set(this.modalData, "productAttributeList", []);
}
if (row.otherAttribute) {
this.modalData.otherAttribute = JSON.parse(row.otherAttribute);
} else {
this.modalData.otherAttribute = [];
}
}, },
addSpecs() { addSpecs() {
console.log("123"); console.log("123");
if (this.isAdd) { if (this.isAdd) {
this.$refs.addSpecifications.toggle().add();
} else {
this.$refs.addSpecifications this.$refs.addSpecifications
.toggle() .toggle()
.update( .add(
this.modalData.productAttributeList, this.modalData.productAttributeList,
this.modalData.productSpecificationList this.modalData.productSpecificationList
); );
} else {
if (this.modalData.productAttributeList.length == 0) {
this.$refs.addSpecifications.toggle().update([], []);
} else {
this.$refs.addSpecifications
.toggle()
.update(
this.modalData.productAttributeList,
this.modalData.productSpecificationList
);
}
} }
}, },
// //
@ -250,7 +299,11 @@ export default {
this.$set(this.modalData, "singleStock", stockNum); this.$set(this.modalData, "singleStock", stockNum);
}, },
addAttribute() { addAttribute() {
this.$refs.addAttribute.toggle().add(); if (this.isAdd) {
this.$refs.addAttribute.toggle().add(this.modalData.otherAttribute);
} else {
this.$refs.addAttribute.toggle().update(this.modalData.otherAttribute);
}
}, },
getAttribute(data) { getAttribute(data) {
console.log(data); console.log(data);
@ -488,9 +541,7 @@ export default {
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={ readonly={this.modalData.productAttributeList.length > 0}
this.modalData.productSpecificationList.length > 0
}
placeholder="请输入价格" placeholder="请输入价格"
v-model={this.modalData.singlePrice} v-model={this.modalData.singlePrice}
></el-input> ></el-input>
@ -504,9 +555,7 @@ export default {
render: () => { render: () => {
return ( return (
<el-input <el-input
readonly={ readonly={this.modalData.productAttributeList.length > 0}
this.modalData.productSpecificationList.length > 0
}
placeholder="请输入库存" placeholder="请输入库存"
v-model={this.modalData.singleStock} v-model={this.modalData.singleStock}
></el-input> ></el-input>
@ -603,6 +652,8 @@ export default {
drag drag
action={this.$api.mer_admin.uploadFile()} action={this.$api.mer_admin.uploadFile()}
limit={1} limit={1}
file-list={this.fileListOne}
list-type="picture"
{...{ {...{
props: { props: {
"on-change": handleChange, "on-change": handleChange,
@ -652,6 +703,8 @@ export default {
drag drag
action={this.$api.mer_admin.uploadFile()} action={this.$api.mer_admin.uploadFile()}
limit={1} limit={1}
file-list={this.fileListTwo}
list-type="picture"
{...{ {...{
props: { props: {
"on-change": handleChange, "on-change": handleChange,

View File

@ -133,24 +133,50 @@ export default {
this.init(cloneDeep(e.row)); this.init(cloneDeep(e.row));
} }
return { return {
add: () => { add: (productAttributeList, productSpecificationList) => {
this.modalConfig.title = "属性"; this.modalConfig.title = "添加属性";
this.$nextTick(() => { if (productAttributeList.length == 0) {
// this.$refs.modal.resetFields(); this.AttributeData = [
this.modalData = {}; {
}); attributeName: "",
attributeValue: [],
inputVisible: false,
},
];
} else {
this.AttributeData = productAttributeList.map((item) => {
return {
attributeName: item.attributeName,
attributeValue: item.attributeValue.split(","),
id: item.id,
inputVisible: false,
};
});
}
this.tableData = productSpecificationList;
this.isAdd = true; this.isAdd = true;
}, },
update: (productAttributeList, productSpecificationList) => { update: (productAttributeList, productSpecificationList) => {
this.modalConfig.title = "编辑属性";
console.log(productAttributeList, productSpecificationList); console.log(productAttributeList, productSpecificationList);
this.AttributeData = productAttributeList.map((item) => { if (productAttributeList.length == 0) {
return { this.AttributeData = [
attributeName: item.attributeName, {
attributeValue: item.attributeValue.split(","), attributeName: "",
id: item.id, attributeValue: [],
inputVisible: false, inputVisible: false,
}; },
}); ];
} else {
this.AttributeData = productAttributeList.map((item) => {
return {
attributeName: item.attributeName,
attributeValue: item.attributeValue.split(","),
id: item.id,
inputVisible: false,
};
});
}
this.tableData = productSpecificationList; this.tableData = productSpecificationList;
this.isAdd = false; this.isAdd = false;
}, },