From dd4a1597a35e19078aa580f596418902df0f8c5f Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期四, 11 四月 2024 19:22:48 +0800
Subject: [PATCH] Merge branch 'master' of ssh://192.168.5.5:29418/silk/silk-web

---
 src/views/productManage/productRegisterForm/addProductRegisterPage.vue |  443 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 405 insertions(+), 38 deletions(-)

diff --git a/src/views/productManage/productRegisterForm/addProductRegisterPage.vue b/src/views/productManage/productRegisterForm/addProductRegisterPage.vue
index 10b98b7..b205f13 100644
--- a/src/views/productManage/productRegisterForm/addProductRegisterPage.vue
+++ b/src/views/productManage/productRegisterForm/addProductRegisterPage.vue
@@ -72,6 +72,7 @@
                     v-model="ruleForm.marketId"
                     placeholder="璇烽�夋嫨"
                     class="select-width"
+                    @change='getGroupNumber'
                   >
                     <el-option
                       v-for="item in marketList"
@@ -356,6 +357,7 @@
           style="width: 100%"
           border
           :height="'calc(100% - 0px)'"
+          :cell-style='cellStyle'
         >
           <el-table-column
             prop="carNumber"
@@ -371,6 +373,7 @@
               width="60"
               align="center"
             >
+
             </el-table-column>
             <el-table-column
               prop="pieceNumber12"
@@ -455,6 +458,9 @@
             </el-table-column>
           </el-table-column>
           <el-table-column prop="oneYield" label="鍙颁骇閲�" align="center">
+            <template slot-scope="scope">
+               {{getOneYield(scope.row)}}
+            </template>
           </el-table-column>
           <el-table-column
             prop="peopleYield"
@@ -462,13 +468,19 @@
             width="60"
             align="center"
           >
+          <template slot-scope="scope">
+               {{scope.row.peopleYield!=0?scope.row.peopleYield:''}}
+            </template>
           </el-table-column>
-          <el-table-column
+          <el-table-column  
             prop="hourYield"
             label="鍙版椂浜ч噺"
             width="60"
             align="center"
           >
+            <template slot-scope="scope">
+              {{(ruleForm.record&&scope.row.oneYield)?(scope.row.oneYield/ruleForm.record).toFixed(2):''}}
+            </template>
           </el-table-column>
           <el-table-column
             prop="personReelingdiscount"
@@ -483,6 +495,9 @@
             width="60"
             align="center"
           >
+            <template slot-scope="scope">
+               {{getallYield(scope.row,1)}}
+            </template>
           </el-table-column>
           <el-table-column
             prop="oneYield1"
@@ -490,6 +505,9 @@
             width="60"
             align="center"
           >
+            <template slot-scope="scope">
+                 {{(ruleForm.record&&scope.row.allYield1)?(scope.row.allYield1/ruleForm.record).toFixed(2):''}}
+            </template>
           </el-table-column>
           <el-table-column
             prop="reelingdiscount1"
@@ -504,6 +522,9 @@
             width="60"
             align="center"
           >
+          <template slot-scope="scope">
+               {{getallYield(scope.row,2)}} 
+            </template>
           </el-table-column>
           <el-table-column
             prop="oneYield2"
@@ -511,6 +532,9 @@
             width="60"
             align="center"
           >
+          <template slot-scope="scope">
+               {{(ruleForm.record&&scope.row.allYield2)?(scope.row.allYield2/ruleForm.record).toFixed(2):''}}
+            </template>
           </el-table-column>
           <el-table-column
             prop="reelingdiscount2"
@@ -525,6 +549,9 @@
             width="60"
             align="center"
           >
+          <template slot-scope="scope">
+               {{getallYield(scope.row,3)}} 
+            </template>
           </el-table-column>
           <el-table-column
             prop="oneYield3"
@@ -532,6 +559,9 @@
             width="60"
             align="center"
           >
+          <template slot-scope="scope">
+            {{(ruleForm.record&&scope.row.allYield3)?(scope.row.allYield3/ruleForm.record).toFixed(2):''}} 
+            </template>
           </el-table-column>
           <el-table-column
             prop="reelingdiscount3"
@@ -542,22 +572,24 @@
           </el-table-column>
         </el-table>
       </div>
+       
     </div>
     <!-- 浠櫒杩炴帴姝e父寮圭獥 -->
     <addProductDialog ref="addProductDialog" 
