浏览代码

销售出库添加出库历史详情功能

lph 10 月之前
父节点
当前提交
05ea03dff4
共有 1 个文件被更改,包括 221 次插入0 次删除
  1. 221 0
      zkqy-ui/src/views/orderMange/outStock/index.vue

+ 221 - 0
zkqy-ui/src/views/orderMange/outStock/index.vue

@@ -212,6 +212,9 @@
                       >出库
                     </el-button>
                     <el-button @click="refreshHandler">刷新</el-button>
+                    <el-button type="info" @click="outStockDetailHandler"
+                      >出库详情</el-button
+                    >
                   </el-form-item>
                 </el-col>
               </el-form>
@@ -282,6 +285,109 @@
         </el-col>
       </el-row>
     </div>
+    <el-dialog title="出库详情" :visible.sync="detailVisible" width="1000px">
+      <el-descriptions title="通知单信息">
+        <el-descriptions-item label="客户名称">{{
+          currentSaleOrder.customerName
+        }}</el-descriptions-item>
+        <el-descriptions-item label="通知单号">{{
+          currentSaleOrder.noticeNumber
+        }}</el-descriptions-item>
+        <el-descriptions-item label="开单日期">{{
+          currentSaleOrder.noticeDate
+        }}</el-descriptions-item>
+      </el-descriptions>
+      <el-tabs v-model="activeName">
+        <el-tab-pane
+          v-for="item in batchOptions"
+          :key="item.value"
+          :label="item.label"
+          :name="item.value"
+        >
+          <el-table
+            ref="tableRef"
+            :data="batchMap[activeName].list"
+            border
+            stripe
+            row-key="productNo"
+            :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
+            @expand-change="getDetail"
+          >
+            <el-table-column type="expand">
+              <template slot-scope="props">
+                <el-table v-if="load" :data="props.row.children" border stripe>
+                  <el-table-column type="index" width="50" />
+                  <el-table-column
+                    v-for="col in columns"
+                    :key="col.prop"
+                    :prop="col.prop"
+                    :label="col.label"
+                  >
+                  </el-table-column>
+                  <el-table-column label="操作">
+                    <template slot-scope="scope">
+                      <el-button
+                        v-show="props.row.batchState == 1"
+                        size="mini"
+                        type="danger"
+                        @click="
+                          handleDelete(scope.$index, scope.row, props.row)
+                        "
+                        >删除</el-button
+                      >
+                    </template>
+                  </el-table-column>
+                </el-table>
+              </template>
+            </el-table-column>
+            <el-table-column type="index" width="50" />
+            <el-table-column label="名称" prop="productName"></el-table-column>
+            <el-table-column
+              label="规格"
+              prop="productSpecifications"
+            ></el-table-column>
+            <el-table-column label="批号" prop="lotNumber"></el-table-column>
+            <el-table-column label="等级" prop="productLevel"></el-table-column>
+            <el-table-column label="单位" prop="unit"> </el-table-column>
+            <el-table-column
+              label="数量"
+              prop="productNumber"
+            ></el-table-column>
+            <el-table-column
+              label="单价"
+              prop="productUnitPrice"
+            ></el-table-column>
+            <el-table-column
+              label="金额"
+              prop="productAmounts"
+            ></el-table-column>
+            <el-table-column label="批次状态" prop="batchState">
+              <template slot-scope="scope">
+                {{ scope.row.batchState == 1 ? "撤销登账" : "正常" }}
+              </template>
+            </el-table-column>
+            <el-table-column label="操作">
+              <template slot-scope="scope">
+                <el-button
+                  v-show="scope.row.batchState == 1"
+                  size="mini"
+                  type="danger"
+                  @click="handleReAcount(scope.row)"
+                  >重新登账</el-button
+                >
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-tab-pane>
+      </el-tabs>
+
+      <template #footer>
+        <span>
+          <el-button @click="detailVisible = false">关闭</el-button>
+          <!-- <el-button type="primary" @click="">确认</el-button> -->
+        </span>
+      </template>
+    </el-dialog>
   </el-card>
 </template>
 
@@ -294,6 +400,8 @@ import {
   printOutsourceOrderList,
 } from "@/api/tablelist/commonTable";
 import { mapState } from "vuex";
