From 37630069ea5db733bd8d20fd6b10b5000fb99eb9 Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期一, 08 四月 2024 10:55:57 +0800
Subject: [PATCH] 发货单关联发货仓库

---
 src/views/sales/salesDetails/shipmentsDialog.vue |   82 +++++++++++++++++++++++++++++-----------
 src/api/sales/salesDetails.js                    |    8 ++++
 src/views/sales/salesDetails/index.vue           |    2 
 3 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/src/api/sales/salesDetails.js b/src/api/sales/salesDetails.js
index 65faa26..6394aa0 100644
--- a/src/api/sales/salesDetails.js
+++ b/src/api/sales/salesDetails.js
@@ -96,4 +96,12 @@
     data
   })
 }
+// 鎸変粨搴撹繘琛屽彂璐�
+export function getDeliveryPrepareInfoByWarehouse(data) {
+  return request({
+    url: "/api/salesDetails/getDeliveryPrepareInfoByWarehouse",
+    method: "post",
+    data
+  })
+}
 
diff --git a/src/views/sales/salesDetails/index.vue b/src/views/sales/salesDetails/index.vue
index a38945c..a6acc06 100644
--- a/src/views/sales/salesDetails/index.vue
+++ b/src/views/sales/salesDetails/index.vue
@@ -785,7 +785,7 @@
       this.editShipmentsConfig.infomation.saleDetailID = row.id
       this.editShipmentsConfig.infomation.deliverType = row.deliverType ? row.deliverType : 1
       this.editShipmentsConfig.infomation.saleDetailNumber = row.number
-      this.editShipmentsConfig.infomation.projectId = row.projectId
+      // this.editShipmentsConfig.infomation.projectId = row.projectId
     },
     // 纭鍙戣揣瀹屾垚
     async confirmClick(row) {
diff --git a/src/views/sales/salesDetails/shipmentsDialog.vue b/src/views/sales/salesDetails/shipmentsDialog.vue
index 3b9f538..f7e7039 100644
--- a/src/views/sales/salesDetails/shipmentsDialog.vue
+++ b/src/views/sales/salesDetails/shipmentsDialog.vue
@@ -30,13 +30,12 @@
                   </el-radio-group>
                 </el-form-item>
               </el-col>
-              <el-col :span="24">
+              <!-- <el-col :span="24">
                 <el-form-item label="鍏宠仈椤圭洰锛�" prop="projectId">
                   <el-select
                     v-model="editConfig.infomation.projectId"
                     placeholder="璇烽�夋嫨"
                     size="mini"
-                    :disabled="true"
                   >
                     <el-option
                       v-for="item in projectList"
@@ -47,19 +46,19 @@
                     </el-option>
                   </el-select>
                 </el-form-item>
-              </el-col>
-              <!-- <el-col :span="24">
+              </el-col> -->
+              <el-col :span="24">
                 <el-form-item  label="鍙戣揣浠撳簱" prop="addressee">
-                  <el-select  v-model="value" placeholder="璇烽�夋嫨">
+                  <el-select  v-model="value" placeholder="璇烽�夋嫨" @change="optionsChange">
                     <el-option
                       v-for="item in options"
-                      :key="item.value"
-                      :label="item.label"
-                      :value="item.value">
+                      :key="item.warehouseId"
+                      :label="item.warehouseName"
+                      :value="item">
                     </el-option>
                   </el-select>
                 </el-form-item>
-              </el-col> -->
+              </el-col>
             </el-row>
           </div>
           <div class="product-view" v-if="isCommonShow">
@@ -98,7 +97,7 @@
 <script>
 import CommonFormTableView from "@/components/makepager/CommonFormTableView"
 import { getAllData } from "@/api/client/client"
-import { getProjectList,getDeliveryPrepareInfo,confirmOutput } from "@/api/sales/salesDetails"
+import { getProjectList,getDeliveryPrepareInfo,confirmOutput,getDeliveryPrepareInfoByWarehouse } from "@/api/sales/salesDetails"
 import codeMixin from "@/components/makepager/mixin/codeMixin"
 import { getSaleChanceList } from "@/api/sales/salesOpportunity"
 import { getDataByType } from "@/api/data"
@@ -211,19 +210,14 @@
           return time.getTime() > Date.now()
         }
       },
-      options: [{
-        value: '1',
-        label: '浠撳簱1--搴撳瓨涓嶈冻鐨勬儏鍐�'
-      }, {
-        value: '2',
-        label: '浠撳簱1--搴撳瓨鍏呰冻鐨勬儏鍐�'
-      }],
+      options: [],
       value:"",
       shipmentsList:[],
       shipmentsMsg:"",
       dissatisfy:false, // 涓�娆″彂璐�-涓嶈冻
       completely:false, // 澶氭鍙戣揣锛屽厖瓒�
       isCommonShow:true,
