Преглед изворни кода

库存管理新增物品机型和颜色字典选择,优化单位处理和数字格式化

yusheng пре 10 месеци
родитељ
комит
cd89da8d6b

+ 6 - 2
src/components/Dict/DictSelection.vue

@@ -28,7 +28,7 @@
     },
     },
     props: {
     props: {
       value: {
       value: {
-        type: [String, Number],
+        type: [String, Number,Array],
         default: ''
         default: ''
       },
       },
       isProhibit: {
       isProhibit: {
@@ -50,6 +50,10 @@
       ChinEng: {
       ChinEng: {
         Boolean,
         Boolean,
         default: false
         default: false
+      }, //列表使用了多个时,防止多次请求
+      isOne: {
+        type: Boolean,
+        default: true
       }
       }
     },
     },
     data() {
     data() {
@@ -73,7 +77,7 @@
       }
       }
     },
     },
     created() {
     created() {
-      if (this.dictName) {
+      if (this.dictName&&this.isOne) {
         this.requestDict(this.dictName);
         this.requestDict(this.dictName);
       }
       }
     },
     },

+ 3 - 2
src/enum/dict.js

@@ -18,6 +18,7 @@ export default {
   不拆物料层规格: 'material_layer',
   不拆物料层规格: 'material_layer',
   紧急程度: 'urgent_type',
   紧急程度: 'urgent_type',
   条码分类: 'strip_type',
   条码分类: 'strip_type',
-  产地:'purchase_origin',
-
+  产地: 'purchase_origin',
+  物品机型: 'product_model_key',
+  物品颜色: 'product_color_key'
 };
 };

+ 88 - 7
src/views/warehouseManagement/stockManagement/add.vue

@@ -359,6 +359,37 @@
                 >
                 >
                 </el-input>
                 </el-input>
               </template>
               </template>
+              <template v-slot:modelKey="{ row, $index }">
+                <el-form-item>
+                  <DictSelection
+                    dictName="物品机型"
+                    clearable
+                    v-model="row.modelKey"
+                    :isOne="$index === 0"
+                    multiple
+                    filterable
+                    allow-create
+                    default-first-option
+                  >
+                  </DictSelection>
+                </el-form-item>
+              </template>
+              <template v-slot:colorKey="{ row, $index }">
+                <el-form-item>
+                  <DictSelection
+                    dictName="物品颜色"
+                    clearable
+                    v-model="row.colorKey"
+                    :isOne="$index === 0"
+                    multiple
+                    filterable
+                    allow-create
+                    default-first-option
+                  >
+                  </DictSelection>
+                </el-form-item>
+              </template>
+
               <template v-slot:detailProductionDate="{ row, $index }">
               <template v-slot:detailProductionDate="{ row, $index }">
                 <template v-if="row.isSave">
                 <template v-if="row.isSave">
                   {{ row.detailProductionDate }}
                   {{ row.detailProductionDate }}
@@ -604,6 +635,36 @@
               {{ row.weightUnit }}
               {{ row.weightUnit }}
             </template>
             </template>
           </el-table-column>
           </el-table-column>
+          <!-- <el-table-column label="机型" prop="modelKey">
+            <template slot-scope="{ row }">
+              <DictSelection
+                dictName="物品机型"
+                clearable
+                v-model="row.modelKey"
+                :isOne="false"
+                multiple
+                filterable
+                allow-create
+                default-first-option
+              >
+              </DictSelection>
+            </template>
+          </el-table-column>
+         <el-table-column label="颜色" prop="colorKey">
+            <template slot-scope="{ row }">
+              <DictSelection
+                dictName="物品颜色"
+                clearable
+                v-model="row.colorKey"
+                :isOne="false"
+                multiple
+                filterable
+                allow-create
+                default-first-option
+              >
+              </DictSelection>
+            </template>
+          </el-table-column> -->
 
 
           <el-table-column label="质检结果" prop="result" width="120">
           <el-table-column label="质检结果" prop="result" width="120">
             <template slot-scope="{ row }">
             <template slot-scope="{ row }">
@@ -1173,6 +1234,20 @@
             width: 300,
             width: 300,
             align: 'center'
             align: 'center'
           },
           },
+          // {
+          //   width: 200,
+          //   prop: 'modelKey',
+          //   label: '机型',
+          //   slot: 'modelKey',
+          //   align: 'center'
+          // },
+          // {
+          //   width: 200,
+          //   prop: 'colorKey',
+          //   label: '颜色',
+          //   slot: 'colorKey',
+          //   align: 'center'
+          // },
           {
           {
             label: '采购原因',
             label: '采购原因',
             prop: 'purpose',
             prop: 'purpose',
@@ -1181,6 +1256,7 @@
             width: 200,
             width: 200,
             align: 'center'
             align: 'center'
           },
           },
+
           {
           {
             label: '生产日期',
             label: '生产日期',
             prop: 'detailProductionDate',
             prop: 'detailProductionDate',
@@ -1460,7 +1536,7 @@
       // 小数处理,最大3位
       // 小数处理,最大3位
       format3(str) {
       format3(str) {
         let value = str;
         let value = str;
-        value = value.replace(/[^0-9.]/g, '');
+        value = value.toString().replace(/[^0-9.]/g, '');
         const parts = value.split('.');
         const parts = value.split('.');
         if (parts.length > 2) {
         if (parts.length > 2) {
           value = parts[0] + '.' + parts.slice(1).join('');
           value = parts[0] + '.' + parts.slice(1).join('');
@@ -1473,7 +1549,6 @@
         return value;
         return value;
       },
       },
       async computeNum(row, index, isClear) {
       async computeNum(row, index, isClear) {
-        console.log('row,', row);
         row.packingQuantity = this.format3(row.packingQuantity);
         row.packingQuantity = this.format3(row.packingQuantity);
 
 
         let data = row.packingSpecificationOption.find(
         let data = row.packingSpecificationOption.find(
@@ -1709,11 +1784,17 @@
             if (item.weight === null || item.weight === undefined) {
             if (item.weight === null || item.weight === undefined) {
               item.weight = 0;
               item.weight = 0;
             }
             }
-            if (this.formData.bizType == 4) {
-              item.packingUnit = '箱';
-            } else {
-              item.packingUnit = '';
-            }
+
+            item.packingUnit = item.measuringUnit; // 单位
+            item.packingUnitId = item.packingSpecificationOption.find(
+              (v) => v.conversionUnit == item.measuringUnit
+            )?.id; // 单位
+
+            // if (this.formData.bizType == 4) {
+            //   item.packingUnit = '箱';
+            // } else {
+            //   item.packingUnit = '';
+            // }
             return item;
             return item;
           });
           });
           console.log(this.productList, 'productList');
           console.log(this.productList, 'productList');