-    :marketList='marketList' 
-    :nameList='nameList'  
-    :form='ruleForm'
-    :specList='specList'
-    @changeForm='changeForm'
-    @changeTableInput='changeTableInput' />
-  </div>
+      :marketList='marketList' 
+      :nameList='nameList'  
+      :form='ruleForm'
+      :specList='specList'
+      @changeForm='changeForm'
+      @changeTableInput='changeTableInput' />
+    </div>
+   
 </template>
 
 <script>
 import addProductDialog from "./components/addProductDialog";
 import {
-  // getYieldRegisterInfo,
+  getYieldRegisterInfo,
   saveYieldRegister,
   getWorkshopManageCar,
   getWorkshopManageGroup,
@@ -632,6 +664,8 @@
       isAddloading: false,
       productRegisterId:null,
       productRegisterNumber:null,
+      tableDataItems:[],
+      tableDataCircles:[],
     };
   },
   mounted() {
@@ -641,40 +675,240 @@
       this.productRegisterNumber = query.number ? query.number : "";
     }
     this.getSelectDataList();
+    this.getDetailsData()
   },
   methods: {
-    changeForm(form,val){
-      if(val){
-        this.ruleForm.createTime=form.createTime
-        this.ruleForm.groupNumber=form.groupNumber
-        this.ruleForm.spec=form.spec
-        this.ruleForm.marketId=form.marketId
-        this.getGroupNumber()
+    getDetailsData(){
+      this.ruleForm = {
+        number: "",
+        record: "",
+        createTime: "",
+        circle: "",
+        marketId: "",
+        fallingSilkCocoonNumber: "",
+        workshopId: "",
+        bucketCocoonNumber: "",
+        groupNumber: "",
+        vehicleSpeed: "",
+        spec: "",
+        timeYi: "",
+        jieZhuang: "",
+        timeJia: "",
+        level: "",
+        groupReelingdiscount: "",
+        fallingSilkBucket: "",
+        fallingSilkBucketOne: "",
+        isfallingSilkBucketOne: "",
+        fallingSilkBucketTwo: "",
+        isfallingSilkBucketTwo: "",
+        fallingSilkBucketThree: "",
+        isfallingSilkBucketThree: "",
+        back: "",
+        oneBack: "",
+        twoBack: "",
+        threeBack: "",
+        theorySilkAmount: "",
+        total: "",
+        hourYield: "",
+      };
+        if (this.productRegisterNumber) {
+          getYieldRegisterInfo({ number:this.productRegisterNumber }).then(
+            (response) => {
+              if (response.code === 200) {
+                let config = JSON.parse(
+                  JSON.stringify(response.data ? response.data : {})
+                );
+                this.ruleForm = config;
+                this.tableDataItems=config.items
+                  ? config.items
+                  : [];
+                  this.tableDataCircles=config.circles
+                  ? config.circles
+                  : [];
+                this.getGroupNumber(true)
+              }
+            }
+          );
+        }
+    },
+    getTableEdit(){
+      this.tableData=this.tableDataItems
+      if( this.tableDataCircles.length>0){
+        for(let i in this.tableData){
+          for(let j in this.tableDataCircles){
+            if(this.tableDataCircles[j].carNumber==this.tableData[i].carNumber){
+              let circle=this.tableDataCircles[j].circle
+              let pieceNumberList=this.tableDataCircles[j].pieceNumber||[]
+              this.tableData[i]['allYield'+circle]=this.tableDataCircles[j]['allYield'+circle]
+              this.tableData[i]['oneYield'+circle]=this.tableDataCircles[j]['oneYield'+circle]
+              this.tableData[i]['reelingdiscount'+circle]=this.tableDataCircles[j]['reelingdiscount'+circle]
+              if(pieceNumberList.length>0){
+                for(let k in pieceNumberList){
+                  this.tableData[i]['pieceNumber'+circle+pieceNumberList[k].pieceNumber]
+                }
+              }
+              this.tableData[i]
+            }
+          }
+        }
       }
+    },
+    // 琛ㄦ牸鐨勮绠楅棶棰�
+    getOneYield(row){
+      let string='';
+      if(row.pieceNumber11||row.pieceNumber12||row.pieceNumber13||row.pieceNumber14||row.pieceNumber21||row.pieceNumber22||row.pieceNumber23||row.pieceNumber24||row.pieceNumber31||row.pieceNumber32||row.pieceNumber33||row.pieceNumber34){
+        if(row.pieceNumber11){
+          string=Number(row.pieceNumber11)
+        }
+        if(row.pieceNumber12){
+          string=Number(string)+Number(row.pieceNumber12)
+        }
+        if(row.pieceNumber13){
+          string=Number(string)+Number(row.pieceNumber13)
+        }
+        if(row.pieceNumber14){
+          string=Number(string)+Number(row.pieceNumber14)
+        }
+        if(row.pieceNumber21){
+          string=Number(string)+Number(row.pieceNumber21)
+        }
+        if(row.pieceNumber22){
+          string=Number(string)+Number(row.pieceNumber22)
+        }
+        if(row.pieceNumber23){
+          string=Number(string)+Number(row.pieceNumber23)
+        }
+        if(row.pieceNumber24){
+          string=Number(string)+Number(row.pieceNumber24)
+        }
+        if(row.pieceNumber31){
+          string=Number(string)+Number(row.pieceNumber31)
+        }
+        if(row.pieceNumber32){
+          string=Number(string)+Number(row.pieceNumber32)
+        }
+        if(row.pieceNumber33){
+          string=Number(string)+Number(row.pieceNumber33)
+        }
+        if(row.pieceNumber34){
+          string=Number(string)+Number(row.pieceNumber34)
+        }
+      }
+      this.getPeopleYield(row)
+      row.oneYield=Number(string);
+      return string;
+    },
+    getPeopleYield(row){
+      let string=0
+      if(row.perList){
+        if(row.perList.length>0){
+          let carNumber=row.perList[row.perList.length-1]
+          for(let i in this.tableData){
+            for(let j in row.perList){
+              if(row.perList[j]==this.tableData[i].carNumber){
+                string=string+this.tableData[i].oneYield
+              }
+            }
+          }
+          for(let k in this.tableData){
+            if(this.tableData[k].carNumber==carNumber){
+              this.$set(this.tableData[k],'peopleYield',string)
+              break;
+            }
+          }
+        }
+      }
+    },
+    getallYield(row,val){
+      let string='';
+      if(row['pieceNumber'+val+'1']||row['pieceNumber'+val+'2']||row['pieceNumber'+val+'3']||row['pieceNumber'+val+'4']){
+        if(row['pieceNumber'+val+'1']){
+          string=Number(row['pieceNumber'+val+'1'])
+        }
+        if(row['pieceNumber'+val+'2']){
+          string=Number(string)+Number(row['pieceNumber'+val+'2'])
+        }
+        if(row['pieceNumber'+val+'3']){
+          string=Number(string)+Number(row['pieceNumber'+val+'3'])
+        }
+        if(row['pieceNumber'+val+'4']){
+          string=Number(string)+Number(row['pieceNumber'+val+'4'])
+        }
+      }
+      row['allYield'+val]=Number(string);
+      return string;
+    },
+    changeForm(form,val,data){
+      if(val){
+        if(Object.keys(data).length>0){
+          let config = JSON.parse(
+                  JSON.stringify(data ? data : {})
+                );
+                this.ruleForm = config;
+                this.tableDataItems=config.items
+                  ? config.items
+                  : [];
+                  this.tableDataCircles=config.circles
+                  ? config.circles
+                  : [];
+          this.$router.push({
+            name:'addProductRegisterPage',
+            query:{
+                id:data.id,
+                number:data.number,
+              }
+          });
+          this.getGroupNumber(true)
+        }
+      }
+    },
+    cellStyle({row,columnIndex}){
+      let cellStyle;
+      if(row.isBlue){
+        let pieceNumber=this.$refs.addProductDialog.proForm.pieceNumber||1
+        let pieces=this.$refs.addProductDialog.proForm.pieces||1
+        let number=(Number(pieceNumber)-1)*4+Number(pieces)
+        if(columnIndex==number){
+          cellStyle='borderColor:#2a78fb;borderTop:1px solid #2a78fb;borderLeft:1px solid #2a78fb;'
+        }
+      }else{
+        cellStyle='borderColor:#EBEEF5;borderTop:0;borderLeft:0'
+      }
+      return cellStyle;
     },
     changeTableInput(form){
       let string=''
       for(let i in this.tableData){
         if(this.tableData[i].carNumber==form.carNumber){
           string=i
-          if(Number(form.pieceNumber)>0&&Number(form.pieces)<5){
+           if(Number(form.pieceNumber)>0&&Number(form.pieces)<5){
+            this.tableData.map((item) => {
+              item.isBlue=false
+            })
+            this.$set(this.tableData[i],'isBlue',true)
             this.$set(this.tableData[i],'pieceNumber'+form.pieceNumber+form.pieces,form.netWeight)
             break;
           }
         }
       }
-      if(form.pieceNumber==3&&form.pieces==4){
-        this.$refs.addProductDialog.proForm.carNumber=this.tableData[Number(string)+1].carNumber
-      }else{
-        if(form.pieces==4){
-          this.$refs.addProductDialog.proForm.pieceNumber=Number(form.pieceNumber)+1
+      if(form.netWeight){
+        if(form.pieceNumber==3&&form.pieces==4){
+          this.$refs.addProductDialog.proForm.carNumber=this.tableData[Number(string)+1].carNumber
+          this.$set(this.tableData[Number(string)],'isBlue',false)
+          this.$set(this.tableData[Number(string+1)],'isBlue',true)
+          this.$refs.addProductDialog.proForm.pieceNumber=1
           this.$refs.addProductDialog.proForm.pieces=1
         }else{
-          this.$refs.addProductDialog.proForm.pieces=Number(form.pieces)+1
+          if(form.pieces==4){
+            this.$refs.addProductDialog.proForm.pieceNumber=Number(form.pieceNumber)+1
+            this.$refs.addProductDialog.proForm.pieces=1
+          }else{
+            this.$refs.addProductDialog.proForm.pieces=Number(form.pieces)+1
+          }
         }
+        this.$refs.addProductDialog.proForm.netWeight=''
+        this.$forceUpdate();
       }
-      this.$refs.addProductDialog.proForm.netWeight=''
-      this.$forceUpdate();
     },
     getSelectDataList() {
       //杞﹂棿
@@ -702,7 +936,7 @@
         }
       });
     },
-    getGroupNumber(){
+    getGroupNumber(val){
       if(this.ruleForm.workshopId){
         //缁勫埆
         getWorkshopManageGroup({number:this.ruleForm.workshopId}).then((res) => {
@@ -716,22 +950,44 @@
               }
             }
           });
-          if(this.ruleForm.groupNumber){
+          if(this.ruleForm.groupNumber&&this.ruleForm.marketId){
+            let workshopName=''
+            for(let i in this.nameList){
+              if( this.nameList[i].number==this.ruleForm.workshopId){
+                workshopName= this.nameList[i].name
+                break;
+              }
+            }
+            let marketName=''
+            for(let i in this.marketList){
+              if( this.marketList[i].ID==this.ruleForm.marketId){
+                marketName= this.marketList[i].name
+                break;
+              }
+            }
             getWorkshopManageCar({
-              workshopNumber:this.ruleForm.workshopId+'',
+              workshopName:workshopName,
+              marketName:marketName,
               groupNumber:this.ruleForm.groupNumber,
             }).then((res) => {
               if (res.code == 200) {
                 this.tableData=[]
-                let data = JSON.parse(JSON.stringify(res.data)) || {};
+                this.ruleForm.level=res.data.level||''
+                let data = JSON.parse(JSON.stringify(res.data.car)) || [];
                if(Object.keys(data).length>0){
                 for(let i in data){
                   for(let j in data[i]){
-                    this.tableData.push({carNumber:data[i][j],perList:data[i]})
+                    this.tableData.push({carNumber:data[i][j],perList:data[i],isBlue:false})
                   }
                 }
+                this.tableData[0].isBlue=true
+               }
+              //  缂栬緫
+               if(val){
+                this.getTableEdit()
                }
                this.ruleForm.carNumber=this.tableData.length>0?this.tableData[0].carNumber:''
+               
               }
             });
           }
@@ -748,8 +1004,8 @@
     // 浠櫒杩炴帴寮圭獥
     deviceConnectClick() {
       if (this.isDeviceConnectStatus) {
-        this.$refs.addProductDialog.proForm.pieceNumber=1
-        this.$refs.addProductDialog.proForm.pieces=1
+        this.$refs.addProductDialog.proForm.pieceNumber= this.$refs.addProductDialog.proForm.pieceNumber||1
+        this.$refs.addProductDialog.proForm.pieces= this.$refs.addProductDialog.proForm.pieces||1
         this.$forceUpdate();
         this.$refs.addProductDialog.editDialogVisible = true;
       }
@@ -803,14 +1059,119 @@
           // params.workshopGroup=Number(params.workshopGroup)
           this.isAddloading = true;
           delete form.circleTwo;
-          let finenessList = JSON.parse(
-            JSON.stringify(this.tableList.tableData)
+          let circles=[]
+          let items=[]
+          let tableData = JSON.parse(
+            JSON.stringify(this.tableData)
           );
-          for (let i in finenessList) {
-            delete finenessList[i].productId;
+          form.bucketCocoonNumber=Number(form.bucketCocoonNumber)
+          form.circle=Number(form.circle)
+          form.fallingSilkBucketOne=Number(form.fallingSilkBucketOne)
+          form.fallingSilkBucketThree=Number(form.fallingSilkBucketThree)
+          form.fallingSilkBucketTwo=Number(form.fallingSilkBucketTwo)
+          form.fallingSilkCocoonNumber=Number(form.fallingSilkCocoonNumber)
+          form.groupNumber=Number(form.groupNumber)
+          form.hourYield=Number(form.hourYield)
+          form.marketId=Number(form.marketId)
+          form.record=Number(form.record)
+          form.theorySilkAmount=Number(form.theorySilkAmount)
+          form.total=Number(form.total)
+          form.vehicleSpeed=Number(form.vehicleSpeed)
+          form.workshopId	=Number(form.workshopId)
+          delete form.isfallingSilkBucketOne
+          delete form.isfallingSilkBucketThree
+          delete form.isfallingSilkBucketTwo
+          for(let i in tableData){
+            circles.push({
+              allYield:Number(tableData[i].allYield1)||0, //浜ч噺
+              carNumber:tableData[i].carNumber,
+              circle:1,//鍥炴暟
+              oneYield:Number(tableData[i].oneYield1)||0,//	鍙颁骇
+              pieceNumber:[
+                {
+                  pieceNumber:1,
+                  value:Number(tableData[i].pieceNumber11)||0
+                },
+                {
+                  pieceNumber:2,
+                  value:Number(tableData[i].pieceNumber12)||0
+                },
+                {
+                  pieceNumber:3,
+                  value:Number(tableData[i].pieceNumber13)||0
+                },
+                {
+                  pieceNumber:4,
+                  value:Number(tableData[i].pieceNumber14)||0
+                },
+              ],
+              reelingdiscount:tableData[i].reelingdiscount1||'', //缂姌
+              // yieldRegisterId:''
+            })
+            circles.push({
+              allYield:Number(tableData[i].allYield2)||0, //浜ч噺
+              carNumber:tableData[i].carNumber,
+              circle:2,//鍥炴暟
+              pieceNumber:[
+                {
+                  pieceNumber:1,
+                  value:Number(tableData[i].pieceNumber21)||0
+                },
+                {
+                  pieceNumber:2,
+                  value:Number(tableData[i].pieceNumber22)||0
+                },
+                {
+                  pieceNumber:3,
+                  value:Number(tableData[i].pieceNumber23)||0
+                },
+                {
+                  pieceNumber:4,
+                  value:Number(tableData[i].pieceNumber24)||0
+                },
+              ],
+              oneYield:Number(tableData[i].oneYield2)||0,//	鍙颁骇
+              reelingdiscount:tableData[i].reelingdiscount2||'', //缂姌
+              // yieldRegisterId:''
+            })
+            circles.push({
+              allYield:Number(tableData[i].allYield3)||0, //浜ч噺
+              carNumber:tableData[i].carNumber,
+              circle:3,//鍥炴暟
+              oneYield:Number(tableData[i].oneYield3)||0,//	鍙颁骇
+              pieceNumber:[
+                {
+                  pieceNumber:1,
+                  value:Number(tableData[i].pieceNumber31)||0
+                },
+                {
+                  pieceNumber:2,
+                  value:Number(tableData[i].pieceNumber32)||0
+                },
+                {
+                  pieceNumber:3,
+                  value:Number(tableData[i].pieceNumber33)||0
+                },
+                {
+                  pieceNumber:4,
+                  value:Number(tableData[i].pieceNumber34)||0
+                },
+              ],
+              reelingdiscount:tableData[i].reelingdiscount3||'', //缂姌
+              // yieldRegisterId:''
+            })
+            items.push({
+              hourYield:Number(tableData[i].hourYield)||0,
+              carNumber:tableData[i].carNumber,
+              oneYield:Number(tableData[i].oneYield)||0,
+              peopleYield:Number(tableData[i].peopleYield)||0,
+              personReelingdiscount:tableData[i].personReelingdiscount||'',
+              // yieldRegisterId:''
+            })
           }
           let params = {
-            finenessList: finenessList,
+            circles: circles,
+            items:items,
             ...form,
           };
           // 缂栬緫
@@ -826,7 +1187,7 @@
                   type: "success",
                 });
                 this.$router.push({
-                  path: "/productManage/silkRegisterForm",
+                  path: "/productManage/productRegisterForm",
                 });
               }
               this.isAddloading = false;
@@ -851,6 +1212,12 @@
 <style lang="scss" scoped>
 .add-product-page {
   height: 100%;
+  position:relative;
+  ::v-deep .el-table .el-table__cell {
+    padding: 6px 0 !important;
+    height: 35px;
+    text-align: center;
+  }
   .top-view {
     margin: 20px 30px;
     height: 52px;

--
Gitblit v1.8.0