+      warehouseId:null,
     }
   },
   mounted(){
@@ -241,6 +235,11 @@
     this.getDeliveryPrepareInfo({
           saleDetailID: this.editCommonConfig.infomation.saleDetailID,
           saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
+    })
+    this.getDeliveryPrepareInfoByWarehouse({
+      groupByWarehouse: true,
+      saleDetailID: this.editCommonConfig.infomation.saleDetailID,
+      saleDetailNumber: this.editCommonConfig.infomation.saleDetailNumber
     })
   },
   watch: {
@@ -291,7 +290,6 @@
       this.$refs[formName].validate((valid) => {
         if (valid) {
           const params = this.saveParams()
-          console.log(params,"鍙傛暟")
           let isShipments=false
           let shipmentsNum=false
           this.shipmentsList.map((item)=>{
@@ -307,8 +305,6 @@
               if(item.outputAmount>item.availableAmount||item.outputAmount>item.leftAmount){
                 isShipments=true
               }else if(item.outputAmount===0){
-                shipmentsNum=true
-              }else if(!item.outputAmount){
                 shipmentsNum=true
               }else if(item.leftAmount<=0){
                 isShipments=true
@@ -336,7 +332,8 @@
     saveParams() {
       let params = {
         products:[],
-        saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber
+        saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber,
+        warehouseId:this.warehouseId
       }
       this.shipmentsList.map((item)=>{
         let obj={
@@ -375,7 +372,6 @@
       var restaurants = []
       if (value === "client") {
         restaurants = this.clientList
-        console.log(restaurants, "瀹㈡埛鍗�")
       } else if (value === "chance") {
           restaurants = this.saleChancelist
       } else if (value === "subbill") {
@@ -570,6 +566,9 @@
         pageSize: 100
       }).then((res) => {
         this.projectList = res.data
+        // if(res&&res.data.length>0){
+        //   this.editConfig.infomation.projectId=res.data[0].projectId
+        // }
       })
     },
     // 閿�鍞礋璐d汉鑷畾涔夋牎楠岃鍒�
@@ -702,7 +701,6 @@
                 this.shipmentsList.push(item)
               }
             })
-            console.log(portion,"portion2")
             if(portion===0){// 娌℃湁浜у搧婊¤冻鍙戣揣鏉′欢
               this.completely=false
               this.dissatisfy=true
@@ -720,6 +718,44 @@
           }
         }
       })
+    },
+    // 鎸変粨搴撹繘琛屽彂璐�
+    async getDeliveryPrepareInfoByWarehouse(params){
+      await getDeliveryPrepareInfoByWarehouse(params).then((res)=>{
+        this.options=res.data
+      })
+    },
+    // 閫夋嫨浠撳簱
+    optionsChange(val){
+      this.warehouseId=val.warehouseId
+      this.productTableList.tableData=val.storeInfoList||[]
+          if(this.editConfig.infomation.deliverType===1){
+            let portion=0
+            this.productTableList.tableData.map((item)=>{
+              item.availableAmount=Number(item.availableAmount)
+              item.leftAmount=Number(item.leftAmount)
+              item.finishAmount=Number(item.finishAmount)
+              item.orderAmount=Number(item.orderAmount)
+              if(item.availableAmount>=item.leftAmount&&item.availableAmount>0&&item.leftAmount>0){
+                portion++
+                this.shipmentsList.push(item)
+              }
+            })
+            if(portion===0){// 娌℃湁浜у搧婊¤冻鍙戣揣鏉′欢
+              this.completely=false
+              this.dissatisfy=true
+              this.shipmentsMsg="鍙敤搴撳瓨鎴栨湭鍙戣揣鏁伴噺涓�0鎴栧綋鍓嶅彲鐢ㄥ簱瀛樹笉婊¤冻鏈彂璐ф暟閲忥紝涓嶈兘瀹屾垚涓�娆″彂璐�"
+            }else if(portion>0&&portion<this.productTableList.tableData.length){
+              this.dissatisfy=false
+              this.completely=true
+              this.shipmentsMsg="鍙兘婊¤冻閮ㄥ垎鍙戣揣闇�姹傦紝鏄惁纭鍙戣揣"
+              // 閮ㄥ垎浜у搧婊¤冻鍙戣揣鏉′欢
+            }else{
+              this.dissatisfy=false
+              this.completely=true
+              this.shipmentsMsg="鑳芥弧瓒冲彂璐ч渶姹傦紝鐩存帴鍙戣揣鍚�"
+            }
+          }
     }
   }
 }

--
Gitblit v1.8.0