Browse Source

明细账明细 类型为库区调拨不计合计

Qukatie 1 day ago
parent
commit
b0f646c22b
1 changed files with 182 additions and 145 deletions
  1. 182 145
      src/views/tirePartsMall/inventory/detail.vue

+ 182 - 145
src/views/tirePartsMall/inventory/detail.vue

@@ -1,8 +1,21 @@
 <template>
   <basic-container>
-    <avue-crud ref="crud" :data="dataList" :option="option" v-model="form" :search.sync="search" :table-loading="loading"
-      @saveColumn="saveColumn" @resetColumn="resetColumn" @search-change="searchChange" @current-change="currentChange"
-      @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
+    <avue-crud
+      ref="crud"
+      :data="dataList"
+      :option="option"
+      v-model="form"
+      :search.sync="search"
+      :table-loading="loading"
+      @saveColumn="saveColumn"
+      @resetColumn="resetColumn"
+      @search-change="searchChange"
+      @current-change="currentChange"
+      @size-change="sizeChange"
+      @refresh-change="refreshChange"
+      @on-load="onLoad"
+      :summary-method="summaryMethod"
+    >
       <template slot="billno" slot-scope="{ row, index }">
         <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(row, index)">{{ row.billno }}</span>
       </template>
@@ -12,8 +25,9 @@
 
 <script>
 import option from "./config/detail.json";
