From 8de0b9b35511382d3f3576acce2d21e928e2902c Mon Sep 17 00:00:00 2001
From: qb <1191961160@qq.com>
Date: Mon, 25 Sep 2023 13:40:53 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A2=84=E7=BA=A6=E5=8D=95?=
 =?UTF-8?q?=E9=99=90=E5=88=B6=E4=B8=BA=E5=90=8C=E4=B8=80=E5=95=86=E5=9C=BA?=
 =?UTF-8?q?,=20=E6=B8=85=E7=A9=BA=E9=A2=84=E7=BA=A6=E5=8D=95=E6=95=B0?=
 =?UTF-8?q?=E6=8D=AE=E8=AF=BB=E5=8F=96=E6=95=B0=E6=8D=AE=E4=B9=9F=E6=B8=85?=
 =?UTF-8?q?=E7=A9=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../reservation/reservationAddFrom.vue        | 87 ++++++++++++++-----
 vite.config.js                                |  4 +-
 2 files changed, 69 insertions(+), 22 deletions(-)

diff --git a/src/views/distribution/reservation/reservationAddFrom.vue b/src/views/distribution/reservation/reservationAddFrom.vue
index cb9de079..5ca099d7 100644
--- a/src/views/distribution/reservation/reservationAddFrom.vue
+++ b/src/views/distribution/reservation/reservationAddFrom.vue
@@ -368,13 +368,8 @@
                 <tablecmt
                         :columnList="columnParcels"
                         :tableData="packageData"
-                        :checkselect="packageData"
-
+                        :checkselect="packageDataSec"
                         :loading="loading"
-                        @inputTxt="inputsc"
-                        @timeCheck="timesc"
-                        @btnCheck="btnsc"
-                        @selectCheck="selectsc"
                         @selection="selectionPackageChange"
                 >
                     <template #default="slotProps">
@@ -1669,6 +1664,10 @@
         orderIds: '',
         //预约编号
         reservationId: '',
+        // 商城名称
+        marketName: '',
+        // 包件复选框列表
+        packageDataSec: [],
         inventoryData: [],
         orderData: [],
         stockListShow: false,
@@ -1809,7 +1808,11 @@
               item.applyNum = item.quantityStock - item.quantityOccupied;
             });
             this.page.total = inventoryList.total;
-            this.inventoryInfo = inventoryList.records;
+            console.log('res :>> ', res);
+            this.inventoryInfo = inventoryList.records.filter(value=>{
+              if(this.marketName === '')return value
+              return value.marketName === this.marketName
+            });
             //存在库存品,需要将库存品进行回显勾选
             if (this.inventoryData) {
               this.inventoryInfo.forEach((item, index) => {
@@ -1907,7 +1910,7 @@
         this.loading = true;
         this.packageList = row.packageList;
         this.obj = row;
-        console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', row);
+        console.log('row>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>', row);
         if (this.reservationId) {
           //这里就是编辑的数据回显问题
           let packageInfo = row.parcelListVOS;
@@ -1933,8 +1936,21 @@
             });
           }
           this.packageData = row.parcelListVOS;
+          
+          // 当row内packageList为空时, 默认全选
+          if(row.packageList.length === 0) {
+            this.packageDataSec = row.parcelListVOS
+          }else{
+            this.packageDataSec = row.parcelListVOS.filter(item => {
+              return row.packageList.some( value => value.id === item.id)
+            });
+          }
+
         } else {
           this.packageData = row.parcelListVOS;
+          this.packageDataSec = row.parcelListVOS.filter(item => {
+            return row.packageList.some( value => value.id === item.id)
+          });
           //这里回显展示的效果应该是展示被其他预约单勾选的订单处于禁用勾选,冻结订单处于禁用无法勾选,其他默认为全选
           let data = row.parcelListVOS;
           data.forEach((item, index) => {
@@ -2029,13 +2045,13 @@
         this.handleAddInventory();
       },
       onSubmitPackage() {
-        if (this.packageList.length === 0) {
+        if (this.packageDataSec.length === 0) {
           this.$message.warning('请选择包件!!!');
           return;
         }
         this.orderData.forEach(item => {
           if (item.id === this.obj.id) {
-            item.packageList = this.packageList;
+            item.packageList = this.packageDataSec;
           }
         });
         console.log('this.orderData------------>', this.orderData);
@@ -2149,6 +2165,10 @@
           }
           console.log(item);
         });
+        // 当两个列表没有数据时, 清空限制
+        if(this.inventoryData.length === 0 && this.orderData.length === 0) this.marketName = ''
+        // 当列表没有数据时, 表单清空
+        if(this.orderData.length === 0) this.form = {}
         console.log('>>>>>>>>>>>>>>>row', row);
       },
       removeStockList(row) {
@@ -2160,8 +2180,10 @@
           if (item.id === row.id) {
             this.inventoryData.splice(index, 1);
           }
-          console.log(item);
+          console.log('item>>>>>>>>>>>',item);
         });
