Browse Source

解决打印合计行错位

jbb 2 years ago
parent
commit
00a956bb4b
1 changed files with 207 additions and 129 deletions
  1. 207 129
      src/views/reportForms/fabric-loss-table.vue

+ 207 - 129
src/views/reportForms/fabric-loss-table.vue

@@ -212,7 +212,6 @@
           :data-source="fabricLoss.fabricCostInvoiceList"
           bordered
           :pagination="false"
-          :footer="costFooterShow"
         >
         </a-table>
       </div>
@@ -228,7 +227,6 @@
           :data-source="fabricLoss.fabricCostClothList"
           bordered
           :pagination="false"
-          :footer="clothFooterShow"
         >
           <!-- 发票号码明细  -->
           <span slot="invoiceNum" slot-scope="text">
@@ -247,7 +245,6 @@
           :data-source="fabricLoss.fabricCostClothesList"
           bordered
           :pagination="false"
-          :footer="clothesFooterShow"
         >
           <!-- 发票数量 -->
           <span slot="clInvoiceQuantity" slot-scope="text">
@@ -266,7 +263,6 @@
           :data-source="fabricLoss.fabricCostAssistList"
           bordered
           :pagination="false"
-          :footer="assistFooterShow"
         >
           <!-- 发票数量 -->
           <span slot="ingredientsInvoiceQuantity" slot-scope="text">
@@ -276,7 +272,7 @@
       </div>
 
       <!-- 费用支出 -->
-      <div class="costPay-table" style="margin:40px 0">
+      <div class="costPay-table noprint" style="margin:40px 0">
         <h6 class="table-title">费用支出</h6>
         <a-table
           :row-key="record => record.id"
@@ -300,7 +296,6 @@
           :data-source="fabricLoss.fabricAccidentList"
           bordered
           :pagination="false"
-          :footer="accidentFooterShow"
         >
           <!-- 事故单 -->
           <span slot="accidentNum" slot-scope="text">
@@ -810,6 +805,7 @@ export default {
               if (this.fabricLoss.fabricAccidentList == null){
                 this.fabricLoss.fabricAccidentList = [];
               }
+              this.calculateTotal()
             }else{
               this.fabricLoss = {fabricPoOrderList:[],fabricOMOrderList1:[],fabricOMOrderList2:[],fabricCostAssistList:[],fabricCostClothList:[],fabricCostClothesList:[],fabricCostInvoiceList:[],fabricExpensesList:[],fabricAccidentList:[]};
               this.$message.info(res.message);
@@ -819,6 +815,88 @@ export default {
         })
       }
     },