-import LTdetail from './config/LTdetail.json'
-import {AppPartsStockDataDetails, stockDataDetails} from "@/api/basicData/inventoryAccount";
+import LTdetail from "./config/LTdetail.json";
+import { AppPartsStockDataDetails, stockDataDetails } from "@/api/basicData/inventoryAccount";
+import _ from "lodash";
 
 export default {
   name: "detail",
@@ -25,71 +39,101 @@ export default {
       page: {
         pageSize: 10,
         pagerCount: 5,
-        total: 0,
+        total: 0
       },
       search: {},
       loading: false,
-      params: null,
-    }
+      params: null
+    };
   },
   async created() {
     // this.option = option
-    console.log('打开了');
-    if (JSON.parse(localStorage.getItem('saber-tenantId')).content == 883868){
-        this.option = LTdetail;
-    }else {
-        this.option = await this.getColumnData(this.getColumnName(279), option);
+    console.log("打开了");
+    if (JSON.parse(localStorage.getItem("saber-tenantId")).content == 883868) {
+      this.option = LTdetail;
+    } else {
+      this.option = await this.getColumnData(this.getColumnName(279), option);
     }
     this.$store.commit("DOMAS_IN_DETAIL");
   },
   activated() {
     this.$store.commit("DOMAS_IN_DETAIL");
-    if (this.$route.query.type == 'JL'){
-        this.params = {
-            goodsId: this.$route.query.goodsId,
-            storageId: this.$route.query.stockId
-        }
-    }else {
-        this.params = {
-            goodsId: this.$route.query.goodsId,
-            stockId: this.$route.query.stockId,
-            dot:this.$route.query.dot
-        }
+    if (this.$route.query.type == "JL") {
+      this.params = {
+        goodsId: this.$route.query.goodsId,
+        storageId: this.$route.query.stockId
+      };
+    } else {
+      this.params = {
+        goodsId: this.$route.query.goodsId,
+        stockId: this.$route.query.stockId,
+        dot: this.$route.query.dot
+      };
     }
-      this.onLoad(this.page)
+    this.onLoad(this.page);
   },
   methods: {
+    summaryMethod({ columns, data }) {
+      const sums = [];
+      if (columns.length > 0) {
+        columns.forEach((item, index) => {
+          sums[0] = "合计";
+          // 选择要合计的参数
+          if (item.property == "addSendTotalNum" || item.property == "subSendTotalNum") {
+            let addSendTotalNumSum = 0;
+            let subSendTotalNumSum = 0;
+            this.dataList.forEach(e => {
+              if (e.bizTypeName != "库区调拨") {
+                addSendTotalNumSum = _.add(addSendTotalNumSum, Number(e.addSendTotalNum));
+                subSendTotalNumSum = _.add(subSendTotalNumSum, Number(e.subSendTotalNum));
+              }
+            });
+            // 结算金额合计
+            if (item.property == "addSendTotalNum") {
+              sums[index] = addSendTotalNumSum ? addSendTotalNumSum.toFixed(0) : "0.00";
+            }
+            // 金额合计
+            if (item.property == "subSendTotalNum") {
+              sums[index] = subSendTotalNumSum ? subSendTotalNumSum.toFixed(2) : "0.00";
+            }
+          }
+        });
+      }
+      return sums;
+    },
     onLoad(page, params) {
-      if (!this.params) return
-      params = { ...params, ...this.params }
+      if (!this.params) return;
+      params = { ...params, ...this.params };
       this.dataList.forEach(item => {
-        this.$refs.crud.toggleRowExpansion(item, false)
-      })
+        this.$refs.crud.toggleRowExpansion(item, false);
+      });
       this.loading = true;
-      if (this.$route.query.type == 'JL') {
-          AppPartsStockDataDetails(params).then(res=>{
-              console.log(res)
-              this.dataList = res.data.data ? res.data.data : [];
-              this.page.total = res.data.data.total;
-              if (this.page.total) {
-                  this.option.height = window.innerHeight - 260;
-              }
-          }).finally(() => {
-              this.loading = false;
+      if (this.$route.query.type == "JL") {
+        AppPartsStockDataDetails(params)
+          .then(res => {
+            console.log(res);
+            this.dataList = res.data.data ? res.data.data : [];
+            this.page.total = res.data.data.total;
+            if (this.page.total) {
+              this.option.height = window.innerHeight - 260;
+            }
+          })
+          .finally(() => {
+            this.loading = false;
+          });
+      } else {
+        stockDataDetails(params)
+          .then(res => {
+            console.log("res", res);
+            this.dataList = res.data.data ? res.data.data : [];
+            this.page.total = res.data.data.total;
+            if (this.page.total) {
+              this.option.height = window.innerHeight - 260;
+            }
+          })
+          .finally(() => {
+            this.loading = false;
           });
-      }else {
-          stockDataDetails(params)
-              .then(res => {
-                  console.log('res', res);
-                  this.dataList = res.data.data ? res.data.data : [];
-                  this.page.total = res.data.data.total;
-                  if (this.page.total) {
-                      this.option.height = window.innerHeight - 260;
-                  }
-              })
-              .finally(() => {
-                  this.loading = false;
-              });
       }
     },
     searchChange(params, done) {
@@ -105,16 +149,13 @@ export default {
     },
     refreshChange() {
       this.dataList.forEach(item => {
-        this.$refs.crud.toggleRowExpansion(item, false)
-      })
+        this.$refs.crud.toggleRowExpansion(item, false);
+      });
       this.page.currentPage = 1;
       this.onLoad(this.page, this.search);
     },
     async saveColumn() {
-      const inSave = await this.saveColumnData(
-        this.getColumnName(279),
-        this.option
-      );
+      const inSave = await this.saveColumnData(this.getColumnName(279), this.option);
       if (inSave) {
         this.$message.success("保存成功");
         //关闭窗口
@@ -123,10 +164,7 @@ export default {
     },
     async resetColumn() {
       this.option = option;
-      const inSave = await this.delColumnData(
-        this.getColumnName(279),
-        option
-      );
+      const inSave = await this.delColumnData(this.getColumnName(279), option);
       if (inSave) {
         this.$message.success("重置成功");
         //关闭窗口
@@ -135,91 +173,90 @@ export default {
     },
     // 跳转
     beforeOpenPage(row, index) {
-        if(row.bizTypeName == '盘点') {
-            console.log(this.$store.getters,139)
-            if (this.$store.getters.Inventory) {
-                this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
-                    confirmButtonText: "确定",
-                    type: "warning",
-                    callback: action => {
-                        console.log(action);
-                    }
-                });
-            }else {
-                this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/Inventory/index");
-                this.$router.push({
-                    path: "/tirePartsMall/salesManagement/Inventory/index",
-                    query: {
-                        orderId: row.id
-                    },
-                });
+      if (row.bizTypeName == "盘点") {
+        console.log(this.$store.getters, 139);
+        if (this.$store.getters.Inventory) {
+          this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
+            confirmButtonText: "确定",
+            type: "warning",
+            callback: action => {
+              console.log(action);
+            }
+          });
+        } else {
+          this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/Inventory/index");
+          this.$router.push({
+            path: "/tirePartsMall/salesManagement/Inventory/index",
+            query: {
+              orderId: row.id
             }
-        }else {
-            if (this.$store.getters.inboundAndOutbound) {
-                this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
-                    confirmButtonText: "确定",
-                    type: "warning",
-                    callback: action => {
-                        console.log(action);
-                    }
-                });
+          });
+        }
+      } else {
+        if (this.$store.getters.inboundAndOutbound) {
+          this.$alert("明细账已存在,请保存关闭明细账再进行操作", "温馨提示", {
+            confirmButtonText: "确定",
+            type: "warning",
+            callback: action => {
+              console.log(action);
+            }
+          });
+        } else {
+          if (row.bizTypeName == "出库") {
+            this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/outboundWorkOrder/index");
+            this.$router.push({
+              path: "/tirePartsMall/salesManagement/outboundWorkOrder/index",
+              query: {
+                id: row.id
+              }
+            });
+          } else if (row.bizTypeName == "销售") {
+            this.$router.$avueRouter.closeTag("/salesOrder/index");
+            this.$router.push({
+              path: "/salesOrder/index",
+              query: {
+                orderId: row.id
+              }
+            });
+          } else if (row.bizTypeName == "采购") {
+            this.$router.$avueRouter.closeTag("/purchaseOrder/index");
+            this.$router.push({
+              path: "/purchaseOrder/index",
+              query: {
+                orderId: row.id
+              }
+            });
+          } else if (row.bizTypeName == "调出") {
+            if (this.$store.getters.Allocateandtransfer) {
+              this.$alert("调拨明细已存在,请保存关闭明细账再进行操作", "温馨提示", {
+                confirmButtonText: "确定",
+                type: "warning",
+                callback: action => {
+                  console.log(action);
+                }
+              });
             } else {
-                if (row.bizTypeName == '出库') {
-                    this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/outboundWorkOrder/index");
-                    this.$router.push({
-                        path: "/tirePartsMall/salesManagement/outboundWorkOrder/index",
-                        query: {
-                            id: row.id
-                        },
-                    });
-                }else if (row.bizTypeName == '销售') {
-                    this.$router.$avueRouter.closeTag("/salesOrder/index");
-                    this.$router.push({
-                        path: "/salesOrder/index",
-                        query: {
-                            orderId: row.id
-                        },
-                    });
-                } else if (row.bizTypeName == '采购') {
-                    this.$router.$avueRouter.closeTag("/purchaseOrder/index");
-                    this.$router.push({
-                        path: "/purchaseOrder/index",
-                        query: {
-                            orderId: row.id
-                        },
-                    });
-                } else if (row.bizTypeName == '调出') {
-                    if (this.$store.getters.Allocateandtransfer) {
-                        this.$alert("调拨明细已存在,请保存关闭明细账再进行操作", "温馨提示", {
-                            confirmButtonText: "确定",
-                            type: "warning",
-                            callback: action => {
-                                console.log(action);
-                            }
-                        });
-                    }else {
-                        this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/outboundWorkOrderL/index");
-                        this.$router.push({
-                            path: "/tirePartsMall/salesManagement/outboundWorkOrderL/index",
-                            query: {
-                                id: row.id
-                            },
-                        });
-                    }
-                } else {
-                    this.$router.$avueRouter.closeTag("/tirePartsMall/purchasingManagement/warehouseEntryOrder/index");
-                    this.$router.push({
-                        path: "/tirePartsMall/purchasingManagement/warehouseEntryOrder/index",
-                        query: {
-                            id: row.id
-                        },
-                    });
+              this.$router.$avueRouter.closeTag("/tirePartsMall/salesManagement/outboundWorkOrderL/index");
+              this.$router.push({
+                path: "/tirePartsMall/salesManagement/outboundWorkOrderL/index",
+                query: {
+                  id: row.id
                 }
+              });
             }
+          } else {
+            this.$router.$avueRouter.closeTag("/tirePartsMall/purchasingManagement/warehouseEntryOrder/index");
+            this.$router.push({
+              path: "/tirePartsMall/purchasingManagement/warehouseEntryOrder/index",
+              query: {
+                id: row.id
+              }
+            });
+          }
         }
+      }
 
-
-      return
+      return;
       if (this.$store.getters.domSaleStatus) {
         this.$alert("销售单存在,请保存关闭销售单再进行操作", "温馨提示", {
           confirmButtonText: "确定",
@@ -234,12 +271,12 @@ export default {
           path: "/businessManagement/salesOrder/index",
           query: {
             id: row.id
-          },
+          }
         });
       }
-    },
-  },
-}
+    }
+  }
+};
 </script>
 
 <style scoped></style>