yusheng 2 weeks ago
parent
commit
49aebe1bba
5 changed files with 470 additions and 520 deletions
  1. 1 2
      package-lock.json
  2. 2 2
      package.json
  3. 128 177
      src/views/warehouseManagement/stockManagement/add.vue
  4. 1 1
      vue.config.js
  5. 338 338
      yarn.lock

+ 1 - 2
package-lock.json

@@ -6674,8 +6674,7 @@
     "node_modules/file-saver": {
       "version": "2.0.5",
       "resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
-      "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA==",
-      "license": "MIT"
+      "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
     },
     "node_modules/fill-range": {
       "version": "7.0.1",

+ 2 - 2
package.json

@@ -30,6 +30,7 @@
     "el-table-infinite-scroll": "^2.0.2",
     "ele-admin": "^1.11.2",
     "element-ui": "2.15.7",
+    "file-saver": "^2.0.5",
     "github-markdown-css": "^5.1.0",
     "highlight.js": "^9.18.5",
     "jsbarcode": "^3.11.6",
@@ -52,8 +53,7 @@
     "vuex-persistedstate": "^4.1.0",
     "xgplayer-vue": "^1.1.5",
     "xlsx": "^0.14.1",
-    "xml-js": "1.6.11",
-    "file-saver": "^2.0.5"
+    "xml-js": "1.6.11"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "^5.0.8",

+ 128 - 177
src/views/warehouseManagement/stockManagement/add.vue

@@ -203,41 +203,41 @@
                   </el-input>
                 </el-form-item>
               </template>
-              <template v-slot:packingQuantity="{ row, $index }">
+              <template v-slot:quantity="{ row, $index }">
                 <template v-if="row.isSave">
-                  {{ row.packingQuantity }}
+                  {{ row.quantity }}
                 </template>
                 <el-form-item
                   v-else
-                  :prop="`productList.${$index}.packingQuantity`"
+                  :prop="`productList.${$index}.quantity`"
                   required
                 >
                   <el-input
-                    :ref="'packingQuantity' + $index"
+                    :ref="'quantity' + $index"
                     type="number"
                     placeholder="请输入"
                     @keyup.native="
-                      moveFocus($event, $index, 'packingQuantity', '产品', row)
+                      moveFocus($event, $index, 'quantity', '产品', row)
                     "
-                    v-model="row.packingQuantity"
+                    v-model="row.quantity"
                     @input="computeNum(row, $index, true)"
                     :disabled="row.isSave"
                   >
                   </el-input>
                 </el-form-item>
               </template>
-              <template v-slot:packingUnit="{ row, $index }">
+              <template v-slot:unit="{ row, $index }">
                 <template v-if="row.isSave">
-                  {{ row.packingUnit }}
+                  {{ row.unit }}
                 </template>
                 <el-form-item
                   v-else
-                  :prop="`productList.${$index}.packingUnit`"
+                  :prop="`productList.${$index}.unit`"
                   required
                 >
                   <el-select
                     :disabled="row.isSave"
-                    v-model="row.packingUnitId"
+                    v-model="row.unitId"
                     placeholder="请选择"
                     @change="computeNum(row, $index)"
                   >
@@ -258,7 +258,7 @@
               </template>
               <template v-slot:singleWeight="{ row, $index }">
                 <el-input
-                  :disabled="row.isSave || row.weightUnit == row.packingUnit"
+                  :disabled="row.isSave || row.weightUnit == row.unit"
                   v-model="row.singleWeight"
                   placeholder="请输入"
                   :min="0"
@@ -272,7 +272,7 @@
               </template>
               <template v-slot:weight="{ row, $index }">
                 <el-input
-                  :disabled="row.isSave || row.weightUnit == row.packingUnit"
+                  :disabled="row.isSave || row.weightUnit == row.unit"
                   v-model="row.weight"
                   placeholder="请输入"
                   @input="inputAllweight(row, $index)"
@@ -1114,20 +1114,36 @@
             width: 200,
             slot: 'batchNo',
             align: 'center',
-            headerSlot: 'headerBatchNo',
+            headerSlot: 'headerBatchNo'
           },
           {
             label: '数量',
             showOverflowTooltip: true,
-            prop: 'packingQuantity',
-            slot: 'packingQuantity',
+            prop: 'quantity',
+            slot: 'quantity',
             width: 180,
             align: 'center',
-            headerSlot: 'headerPackingQuantity',
+            headerSlot: 'headerPackingQuantity'
           },
           {
             label: '单位',
             showOverflowTooltip: true,
+            prop: 'unit',
+            slot: 'unit',
+            width: 100,
+            align: 'center'
+          },
+          {
+            label: '包装数量',
+            showOverflowTooltip: true,
+            prop: 'packingQuantity',
+            slot: 'packingQuantity',
+            width: 180,
+            align: 'center'
+          },
+          {
+            label: '包装单位',
+            showOverflowTooltip: true,
             prop: 'packingUnit',
             slot: 'packingUnit',
             width: 100,
@@ -1532,7 +1548,7 @@
           this.$set(this.productList[index], 'singleWeight', 1);
         }
         if (row.measureUnit == row.weightUnit) {
-          row.weight = row.singleWeight * row.packingQuantity;
+          row.weight = row.singleWeight * row.quantity;
           row.measureQuantity = row.weight;
         } else {
           row.weight = row.singleWeight * row.measureQuantity;
@@ -1558,7 +1574,7 @@
         if (row.measureUnit == row.weightUnit) {
           row.measureQuantity = row.weight;
           row.singleWeight =
-            Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) / 10000;
+            Math.trunc((row.measureQuantity / row.quantity) * 10000) / 10000;
         } else {
           row.singleWeight = row.measureQuantity
             ? row.weight / row.measureQuantity
@@ -1590,22 +1606,22 @@
         return value;
       },
       async computeNum(row, index, isClear) {
-        row.packingQuantity = this.format3(row.packingQuantity);
-        console.log(row.packingSpecificationOption);
-        console.log(row.packingUnit);
+        row.quantity = this.format3(row.quantity);
+        // console.log(row.packingSpecificationOption);
+        // console.log(row.packingUnit);
 
         let data = row.packingSpecificationOption.find(
-          (item) => item.id == row.packingUnitId
+          (item) => item.id == row.unitId
         );
-        row.packingUnit = data.conversionUnit;
+        row.unit = data.conversionUnit;
         // 清空仓库(包装数量输入)
         if (isClear) {
-          if (row.packingQuantity < 0) {
-            this.$set(this.productList[index], 'packingQuantity', 1);
-          } 
+          if (row.quantity < 0) {
+            this.$set(this.productList[index], 'quantity', 1);
+          }
         }
         //如果有包装数量和包装单位
-        if (row.packingQuantity && row.packingUnit) {
+        if (row.quantity && row.unit) {
           //获取仓库
           const res = await warehouseDefinition.list({
             inventoryType: row?.categoryLevelPathIdParent
@@ -1621,7 +1637,7 @@
             let table1 = [];
             table1.push({
               measureQuantity: row.measureQuantity,
-              packingQuantity: row.packingQuantity,
+              packingQuantity: row.quantity,
               warehouseName: name,
               warehouseId: res[0].id
             });
@@ -1643,7 +1659,7 @@
             (ite) => data.id == ite.id
           );
           console.log(endIndex, 'endIndex');
-          let total = Number(row.packingQuantity);
+          let total = Number(row.quantity);
 
           for (; 0 < endIndex; endIndex--) {
             total = this.$math.format(
@@ -1661,17 +1677,18 @@
           if (row.measureUnit == row.weightUnit) {
             weight = row.measureQuantity;
             //包装单位与重量单位相等时,单重重量为0
-            if (row.packingUnit == row.weightUnit) {
+            if (row.unit == row.weightUnit) {
               row.singleWeight = 0;
             } else {
               row.singleWeight =
-                Math.trunc((row.measureQuantity / row.packingQuantity) * 10000) /
+                Math.trunc((row.measureQuantity / row.quantity) * 10000) /
                 10000;
             }
           } else if (row.singleWeight) {
             weight = row.measureQuantity * Number(row.singleWeight);
           }
           this.$set(this.productList[index], 'weight', weight);
+          this.$set(this.productList[index], 'packingQuantity', this.setPNum(row));
         }
       },
       //出入库申请列表操作直接入库
@@ -2004,7 +2021,7 @@
         switch (type) {
           case '产品':
             listLength = this.productList.length;
-            keyfield = ['batchNo', 'packingQuantity', 'unitPrice', 'purpose'];
+            keyfield = ['batchNo', 'quantity', 'unitPrice', 'purpose'];
             break;
           case '包装':
             listLength = this.showPackingList.length;
@@ -2610,87 +2627,8 @@
         return number;
       },
 
-      // 包装维度最小包装单元改变——>总重量
-      minPackingQuantityChange(row, value, index) {
-        console.log(value);
-        if (row.measureUnit !== 'KG') {
-          if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
-            this.$set(this.productList[index], 'minPackingQuantity', 9999);
-          } else {
-            this.$set(
-              this.productList[index],
-              'minPackingQuantity',
-              value.replace(/^(0+)|[^\d]+/g, '')
-            );
-          }
-        } else {
-          if (value < 1) {
-            this.$set(this.productList[index], 'minPackingQuantity', 1);
-          } else if (value > 9999) {
-            this.$set(this.productList[index], 'minPackingQuantity', 9999);
-          }
-        }
-        if (row.packingQuantity >= 0 && value >= 0) {
-          this.packNum(row, row.packingQuantity, index);
-        }
-      },
-      // 包装数量过滤处理改变——>总重量
-      packNum(row, value, index) {
-        const total = {
-          minPackingQuantity: Number(
-            row.minPackingQuantity > 0
-              ? row.minPackingQuantity > 9999
-                ? 9999
-                : row.minPackingQuantity
-              : 0
-          ),
-          packingQuantity: Number(
-            row.packingQuantity > 0
-              ? row.packingQuantity > 9999
-                ? 9999
-                : row.packingQuantity
-              : 0
-          )
-        };
-        const totals = Number(
-          this.$math.format(
-            total.minPackingQuantity * total.packingQuantity,
-            14
-          )
-        );
-        if (row.measureUnit == row.weightUnit) {
-          row.weight = Number(
-            this.$math.format(
-              total.minPackingQuantity *
-                1 *
-                Number(total.packingQuantity).toFixed(2),
-              14
-            )
-          );
-        } else {
-          row.weight = Number(
-            this.$math.format(
-              totals *
-                (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
-              14
-            )
-          );
-        }
-        this.$set(this.productList[index], 'measureQuantity', totals);
-        // 清空仓库
-        this.$set(this.productList[index], 'warehouseId', '');
-        this.$set(this.productList[index], 'warehouseName', '');
-        if (value.replace(/^(0+)|[^\d]+/g, '') > 9999) {
-          this.$set(this.productList[index], 'packingQuantity', 9999);
-        } else {
-          this.$set(
-            this.productList[index],
-            'packingQuantity',
-            value.replace(/^(0+)|[^\d]+/g, '')
-          );
-        }
-        // return (row.packingQuantity = value.replace(/^(0+)|[^\d]+/g, ''));
-      },
+
+ 
       // 表格样式
       rowClass({ row, column, rowIndex, columnIndex }) {
         if (rowIndex === 1) {
@@ -2782,8 +2720,9 @@
             packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
             minPackingQuantity: '', // 最小包装单元数量
             packingQuantity: '', // 包装数量
-            packingUnit: item.measuringUnit, // 单位
-            packingUnitId: newSpecificationOption[index].find(
+            packingUnit: item.packingUnit, // 包装数量
+            unit: item.measuringUnit, // 单位
+            unitId: newSpecificationOption[index].find(
               (v) => v.conversionUnit == item.measuringUnit
             )?.id, // 单位
             measureQuantity: 0, // 计量数量
@@ -2808,8 +2747,8 @@
           let list = this.productList.map(async (row, index) => {
             let fileds = [
               `productList.${index}.batchNo`,
-              `productList.${index}.packingQuantity`,
-              `productList.${index}.packingUnit`,
+              `productList.${index}.quantity`,
+              `productList.${index}.unit`,
               `productList.${index}.warehouseId`
             ];
             console.log(fileds);
@@ -2850,8 +2789,8 @@
           console.log(index);
           let fileds = [
             `productList.${index}.batchNo`,
-            `productList.${index}.packingQuantity`,
-            `productList.${index}.packingUnit`,
+            `productList.${index}.quantity`,
+            `productList.${index}.unit`,
             `productList.${index}.warehouseId`
           ];
           Promise.all(
@@ -2932,6 +2871,36 @@
           this.$message.error('批量保存失败,请检查必填项');
         }
       },
+
+      setPNum(row) {
+        let pNum = 0;
+        if (row.unitId) {
+          let splitIndex = row.packingSpecificationOption.findIndex(
+            (item) => item.id == row.unitId
+          );
+          if (splitIndex == 0) {
+            pNum = Math.ceil(
+              row.measureQuantity /
+                row.packingSpecificationOption[1]?.packageCell
+            );
+          }
+          if (splitIndex == 1) {
+            pNum = row.quantity;
+          }
+
+          for (; splitIndex > 1; splitIndex--) {
+            pNum = Math.ceil(
+              row.quantity *
+                row.packingSpecificationOption[splitIndex].packageCell
+            );
+          }
+        } else {
+          pNum = Math.ceil(
+            row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
+          );
+        }
+        return pNum;
+      },
       //产品保存操作
       async listSave(row, index) {
         console.log(row, ';ddd');
@@ -2947,11 +2916,11 @@
             // 不拆包
             if (!row.isUnpack) {
               if (row.packingUnit != row.measureUnit) {
-                let pNum = row.packingQuantity;
+                let pNum = row.quantity;
                 let splitIndex = row.packingSpecificationOption.findIndex(
                   (item) =>
-                    item.conversionUnit == row.packingUnit &&
-                    item.packageUnit != item.conversionUnit
+                    item.conversionUnit == row.unit &&
+                    item.unit != item.conversionUnit
                 );
                 for (; splitIndex > 1; splitIndex--) {
                   pNum = this.$math.format(
@@ -2980,33 +2949,8 @@
                 ]);
               }
             } else {
-              let pNum = 0;
-              if (row.packingUnitId) {
-                let splitIndex = row.packingSpecificationOption.findIndex(
-                  (item) => item.id == row.packingUnitId
-                );
-                if (splitIndex == 0) {
-                  pNum = Math.ceil(
-                    row.measureQuantity /
-                      row.packingSpecificationOption[1]?.packageCell
-                  );
-                }
-                if (splitIndex == 1) {
-                  pNum = row.packingQuantity;
-                }
+              let pNum = this.setPNum(row);
 
-                for (; splitIndex > 1; splitIndex--) {
-                  pNum = Math.ceil(
-                    row.packingQuantity *
-                      row.packingSpecificationOption[splitIndex].packageCell
-                  );
-                }
-              } else {
-                pNum = Math.ceil(
-                  row.measureQuantity /
-                    row.packingSpecificationOption[1]?.packageCell
-                );
-              }
               // row.packingQuantity;
               // console.log(row.packingQuantity,'row.packingQuantity')
               // return
@@ -3021,8 +2965,15 @@
               console.log(data, 'data');
 
               this.generateWrappers(row, index, data);
+              this.$set(
+                this.productList[index],
+                'packingQuantity',
+                data.length
+              );
             }
             this.$set(this.productList[index], 'isSave', true);
+
+            // this.$set(this.productList[index], 'isSave', data.length);
             this.$set(this.productList[index], 'warehouseId', row.warehouseId);
             this.$set(
               this.productList[index],
@@ -3048,7 +2999,7 @@
         //计量类型不是数量
         if (!row.isUnpack && row.measureType != 1) {
           // 计量单位=包装单位,则不生成包装层数据
-          if (row.measureUnit == row.packingUnit) {
+          if (row.measureUnit == row.unit) {
             // 直接生成物品层数据
             this.productList[productIndex].measureQuantity =
               row.measureQuantity;
@@ -3089,12 +3040,12 @@
             packingBoolen,
             'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen'
           );
-          if (!row.isUnpack && row.packingUnit == '立方') {
+          if (!row.isUnpack && row.unit == '立方') {
             num = 1;
           } else {
             filterArr = row.packingSpecificationOption.filter((item) => {
               return (
-                item.packageUnit == row.packingUnit &&
+                item.packageUnit == row.unit &&
                 item.packageUnit != item.conversionUnit
               );
             });
@@ -3105,7 +3056,7 @@
             // 处理单位不为KG类,计量单位为KG类的情况
             let splitIndex = row.packingSpecificationOption.findIndex(
               (item) =>
-                item.conversionUnit == row.packingUnit &&
+                item.conversionUnit == row.unit &&
                 item.packageUnit != item.conversionUnit
             );
             for (; splitIndex > 1; splitIndex--) {
@@ -3122,7 +3073,7 @@
               );
               filterArr = row.packingSpecificationOption.filter((item) => {
                 return (
-                  item.packageUnit == row.packingUnit &&
+                  item.packageUnit == row.unit &&
                   item.packageUnit != item.conversionUnit
                 );
               });
@@ -3136,17 +3087,16 @@
           // let packingUnit = !row.isUnpack ? row.packingUnit : row.packingSpecificationOption[1].conversionUnit;
           // let packingQuantity = row.packingQuantity / packingCodeList.length;
 
-          let packingUnit = row.packingSpecificationOption[1]?.conversionUnit;
+          let unit = row.packingSpecificationOption[1]?.conversionUnit;
           let startIndex = row.packingSpecificationOption.findIndex((ite) => {
             return (
-              row.measuringUnit == ite.packingUnit &&
-              ite.packingUnit != ite.conversionUnit
+              row.measuringUnit == ite.unit && ite.unit != ite.conversionUnit
             );
           });
           let endIndex = row.packingSpecificationOption.findIndex(
-            (ite) => row.packingUnit == ite.conversionUnit
+            (ite) => row.unit == ite.conversionUnit
           );
-          let total = Number(row.packingQuantity);
+          let total = Number(row.quantity);
           for (; startIndex < endIndex; endIndex--) {
             total = this.$math.format(
               row.packingSpecificationOption[endIndex].packageCell * total,
@@ -3267,21 +3217,22 @@
           for (let index = 0; index < packingCodeList.length; index++) {
             let measureQuantity = 1;
             let packingQuantity = 1;
-            let packingUnit = row.packingUnit;
+            // let packingUnit = row.unit;
 
             // 处理单位为KG类,计算每桶KG值
             if (packingBoolen) {
-               measureQuantity =
-                  Number(row.packingQuantity) >
-                  this.$math.format(filterArr[0].packageCell * (index + 1), 14)
-                    ? filterArr[0].packageCell
-                    : Number(row.packingQuantity) -
-                      this.$math.format(filterArr[0].packageCell * index, 14);
+              measureQuantity =
+                Number(row.quantity) >
+                this.$math.format(filterArr[0].packageCell * (index + 1), 14)
+                  ? filterArr[0].packageCell
+                  : Number(row.quantity) -
+                    this.$math.format(filterArr[0].packageCell * index, 14);
             } else {
               //计量单位等于重量单位并且有总重 计量数量=总重/包装数
               if (row.weightUnit == row.measureUnit && row.weight) {
                 measureQuantity =
-                  Math.trunc((row.weight / packingCodeList.length) * 10000) / 10000;
+                  Math.trunc((row.weight / packingCodeList.length) * 10000) /
+                  10000;
               } else {
                 measureQuantity = row.packingSpecificationOption[1].packageCell;
               }
@@ -3362,12 +3313,12 @@
 
             let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
               .dictValue;
-               //计量单位等于重量单位
-          if (row.weightUnit == row.measureUnit) {
-            item.weight = item.measureQuantity
-              ? Number(item.measureQuantity)
-              : 0;
-          } else if (outBoolen) {
+            //计量单位等于重量单位
+            if (row.weightUnit == row.measureUnit) {
+              item.weight = item.measureQuantity
+                ? Number(item.measureQuantity)
+                : 0;
+            } else if (outBoolen) {
               // 计量单位为KG类,直接替换
               item.weight = item.measureQuantity
                 ? Number(item.measureQuantity)
@@ -3491,11 +3442,11 @@
         }
         //单个
         if (idx > -1 && type != 'batch') {
-          if (row.packingQuantity > 0) {
+          if (row.quantity > 0) {
             if (!row.isUnpack) {
               console.log('不拆');
               //计量和包装单位相同
-              if (row.measureUnit == row.packingUnit) {
+              if (row.measureUnit == row.unit) {
                 let pNum = 0;
                 let mNum = row.measureQuantity;
                 this.$refs.wareHouseDailogRef.open({
@@ -3508,10 +3459,10 @@
                 });
               } else {
                 if (row.packingSpecificationOption[1]?.packageCell) {
-                  let num = row.packingQuantity;
+                  let num = row.quantity;
                   let splitIndex = row.packingSpecificationOption.findIndex(
                     (item) =>
-                      item.conversionUnit == row.packingUnit &&
+                      item.conversionUnit == row.unit &&
                       item.packageUnit != item.conversionUnit
                   );
                   for (; splitIndex > 1; splitIndex--) {
@@ -3574,7 +3525,7 @@
           console.log(type, 'type');
 
           // 验证所有选中行是否填写了包装数量
-          if (row.some((item) => !item.packingQuantity)) {
+          if (row.some((item) => !item.quantity)) {
             this.$message.error('请先填写所有行的包装数量!');
             return;
           }

+ 1 - 1
vue.config.js

@@ -35,7 +35,7 @@ module.exports = {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.132:18086',
         // target: 'http://192.168.1.105:18086', //开发
-        target: 'http://192.168.1.251:18086', //开发
+        target: 'http://192.168.1.25:18086', //开发
         // target: 'http://192.168.1.251:18186', //测试
         // target: 'http://192.168.1.116:18086',
 

File diff suppressed because it is too large
+ 338 - 338
yarn.lock


Some files were not shown because too many files changed in this diff