chenrui 1 年間 前
コミット
94281af8c2
1 ファイル変更29 行追加7 行削除
  1. 29 7
      src/views/common/chooseBrandModal.vue

+ 29 - 7
src/views/common/chooseBrandModal.vue

@@ -12,8 +12,8 @@
       <div>
         <a-checkbox :checked="checkAll" :disabled="disabledList.length>0" @change="onCheckAllChange">全选</a-checkbox>
         <span v-if="pageType==='1'">
-          <a-checkbox :checked="checkOwn" :disabled="disabledList.length>0" @change="onCheckOwnChange">自主品牌</a-checkbox>
-          <a-checkbox :checked="checkAgent" :disabled="disabledList.length>0" @change="onCheckAgentChange">代理品牌</a-checkbox>
+          <a-checkbox :checked="checkOwn" @change="onCheckOwnChange">自主品牌</a-checkbox>
+          <a-checkbox :checked="checkAgent" @change="onCheckAgentChange">代理品牌</a-checkbox>
         </span>
       </div>
       <a-divider />
@@ -142,12 +142,38 @@ export default {
       if (e.target.checked) {
         this.checkedList = []
         this.checkedRowList = []
-        this.brandList.map(item => {
+        this.brandList.forEach(item => {
           if (item.brandType == 1) {
             _this.checkedList.push(item.brandSn)
             _this.checkedRowList.push(item)
           }
         })
+        if (_this.disabledList && _this.disabledList.length > 0) {
+          _this.checkedRowList.forEach(con => {
+            const pos = _this.disabledList.findIndex(list => { con.brandSn == list })
+            if (pos != -1) {
+              _this.checkedList.splice(pos, 1)
+              _this.checkedRowList.splice(pos, 1)
+            }
+          })
+        }
+        if (_this.chooseData && _this.chooseData.length > 0) {
+          const arr = []
+          _this.chooseData.forEach(con => {
+            const pos = _this.disabledList.findIndex(list => { list == con.goodsSn })
+            _this.checkedList.push(_this.disabledList[pos])
+            arr.push(_this.disabledList[pos])
+          })
+          this.brandList.forEach(newCon => {
+            if (arr.length > 0) {
+              arr.forEach(newItem => {
+                if (newItem === newCon.brandSn) {
+                  _this.checkedRowList.push(newCon)
+                }
+              })
+            }
+          })
+        }
       } else {
         const noArr = this.getDifferData(this.checkedList, this.brandOwnList)
         _this.checkedList = noArr
@@ -217,10 +243,6 @@ export default {
         }
       })
       // this.$forceUpdate()
-    },
-    // 获取品牌长度
-    getAllBrandLength () {
-      return this.brandList.length
     }
   },
   watch: {