lilei 3 лет назад
Родитель
Сommit
5a7ae33d0c

+ 17 - 7
src/views/common/productCodeList.vue

@@ -61,6 +61,11 @@ export default {
         this.fetching = false
       })
     },
+    getRow (cur) {
+      const _this = this
+      const ind = _this.data.findIndex(item => item.productSn == cur.key)
+      cur.row = ind != -1 ? _this.data[ind] : undefined
+    },
     handleChange (value) {
       const _this = this
       if (this.mode == 'default') { //  单选
@@ -69,13 +74,18 @@ export default {
           value.row = ind != -1 ? _this.data[ind] : undefined
         }
       } else if (this.mode == 'multiple') { //  多选
-        if (value.length > 0) {
-          const ind = _this.data.findIndex(item => item.productSn == value[value.length - 1].key)
-          value[value.length - 1].row = ind != -1 ? _this.data[ind] : undefined
-        }
-        if (this.lastData && this.lastData.length > 0) {
-          this.lastData = this.lastData.concat(value[value.length - 1])
-          value = this.lastData
+        console.log('===========')
+        console.log(this.lastData)
+        console.log(value)
+        console.log('===========')
+        // 新增
+        if (_this.lastData.length < value.length) {
+          _this.getRow(value[value.length - 1])
+          value = this.lastData.concat(value[value.length - 1])
+        } else {
+          // 删除
+          const delItem = this.lastData.filter(item => !value.find(a => a.key == item.key))
+          console.log(delItem)
         }
       }
       Object.assign(this, {

+ 3 - 0
src/views/productManagement/productInfo/offlineModal.vue

@@ -106,6 +106,7 @@ export default {
   },
   methods: {
     productCodeChange (val, row) {
+      console.log(val)
       row.commonProductList = []
       if (val.length > 0) {
         val.map(item => {
@@ -132,6 +133,8 @@ export default {
         if (valid) {
           const params = JSON.parse(JSON.stringify(_this.form))
           params.offlineProductList = _this.loadData
+          console.log(params)
+          return
           _this.spinning = true
           productOffline(params).then(res => {
             if (res.status == 200) {