+import { outboundDetails } from "@/api/system/retailMange.js";
+import { removeErrorOutboundRecord } from "@/api/system/ProductWarehousingRecord";
 
 export default {
   name: "OutStock",
@@ -302,6 +410,14 @@ export default {
   components: {},
   data() {
     return {
+      // 详情弹窗数据  start
+      load: true,
+      currentSaleOrder: {}, //当前订单数据
+      detailVisible: false,
+      batchOptions: [],
+      batchMap: {},
+      activeName: "0",
+      // 详情弹窗数据  end
       spanArr: [], // 用于记录每个 productCode 的跨行信息
       loading: false,
       currentIndex: "",
@@ -347,9 +463,112 @@ export default {
       batchList: [], //批次数据
       rightProductInfoList: [],
       allSaleProductInfoList: [],
+      columns: [
+        { prop: "productName", label: "品名" },
+        { prop: "productSpecifications", label: "规格" },
+        { prop: "productColor", label: "颜色" },
+        { prop: "lotNum", label: "批号" },
+        { prop: "levels", label: "等级" },
+        { prop: "grossWeight", label: "毛重" },
+        { prop: "suttle", label: "净重" },
+        { prop: "qrCode", label: "码单号" },
+        { prop: "boxNum", label: "箱号" },
+      ],
     };
   },
   methods: {
+    //删除回滚对应产品的库存
+    handleDelete(index, row, prop) {
+      this.$confirm(
+        "是否删除名称为 “" + row.productName + "” 出库明细数据",
+        "提示",
+        { type: "warning" }
+      ).then(() => {
+        removeErrorOutboundRecord(row.id).then((res) => {
+          if (res.code == 200) {
+            this.$message.success("删除成功");
+            this.getDetail(prop);
+            // this.load = false;
+            // setTimeout(() => {
+            //   console.log("强制更新");
+            //   this.$forceUpdate();
+            //   this.load = true;
+            // }, 1000);
+          } else {
+            this.$message.error("删除失败");
+            throw Error("删除失败");
+          }
+        });
+      });
+      //出库
+      console.log("删除出库产品、回滚库存", row);
+    },
+    // 获取详情回调
+    async getDetail(tree) {
+      console.log(tree);
+      let res = await outboundDetails({
+        saleOrderNo: tree.saleNo,
+        productNo: tree.productNo,
+        isEnablePaging: false,
+      });
+      if (res.code == 200) {
+        tree.children = res.rows;
+      } else {
+        tree.children = [];
+        this.$message.error(res.msg);
+      }
+    },
+    // 初始化批次数据
+    initPatchData(list) {
+      this.activeName = "0";
+
+      this.batchMap = {
+        0: {
+          value: "0",
+          label: "当前批",
+          list: [],
+        },
+      };
+      list.forEach((item) => {
+        item.children = [];
+        item.hasChildren = true;
+        let productAmounts = 0;
+        if (Number(item.productUnitPrice) && Number(item.productNumber)) {
+          productAmounts = (
+            Number(item.productNumber) * Number(item.productUnitPrice)
+          ).toFixed(2);
+        }
+        item.productAmounts = productAmounts;
+        if (item.batchNumber) {
+          let temp = this.batchMap[item.batchNumber];
+          if (temp) {
+            temp.list.push(item);
+          } else {
+            this.batchMap[item.batchNumber] = {
+              value: item.batchNumber,
+              label: item.batchNumber + "批",
+              list: [item],
+            };
+          }
+        } else {
+          this.batchOptions[0].list.push(item);
+        }
+      });
+      this.batchOptions = Object.values(this.batchMap);
+    },
+    // 获取出库详情回调
+    async outStockDetailHandler() {
+      let lotRes = await printOutsourceOrderList({
+        saleNo: this.currentSaleOrder.saleOrderNo,
+      });
+      console.log("lotRes", lotRes);
+      if (lotRes.code == 200) {
+        this.initPatchData(lotRes.data);
+        this.$nextTick(() => {
+          this.detailVisible = true;
+        });
+      }
+    },
     // 批次改变
     batchChangeHandler(value) {
       if (value === "all") {
@@ -550,6 +769,7 @@ export default {
           this.total = res.total;
           this.$nextTick(() => {
             this.$refs.leftTableDataRef.setCurrentRow(this.leftTableData[0]);
+            this.currentSaleOrder = this.leftTableData[0];
           });
           if (this.leftTableData.length > 0) {
             this.currentIndex = 0;
@@ -579,6 +799,7 @@ export default {
         id = this.leftTableData[this.currentIndex].id;
         customerName = this.leftTableData[this.currentIndex].customerName;
         saleNo = this.leftTableData[this.currentIndex].saleOrderNo;
+        this.currentSaleOrder = this.leftTableData[this.currentIndex];
       }
       if (!id) {
         //重置表单数据