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));
}
return {
add: () => {
add: (data) => {
this.modalConfig.title = "添加属性";
this.$nextTick(() => {
this.modalData = {};
this.$refs.ruleForm.resetFields();
});
if (data.length == 0) {
this.ruleForm = {
name: "",
value: [],
};
} else {
this.ruleForm = {
name: data[0].name,
value: data[0].value.split(","),
};
}
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;
},
};

View File

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

View File

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

View File

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