diff --git a/src/views/system/goods/add/components/goodsinfomation.vue b/src/views/system/goods/add/components/goodsinfomation.vue index fb23b446b37e7c87f8fda23c3a14ebec3c3f9523..aaa142d039b86a4f1375f8e13ed1ae49bb3c0dc1 100644 --- a/src/views/system/goods/add/components/goodsinfomation.vue +++ b/src/views/system/goods/add/components/goodsinfomation.vue @@ -224,7 +224,7 @@ this.goodsInfoForm.categoryList = this.goodsinfodata.categoryList; } // èŽ·å– çœ - this.getArea(); + //this.getArea(); // èŽ·å– å•†å“å“牌 this.getBrands(); }, @@ -235,18 +235,24 @@ this.goodsImgFileList = []; }, // èŽ·å– çœ - getArea() { - let limboNode = { - pid: 0 - }; - NewGetCategory(limboNode).then( res=> { - if(res.data) { - this.areaOptions = res.data; - }else { - this.areaOptions = []; - } - }); - }, + // getArea() { + // let limboNode = { + // pid: 0 + // }; + // NewGetCategory(limboNode).then( res=> { + // if(res.data && res.data.length > 0) { + // res.data.forEach( item => { + // let obj = { value: '', label: '' }; + // obj.value = item.id; + // obj.label = item.label; + // this.areaOptions.push(obj); + // }); + // //this.areaOptions = res.data; + // }else { + // this.areaOptions = []; + // } + // }); + // }, // èŽ·å– å•†å“å“牌 getBrands() { getBrandsInf().then( res => { @@ -272,46 +278,66 @@ const level = node.level; let limboNode = {}; if(level === 0) { - //debugger - limboNode = {pid: 0} + limboNode = {id: 0} } if(level === 1) { - //debugger - limboNode = { pid: node.value }; + limboNode = { id: node.value }; } if(level === 2) { - limboNode = { pid: node.value }; + limboNode = { id: node.value }; } + //this.loading = true; NewGetCategory(limboNode).then(res => { + let result = {}; + //debugger if (level === 0) { result = res.data result.forEach(item => { item.value = item.id; - item.label = item.name; - item.children=[]; + item.label = item.label; + item.children = []; item.leaf = 0; // å¯ä»¥æŽ§åˆ¶ æ˜¯å¦æœ‰ä¸‹çº§ 值为true都ä¸è¡Œï¼Œå¿…é¡»ç‰äºŽ0 }) } + if (level === 1) { - result = res.data + for(let i = 0; i < res.data.length; i++) { + if( limboNode.id === res.data[i].id ) { + result = res.data[i].children; + break; + } + } result.forEach(item => { item.value = item.id; - item.label = item.name + item.label = item.label item.children=[]; //è¿™å¥ä»£ç 表示当点击最åŽä¸€çº§çš„æ—¶å€™ labelåŽé¢ä¸ä¼šè½¬åœˆåœˆ 并把相关值赋值到选择器上 item.leaf = 0 }) } + if (level === 2) { - result = res.data + for(let i = 0; i < res.data.length; i++) { + if( res.data[i].children.length > 0) { + for(let j = 0; j < res.data[i].children.length; j++) { + if( limboNode.id === res.data[i].children[j].id ) { + result = res.data[i].children[j].children; + break; + } + } + } + } + result.forEach(item => { item.value = item.id; - item.label = item.name + item.label = item.label item.leaf = 1; }) } + resolve(result) + //this.loading = false; }); }, SSQGoodsChange(value) {