From 7fbfeddedebd05e2d23ce411be887106d31e8eff Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期三, 27 三月 2024 15:02:18 +0800
Subject: [PATCH] 销售明细单产品列表添加动态表头,产品信息列表根据完成数量展示字体色

---
 src/views/sales/salesDetails/shipmentsDialog.vue |  224 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 170 insertions(+), 54 deletions(-)

diff --git a/src/views/sales/salesDetails/shipmentsDialog.vue b/src/views/sales/salesDetails/shipmentsDialog.vue
index 99cadd4..79dcc11 100644
--- a/src/views/sales/salesDetails/shipmentsDialog.vue
+++ b/src/views/sales/salesDetails/shipmentsDialog.vue
@@ -12,7 +12,7 @@
         ref="form"
         :model="editConfig.infomation"
         :rules="rules"
-        label-position="right"
+        label-position="left"
         label-width="10%"
         size="mini"
         style="height: 60vh; overflow-x: hidden"
@@ -69,15 +69,10 @@
               :selectBox="false"
               :addTypeIdMultiple="true"
               pageName="quotation"
+              :isBorder="true"
               :detailEnter="true"
-              :isOperate="
-                (autoCodeHeadersObj.Bjd == 'yes' && editConfig.infomation.quotation_number) ||
-                autoCodeHeadersObj.Bjd != 'yes'
-                  ? true
-                  : false
-              "
-              :quotationNumber="autoCodeHeadersObj.Bjd == 'yes' ? editConfig.infomation.quotation_number : ''"
               :product-table-list="productTableList"
+              :isOperate="true"
               @inputContent="inputContent"
               @addProductClick="addProductClick"
               @getSelectArray="getSelectArray"
@@ -85,9 +80,8 @@
               @clearupProduct="clearupProduct"
             ></CommonFormTableView>
           </div>
-          <p class="tips" v-if="completely"><i class="el-icon-warning-outline">褰撳墠浠撳簱鑳芥弧瓒冲彂璐ч渶姹傦紝鐩存帴鍙戣揣鍚�</i></p>
-          <p class="tips" v-if="satisfyPartly"><i class="el-icon-warning-outline"></i>褰撳墠浠撳簱鍙兘閮ㄥ垎婊¤冻鍙戣揣闇�姹傦紝鏄惁纭鍙戣揣</p>
-          <p class="tips" v-if="dissatisfy"><i class="el-icon-warning-outline"></i>褰撳墠浠撳簱搴撳瓨涓嶈冻锛屼笉鑳藉畬鎴愪竴娆″彂璐э紝璇烽�夋嫨鍏朵粬浠撳簱鍚�</p>
+          <p class="tips tips_success" v-if="completely"><i class="el-icon-warning-outline"></i>{{ shipmentsMsg }}</p>
+          <p class="tips tips_insufficient" v-if="dissatisfy"><i class="el-icon-warning-outline"></i>{{shipmentsMsg}}</p>
         </div>
       </el-form>
 
@@ -205,9 +199,10 @@
         label: '浠撳簱1--搴撳瓨鍏呰冻鐨勬儏鍐�'
       }],
       value:"",
+      shipmentsList:[],
+      shipmentsMsg:"",
       dissatisfy:false, // 涓�娆″彂璐�-涓嶈冻
       completely:false, // 澶氭鍙戣揣锛屽厖瓒�
-      satisfyPartly:false, //澶氭鍙戣揣锛岄儴鍒嗘弧瓒�
     }
   },
   mounted(){
@@ -272,14 +267,45 @@
       this.$refs[formName].validate((valid) => {
         if (valid) {
           const params = this.saveParams()
-          confirmOutput(params).then((res)=>{
-            console.log(res,"res")
-            if(res&&res.code===200){
-              this.$message.success("鍙戣揣鎴愬姛!")
-              this.$parent.getData()
-              this.editConfig.visible=false
+          console.log(params,"鍙傛暟")
+          let isShipments=false
+          let shipmentsNum=false
+          this.shipmentsList.map((item)=>{
+            if(this.shipmentsType===1){
+              if(item.leftAmount<item.availableAmount&&item.leftAmount>0){
+                isShipments=false
+              }else if(item.leftAmount<=0){
+                shipmentsNum=true
+              }else{
+                isShipments=true
+              }
+            }else{
+              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
+              }else{
+                isShipments=false
+              }
             }
           })
+          if(isShipments){
+            this.$message.warning("鍙戣揣鏁伴噺瓒呭嚭鏈彂璐ф暟閲忔垨瓒呭嚭褰撳墠鍙敤搴撳瓨")
+          }else if(shipmentsNum){
+            this.$message.warning("鍙戣揣鏁伴噺涓嶈兘涓�0")
+          }else{
+            confirmOutput(params).then((res)=>{
+              if(res&&res.code===200){
+                this.$message.success("鍙戣揣鎴愬姛!")
+                this.$parent.getData()
+                this.editConfig.visible=false
+              }
+            })
+          }
         }
       })
     },
@@ -288,10 +314,10 @@
         products:[],
         saleDetailNumber:this.editCommonConfig.infomation.saleDetailNumber
       }
-      this.productTableList.tableData.map((item)=>{
+      this.shipmentsList.map((item)=>{
         let obj={
           number:item.number,
-          outputAmount:item.outputAmount||''
+          outputAmount:this.shipmentsType===1?item.leftAmount:item.outputAmount // 鏈鍙戣揣鏁伴噺
         }
         params.products.push(obj)
       })
@@ -425,20 +451,20 @@
         tableColumn: [
           { label: "浜у搧缂栧彿", prop: "number" },
           { label: "浜у搧鍚嶇О", prop: "name",   min: 110 },
-          { label: "璁㈠崟鏁伴噺", prop: "specs" },
-          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "type" },
+          { label: "璁㈠崟鏁伴噺", prop: "orderAmount" },
+          { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" },
           // { label: "鍙敤搴撳瓨", prop: "unit" },
         ]
       }
     },
     // 浜у搧鍒楄〃杈撳叆
     inputContent(val, prop, row) {
-      // this.productId = row.productId
-      this.tableData.map((item) => {
-        if (item.number === row.number) {
-          item[prop] = val
-        }
-      })
+      console.log(val,prop,row,)
+      // this.productTableList.tableData.map((item) => {
+      //   if (item.number === row.number) {
+      //     item[prop] = val
+      //   }
+      // })
     },
     // 浜у搧鏂板
     addProductClick() {
@@ -504,9 +530,10 @@
     },
     // 閫夋嫨鍙戣揣鏂瑰紡
     handleRadioChange(value) {  
+      this.shipmentsList=[]
+      this.dissatisfy=false
+      this.completely=false
       if(value===1){
-        this.completely=false
-        this.satisfyPartly=false
         this.productTableList.tableColumn=[
           { label: "浜у搧缂栧彿", prop: "number" },
           { label: "浜у搧鍚嶇О", prop: "name",   min: 110 },
@@ -516,21 +543,48 @@
         ]
         this.dissatisfy=false
         let portion=0
+        // let noUsable=false
         this.productTableList.tableData.map((item)=>{
-          if(item.availableAmount-item.leftAmount<0){
-            this.dissatisfy=true
-            return this.dissatisfy
-          }else{
+          item.availableAmount=Number(item.availableAmount)
+          item.leftAmount=Number(item.leftAmount)
+          item.finishAmount=Number(item.finishAmount)
+          item.orderAmount=Number(item.orderAmount)
+          console.log(item,"item")
+          if(item.availableAmount>=item.leftAmount&&item.availableAmount>0&&item.leftAmount>0){
             portion++
+            this.shipmentsList.push(item)
           }
+          // if(item.availableAmount<item.leftAmount){
+          //   noUsable=true
+          // }
         })
-        if(portion===this.productTableList.tableData.length){
+          if(portion===0){// 娌℃湁浜у搧婊¤冻鍙戣揣鏉′欢
+            this.completely=false
+            this.dissatisfy=true
+            // if(noUsable){
+            //   this.shipmentsMsg="鍙敤搴撳瓨涓嶆弧瓒虫湭鍙戣揣鏁伴噺,鏃犳硶鍙戣揣"
+            // }else{
+            // }
+            this.shipmentsMsg="鍙敤搴撳瓨鎴栨湭鍙戣揣鏁伴噺涓�0鎴栧綋鍓嶅彲鐢ㄥ簱瀛樹笉婊¤冻鏈彂璐ф暟閲忥紝涓嶈兘瀹屾垚涓�娆″彂璐�"
+
+          }else if(portion>0&&portion<this.productTableList.tableData.length){// 閮ㄥ垎浜у搧婊¤冻鍙戣揣鏉′欢
+            this.dissatisfy=false
+            this.completely=true
+            this.shipmentsMsg="鍙兘婊¤冻閮ㄥ垎鍙戣揣闇�姹傦紝鏄惁纭鍙戣揣"
+            
+          }else if(portion!==0){
+            this.dissatisfy=false
+            this.completely=true
+            console.log(portion,"portion")
+            this.shipmentsMsg="鑳芥弧瓒冲彂璐ч渶姹傦紝鐩存帴鍙戣揣鍚�"
+          }
+
+        if(portion===this.productTableList.tableData.length){ // 鍏ㄩ儴婊¤冻鍙戣揣鏉′欢
           this.dissatisfy=false
           this.completely=false
           this.completely=true
         }
       }else if(value===2){
-        this.dissatisfy=false
         this.productTableList.tableColumn= [
           { label: "浜у搧缂栧彿", prop: "number" },
           { label: "浜у搧鍚嶇О", prop: "name",  min: 110 },
@@ -538,39 +592,68 @@
           { label: "璁㈠崟瀹屾垚鏁伴噺", prop: "finishAmount" },
           { label: "鍙敤搴撳瓨", prop: "availableAmount" },
           { label: "鏈彂璐ф暟閲�", prop: "leftAmount",  },
-          { label: "鏈鍙戣揣鏁伴噺", prop: "outputAmount", inputFloat: true,isRequird: true  },
+          { label: "鏈鍙戣揣鏁伴噺", prop: "outputAmount", inputFloat: true,isRequird:true },
           { label: "鍓╀綑鍙戣揣鏁伴噺", prop: "availableAmount",},
         ]
         let portion=0
         this.productTableList.tableData.map((item)=>{
-          if(item.availableAmount-item.leftAmount>=0){
+          item.availableAmount=Number(item.availableAmount)
+          item.leftAmount=Number(item.leftAmount)
+          item.finishAmount=Number(item.finishAmount)
+          item.orderAmount=Number(item.orderAmount)
+          if(item.availableAmount>0&&item.leftAmount>0){ 
             portion++
+            this.shipmentsList.push(item)
           }
         })
-        if(0<portion<this.productTableList.tableData.length){
-          this.satisfyPartly=true
-        }else if(portion===this.productTableList.tableData.length){
-          this.completely=true
-          this.dissatisfy=fasle
-        }else if(portion===0){
-          this.dissatisfy=true
+        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 if(portion===this.productTableList.tableData.length){
+          this.dissatisfy=false
+          this.completely=true
+          this.shipmentsMsg="鑳芥弧瓒冲彂璐ч渶姹傦紝鐩存帴鍙戣揣鍚�"
         }
       }
     },
     // 浜у搧鍏ュ簱淇℃伅
     async getDeliveryPrepareInfo(params){
       await getDeliveryPrepareInfo(params).then((res)=>{
+        this.shipmentsList=[]
         if(res&&res.code===200){
           this.productTableList.tableData=res.data||[]
           if(this.shipmentsType===1){
+            let portion=0
             this.productTableList.tableData.map((item)=>{
-              if(item.availableAmount-item.leftAmount<0){
-                this.dissatisfy=true
-                return this.dissatisfy
+              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)
               }
             })
+            console.log(portion,"portion2")
+            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="鑳芥弧瓒冲彂璐ч渶姹傦紝鐩存帴鍙戣揣鍚�"
+            }
           }
         }
       })
@@ -589,6 +672,9 @@
       }
     }
     .basic-info {
+      padding: 0px 20px ;
+      .product-view{
+      }
       .basic-info-title {
         background-color: #f4f8fe;
         padding-left: 10px;
@@ -623,13 +709,20 @@
       }
       .tips{
         font-size: 16px;
-        color: #FF9C49;
         display: flex;
-        margin-left: 20px;
         i{
           font-size: 24px;
           margin-right: 10px;
         }
+      }
+      .tips_success{
+        color: #5299FF;
+      }
+      .tips_portion{
+        color: #FF9C49;
+      }
+      .tips_insufficient{
+        color: #FF9C49;
       }
     }
     .unflod-collapse {
@@ -643,10 +736,33 @@
       background-color: #f5f5f5;
       height: 55px;
       line-height: 55px;
+      text-align: right !important;
     }
-    .el-input__inner {
-      text-align: left;
-    }
+    // .el-input__inner {
+    //   text-align: left;
+    // }
   }
+  .el-table tr {
+    background-color: #fff;
+  }
+  .el-table th.el-table__cell.is-leaf{
+    background-color: #F1F3F8 !important;
+  }
+  .el-dialog__footer{
+    text-align: right !important;
+    padding-right: 20px;
+  }
+  .el-dialog__header {
+    background: #f5f7fa;
+    height: 50px !important;
+    line-height: 50px !important;
+    padding: 0;
+    font-weight: 600 !important;
+    font-size: 15px !important;
+    padding-left: 20px !important;
+  }
+  // .el-table{
+  //   border: 1px solid #e1e1e1;
+  // }
 }
 </style>

--
Gitblit v1.8.0