商品信息修改回显

master
rouchen 2024-03-24 10:53:31 +08:00
parent c24b09d95a
commit cc8f437a06
1 changed files with 70 additions and 15 deletions

View File

@ -332,6 +332,7 @@
<el-button type="primary" @click="oneSetting"></el-button> <el-button type="primary" @click="oneSetting"></el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
{{skuList}}
<el-table <el-table
:data="skuList" :data="skuList"
border border
@ -374,7 +375,7 @@ import {addAttribute} from "@/api/product/attribute";
export default { export default {
name: "Info", name: "Info",
dicts: ['sys_yes_no'], dicts: {type:{'sys_yes_no':[]}},
data() { data() {
return { return {
// //
@ -419,6 +420,7 @@ export default {
price: '', price: '',
stock: '' stock: ''
}, },
fufObj: [],
// //
rules: { rules: {
name: [ name: [
@ -484,7 +486,9 @@ export default {
"image": null, "image": null,
"stock": null, "stock": null,
"price": null "price": null
} },
respData:[],
fifObj: []
}; };
}, },
watch: { watch: {
@ -505,14 +509,54 @@ export default {
handler(value) { handler(value) {
if (value != null){ if (value != null){
getTemplateAttribute(value).then(response => { getTemplateAttribute(value).then(response => {
console.log("res",response)
const {data} = response; const {data} = response;
const {templateAttributeGroupList,templateAttributeList,attributeList} = data; const {templateAttributeGroupList,templateAttributeList,attributeList} = data;
this.categoryCommonElement.templateAttributeGroupList = templateAttributeGroupList; this.categoryCommonElement.templateAttributeGroupList = templateAttributeGroupList;
this.categoryCommonElement.templateAttributeList = templateAttributeList; this.categoryCommonElement.templateAttributeList = templateAttributeList;
this.categoryCommonElement.attributeList = attributeList; this.categoryCommonElement.attributeList = attributeList;
})
}
console.log("resData",this.respData);
if (this.respData != null && this.respData.length !== 0){
this.categoryCommonElement.templateAttributeGroupList.forEach(template => {
template.attributeList.forEach(te => {
this.respData.forEach(asPro => {
if (te.id == asPro.attributeId){
console.log("value",asPro.value)
te.value = asPro.value;
this.fufObj.push(asPro);
}
});
});
});
this.categoryCommonElement.templateAttributeList.forEach(tem => {
this.respData.forEach(asPro => {
console.log(asPro)
if (tem.id === asPro.attributeId){
tem.value = asPro.value;
this.fufObj.push(asPro);
}
});
});
this.respData.forEach(asPro => {
if (!this.fufObj.includes(asPro)){
this.attributeCheckedList.push(asPro);
}
});
this.categoryCommonElement.attributeList.forEach(attr => {
this.attributeCheckedList.forEach(attri => {
if (attr.id == attri.attributeId){
attri.name = attr.name;
this.attributeIdCheckedList.push(Number(attr.id));
}
});
});
}
});
}
} }
} }
}, },
@ -685,13 +729,16 @@ export default {
image: null, image: null,
carouselImages: null, carouselImages: null,
status: null, status: null,
ruleId: null,
brandId: null, brandId: null,
remark: null, remark: null,
createBy: null, createBy: null,
createTime: null, createTime: null,
updateBy: null, updateBy: null,
updateTime: null updateTime: null,
skuList: [],
titleList: [],
categoryCommonElement: [],
oneSettingForm: {}
}; };
this.resetForm("form"); this.resetForm("form");
this.initCategoryTree(); this.initCategoryTree();
@ -716,7 +763,11 @@ export default {
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.initCategoryTree()
this.open = true; this.open = true;
this.skuList=[]
this.titleList= []
this.oneSettingForm = {}
this.title = "添加商品信息"; this.title = "添加商品信息";
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -725,20 +776,24 @@ export default {
const id = row.id || this.ids const id = row.id || this.ids
getInfo(id).then(response => { getInfo(id).then(response => {
console.log("response",response)
console.log(response) this.respData = response.data.asProductAttributeInfos
this.form = response.data; this.form = response.data;
this.initCategoryTree() this.initCategoryTree()
this.form.mianType=parseInt(response.data.mianType) this.oneSettingForm = response.data.projectSkuInfos
this.form.type=parseInt(response.data.type) this.categoryOptionValue = [Number(response.data.mianType),Number(response.data.parentType),Number(response.data.type)]
this.oneSettingForm = response.data.productSkuModel
this.changeRule(response.data.ruleId) this.changeRule(response.data.ruleId)
this.oneSetting() console.log("sku",this.skuList)
console.log("skuu",response.data.projectSkuInfos)
for (var i = 0; i < this.skuList.length; i++) {
this.$set(this.skuList[i], 'image', response.data.projectSkuInfos[i].image);
this.$set(this.skuList[i], 'price', response.data.projectSkuInfos[i].price);
this.$set(this.skuList[i], 'stock', response.data.projectSkuInfos[i].stock);
console.log(this.skuList[i].price, response.data.projectSkuInfos[i].price);
}
console.log("sfdf",this.skuList)
this.open = true; this.open = true;
this.title = "修改商品信息"; this.title = "修改商品信息";
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */