阿赫 7 months ago
parent
commit
f59a993ecd

+ 24 - 5
zkqy-custom-business/src/main/resources/mapper/business/ProductInventoryMapper.xml

@@ -258,14 +258,33 @@
         where del_flag = '0' and qr_code = #{qrCode}
     </select>
 
+<!--    根据产品、规格、色泽查询库存数量重量-->
     <select id="selectProductInventoryByLotNumAndProductId" resultType="com.zkqy.business.domain.ProductInventory">
-        select sum(total_box_num) as totalBoxNum,sum(total_suttle) as totalSuttle from {DBNAME}.product_inventory
-        where del_flag = '0' and del_flag = '0'
+
+        SELECT
+        sum( total_box_num ) AS totalBoxNum,
+        sum( total_suttle ) AS totalSuttle
+        FROM
+        {DBNAME}.product_inventory as a
+        LEFT JOIN
+        (
+        SELECT DISTINCT
+        b.materiel_code,
+        CONCAT( b.materie_encoding, b.materie_color_number ) AS productColour,
+        c.colours
+        FROM
+        {DBNAME}.materiel AS b
+        LEFT JOIN {DBNAME}.sale_products AS c ON c.colour_number = b.materiel_code
+        AND c.del_flag = 0
+        WHERE
+        c.colours IS NOT NULL
+        ) AS bb ON a.product_colour = bb.productColour
+        WHERE a.del_flag = '0'
         <if test="lotNum != null and lotNum != '' ">and lot_num = #{lotNum}</if>
-        <if test="productId != null">and product_id = #{productId}</if>
-        <if test="productColour != null and productColour != ''">and product_colour LIKE concat('%', #{productColour},
+        <if test="productId != null">and a.product_id = #{productId}</if>
+        <if test="productColour != null and productColour != ''">and bb.colours LIKE concat('%', #{productColour},
             '%')</if>
-        <if test="inventoryType != null and inventoryType != ''">and inventory_type = #{inventoryType}</if>
+        <if test="inventoryType != null and inventoryType != ''">and a.inventory_type = #{inventoryType}</if>
     </select>
 
     <select id="oldselectProductInventoryByLotNumAndProductId" resultType="com.zkqy.business.domain.ProductInventory">

+ 126 - 46
zkqy-ui/src/views/orderMange/index.vue

@@ -582,6 +582,17 @@
                 </template>
               </el-table-column>
 
+              <el-table-column prop="inventoryBoxNum" label="库存箱数">
+                <template slot-scope="scope">
+                  {{ scope.row.inventoryBoxNum }}
+                </template>
+              </el-table-column>
+              <el-table-column prop="inventoryWeight" label="库存重量/kg">
+                <template slot-scope="scope">
+                  {{ scope.row.inventoryWeight }}
+                </template>
+              </el-table-column>
+
               <el-table-column prop="remark" label="备注">
                 <template slot-scope="scope">
                   <el-input
@@ -872,7 +883,7 @@ import {
   printOutsourceOrder,
   productColourList,
 } from "@/api/tablelist/commonTable";
-import { updateOrder } from "@/api/system/retailMange.js";
+import {getProductInventory, updateOrder} from "@/api/system/retailMange.js";
 import { listData } from "@/api/system/tenant/data";
 import { getToken } from "@/utils/auth";
 import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
@@ -975,6 +986,8 @@ export default {
         colours: "", //色号
         remark: "", //备注
         level: "", //等级
+        inventoryBoxNum: "", //库存箱数
+        inventoryWeight: "", //库存重量
         // 工艺表
         craftGrid: "", //网络
         craftOil: "", //油剂
@@ -1217,14 +1230,70 @@ export default {
       this.outStockShow = false;
       this.getList(this.queryParams);
     },
+    // 更新库存箱数和重量
+    async updateStorage(row) {
+      // console.log("查询库存箱数和重量")
+      let {
+        productNo,
+        productType,
+        lotNumber,
+        productName,
+        productSpecifications,
+        colours,
+        specificationsList,
+      } = row;
+
+      let productColour = "";
+      let targetColor = this.colourNumberOptions.find((item) => {
+        return item.colour == colours;
+      });
+      let productId = "";
+      if (specificationsList && specificationsList.length > 0) {
+        let targetItem = specificationsList.find(
+          (item) => item.productSpecifications == productSpecifications
+        );
+        productId = targetItem.id;
+      }
+      if (targetColor) {
+        productColour =
+          targetColor.materieEncoding + "" + targetColor.materieColorNumber;
+      }
+      productColour =colours;
+      let payload = {
+        productId,
+        productType,
+        lotNum: lotNumber,
+        productName,
+        productSpecifications,
+        productColour,
+      };
+      if (
+        !lotNumber &&
+        !productId &&
+        !productType &&
+        !productName &&
+        !productSpecifications &&
+        !productColour
+      )
+        return;
+      let res = await getProductInventory(payload);
+      if ((res.code = 200)) {
+        // console.log(res);
+        row.inventoryWeight = res.data.inventoryWeight || 0;
+        row.inventoryBoxNum = res.data.inventoryBoxNum || 0;
+      } else {
+        // console.log(res);
+      }
+    },
     // 规格变化回调
     handleSpecificationsChange(row) {
+      this.updateStorage(row);
       let { productSpecifications, specificationsList } = row;
       if (productSpecifications) {
         let targetItem = specificationsList.find(
           (item) => item.productSpecifications == productSpecifications
         );
-        console.log(targetItem);
+        // console.log(targetItem);
         row.productNo = targetItem?.productNo;
         row.productType = targetItem?.productType;
       } else {
@@ -1235,6 +1304,7 @@ export default {
     // 新的产品改变回调
     async newProductChange(productName, row) {
       // 发请求获取对应的规格数据
+      this.updateStorage(row);
       if (!productName) {
         row.specificationsList = [];
         (row.productNo = ""), (row.productType = "");
@@ -1252,7 +1322,7 @@ export default {
       });
       if (res.code == 200) {
         row.specificationsList = res.data;
-        console.log(row.specificationsList);
+        // console.log(row.specificationsList);
         let defaultItem = row.specificationsList.find(
           (item) => item.isDefaultSpecifications
         );
@@ -1269,10 +1339,11 @@ export default {
       } else {
         row.specificationsList = [];
       }
+
     },
     // 自定义筛选方法
     mySelectFilter(value, row) {
-      console.log(value);
+      // console.log(value);
       // row.productNo = value;
       if (value) {
         let target = [];
@@ -1280,7 +1351,7 @@ export default {
         target = this.allProductionOptions.filter((item) =>
           item.productName.includes(value)
         );
-        console.log(target);
+        // console.log(target);
         this.productionOptions = target;
         // if (target.length) {
         //   this.productionOptions = target;
@@ -1322,7 +1393,7 @@ export default {
     },
     // 出库单回调
     async myPrintOutBoundHandler(row, data) {
-      console.log("row", row);
+      // console.log("row", row);
       this.oldInventoryState = row.oldInventoryState;
       this.currentRow = row;
       this.outBoundShow = true;
@@ -1342,7 +1413,7 @@ export default {
       } else {
         res = await this.$refs.oldOutBoundRef.getPrintData();
       }
-      console.log(res);
+      // console.log(res);
       if (res.flag) {
         try {
           if (this.oldInventoryState != 2) {
@@ -1393,7 +1464,7 @@ export default {
     },
     // 产品名失焦
     handleProductBlur(productNo, row) {
-      console.log("blur", productNo);
+      // console.log("blur", productNo);
       // if (!productNo) {
       //   this.productionOptions = this.allProductionOptions.slice(0, 500);
       //   row.productType = "";
@@ -1401,7 +1472,7 @@ export default {
     },
     // 产品名称改变
     handleProductChange(productNo, row) {
-      console.log(productNo);
+      // console.log(productNo);
       if (!productNo) {
         this.productionOptions = this.allProductionOptions.slice(0, 500);
         row.productType = "";
@@ -1484,7 +1555,7 @@ export default {
     // 自定义的小计计算方法
     getSummaries(param) {
       const { columns, data } = param;
-      console.log(columns, data);
+      // console.log(columns, data);
       const sums = [];
       columns.forEach((column, index) => {
         if (index === 0) {
@@ -1499,7 +1570,9 @@ export default {
           index === 4 ||
           index === 8 ||
           index === 9 ||
-          index === 10
+          index === 10 ||
+          index === 11 ||
+          index === 12
         ) {
           sums[index] = "";
         } else if (!values.every((value) => isNaN(value))) {
@@ -1513,7 +1586,7 @@ export default {
               }
             }, 0)
             ?.toFixed(2);
-          if (index == 6) {
+          if (index == 7) {
             this.totalMoney = sums[index];
           }
         } else {
@@ -1546,21 +1619,24 @@ export default {
         remark: "", //备注
         specificationsList: [],
         productSpecifications: "", //型号
+
+        inventoryBoxNum: "", //库存箱数
+        inventoryWeight: "", //库存重量
       });
       // 添加校验规则
       this.initTableValidate();
     },
     // 自定义校验规则
     validateTableField(rule, value, callback) {
-      console.log("校验规则", rule, value);
+      // console.log("校验规则", rule, value);
       let { message, field } = rule;
       let index = field.split("-")[1],
         fieldName = field.split("-")[0];
-      console.log(
-        index,
-        fieldName,
-        this.productionTableData[Number(index)][fieldName]
-      );
+      // console.log(
+      //   index,
+      //   fieldName,
+      //   this.productionTableData[Number(index)][fieldName]
+      // );
       if (
         !this.productionTableData[Number(index)][fieldName] &&
         this.productionTableData[Number(index)][fieldName] !== 0 &&
@@ -1616,7 +1692,7 @@ export default {
           },
         ];
       }
-      console.log(this.rules);
+      // console.log(this.rules);
     },
     // 客户名称改变回调
     customChangeHandler(val) {
@@ -1669,9 +1745,9 @@ export default {
           throw Error("获取下拉框数据失败");
         }
         let proRes = await getSaleOrderProductionListDistinct();
-        console.log("proRes", proRes);
+        // console.log("proRes", proRes);
         if (proRes.code == 200) {
-          console.log(proRes.data);
+          // console.log(proRes.data);
           // let { production, customer } = proRes.data.resultMap;
           // this.allProductionOptions = proRes.data || [];
           // this.productionOptions =
@@ -1705,7 +1781,7 @@ export default {
         // let res = await queryMaterielList();
         let res = await productColourList({ isEnablePaging: false });
         if (res.code == 200) {
-          console.log(res.data);
+          // console.log(res.data);
           // let { materiel } = res.data;
           this.colourNumberOptions = res.rows || [];
         } else {
@@ -1728,7 +1804,7 @@ export default {
         ];
         let res = await queryDropDownBoxData(payLoad);
         if (res.code == 200) {
-          console.log(res.data.resultMap);
+          // console.log(res.data.resultMap);
           let { materiel } = res.data.resultMap;
           this.sliceTypeOptions = materiel || [];
         } else {
@@ -1742,7 +1818,7 @@ export default {
         let res = await getOptionLsit();
         if (res.code == 200) {
           this.levelOptions = res.data.level;
-          console.log("----------------------",res.data.level)
+          // console.log("----------------------",res.data.level)
         } else {
           this.$message.error("网络异常!");
         }
@@ -1773,7 +1849,7 @@ export default {
           });
           // 获取操作列的按钮数据
           this.excuteBtnArr = res.data.resultMap.button;
-          console.log(this.excuteBtnArr, "excuteBtnArr");
+          // console.log(this.excuteBtnArr, "excuteBtnArr");
           // if (this.excuteBtnArr.length) {
           this.excuteBtnArr[0].children.push(
             {
@@ -1875,7 +1951,7 @@ export default {
           this.columns = this.columnsHandler(
             JSON.parse(this.templateInfo.template.dtColumnName)
           );
-          console.log(this.columns, "000");
+          // console.log(this.columns, "000");
         })
         .finally((fes) => {
           if (this.templateInfo == {}) return;
@@ -1931,7 +2007,7 @@ export default {
             //   this.tableList = this.setFieldStyleData(this.tableList);
             // });
             this.tableList = await this.setFieldStyleData(tempTableList);
-            console.log(this.tableList);
+            // console.log(this.tableList);
             this.total = res.total;
             this.$nextTick(() => {
               this.$refs.tableRef?.clearSelection();
@@ -1952,7 +2028,7 @@ export default {
     },
     // 校验定金
     validateEarnestMoney(rule, value, callback) {
-      console.log(value);
+      // console.log(value);
       if (this.formData.salePayType == "1") {
         if (value == "" || value == null || value == undefined) {
           callback(new Error("请输入定金金额"));
@@ -1965,7 +2041,7 @@ export default {
     },
     // 校验订单号是否有效
     async validateOrderNo(rule, value, callback) {
-      console.log(value);
+      // console.log(value);
       // let saleNo = this.formData.orderNo;
       // 检验订单号合法
       let checkNoPayload = {
@@ -2122,6 +2198,7 @@ export default {
             commMap: {},
             btnParametersMap: {},
           };
+         // console.log("===========================",this.productionTableData);return;
           this.productionTableData.forEach((item) => {
             item.saleOrderNo = saleNo;
             item.lotNumber = lotNumber;
@@ -2146,6 +2223,8 @@ export default {
             delete item.specificationsList;
             delete item.productSpecifications;
             delete item.productType;
+            delete item.inventoryBoxNum;
+            delete item.inventoryWeight;
             const matchedOption = this.colourNumberOptions.find(
               (option) => option.colour === item.colours
             );
@@ -2158,7 +2237,7 @@ export default {
           // this.productionTableData.forEach((item) => {
           //   delete item.productType; //删除产品类型
           // });
-          console.log(this.productionTableData);
+          //console.log("===========================",this.productionTableData);return;
           // return;
           let productData = {
             //货品表新增数据
@@ -2202,7 +2281,7 @@ export default {
             if (productData.addListMap.length) {
               addProductRes = await addTableData(productData);
             }
-            console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
+            // console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
             if (
               delRes?.code === 200 &&
               updateSaleRes?.code === 200 &&
@@ -2254,7 +2333,7 @@ export default {
     },
     // 审计   编辑回调
     async handleEdit(index, row) {
-      console.log(row);
+      // console.log(row);
       let { saleOrderSaleNo } = row;
       try {
         let payLoad = [
@@ -2438,7 +2517,7 @@ export default {
     // 处理列表信息
     columnsHandler(columns) {
       let resArr = [];
-      console.log(columns, 111);
+      // console.log(columns, 111);
       columns.forEach((item) => {
         for (const key in item) {
           let tempObj = {};
@@ -2447,7 +2526,7 @@ export default {
           resArr.push(tempObj);
         }
       });
-      console.log(resArr, 222);
+      // console.log(resArr, 222);
       return resArr;
     },
     // 取消按钮
@@ -2484,7 +2563,7 @@ export default {
       // );
       this.selection = selection;
       this.myDelIds = selection.map((item) => item.saleOrderId);
-      console.log(this.myDelIds);
+      // console.log(this.myDelIds);
       this.ids = selection.map((item) => item.saleOrderSaleNo);
       this.single = selection.length != 1;
       this.multiple = !selection.length;
@@ -2669,7 +2748,7 @@ export default {
         // });
       } catch (error) {
         this.$message.error("网络异常,请稍后再试");
-        console.log(error);
+        // console.log(error);
       }
       return;
       // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
@@ -3130,7 +3209,7 @@ export default {
 
     // 设置表格字段样式
     async setFieldStyleData(tableList) {
-      console.log(JSON.parse(JSON.stringify(tableList)));
+      // console.log(JSON.parse(JSON.stringify(tableList)));
       let fieldConditionList = this.styleList.filter(
         (item) => item.styleType == 1 || item.styleType == 2
       );
@@ -3252,6 +3331,7 @@ export default {
     },
     // 色号改变回调
     colourNumberChangeHandler(row) {
+      this.updateStorage(row);
       let { colours } = row;
       if (colours) {
         let target = this.colourNumberOptions.find(
@@ -3313,7 +3393,7 @@ export default {
       ];
       let res = await queryDropDownBoxData(payLoad);
       if (res.code == 200) {
-        console.log(res);
+        // console.log(res);
         let { sale_craft, sale_order, sale_products } = res.data.resultMap;
         let {
           //订单表数据
@@ -3426,7 +3506,7 @@ export default {
           let productData = this.allProductionOptions.find(
             (pro) => pro.productNo == item.productNo
           );
-          console.log(item.productNo, productData, this.allProductionOptions);
+          // console.log(item.productNo, productData, this.allProductionOptions);
           item.sliceTypeLabel =
             this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
               ?.materielName || "";
@@ -3565,13 +3645,13 @@ export default {
     },
     // 自定义删除按钮
     async myDeleteHandler(row) {
-      console.log(row);
+      // console.log(row);
       let stateArr = ["2", "3", "4", "5", "6", "8", "9"];
       let isDeleteValidate = this.selection.some((item) => {
         return stateArr.includes(item.status);
       });
-      console.log(this.selection);
-      console.log(isDeleteValidate);
+      // console.log(this.selection);
+      // console.log(isDeleteValidate);
       if (isDeleteValidate) {
         this.$message.error("仅允许删除订单状态为'未提交'或'未通过'的订单");
         return;
@@ -3582,7 +3662,7 @@ export default {
         type: "warning",
       });
       let payLoad = row.saleOrderId ? [row.saleOrderId] : this.myDelIds;
-      console.log(payLoad);
+      // console.log(payLoad);
       try {
         let res = await delOrder(payLoad);
         if (res.code === 200) {
@@ -3626,7 +3706,7 @@ export default {
       let { btnType, btnParams, btnFormType } = btnData;
       this.currentBtnData = btnData;
       this.currentRow = JSON.parse(JSON.stringify(row));
-      console.log("btnData", btnType, btnData, row);
+      // console.log("btnData", btnType, btnData, row);
       // 无表单
       if (btnFormType == "noNeed") {
         this.noNeedHandler(btnData, row);
@@ -3730,7 +3810,7 @@ export default {
             commMap: {},
             btnParametersMap: {},
           };
-          console.log(this.currentBtnData, this.currentRow);
+          // console.log(this.currentBtnData, this.currentRow);
           if (this.currentBtnData.btnParams) {
             let conditionData =
               JSON.parse(this.currentBtnData.btnParams).conditionData || [];
@@ -3762,7 +3842,7 @@ export default {
               this.$message.error("网络异常,请稍后再试");
             }
           } catch (error) {
-            console.log(error);
+            // console.log(error);
             this.$message.error("网络异常,请稍后再试");
           }
         })