chenrui 1 年間 前
コミット
b16c779071
1 ファイル変更16 行追加15 行削除
  1. 16 15
      src/views/common/chooseBrandModal.vue

+ 16 - 15
src/views/common/chooseBrandModal.vue

@@ -229,9 +229,23 @@ export default {
     },
     // 获取品牌数据
     getBrandList () {
+      const _this = this
       productBrandQuery({}).then(res => {
         if (res.status == 200) {
-          this.brandList = res.data
+          _this.brandList = res.data
+          if (_this.chooseData && _this.chooseData.length > 0) {
+            const checkedList = []
+            _this.chooseData.map(item => {
+              checkedList.push(item.goodsSn)
+            })
+            this.brandList.map(item => {
+              if (checkedList.includes(item.brandSn)) {
+                item.checked = true
+              } else {
+                item.checked = false
+              }
+            })
+          }
         } else {
           this.brandList = []
         }
@@ -266,20 +280,7 @@ export default {
         })
       } else {
         const _this = this
-        const checkedList = []
-        _this.chooseData.map(item => {
-          checkedList.push(item.goodsSn)
-        })
-        this.brandList.map(item => {
-          if (checkedList.includes(item.brandSn)) {
-            item.checked = true
-          } else {
-            item.checked = false
-          }
-        })
-        if (this.brandList.length == 0) {
-          this.getBrandList()
-        }
+        _this.getBrandList()
       }
     }
   }