소스 검색

修改bug 品牌产品回显

chenrui 1 년 전
부모
커밋
931d60ba94

+ 4 - 2
src/views/promotionRulesManagement/dealerPromotions/chooseProductsModal.vue

@@ -193,6 +193,9 @@ export default {
       this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
+    },
+    handleDisabled (list) {
+      this.chooseDataList = list
     }
   },
   watch: {
@@ -207,13 +210,12 @@ export default {
       } else {
         const _this = this
         _this.resetSearchForm()
-        let selectedRows = []
+        const selectedRows = []
         const selectedRowKeys = []
         selectedRows = this.chooseData
         this.chooseData.map(item => {
           selectedRowKeys.push(item.goodsSn)
         })
-        this.chooseDataList = selectedRowKeys
         this.$nextTick(() => { // 页面渲染完成后的回调
           _this.$refs.table.setTableSelected(selectedRowKeys, selectedRows) // 设置表格选中项
         })

+ 22 - 24
src/views/promotionRulesManagement/dealerPromotions/tableType1.vue

@@ -132,6 +132,7 @@
     <!-- 选择产品 -->
     <chooseProductsModal
       type="dealership"
+      ref="productBox"
       :openModal="openProductsModal"
       :chooseData="chooseProducts"
       @close="openProductsModal=false"
@@ -255,21 +256,11 @@ export default {
       const _this = this
       _this.brandTagIndex = pos
       // 每行品牌都是唯一滴
-      // const snArr = []
-      // const snObjList = []
-      // _this.dataSource.forEach(item => {
-      //   if (item.productBrandList && item.productBrandList.length > 0) {
-      //     item.productBrandList.forEach(con => {
-      //       con.goodsSn = con.productBrandSn
-      //       snArr.push(con.productBrandSn)
-      //       snObjList.push(con)
-      //     })
-      //   }
-      // })
       const dataList = _this.setShowData('Brand')
       _this.openBrandModal = true
-      _this.chooseBrand = dataList[1]
-      _this.$refs.brandBox.handleDisabled(dataList[0])
+      const echoData = _this.handleEchoData('Brand', row.productBrandList)
+      _this.chooseBrand = echoData
+      _this.$refs.brandBox.handleDisabled(dataList)
     },
     handleBrandOk (conList) {
       const newConList = conList.map(con => {
@@ -282,9 +273,12 @@ export default {
     },
     // 添加产品
     addProductTag (pos, row) {
+      debugger
       this.productTagIndex = pos
       const dataList = this.setShowData('This')
-      this.chooseProducts = dataList[1]
+      const echoData = this.handleEchoData('This', row.productThisList)
+      this.chooseProducts = echoData
+      this.$refs.productBox.handleDisabled(dataList)
       this.openProductsModal = true
     },
     handleProductsOk (arr) {
@@ -302,22 +296,26 @@ export default {
     setShowData (name) {
       const _this = this
       const snArr = []
-      const snObjList = []
       _this.dataSource.forEach(item => {
         if (item['product' + name + 'List'] && item['product' + name + 'List'].length > 0) {
           item['product' + name + 'List'].forEach(con => {
-            if (name === 'This') {
-              con.goodsSn = con.productSn
-              snArr.push(con.productSn)
-            } else {
-              con.goodsSn = con['product' + name + 'Sn']
-              snArr.push(con['product' + name + 'Sn'])
-            }
-            snObjList.push(con)
+            const newName = name === 'This' ? '' : name
+            snArr.push(con['product' + newName + 'Sn'])
           })
         }
       })
-      return [snArr, snObjList]
+      return snArr
+    },
+    handleEchoData (name, conArr) {
+      conArr.map(item => {
+        if (name === 'This') {
+          item.code = item.productCode
+          item.goodsSn = item.productSn
+        } else {
+          item.goodsSn = item['product' + name + 'Sn']
+        }
+      })
+      return conArr
     },
     getResultVal () {
       const resultObj = JSON.parse(JSON.stringify(this.dataSource))