+        // 当两个列表没有数据时, 清空限制
+        if(this.inventoryData.length === 0 && this.orderData.length === 0) this.marketName = ''
         console.log('>>>>>>>>>>>>>>>row', row);
       },
       showStockListEdit(row) {
@@ -2210,7 +2232,7 @@
       selectionPackageChange(list) {
         console.log('-----------<>', list);
         if (this.reservationId) {
-          this.packageList = list;
+          this.packageDataSec = list;
         } else {
           //新增
           let a = [];
@@ -2223,7 +2245,7 @@
               a.push(item);
             }
           });
-          this.packageList = a;
+          this.packageDataSec = a;
         }
       },
       selectionInventoryChange(list) {
@@ -2254,6 +2276,18 @@
             return;
           }
         });
+        console.log('this.inventoryList :>> ', this.inventoryList);
+        // 检测商场是否选择统一商场
+        let _marketName = ''
+        const _isUnifyMarketName = this.inventoryList.every(value => {
+          if (_marketName === '') _marketName = value.marketName
+          return _marketName === value.marketName 
+        })
+        if(!_isUnifyMarketName){
+          this.$message.warning('请选择统一商场!!!');
+          return;
+        }
+        this.marketName = _marketName
         this.inventoryData = this.inventoryList;
 
         // if (this.orderData.length) {
@@ -2308,6 +2342,9 @@
           }
         }
 
+        // 设置商场名称
+        this.marketName = list[0].marketName
+
         this.form.consignee = name;
         this.form.deliveryAddress = address;
         this.form.deliveryPhone = phone;
@@ -2388,8 +2425,9 @@
           this.reservationId,
           Object.assign(params, this.query)
         ).then(res => {
-          console.log('res------------>', res);
+          console.log('res123123------------>', res);
           const data = res.data.data;
+          console.log('data :>> ', data);
           this.stockArticleInfo = data.records;
           this.stockArticleInfo.forEach((item, index) => {
             //检查订单是否冻结
@@ -2475,9 +2513,16 @@
           page.pageSize,
           Object.assign(params, this.query)
         ).then(res => {
-          console.log('res------------>', res);
-          const data = res.data.data;
-          this.stockArticleInfo = data.records;
+          console.log('res123------------>', res);
+          const {records, total} = res.data.data;
+          this.stockArticleInfo = records.filter(value => {
+            if(this.marketName === '') return value
+            if(this.marketName) {
+              console.log('value.marketName :>> ', value.marketName);
+              return value.mallName === this.marketName
+            }
+          });
+          console.log('this.stockArticleInfo :>> ', this.stockArticleInfo);
           this.stockArticleInfo.forEach((item, index) => {
             //检查订单是否冻结
             this.checkOrder(item, index);
@@ -2492,7 +2537,7 @@
             // }else {
             //   this.orderList = [];
             // }
-            this.page.total = data.total;
+            this.page.total = total;
           });
           this.orderList = [];
         });
@@ -2541,7 +2586,9 @@
             // stockArticleListInfo.forEach(item=>{
             //
             // })
-            console.log('>>>>>>>>', reservation);
+            console.log('reservation>>>>>>>>', reservation);
+            // 添加限制的商场名称
+            this.marketName = reservation.mallName;
             this.orderData = reservation.stockArticleList;
             this.inventoryData = reservation.inventoryList;
             this.inventoryData.forEach(item => {
@@ -2565,7 +2612,7 @@
     }
   };
 </script>
-<style>
+<style lang="scss">
     input::-webkit-outer-spin-button,
     input::-webkit-inner-spin-button {
         -webkit-appearance: none;
diff --git a/vite.config.js b/vite.config.js
index 59920f4a..09ffe9b9 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -17,8 +17,8 @@ export default ({ mode, command }) => {
           // target: 'http://192.168.10.123:8889',
           // target: 'http://192.168.10.75:8777',
           // target: 'http://192.168.10.101:8888',
-          // target: 'http://192.168.10.29:13000',
-          target: 'http://test.api.huitongys.com',
+          target: 'http://192.168.10.29:13000',
+          // target: 'http://test.api.huitongys.com',
           changeOrigin: true,
           rewrite: path => path.replace(/^\/api/, ''),
         },