This commit is contained in:
曹辉 2022-11-01 10:47:23 +08:00
parent 3afafd012f
commit f016874115
2 changed files with 20 additions and 36 deletions

View File

@ -402,7 +402,7 @@
></el-input>
</template>
</el-table-column>
<el-table-column label="商品属性图片" align="center">
<el-table-column label="商品属性图片" align="center" width="300">
<template slot-scope="scope">
<stationAcatar
@imgUrl="attributePitureUrl"
@ -668,16 +668,8 @@ export default {
},
],
// goodAttributeDetailsLists:[],
goodDetailsLists: [
{
attributePitureUrl: "",
goodsPrice: "",
goodsStock: "",
sort: "",
ids: 9999,
},
],
ids: 9999,
goodDetailsLists: [],
ids: 9999999,
//
shangjia: {
id: null,
@ -775,14 +767,13 @@ export default {
sort: "",
ids: this.ids,
};
this.goodDetailsLists.push(obj);
}
},
//
delgoodAttributeDetail(item) {
console.log(item);
if (item.ids && !item.id) {
if (item.ids && !item.attributeDetailsId) {
if (this.goodDetailsLists.length == 1) {
this.$message.error("最后一条不可删除");
} else {
@ -790,12 +781,12 @@ export default {
(e) => e.ids != item.ids
);
}
} else if (!item.ids && item.id) {
} else if (!item.ids && item.attributeDetailsId) {
if (this.goodDetailsLists.length == 1) {
this.$message.error("最后一条不可删除");
} else {
this.goodDetailsLists = this.goodDetailsLists.filter(
(e) => e.id != item.id
(e) => e.attributeDetailsId != item.attributeDetailsId
);
}
}
@ -805,7 +796,6 @@ export default {
cancel() {
this.open = false;
this.reset();
this.goodDetailsLists = [
{
attributeName: "",
@ -872,23 +862,23 @@ export default {
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "商品基本信息";
console.log(this.ids);
this.goodDetailsLists = [
{
attributePitureUrl: "",
goodsPrice: "",
goodsStock: "",
sort: "",
ids: 99999999999999999999,
ids: 9999999,
},
];
this.open = true;
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.goodsInfoId || this.ids;
getGoodsInfo(id).then((response) => {
this.form = response.data[0];
this.goodDetailsLists = response.data[0].goodAttributeDetailsLists;
@ -910,6 +900,8 @@ export default {
},
/** 提交按钮 */
submitForm() {
console.log(this.goodDetailsLists);
this.form.goodAttributeDetailsLists = [];
this.form.goodDetailsLists = this.goodDetailsLists;
console.log(this.form);
this.$refs["form"].validate((valid) => {
@ -972,9 +964,9 @@ export default {
e.attributePitureUrl = items.attributePitureUrl;
}
});
} else if (!items.ids && items.id) {
} else if (!items.ids && items.attributeDetailsId) {
this.goodDetailsLists.forEach((e) => {
if (e.id == items.id) {
if (e.attributeDetailsId == items.attributeDetailsId) {
e.attributePitureUrl = items.attributePitureUrl;
}
});

View File

@ -131,13 +131,12 @@ export default {
fixedBox: true, //
},
previews: {},
rows: {},
items: {},
};
},
created() {
this.types = this.type;
this.rows = this.item;
this.items = this.item;
if (this.img == null) {
this.options.img = null;
} else if (this.img == "") {
@ -145,19 +144,11 @@ export default {
} else {
this.options.img = baseurl + this.img;
}
console.log(this.item);
},
watch: {
item: {
handler(newimg, oldimg) {
console.log(newimg,oldimg)
if (this.item == null) {
this.rows = null;
} else if (this.img == "") {
this.rows = null;
} else {
this.rows = this.item;
}
this.items = this.item;
},
},
img: {
@ -225,10 +216,11 @@ export default {
updateNurseStationHeads(formData).then((response) => {
this.options.img = baseurl + response.imgUrl;
this.$emit("imgUrl", response.imgUrl);
console.log(this.rows);
console.log(this.items);
console.log(this.types);
if (this.types == "attributePitureUrl") {
this.rows.attributePitureUrl = response.imgUrl;
this.$emit("item", JSON.stringify(this.rows));
this.items.attributePitureUrl = response.imgUrl;
this.$emit("item", JSON.stringify(this.items));
}
this.openimg = false;
});