Procházet zdrojové kódy

物品详情页新增机型和颜色字典选择,支持多选并优化净重计算逻辑

yusheng před 10 měsíci
rodič
revize
d6947b14e0

+ 8 - 0
src/api/system/dictionary/index.js

@@ -53,3 +53,11 @@ export async function removeDictionary(id, f) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+//获取系统参数
+export async function parameterGetByCode(data) {
+  const res = await request.post('/sys/parameter/getByCode', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 1 - 1
src/components/Dict/DictSelection.vue

@@ -29,7 +29,7 @@
     },
     props: {
       value: {
-        type: [String, Number],
+        type: [String, Number, Array],
         default: ''
       },
       isProhibit: {

+ 3 - 1
src/enum/dict.js

@@ -71,7 +71,9 @@ export default {
   执行标准: 'enforceStandards',
   产地: 'purchase_origin',
   文档类型: 'doc_type',
-  存货类型: 'inventory_type'
+  存货类型: 'inventory_type',
+  物品机型:'product_model_key',
+  物品颜色:'product_color_key'
 };
 
 export const numberList = [

+ 95 - 9
src/views/material/product/detail.vue

@@ -271,6 +271,28 @@
               </template>
             </el-form-item>
           </el-col>
+          <el-col :span="8">
+            <el-form-item label="机型" prop="modelKey">
+              <DictSelection
+                dictName="物品机型"
+                clearable
+                v-model="form.modelKey"
+                multiple
+              >
+              </DictSelection>
+            </el-form-item>
+          </el-col>
+          <el-col :span="8">
+            <el-form-item label="颜色" prop="colorKey">
+              <DictSelection
+                dictName="物品颜色"
+                clearable
+                v-model="form.colorKey"
+                multiple
+              >
+              </DictSelection>
+            </el-form-item>
+          </el-col>
           <el-col :span="8">
             <el-form-item label="状态">
               <template>
@@ -286,7 +308,7 @@
           </el-col>
 
           <el-col :span="8" v-for="(f, idx) in fileList" :key="idx">
-            <el-form-item :label="f.label"  :prop="'extField.'+f.prop">
+            <el-form-item :label="f.label" :prop="'extField.' + f.prop">
               <template>
                 <div class="form-line">
                   <component
@@ -406,7 +428,7 @@
   import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
   import { produceTypeList } from '@/enum/dict.js';
   import { copyObj } from '@/utils/util';
-
+  import { parameterGetByCode } from '@/api/system/dictionary/index.js';
   const defCategoryQms = [
     {
       categoryId: '',
@@ -523,7 +545,8 @@
           attributeType: 1,
           weightUnit: '',
           packingUnit: '',
-
+          colorKey: [],
+          modelKey: [],
           extField: {},
           // isConsumables:2,
           extTagField: {
@@ -591,7 +614,8 @@
         ruleCode: null,
         codeShow: false,
 
-        status: null
+        status: null,
+        isNetWeight: 0
       };
     },
     watch: {
@@ -620,6 +644,8 @@
               netWeight: '',
               weightUnit: '',
               packingUnit: '',
+              colorKey: [],
+              modelKey: [],
               extField: {},
               extTagField: {
                 isConsumables: 0
@@ -754,8 +780,19 @@
       // this.getDictList('zeroPartPros');
     },
     async created() {
+      //主数据物品是否计算净重
+      parameterGetByCode({
+        code: 'main_isNetWeight'
+      }).then((res) => {
+        if (res.value) {
+          this.isNetWeight = res.value;
+          if (this.isNetWeight == 1) {
+            this.$set(this.categoryWms, 'isUnpack', 1);
+          }
+        }
+      });
+
       //新增
-      console.log('88888888');
 
       this.$set(
         this.form,
@@ -820,6 +857,34 @@
         } else {
           this.form.volume = '';
         }
+        this.setNetWeight();
+      },
+      //计算净重
+      setNetWeight() {
+        if (
+          this.form.specification &&
+          this.form.weightUnit == 'KG' &&
+          this.isNetWeight == 1
+        ) {
+          let modelArr = this.form.specification.split('*');
+          let modelLong = modelArr[0]; // model规格长度
+          let modeWide = modelArr[1]; // model规格宽度
+          let modeHight = modelArr[2]?.substr(0, modelArr[2].indexOf('mm')); // model规格高度
+          modeHight = Number(modeHight);
+          let volume = (modelLong * modeWide * modeHight) / 1000;
+          this.$set(
+            this.form,
+            'netWeight',
+            parseFloat((volume * 7.85) / 1000).toFixed(4)
+          );
+          this.$nextTick(() => {
+            // this.$refs.warehouseRefs &&
+            //   this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
+            this.handleInput3();
+          });
+
+          // this.form.netWeight = volume*7.85/1000;
+        }
       },
       changeMeasureType() {
         if (this.form.measureType == 1) {
@@ -827,6 +892,7 @@
         } else {
           this.$set(this.categoryWms, 'isUnpack', 0);
         }
+        this.setNetWeight();
       },
       handleInput(value) {
         // this.form.volume = this.$handleInputPublicHasPoint(value);
@@ -851,8 +917,9 @@
         ) {
           this.$refs.warehouseRefs.changeNetWeight(this.form.netWeight);
         }
+        this.setNetWeight();
       },
-      changeUnit() {
+      async changeUnit() {
         if (this.$route.query.id == '' || this.$route.query.id == null) {
           if (this.form.measuringUnit) {
             // 计量单位是‘立方’   体积单位默认是‘立方’
@@ -865,11 +932,14 @@
             } else {
               this.form.volume = 0;
             }
+
             this.categoryPurchase.measuringUnit = this.form.measuringUnit;
             console.log(this.categoryPurchase.measuringUnit, '采购信息');
             // 如果有计量单位和包装单位 默认添加包装组
             if (this.form.packingUnit) {
-              this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+              await this.$refs.warehouseRefs.defaultBuild(
+                this.form.packingUnit
+              );
             }
           }
         } else {
@@ -882,12 +952,15 @@
               console.log(this.form.packingUnit, 'this.form.packingUnit');
               if (this.packageDispositionVOList.length === 0) {
                 console.log('如果没有包装组');
-                this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+                await this.$refs.warehouseRefs.defaultBuild(
+                  this.form.packingUnit
+                );
               }
             }
           }
           this.isShow = true;
         }
+        await this.setNetWeight();
       },
 
       // changeAttribute(val) {
@@ -915,6 +988,14 @@
 
         const info = deepClone(data);
         info.category.produceType = info.category.produceType[0];
+        try {
+          if (info.category.colorKey) {
+            info.category.colorKey = info.category.colorKey.split(',');
+          }
+          if (info.category.modelKey) {
+            info.category.modelKey = info.category.modelKey.split(',');
+          }
+        } catch (error) {}
 
         this.form = {
           ...info.category
@@ -1282,7 +1363,12 @@
               }
             );
           }
-
+          if (data.category.colorKey) {
+            data.category.colorKey = data.category.colorKey.toString();
+          }
+          if (data.category.modelKey) {
+            data.category.modelKey = data.category.modelKey.toString();
+          }
           data.category.produceType = data.category.produceType
             ? [data.category.produceType]
             : [];