+    //计算合计行
+    calculateTotal(){
+       //计算成本发票合计
+         var imoney = 0;
+         for (let row of this.fabricLoss.fabricCostInvoiceList){
+            imoney += row.imoney*1;
+          }
+          if(this.fabricLoss.fabricCostInvoiceList.length !==0){
+            this.fabricLoss.fabricCostInvoiceList.push({
+                cvcname:'',
+                cbusType:'合计',
+                cvenAbbName:'',
+                imoney:parseFloat(imoney.toFixed(2))
+              })
+          }
+        //计算开票成本-面料合计
+         var inatSum = 0;
+         for (let row of this.fabricLoss.fabricCostClothList){
+            inatSum += row.inatSum*1;
+          }
+          if(this.fabricLoss.fabricCostClothList.length !==0){
+             this.fabricLoss.fabricCostClothList.push({
+                 index:'',
+                 csbvcode:'合计',
+                 cvenName:'',
+                 inatSum:parseFloat(inatSum.toFixed(2)),
+                 cshipTime:''
+               })
+          }
+          //计算开票成本-成衣合计
+          var isum = 0,ioriSum=0,iquantity=0,ipbvquantity=0;
+          for (let row of this.fabricLoss.fabricCostClothesList){
+            isum += row.isum*1;
+            ioriSum += row.ioriSum*1;
+            iquantity += row.iquantity*1;
+            ipbvquantity += row.ipbvquantity*1;
+          }
+          if(this.fabricLoss.fabricCostClothesList.length!==0){
+              this.fabricLoss.fabricCostClothesList.push({
+                     cpbvcode:'合计',
+                     isum: parseFloat(isum.toFixed(2)),
+                     ioriSum: parseFloat(ioriSum.toFixed(2)),
+                     iquantity: parseFloat(iquantity.toFixed(4)),
+                     ipbvquantity: parseFloat(ipbvquantity.toFixed(4)),
+
+              })
+          }
+          //开票成本-辅料合计
+          var isum = 0,ioriSum=0,iquantity=0,iquantityIn=0,iquantityInvoice=0;
+          for (let row of this.fabricLoss.fabricCostAssistList){
+            isum += row.isum*1;
+             ioriSum += row.ioriSum*1;
+             iquantity += row.iquantity*1;
+             iquantityIn += row.iquantityIn*1;
+             iquantityInvoice += row.iquantityInvoice*1;
+            }
+          if(this.fabricLoss.fabricCostAssistList.length !== 0){
+             this.fabricLoss.fabricCostAssistList.push({
+               caccount:'合计',
+               isum:parseFloat(isum.toFixed(2)),
+               ioriSum:parseFloat(ioriSum.toFixed(2)),
+               iquantity:parseFloat(iquantity.toFixed(4)),
+              iquantityIn:parseFloat(iquantityIn.toFixed(4)),
+                iquantityInvoice:parseFloat(iquantityInvoice.toFixed(4))
+            })
+          }
+
+        //事故单合计
+        var item = {
+        "cvenAbbName":"合计"
+      };
+      var ioriSum = 0
+      for (let row of this.fabricLoss.fabricAccidentList){
+          ioriSum += row.ioriSum*1       
+      }
+      if(this.fabricLoss.fabricAccidentList.length !== 0){
+        this.fabricLoss.fabricAccidentList.push({
+          cvenAbbName:"合计",
+          ioriSum:parseFloat(ioriSum.toFixed(4))
+        })
+      }
+    },
     //判断哪个列表为空
     judgeListLength(){
       var data = [
@@ -829,7 +907,7 @@ export default {
         {List:this.fabricLoss.fabricCostClothList,class:'.costInvoice-fabric-table'},
         {List:this.fabricLoss.fabricCostClothesList,class:'.costInvoice-clothes-table'},
         {List:this.fabricLoss.fabricCostAssistList,class:'.costInvoice-ingredient-table'},
-        {List:this.fabricLoss.fabricExpensesList,class:'.costPay-table'},
+        // {List:this.fabricLoss.fabricExpensesList,class:'.costPay-table'},
         {List:this.fabricLoss.fabricAccidentList,class:'.accidentBill-table'},
       ]
       data.map(item=>{
@@ -924,48 +1002,48 @@ export default {
     },
 
     //成本发票 -----合计行
-    costFooterShow(data){
-       return (
-        <a-table
-          rowKey={Math.random}
-          bordered={false}
-          pagination={false}
-          columns={this.costInvoiceColumns}
-          dataSource={this.costFooterDataSource || []}
-          showHeader={false}
-        ></a-table>
-      )
-    },
+    // costFooterShow(data){
+    //    return (
+    //     <a-table
+    //       rowKey={Math.random}
+    //       bordered={false}
+    //       pagination={false}
+    //       columns={this.costInvoiceColumns}
+    //       dataSource={this.costFooterDataSource || []}
+    //       showHeader={false}
+    //     ></a-table>
+    //   )
+    // },
     
 
 
     // 开票成本-成衣 ----合计行
-    clothesFooterShow(data) {
-      return (
-        <a-table
-          rowKey={Math.random}
-          bordered={false}
-          pagination={false}
-          columns={this.costInvoiceClothesColumns}
-          dataSource={this.clothesFooterDataSource || []}
-          showHeader={false}
-        ></a-table>
-      )
-    },
+    // clothesFooterShow(data) {
+    //   return (
+    //     <a-table
+    //       rowKey={Math.random}
+    //       bordered={false}
+    //       pagination={false}
+    //       columns={this.costInvoiceClothesColumns}
+    //       dataSource={this.clothesFooterDataSource || []}
+    //       showHeader={false}
+    //     ></a-table>
+    //   )
+    // },
 
     // 开票成本-辅料 ----合计行
-    assistFooterShow(data) {
-      return (
-        <a-table
-          rowKey={Math.random}
-          bordered={false}
-          pagination={false}
-          columns={this.costInvoiceIngredientColumns}
-          dataSource={this.assistFooterDataSource || []}
-          showHeader={false}
-        ></a-table>
-      )
-    },
+    // assistFooterShow(data) {
+    //   return (
+    //     <a-table
+    //       rowKey={Math.random}
+    //       bordered={false}
+    //       pagination={false}
+    //       columns={this.costInvoiceIngredientColumns}
+    //       dataSource={this.assistFooterDataSource || []}
+    //       showHeader={false}
+    //     ></a-table>
+    //   )
+    // },
     //费用支出 ----合计行
     costPayFooterShow(){
        return (
@@ -980,18 +1058,18 @@ export default {
       )
     },
     //事故单 -----合计
-    accidentFooterShow(){
-      return (
-        <a-table
-          rowKey={Math.random}
-          bordered={false}
-          pagination={false}
-          columns={this.accidentListColumns}
-          dataSource={this.accidentFooterDataSource || []}
-          showHeader={false}
-        ></a-table>
-      )
-    },
+    // accidentFooterShow(){
+    //   return (
+    //     <a-table
+    //       rowKey={Math.random}
+    //       bordered={false}
+    //       pagination={false}
+    //       columns={this.accidentListColumns}
+    //       dataSource={this.accidentFooterDataSource || []}
+    //       showHeader={false}
+    //     ></a-table>
+    //   )
+    // },
     // 开票成本-面料 ----合计行
     clothFooterShow(data) {
       return (
@@ -1117,73 +1195,73 @@ export default {
   // },
   // 构建合计数据 --合计
   computed: {
-    costFooterDataSource(){
-       //成本发票 合计
-       var item = {
-        "cbusType":"合计"
-      };
-      var imoney = 0;
-      for (let row of this.fabricLoss.fabricCostInvoiceList){
-        imoney += row.imoney*1;
-      }
+    // costFooterDataSource(){
+    //    //成本发票 合计
+    //    var item = {
+    //     "cbusType":"合计"
+    //   };
+    //   var imoney = 0;
+    //   for (let row of this.fabricLoss.fabricCostInvoiceList){
+    //     imoney += row.imoney*1;
+    //   }
       
-      item.imoney= parseFloat(imoney.toFixed(2));
-      return [item];
-    },
+    //   item.imoney= parseFloat(imoney.toFixed(2));
+    //   return [item];
+    // },
    
-    clothFooterDataSource() {
-      // 开票成本-面料 合计
-      var item = {
-        "csbvcode":"合计"
-      };
-      var inatSum = 0;
-      for (let row of this.fabricLoss.fabricCostClothList){
-        inatSum += row.inatSum*1;
-      }
+    // clothFooterDataSource() {
+    //   // 开票成本-面料 合计
+    //   var item = {
+    //     "csbvcode":"合计"
+    //   };
+    //   var inatSum = 0;
+    //   for (let row of this.fabricLoss.fabricCostClothList){
+    //     inatSum += row.inatSum*1;
+    //   }
       
-      item.inatSum= parseFloat(inatSum.toFixed(2));
-      return [item];
-    },
-    clothesFooterDataSource() {
-      // 开票成本-衬衣 合计
-      var item = {
-        "cpbvcode":"合计"
-      };
-      var isum = 0,ioriSum=0,iquantity=0,ipbvquantity=0;
-      for (let row of this.fabricLoss.fabricCostClothesList){
-        isum += row.isum*1;
-        ioriSum += row.ioriSum*1;
-        iquantity += row.iquantity*1;
-        ipbvquantity += row.ipbvquantity*1;
-      }
+    //   item.inatSum= parseFloat(inatSum.toFixed(2));
+    //   return [item];
+    // },
+    // clothesFooterDataSource() {
+    //   // 开票成本-衬衣 合计
+    //   var item = {
+    //     "cpbvcode":"合计"
+    //   };
+    //   var isum = 0,ioriSum=0,iquantity=0,ipbvquantity=0;
+    //   for (let row of this.fabricLoss.fabricCostClothesList){
+    //     isum += row.isum*1;
+    //     ioriSum += row.ioriSum*1;
+    //     iquantity += row.iquantity*1;
+    //     ipbvquantity += row.ipbvquantity*1;
+    //   }
       
-      item.isum= parseFloat(isum.toFixed(2));
-      item.ioriSum = parseFloat(ioriSum.toFixed(2));
-      item.iquantity = parseFloat(iquantity.toFixed(4));
-      item.ipbvquantity = parseFloat(ipbvquantity.toFixed(4));
-      return [item];
-    },
-    assistFooterDataSource() {
-      // 开票成本-辅料 合计
-      var item = {
-        "caccount":"合计"
-      };
-      var isum = 0,ioriSum=0,iquantity=0,iquantityIn=0,iquantityInvoice=0;
-      for (let row of this.fabricLoss.fabricCostAssistList){
-        isum += row.isum*1;
-        ioriSum += row.ioriSum*1;
-        iquantity += row.iquantity*1;
-        iquantityIn += row.iquantityIn*1;
-        iquantityInvoice += row.iquantityInvoice*1;
-      }
+    //   item.isum= parseFloat(isum.toFixed(2));
+    //   item.ioriSum = parseFloat(ioriSum.toFixed(2));
+    //   item.iquantity = parseFloat(iquantity.toFixed(4));
+    //   item.ipbvquantity = parseFloat(ipbvquantity.toFixed(4));
+    //   return [item];
+    // },
+    // assistFooterDataSource() {
+    //   // 开票成本-辅料 合计
+    //   var item = {
+    //     "caccount":"合计"
+    //   };
+    //   var isum = 0,ioriSum=0,iquantity=0,iquantityIn=0,iquantityInvoice=0;
+    //   for (let row of this.fabricLoss.fabricCostAssistList){
+    //     isum += row.isum*1;
+    //     ioriSum += row.ioriSum*1;
+    //     iquantity += row.iquantity*1;
+    //     iquantityIn += row.iquantityIn*1;
+    //     iquantityInvoice += row.iquantityInvoice*1;
+    //   }
       
-      item.isum= parseFloat(isum.toFixed(2));
-      item.ioriSum = parseFloat(ioriSum.toFixed(2));
-      item.iquantity = parseFloat(iquantity.toFixed(4));
-      item.iquantityIn = parseFloat(iquantityIn.toFixed(4));
-      item.iquantityInvoice = parseFloat(iquantityInvoice.toFixed(4));
-      return [item];
-    },
+    //   item.isum= parseFloat(isum.toFixed(2));
+    //   item.ioriSum = parseFloat(ioriSum.toFixed(2));
+    //   item.iquantity = parseFloat(iquantity.toFixed(4));
+    //   item.iquantityIn = parseFloat(iquantityIn.toFixed(4));
+    //   item.iquantityInvoice = parseFloat(iquantityInvoice.toFixed(4));
+    //   return [item];
+    // },
     costPayFooterDataSource(){
       //费用支出 合计
        var item = {
@@ -1203,18 +1281,18 @@ export default {
       item.imoney = parseFloat(imoney.toFixed(4));
       return [item];
     },
-    accidentFooterDataSource(){
-      //费用支出 合计
-       var item = {
-        "cvenAbbName":"合计"
-      };
-      var ioriSum = 0
-      for (let row of this.fabricLoss.fabricAccidentList){
-          ioriSum += row.ioriSum*1       
-      }
-      item.ioriSum = parseFloat(ioriSum.toFixed(4));
-      return [item];
-    }
+    // accidentFooterDataSource(){
+    //   //事故单 合计
+    //    var item = {
+    //     "cvenAbbName":"合计"
+    //   };
+    //   var ioriSum = 0
+    //   for (let row of this.fabricLoss.fabricAccidentList){
+    //       ioriSum += row.ioriSum*1       
+    //   }
+    //   item.ioriSum = parseFloat(ioriSum.toFixed(4));
+    //   return [item];
+    // }
   }
 }
 </script>