Browse Source

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend into dev

chencc 1 năm trước cách đây
mục cha
commit
5510af804c

+ 342 - 408
src/views/material/product/components/WarehouseInfo.vue

@@ -25,24 +25,16 @@
         </el-col>
         <el-col :span="8">
           <el-form-item label="允许拆包" prop="isUnpack">
-            <el-switch
-              v-model="form.isUnpack"
-              :active-value="1"
-              :inactive-value="0"
-            >
+            <el-switch v-model="form.isUnpack" :active-value="1" :inactive-value="0">
             </el-switch>
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="安全库存"
-            prop="secureInventory"
-            :rules="{
-              required: this.form.isWarn == 1 ? true : false,
-              message: '请输入安全库存',
-              trigger: 'blur'
-            }"
-          >
+          <el-form-item label="安全库存" prop="secureInventory" :rules="{
+            required: this.form.isWarn == 1 ? true : false,
+            message: '请输入安全库存',
+            trigger: 'blur'
+          }">
             <el-input v-model="form.secureInventory" @input="handleInput1">
               <template #append>
                 {{ packingUnit }}
@@ -51,15 +43,11 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="最小库存"
-            prop="minInventory"
-            :rules="{
-              required: this.form.isWarn == 1 ? true : false,
-              message: '请输入最小库存',
-              trigger: 'blur'
-            }"
-          >
+          <el-form-item label="最小库存" prop="minInventory" :rules="{
+            required: this.form.isWarn == 1 ? true : false,
+            message: '请输入最小库存',
+            trigger: 'blur'
+          }">
             <el-input v-model="form.minInventory" @input="handleInput2">
               <template #append>
                 {{ packingUnit }}
@@ -68,15 +56,11 @@
           </el-form-item>
         </el-col>
         <el-col :span="8">
-          <el-form-item
-            label="最大库存"
-            prop="maxInventory"
-            :rules="{
-              required: this.form.isWarn == 1 ? true : false,
-              message: '请输入最大库存',
-              trigger: 'blur'
-            }"
-          >
+          <el-form-item label="最大库存" prop="maxInventory" :rules="{
+            required: this.form.isWarn == 1 ? true : false,
+            message: '请输入最大库存',
+            trigger: 'blur'
+          }">
             <el-input v-model="form.maxInventory" @input="handleInput3">
               <template #append>
                 {{ packingUnit }}
@@ -87,49 +71,25 @@
 
         <el-col :span="8">
           <el-form-item label="质保预警参考" prop="warrantyWarnRefer">
-            <DictSelection
-              dictName="质保预警参考"
-              clearable
-              v-model="form.warrantyWarnRefer"
-            >
+            <DictSelection dictName="质保预警参考" clearable v-model="form.warrantyWarnRefer">
             </DictSelection>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="保质期">
             <div class="form-line">
-              <el-input
-                v-model="form.warrantyPeriod"
-                @input="handleInput4"
-                style="width: calc(100% - 100px)"
-              />
-              <DictSelection
-                dictName="保质期单位"
-                clearable
-                v-model="form.warrantyPeriodUnit"
-                style="width: 100px"
-              >
+              <el-input v-model="form.warrantyPeriod" @input="handleInput4" style="width: calc(100% - 100px)" />
+              <DictSelection dictName="保质期单位" clearable v-model="form.warrantyPeriodUnit" style="width: 100px">
               </DictSelection>
             </div>
           </el-form-item>
         </el-col>
       </el-row>
       <div class="rules_box">
-        <el-button type="primary" @click="addPackingRules"
-          >添加包装组</el-button
-        >
-        <el-tabs
-          v-model="packingRules"
-          editable
-          @tab-click="handleClick"
-          @edit="handleTabsEdit"
-        >
-          <el-tab-pane
-            v-for="(items, indexs) in packagingSpecification"
-            :label="items.name"
-            :name="items.code"
-            :key="indexs"
-          >
+        <el-button type="primary" @click="addPackingRules">添加包装组</el-button>
+        <el-tabs v-model="packingRules" editable @tab-click="handleClick" @edit="handleTabsEdit">
+          <el-tab-pane v-for="(items, indexs) in packagingSpecification" :label="items.name" :name="items.code"
+            :key="indexs">
             <div class="rules_box_tabs">
               <el-row :gutter="24">
                 <el-col :span="8">
@@ -144,10 +104,7 @@
                 </el-col>
                 <el-col :span="8">
                   <el-form-item label="是否启用">
-                    <el-radio-group
-                      v-model="items.status"
-                      @input="statusChange($event, indexs)"
-                    >
+                    <el-radio-group v-model="items.status" @input="statusChange($event, indexs)">
                       <el-radio :label="1">是</el-radio>
                       <el-radio :label="0">否</el-radio>
                     </el-radio-group>
@@ -155,79 +112,42 @@
                 </el-col>
                 <el-col :span="24">
                   <el-form-item label="最小包装单元">
-                    <el-input
-                      class="packingUnit"
-                      v-model="items.minPackageCell"
-                      placeholder="请输入内容"
-                    ></el-input>
+                    <el-input class="packingUnit" v-model="items.minPackageCell" placeholder="请输入内容"></el-input>
                     <div class="packingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.packageUnit"
-                        :isProhibit="true"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.packageUnit" :isProhibit="true">
                       </DictSelection>
                     </div>
                     <span>/</span>
                     <div class="lastPackingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.minConversionUnit"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.minConversionUnit">
                       </DictSelection>
                     </div>
                   </el-form-item>
                 </el-col>
                 <el-col :span="24">
                   <el-form-item label="内包装单元">
-                    <el-input
-                      class="packingUnit"
-                      v-model="items.inPackageCell"
-                      placeholder="请输入内容"
-                    ></el-input>
+                    <el-input class="packingUnit" v-model="items.inPackageCell" placeholder="请输入内容"></el-input>
                     <div class="packingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.minConversionUnit"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.minConversionUnit">
                       </DictSelection>
                     </div>
                     <span>/</span>
                     <div class="lastPackingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.inConversionUnit"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.inConversionUnit">
                       </DictSelection>
                     </div>
                   </el-form-item>
                 </el-col>
                 <el-col :span="24">
                   <el-form-item label="外包装单元">
-                    <el-input
-                      class="packingUnit"
-                      v-model="items.outPackageCell"
-                      placeholder="请输入内容"
-                    ></el-input>
+                    <el-input class="packingUnit" v-model="items.outPackageCell" placeholder="请输入内容"></el-input>
                     <div class="packingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.inConversionUnit"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.inConversionUnit">
                       </DictSelection>
                     </div>
                     <span>/</span>
                     <div class="lastPackingUnit">
-                      <DictSelection
-                        dictName="计量单位"
-                        clearable
-                        v-model="items.outConversionUnit"
-                      >
+                      <DictSelection dictName="计量单位" clearable v-model="items.outConversionUnit">
                       </DictSelection>
                     </div>
                   </el-form-item>
@@ -262,221 +182,169 @@
 </template>
 
 <script>
-  import deptSelect from '@/components/CommomSelect/dept-select.vue';
-  import personSelect from '@/components/CommomSelect/person-select.vue';
-  import { deletePackageDisposition } from '@/api/material/list.js';
-  import { getCode } from '@/api/codeManagement/index.js';
-  export default {
-    components: { deptSelect, personSelect },
-    props: {
-      form: {
-        type: Object,
-        default: () => {}
-      },
-      packageDispositionVOList: {
-        type: Array,
-        default: () => []
-      },
-      measuringUnit: {
-        type: String,
-        default() {
-          return '';
-        }
-      },
-      packingUnit: {
-        type: String,
-        default() {
-          return '';
-        }
-      }
+import deptSelect from '@/components/CommomSelect/dept-select.vue';
+import personSelect from '@/components/CommomSelect/person-select.vue';
+import { deletePackageDisposition } from '@/api/material/list.js';
+import { getCode } from '@/api/codeManagement/index.js';
+export default {
+  components: { deptSelect, personSelect },
+  props: {
+    form: {
+      type: Object,
+      default: () => { }
     },
-    watch: {
-      measuringUnit(val) {
-        this.packagingSpecification = this.packagingSpecification.map(
-          (item) => {
-            return { ...item, packageUnit: val };
-          }
-        );
-      },
-      packingUnit(val) {
-        this.packagingSpecification = this.packagingSpecification.map(
-          (item) => {
-            return { ...item, minConversionUnit: val };
-          }
-        );
-      },
-      packagingSpecification: {
-        handler(val) {
-          this.$emit('change', val);
-        },
-        deep: true
-      },
-      packageDispositionVOList: {
-        handler(packageDispositionVOList) {
-          if (packageDispositionVOList.length > 0) {
-            let codeList = new Set(
-              packageDispositionVOList.map((item) => item.code)
-            );
-            console.log(codeList);
-            let arr = [];
-            codeList.forEach((code) => {
-              let obj = {};
-              let filters = packageDispositionVOList.filter(
-                (item) => item.code == code
-              );
-              this.idsList.push({
-                code,
-                ids: filters.map((item) => item.id)
-              });
-              filters.map((item) => {
-                obj['id' + item.sort] = item.id;
-                switch (item.sort) {
-                  case '0':
-                    obj.code = item.code;
-                    obj.name = item.name;
-                    obj.status = Number(item.status);
-                    break;
-                  case '1':
-                    obj.minPackageCell = item.packageCell;
-                    obj.packageUnit = item.packageUnit;
-                    obj.minConversionUnit = item.conversionUnit;
-                  case '2':
-                    obj.inPackageCell = item.packageCell;
-                    obj.inConversionUnit = item.conversionUnit;
-                    break;
-                  case '3':
-                    obj.outPackageCell = item.packageCell;
-                    obj.outConversionUnit = item.conversionUnit;
-                    break;
-                }
-              });
-              arr.push(obj);
-            });
-            this.packagingSpecification = arr;
-            this.packingRules = arr[0].code;
-          } else {
-            this.packagingSpecification = [];
-          }
-        },
-        deep: true
+    packageDispositionVOList: {
+      type: Array,
+      default: () => []
+    },
+    measuringUnit: {
+      type: String,
+      default() {
+        return '';
       }
     },
-    data() {
-      return {
-        idsList: [],
-        packagingSpecification: [],
-        packingRules: '',
-        dialogVisible: false,
-        ruleItem: {
-          code: '',
-          name: '',
-          status: 0,
-          minPackageCell: '',
-          packageUnit: this.measuringUnit,
-          minConversionUnit: '',
-          inPackageCell: '',
-          inConversionUnit: '',
-          outPackageCell: '',
-          inConversionUnit: '',
-          outConversionUnit: ''
-        },
-        option: [
-          {
-            label: 'KG',
-            value: 'KG'
-          }
-        ],
-        hasPushed: false
-      };
+    packingUnit: {
+      type: String,
+      default() {
+        return '';
+      }
     },
-    created() {
-      console.log(
-        'this.packageDispositionVOList-',
-        this.packageDispositionVOList
+  },
+  watch: {
+    measuringUnit(val) {
+      this.packagingSpecification = this.packagingSpecification.map(
+        (item) => {
+          return { ...item, packageUnit: val };
+        }
       );
-      if (this.packageDispositionVOList.length == 0) {
-        this.hasPushed = false;
-      }
-      console.log(this.hasPushed, 'has');
     },
-    mounted() {
-      console.log(this.packingRules, 'packingRules');
+    packingUnit(val) {
+      this.packagingSpecification = this.packagingSpecification.map(
+        (item) => {
+          return { ...item, minConversionUnit: val };
+        }
+      );
     },
-    methods: {
-      handleInput1(value) {
-        this.form.secureInventory = this.$handleInputPublic(value);
-      },
-      handleInput2(value) {
-        this.form.minInventory = this.$handleInputPublic(value);
+    packagingSpecification: {
+      handler(val) {
+        this.$emit('change', val);
       },
-      handleInput3(value) {
-        this.form.maxInventory = this.$handleInputPublic(value);
-      },
-      handleInput4(value) {
-        this.form.warrantyPeriod = this.$handleInputPublicHasPoint(value);
-      },
-
-      async defaultBuild(val) {
-        if (!this.hasPushed) {
-          let code = await getCode('package_disposition');
-          this.ruleItem = {
-            code: code,
-            name: '默认包装组',
-            status: 1,
-            minPackageCell: '1',
-            packageUnit: this.measuringUnit,
-            minConversionUnit: this.packingUnit,
-            inPackageCell: '',
-            inConversionUnit: '',
-            outPackageCell: '',
-            inConversionUnit: '',
-            outConversionUnit: ''
-          };
-          this.packagingSpecification.push(this.ruleItem);
-          console.log('111111第一次添加');
-          this.packingRules = this.ruleItem.code;
-          this.hasPushed = true;
-        } else {
-          console.log('数组已经进行过push操作,无法再次添加元素。');
-          this.packagingSpecification = this.packagingSpecification.map(
-            (item) => {
-              return { ...item, minConversionUnit: val };
-            }
+      deep: true
+    },
+    packageDispositionVOList: {
+      handler(packageDispositionVOList) {
+        if (packageDispositionVOList.length > 0) {
+          let codeList = new Set(
+            packageDispositionVOList.map((item) => item.code)
           );
-        }
-      },
-      statusChange(value, indexs) {
-        console.log(value);
-        if (value == 1) {
-          this.packagingSpecification = this.packagingSpecification.map(
-            (item, index) => {
-              if (indexs == index) {
-                item.status = 1;
-              } else {
-                item.status = 0;
+          console.log(codeList);
+          let arr = [];
+          codeList.forEach((code) => {
+            let obj = {};
+            let filters = packageDispositionVOList.filter(
+              (item) => item.code == code
+            );
+            this.idsList.push({
+              code,
+              ids: filters.map((item) => item.id)
+            });
+            filters.map((item) => {
+              obj['id' + item.sort] = item.id;
+              switch (item.sort) {
+                case '0':
+                  obj.code = item.code;
+                  obj.name = item.name;
+                  obj.status = Number(item.status);
+                  break;
+                case '1':
+                  obj.minPackageCell = item.packageCell;
+                  obj.packageUnit = item.packageUnit;
+                  obj.minConversionUnit = item.conversionUnit;
+                case '2':
+                  obj.inPackageCell = item.packageCell;
+                  obj.inConversionUnit = item.conversionUnit;
+                  break;
+                case '3':
+                  obj.outPackageCell = item.packageCell;
+                  obj.outConversionUnit = item.conversionUnit;
+                  break;
               }
-              return item;
-            }
-          );
-        }
-      },
-      ruleConig() {
-        console.log(this.ruleItem);
-        if (this.packagingSpecification.length == 0) {
-          this.ruleItem.status = 1;
+            });
+            arr.push(obj);
+          });
+          this.packagingSpecification = arr;
+          this.packingRules = arr[0].code;
         } else {
-          this.ruleItem.status = 0;
+          this.packagingSpecification = [];
         }
-        this.packagingSpecification.push(this.ruleItem);
-        this.dialogVisible = false;
-        this.packingRules = this.ruleItem.code;
       },
-      async addPackingRules() {
+      deep: true
+    }
+  },
+  data() {
+    return {
+      idsList: [],
+      packagingSpecification: [],
+      packingRules: '',
+      dialogVisible: false,
+      ruleItem: {
+        code: '',
+        name: '',
+        status: 0,
+        minPackageCell: '',
+        packageUnit: this.measuringUnit,
+        minConversionUnit: '',
+        inPackageCell: '',
+        inConversionUnit: '',
+        outPackageCell: '',
+        inConversionUnit: '',
+        outConversionUnit: ''
+      },
+      option: [
+        {
+          label: 'KG',
+          value: 'KG'
+        }
+      ],
+      hasPushed: false
+    };
+  },
+  created() {
+    console.log(
+      'this.packageDispositionVOList------------------包装组',
+      this.packageDispositionVOList
+    );
+    if (this.packageDispositionVOList.length == 0) {
+      this.hasPushed = false;
+    }
+    console.log(this.hasPushed, 'has');
+  },
+  mounted() {
+    console.log(this.packingRules, 'packingRules');
+  },
+  methods: {
+
+    handleInput1(value) {
+      this.form.secureInventory = this.$handleInputPublic(value);
+    },
+    handleInput2(value) {
+      this.form.minInventory = this.$handleInputPublic(value);
+    },
+    handleInput3(value) {
+      this.form.maxInventory = this.$handleInputPublic(value);
+    },
+    handleInput4(value) {
+      this.form.warrantyPeriod = this.$handleInputPublicHasPoint(value);
+    },
+
+    async defaultBuild(val) {
+      console.log(this.hasPushed, 'jjjjjjjjjjj')
+      if (!this.hasPushed) {
         let code = await getCode('package_disposition');
         this.ruleItem = {
           code: code,
-          name: '',
-          status: 0,
+          name: '默认包装组',
+          status: 1,
           minPackageCell: '1',
           packageUnit: this.measuringUnit,
           minConversionUnit: this.packingUnit,
@@ -486,114 +354,180 @@
           inConversionUnit: '',
           outConversionUnit: ''
         };
-        this.dialogVisible = true;
-      },
-      handleClick(val) {
-        console.log(val);
-        this.packingRules = val.name;
-      },
-      // 删除tab
-      handleTabsEdit(targetName, action) {
-        if (action == 'remove') {
-          let index = this.packagingSpecification.findIndex(
-            (item) => item.code == targetName
-          );
-          let idsIndex = this.idsList.findIndex(
-            (item) => item.code == targetName
-          );
-          if (this.idsList.length > 0 && idsIndex > -1) {
-            let ids = this.idsList.filter(
-              (item) => item.code == this.packagingSpecification[index].code
-            )[0].ids;
-            deletePackageDisposition(ids).then(() => {
-              this.idsList = this.idsList.filter(
-                (item) => item.code != this.packagingSpecification[index].code
-              );
-              this.packagingSpecification.splice(index, 1);
-            });
-          } else {
-            this.packagingSpecification.splice(index, 1);
+        this.packagingSpecification.push(this.ruleItem);
+        console.log('111111第一次添加');
+        this.packingRules = this.ruleItem.code;
+        this.hasPushed = true;
+      } else {
+        console.log('数组已经进行过push操作,无法再次添加元素。');
+        this.packagingSpecification = this.packagingSpecification.map(
+          (item) => {
+            return { ...item, minConversionUnit: val };
           }
-        }
-      },
-      // inventoryModeChange(value) {
-      //   if (value == 1) {
-      //     this.form.isUnpack = 1;
-      //   } else {
-      //     this.form.isUnpack = 0;
-      //   }
-      // },
-      // 选择所属部门
-      searchDeptNodeClick(id, info) {
-        // 根据部门获取人员
-        const params = { executeGroupId: id };
-        this.$nextTick(() => {
-          this.$refs.directorRef.getList(params);
-        });
-      },
-      //选择负责人
-      handleDirectorChange(id, info) {},
-      getFormValid() {
-        return new Promise((resolve, reject) => {
-          this.$refs.form1.validate(async (valid) => {
-            resolve(await valid);
+        );
+      }
+    },
+    statusChange(value, indexs) {
+      console.log(value);
+      if (value == 1) {
+        this.packagingSpecification = this.packagingSpecification.map(
+          (item, index) => {
+            if (indexs == index) {
+              item.status = 1;
+            } else {
+              item.status = 0;
+            }
+            return item;
+          }
+        );
+      }
+    },
+    ruleConig() {
+      console.log(this.ruleItem);
+      if (this.packagingSpecification.length == 0) {
+        this.ruleItem.status = 1;
+      } else {
+        this.ruleItem.status = 0;
+      }
+      this.packagingSpecification.push(this.ruleItem);
+      this.dialogVisible = false;
+      this.packingRules = this.ruleItem.code;
+    },
+    async addPackingRules() {
+      let code = await getCode('package_disposition');
+      this.ruleItem = {
+        code: code,
+        name: '',
+        status: 0,
+        minPackageCell: '1',
+        packageUnit: this.measuringUnit,
+        minConversionUnit: this.packingUnit,
+        inPackageCell: '',
+        inConversionUnit: '',
+        outPackageCell: '',
+        inConversionUnit: '',
+        outConversionUnit: ''
+      };
+      this.dialogVisible = true;
+    },
+    handleClick(val) {
+      console.log(val);
+      this.packingRules = val.name;
+    },
+    // 删除tab
+    handleTabsEdit(targetName, action) {
+      if (action == 'remove') {
+        let index = this.packagingSpecification.findIndex(
+          (item) => item.code == targetName
+        );
+        let idsIndex = this.idsList.findIndex(
+          (item) => item.code == targetName
+        );
+        if (this.idsList.length > 0 && idsIndex > -1) {
+          let ids = this.idsList.filter(
+            (item) => item.code == this.packagingSpecification[index].code
+          )[0].ids;
+          deletePackageDisposition(ids).then(() => {
+            this.idsList = this.idsList.filter(
+              (item) => item.code != this.packagingSpecification[index].code
+            );
+            this.packagingSpecification.splice(index, 1);
           });
-        });
+        } else {
+          this.packagingSpecification.splice(index, 1);
+        }
       }
+    },
+    // inventoryModeChange(value) {
+    //   if (value == 1) {
+    //     this.form.isUnpack = 1;
+    //   } else {
+    //     this.form.isUnpack = 0;
+    //   }
+    // },
+    // 选择所属部门
+    searchDeptNodeClick(id, info) {
+      // 根据部门获取人员
+      const params = { executeGroupId: id };
+      this.$nextTick(() => {
+        this.$refs.directorRef.getList(params);
+      });
+    },
+    //选择负责人
+    handleDirectorChange(id, info) { },
+    getFormValid() {
+      return new Promise((resolve, reject) => {
+        this.$refs.form1.validate(async (valid) => {
+          resolve(await valid);
+        });
+      });
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .other {
-    background: #fff;
-    padding: 1px 17px;
-  }
-  .divider {
-    margin: 0px 0 20px;
-    .title {
-      display: flex;
-      align-items: center;
-      margin-bottom: 10px;
-      div {
-        width: 8px;
-        height: 20px;
-        margin-right: 10px;
-      }
-      span {
-        font-size: 20px;
-      }
-    }
-    .ele-width {
-      width: 100%;
-      height: 2px;
-    }
-  }
-  .form-line {
+.other {
+  background: #fff;
+  padding: 1px 17px;
+}
+
+.divider {
+  margin: 0px 0 20px;
+
+  .title {
     display: flex;
     align-items: center;
-    justify-content: space-between;
-    .line-select {
-      margin-left: 15px;
+    margin-bottom: 10px;
+
+    div {
+      width: 8px;
+      height: 20px;
+      margin-right: 10px;
     }
-  }
-  .rules_box {
-    margin: 0px 20px 20px 0;
-    .rules_box_tabs {
-      margin: 20px 0;
-      :deep(.el-form-item__content) {
-        > div {
-          display: inline-block;
-        }
-      }
+
+    span {
+      font-size: 20px;
     }
   }
-  .packingUnit {
-    width: 200px;
-    margin-right: 10px;
+
+  .ele-width {
+    width: 100%;
+    height: 2px;
+  }
+}
+
+.form-line {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+
+  .line-select {
+    margin-left: 15px;
   }
-  .lastPackingUnit {
-    width: 200px;
-    margin-left: 10px;
+}
+
+.rules_box {
+  margin: 0px 20px 20px 0;
+
+  .rules_box_tabs {
+    margin: 20px 0;
+
+    :deep(.el-form-item__content) {
+      >div {
+        display: inline-block;
+      }
+    }
   }
+}
+
+.packingUnit {
+  width: 200px;
+  margin-right: 10px;
+}
+
+.lastPackingUnit {
+  width: 200px;
+  margin-left: 10px;
+}
 </style>

+ 663 - 751
src/views/material/product/detail.vue

@@ -1,102 +1,64 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never">
-      <el-form
-        label-width="100px"
-        ref="manageForm"
-        :model="form"
-        :rules="rules"
-      >
+      <el-form label-width="100px" ref="manageForm" :model="form" :rules="rules">
         <headerTitle title="基本信息">
           <el-button @click="cancel">返回</el-button>
-          <el-button type="primary" @click="submit" :loading="loading"
-            >保存
+          <el-button type="primary" @click="submit" :loading="loading">保存
           </el-button>
         </headerTitle>
 
         <el-row :gutter="24">
           <el-col :span="8">
             <el-form-item label="分类" prop="categoryLevelName">
-              <el-input
-                v-model="form.categoryLevelName"
-                @click.native="openCategory"
-              />
+              <el-input v-model="form.categoryLevelName" @click.native="openCategory" />
             </el-form-item>
           </el-col>
 
           <el-col :span="8">
             <el-form-item label="编码" prop="code">
-              <el-input
-                v-if="ruleCode == '自定义'"
-                v-model="form.code"
-                readonly
-                @click.native="openCode"
-                :disabled="status == 0"
-              />
+              <el-input v-if="ruleCode == '自定义'" v-model="form.code" readonly @click.native="openCode"
+                :disabled="status == 0" />
               <el-input v-else v-model="form.code" :disabled="status == 0" />
             </el-form-item>
           </el-col>
 
+          <el-col :span="8">
+            <el-form-item label="图号/件号" prop="imgCode">
+              <el-input v-model="form.imgCode" />
+            </el-form-item>
+          </el-col>
           <el-col :span="8">
             <el-form-item label="名称" prop="name">
               <el-input v-model="form.name" />
             </el-form-item>
           </el-col>
-
           <el-col :span="8">
-            <el-form-item label="图号/件号" prop="imgCode">
-              <el-input v-model="form.imgCode" />
+            <el-form-item label="属性类型:" prop="attributeType">
+              <el-select v-model="form.attributeType" filterable class="ele-block">
+                <el-option v-for="item in attributeList" :key="item.value" :value="item.value"
+                  :label="item.label"></el-option>
+              </el-select>
             </el-form-item>
           </el-col>
 
           <el-col :span="8">
             <el-form-item label="生产类型" prop="produceType">
-              <el-select
-                style="width: 100%"
-                v-model="form.produceType"
-                filterable
-                multiple
-              >
-                <el-option
-                  v-for="item in dictList"
-                  :key="item.value"
-                  :value="item.value"
-                  :label="item.label"
-                ></el-option>
+              <el-select style="width: 100%" v-model="form.produceType" filterable multiple>
+                <el-option v-for="item in dictList" :key="item.value" :value="item.value"
+                  :label="item.label"></el-option>
               </el-select>
             </el-form-item>
           </el-col>
+
           <el-col :span="8">
-            <el-form-item label="属性类型:" prop="attributeType">
-            <el-select
-              v-model="form.attributeType"
-              filterable
-              class="ele-block"
-            >
-              <el-option
-                v-for="item in attributeList"
-                :key="item.value"
-                :value="item.value"
-                :label="item.label"
-              ></el-option>
-            </el-select>
-          </el-form-item>
-          </el-col>
-          <el-col
-            :span="8"
-            v-if="
-              [1, 23, 9, 28].includes(
-                Number(categoryLevelPathId || $route.query.rootTreeId)
-              )
-            "
-          >
+            <!-- v-if="
+            [1, 23, 9, 28].includes(
+              Number(categoryLevelPathId || $route.query.rootTreeId)
+            )
+          " -->
             <el-form-item label="加工类型" prop="isConsumable">
-              <el-select
-                v-model="form.isConsumable"
-                size="small"
-                style="width: 100%"
-                @change="changeConsumable"
-              >
+              <el-select v-model="form.isConsumable" style="width: 100%" @change="changeConsumable">
                 <el-option :value="1" label="批量"></el-option>
                 <el-option :value="0" label="单件"></el-option>
               </el-select>
@@ -122,35 +84,21 @@
 
           <el-col :span="8">
             <el-form-item label="计量单位" prop="measuringUnit">
-              <DictSelection
-                dictName="计量单位"
-                clearable
-                v-model="form.measuringUnit"
-                @change="changeUnit"
-              >
+              <DictSelection dictName="计量单位" clearable v-model="form.measuringUnit" @change="changeUnit">
               </DictSelection>
             </el-form-item>
           </el-col>
 
           <el-col :span="8">
             <el-form-item label="重量单位" prop="weightUnit">
-              <DictSelection
-                dictName="重量单位"
-                clearable
-                v-model="form.weightUnit"
-              >
+              <DictSelection dictName="重量单位" clearable v-model="form.weightUnit">
               </DictSelection>
             </el-form-item>
           </el-col>
 
           <el-col :span="8">
             <el-form-item label="包装单位" prop="packingUnit">
-              <DictSelection
-                dictName="包装单位"
-                clearable
-                v-model="form.packingUnit"
-                @change="changeUnit"
-              >
+              <DictSelection dictName="包装单位" clearable v-model="form.packingUnit" @change="changeUnit">
               </DictSelection>
             </el-form-item>
           </el-col>
@@ -158,18 +106,9 @@
           <el-col :span="8">
             <el-form-item label="体积">
               <div class="form-line">
-                <el-input
-                  v-model="form.volume"
-                  style="width: calc(100% - 100px)"
-                  
-                />
+                <el-input v-model="form.volume" style="width: calc(100% - 100px)" />
                 <!-- @input="handleInput1" -->
-                <DictSelection
-                  dictName="体积单位"
-                  clearable
-                  v-model="form.volumeUnit"
-                  style="width: 100px"
-                >
+                <DictSelection dictName="体积单位" clearable v-model="form.volumeUnit" style="width: 100px">
                 </DictSelection>
               </div>
             </el-form-item>
@@ -194,17 +133,8 @@
           <el-col :span="8">
             <el-form-item label="级别">
               <template>
-                <el-select
-                  style="width: 100%"
-                  v-model="form.level"
-                  placeholder="请选择"
-                >
-                  <el-option
-                    v-for="item in levelOptions"
-                    :label="item.label"
-                    :value="item.value"
-                    :key="item.value"
-                  >
+                <el-select style="width: 100%" v-model="form.level" placeholder="请选择">
+                  <el-option v-for="item in levelOptions" :label="item.label" :value="item.value" :key="item.value">
                   </el-option>
                 </el-select>
               </template>
@@ -215,45 +145,27 @@
             <el-form-item :label="f.label">
               <template>
                 <div class="form-line">
-                  <component
-                    :is="f.tagType"
-                    v-model="form.extField[f.prop]"
-                    :disabled="f.extAttribute?.disabled"
-                    clearable
-                    :isProhibit="
-                      f.modelType == 'dict' ? f.extAttribute?.disabled : false
-                    "
-                    :dictName="f.modelType == 'dict' ? f.label : ''"
-                  ></component>
+                  <component :is="f.tagType" v-model="form.extField[f.prop]" :disabled="f.extAttribute?.disabled"
+                    clearable :isProhibit="f.modelType == 'dict' ? f.extAttribute?.disabled : false
+                      " :dictName="f.modelType == 'dict' ? f.label : ''"></component>
                 </div>
               </template>
             </el-form-item>
           </el-col>
 
-          
+
         </el-row>
       </el-form>
     </el-card>
 
     <!--  自定义编码 -->
-    <CodeDialog
-      ref="codeRefs"
-      v-if="codeShow"
-      @close="codeShow = false"
-      @chooseCode="chooseCode"
-    />
+    <CodeDialog ref="codeRefs" v-if="codeShow" @close="codeShow = false" @chooseCode="chooseCode" />
     <!-- 分类选择弹窗 -->
     <CategoryDialog ref="categoryRefs" @chooseCategory="confirmCategory" />
     <!-- 仓储配置 -->
-    <WarehouseInfo
-      ref="warehouseRefs"
-      v-if="isShow"
-      :form="categoryWms"
-      :measuringUnit="form.measuringUnit"
-      :packingUnit="form.packingUnit"
-      :packageDispositionVOList="packageDispositionVOList"
-      @change="changePackagingSpecification"
-    />
+    <WarehouseInfo ref="warehouseRefs" v-if="isShow" :form="categoryWms" :measuringUnit="form.measuringUnit"
+      :packingUnit="form.packingUnit" :packageDispositionVOList="packageDispositionVOList"
+      @change="changePackagingSpecification" />
     <!-- 销售配置 -->
     <SalesInfos ref="salesRefs" :form="categorySales" />
     <!-- 采购信息 -->
@@ -273,697 +185,697 @@
     <!-- 备注信息 -->
     <RemarkInfo ref="remarkRefs" :form="remarkform" />
     <!-- 关联信息 -->
-    <linkMsg
-      ref="linkMsgRef"
-      :id="$route.query.id"
-      :categoryLevelId="form.categoryLevelId"
-      :categoryLevelGroupId="form.categoryLevelGroupId"
-    />
+    <linkMsg ref="linkMsgRef" :id="$route.query.id" :categoryLevelId="form.categoryLevelId"
+      :categoryLevelGroupId="form.categoryLevelGroupId" />
   </div>
 </template>
 
 <script>
-  import SalesInfos from './components/SalesInfos.vue';
-  import PurchasingInfo from './components/PurchasingInfo.vue';
-  import GroupDialog from './components/GroupDialog.vue';
-  import CodeDialog from './components/codeDialog.vue';
-  import CategoryDialog from './components/CategoryDialog.vue';
-  import WarehouseInfo from './components/WarehouseInfo.vue';
-  import ProcureInfo from './components/ProcureInfo.vue';
-  import ProductionInfo from './components/ProductionInfo.vue';
-  import PlanInfo from './components/PlanInfo.vue';
-  import SalesInfo from './components/SalesInfo.vue';
-  import QualityInfo from './components/QualityInfo.vue';
-  import BoatInfo from './components/BoatInfo.vue';
-  import TurnoverInfo from './components/TurnoverInfo.vue';
-  import MoldInfo from './components/MoldInfo.vue';
-  import RemarkInfo from './components/RemarkInfo.vue';
-  import deptSelect from '@/components/CommomSelect/dept-select.vue';
-  import personSelect from '@/components/CommomSelect/person-select.vue';
-  import linkMsg from './components/link-msg.vue';
-  import { getDetails } from '@/api/classifyManage/itemInformation';
-  import { getByCode } from '@/api/system/dictionary-data';
-  import { getCode, rootCategoryCode, fieldModel } from '@/api/codeManagement';
-
-  import { addMaterial } from '@/api/material/list.js';
-  import { deepClone } from '@/utils/index';
-  import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
-
-  export default {
-    name: 'product',
-    components: {
-      SalesInfos,
-      PurchasingInfo,
-      linkMsg,
-      GroupDialog,
-      deptSelect,
-      personSelect,
-      WarehouseInfo,
-      ProcureInfo,
-      ProductionInfo,
-      PlanInfo,
-      SalesInfo,
-      QualityInfo,
-      BoatInfo,
-      TurnoverInfo,
-      MoldInfo,
-      RemarkInfo,
-      CategoryDialog,
-      CodeDialog
-    },
-    data() {
-      return {
-        isShow: true,
-        packagingSpecificationList: [],
-        loading: false,
-        levelOptions: [
-          {
-            label: '特级',
-            value: '特级'
-          },
-          {
-            label: '一级',
-            value: '一级'
-          },
-          {
-            label: '二级',
-            value: '二级'
-          },
-          {
-            label: '三级',
-            value: '三级'
-          }
-        ],
-        form: {
-          categoryLevelGroupName: '',
-          categoryLevelName: '',
-          isConsumable: 1,
-          measuringUnit: '',
-          attributeType:'',
-          weightUnit: '',
-          packingUnit: '',
-
-          extField: {}
-        },
-        attributeList: [
+import SalesInfos from './components/SalesInfos.vue';
+import PurchasingInfo from './components/PurchasingInfo.vue';
+import GroupDialog from './components/GroupDialog.vue';
+import CodeDialog from './components/codeDialog.vue';
+import CategoryDialog from './components/CategoryDialog.vue';
+import WarehouseInfo from './components/WarehouseInfo.vue';
+import ProcureInfo from './components/ProcureInfo.vue';
+import ProductionInfo from './components/ProductionInfo.vue';
+import PlanInfo from './components/PlanInfo.vue';
+import SalesInfo from './components/SalesInfo.vue';
+import QualityInfo from './components/QualityInfo.vue';
+import BoatInfo from './components/BoatInfo.vue';
+import TurnoverInfo from './components/TurnoverInfo.vue';
+import MoldInfo from './components/MoldInfo.vue';
+import RemarkInfo from './components/RemarkInfo.vue';
+import deptSelect from '@/components/CommomSelect/dept-select.vue';
+import personSelect from '@/components/CommomSelect/person-select.vue';
+import linkMsg from './components/link-msg.vue';
+import { getDetails } from '@/api/classifyManage/itemInformation';
+import { getByCode } from '@/api/system/dictionary-data';
+import { getCode, rootCategoryCode, fieldModel } from '@/api/codeManagement';
+
+import { addMaterial } from '@/api/material/list.js';
+import { deepClone } from '@/utils/index';
+import { finishPageTab, reloadPageTab } from '@/utils/page-tab-util';
+
+export default {
+  name: 'product',
+  components: {
+    SalesInfos,
+    PurchasingInfo,
+    linkMsg,
+    GroupDialog,
+    deptSelect,
+    personSelect,
+    WarehouseInfo,
+    ProcureInfo,
+    ProductionInfo,
+    PlanInfo,
+    SalesInfo,
+    QualityInfo,
+    BoatInfo,
+    TurnoverInfo,
+    MoldInfo,
+    RemarkInfo,
+    CategoryDialog,
+    CodeDialog
+  },
+  data() {
+    return {
+      isShow: true,
+      packagingSpecificationList: [],
+      loading: false,
+      levelOptions: [
         {
-            label: '总装',
-            value: 1
-          },
-          {
-            label: '部件',
-            value: 2
-          },
-          {
-            label: '零件',
-            value: 3
-          },{
-            label: '原材料',
-            value: 4
-          }
-        ],
-        remarkform: {
-          remarkAttach: []
+          label: '特级',
+          value: '特级'
         },
-        categorySales: {},
-        categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
-        categoryAps: {},
-        categoryMes: {},
-        categoryMold: {},
-        categoryPallet: {},
-        categoryQms: {
-          isComeCheck: '1'
+        {
+          label: '一级',
+          value: '一级'
         },
-        categoryVehicle: {},
-        categoryWms: {
-          isUnpack: 1,
-          isWarn: 1,
-          inventoryMode: ''
+        {
+          label: '二级',
+          value: '二级'
         },
-        packageDispositionVOList: [],
-        categoryLevelPathId: null,
-
-        dictList: [],
-
-        fileList: [],
-        // 表单验证规则
-        rules: {
-          categoryLevelGroupName: [
-            { required: true, message: '请选择所属物料组', trigger: 'change' }
-          ],
-          code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
-          name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
-          produceType: [
-            { required: true, message: '请选择生产类型', trigger: 'change' }
-          ],
-          attributeType: [
-            { required: true, message: '请选择属性类型', trigger: 'change' }
-          ],
-          categoryLevelName: [
-            { required: true, message: '请选择所属分类', trigger: 'change' }
-          ],
-          measuringUnit: [
-            { required: true, message: '请选择计量单位', trigger: 'change' }
-          ],
-
-          weightUnit: [
-            { required: true, message: '请选择重量单位', trigger: 'change' }
-          ],
-
-          packingUnit: [
-            { required: true, message: '请选择包装单位', trigger: 'change' }
-          ],
-
-          netWeight: [
-            { required: true, message: '请输入净重', trigger: 'blur' }
-          ]
+        {
+          label: '三级',
+          value: '三级'
+        }
+      ],
+      form: {
+        categoryLevelGroupName: '',
+        categoryLevelName: '',
+        isConsumable: 1,
+        measuringUnit: '',
+        attributeType: '',
+        weightUnit: '',
+        packingUnit: '',
+
+        extField: {}
+      },
+      attributeList: [
+        {
+          label: '总装',
+          value: 1
         },
-        PathInfo: {},
-        id: null,
-
-        ruleCode: null,
-        codeShow: false,
-
-        status: null
-      };
-    },
-    watch: {
-      '$route.query.id': {
-        handler(id) {
-          if (id) {
-            this._getDetails();
-          } else {
-            this.form = {
-              categoryLevelGroupName: '',
-              // categoryLevelName: '',
-              isConsumable: 1,
-              measuringUnit: '',
-              weightUnit: '',
-              packingUnit: '',
-              extField: {}
-            };
-            this.categorySales = {};
-            this.purchaseInfo = {};
-            this.remarkform = {
-              remarkAttach: []
-            };
-            this.categoryAps = {};
-            this.categoryMes = {};
-            this.categoryMold = {};
-            this.categoryPallet = {};
-            this.categoryQms = {};
-            this.categoryVehicle = {};
-            this.categoryWms = {
-              isUnpack: 1,
-              isWarn: 1,
-              inventoryMode: this.form.isConsumable
-            };
-            this.packageDispositionVOList = [];
-            this.categoryLevelPathId = null;
-
-            this.dictList = [];
-
-            this.fileList = [];
-          }
+        {
+          label: '部件',
+          value: 2
         },
-        deep: true,
-        immediate: true
-      }
-    },
-    async activated() {
-      this.status = this.$route.query.status;
-      this.form.categoryLevelId = this.$route.query.categoryLevelId;
-      this.form.categoryLevelName = this.$route.query.categoryLevelName;
-      this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
-      this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
-
-      this.ruleCode = this.$route.query.ruleCode;
-      if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
-        const code = await getCode(this.ruleCode);
-        this.$set(this.form, 'code', code);
-      }
-
-      this.getFieldModel();
-
-      this.getDictList('productionType');
-    },
-    async created() {
-      //新增
-
-      this.$set(
-        this.form,
-        'categoryLevelId',
-        this.$route.query.categoryLevelId
-      );
-      this.$set(
-        this.form,
-        'categoryLevelName',
-        this.$route.query.categoryLevelName
-      );
-      this.$set(
-        this.form,
-        'categoryLevelPath',
-        this.$route.query.categoryLevelPath
-      );
-      this.$set(
-        this.form,
-        'categoryLevelPathId',
-        this.$route.query.categoryLevelPathId
-      );
-      this.status = this.$route.query.status;
-      this.ruleCode = this.$route.query.ruleCode;
-      if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
-        const code = await getCode(this.ruleCode);
-        this.$set(this.form, 'code', code);
-      }
-
-      this.getFieldModel();
-
-      this.getDictList('productionType');
-    },
-    methods: {
-      handleInput(value) {
-        this.form.volume = this.$handleInputPublicHasPoint(value);
-      },
-      handleInput2(value) {
-        this.form.roughWeight = this.$handleInputPublicHasPoint(value);
-      },
-      handleInput3(value) {
-        this.form.netWeight = this.$handleInputPublicHasPoint(value);
-      },
-      changeConsumable() {
-        this.categoryWms.inventoryMode = this.form.isConsumable;
-      },
-      changeUnit() {
-        if (this.$route.query.id == '' || this.$route.query.id == null) {
-          if (this.form.measuringUnit) {
-            this.categoryPurchase.measuringUnit = this.form.measuringUnit;
-            console.log(this.categoryPurchase.measuringUnit, '采购信息');
-            // 如果有计量单位和包装单位 默认添加包装组
-            if (this.form.packingUnit) {
-              this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
-            }
-          }
-        } else {
-          this.isShow = false;
-          if (this.form.measuringUnit) {
-            this.categoryPurchase.measuringUnit = this.form.measuringUnit;
-
-            if (this.form.packingUnit) {
-              console.log(this.form.measuringUnit, 'this.form.measuringUnit');
-              console.log(this.form.packingUnit, 'this.form.packingUnit');
-            }
-          }
-          this.isShow = true;
+        {
+          label: '零件',
+          value: 3
+        }, {
+          label: '原材料',
+          value: 4
         }
+      ],
+      remarkform: {
+        remarkAttach: []
+      },
+      categorySales: {},
+      categoryPurchase: { purchaseMultiplier: 1, measuringUnit: '' },
+      categoryAps: {},
+      categoryMes: {},
+      categoryMold: {},
+      categoryPallet: {},
+      categoryQms: {
+        isComeCheck: '1'
       },
-      changePackagingSpecification(val) {
-        console.log('changePackagingSpecification---', val);
-        this.packagingSpecificationList = val;
+      categoryVehicle: {},
+      categoryWms: {
+        isUnpack: 1,
+        isWarn: 1,
+        inventoryMode: ''
       },
-      async _getDetails() {
-        const data = await getDetails(this.$route.query.id);
-        const info = deepClone(data);
+      packageDispositionVOList: [],
+      categoryLevelPathId: null,
 
-        this.form = {
-          ...info.category
-        };
+      dictList: [],
 
-        // if (this.form.measuringUnit && this.form.packingUnit) {
-        //   this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
-        // }
-        this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
-        this.judgeSet(info);
+      fileList: [],
+      // 表单验证规则
+      rules: {
+        categoryLevelGroupName: [
+          { required: true, message: '请选择所属物料组', trigger: 'change' }
+        ],
+        code: [{ required: true, message: '请输入编码', trigger: 'blur' }],
+        name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
+        produceType: [
+          { required: true, message: '请选择生产类型', trigger: 'change' }
+        ],
+        attributeType: [
+          { required: true, message: '请选择属性类型', trigger: 'change' }
+        ],
+        categoryLevelName: [
+          { required: true, message: '请选择所属分类', trigger: 'change' }
+        ],
+        measuringUnit: [
+          { required: true, message: '请选择计量单位', trigger: 'change' }
+        ],
 
-        if (this.status == 1) {
-          rootCategoryCode(this.categoryLevelPathId).then((res) => {
-            this.$set(this.form, 'code', res);
-          });
+        weightUnit: [
+          { required: true, message: '请选择重量单位', trigger: 'change' }
+        ],
 
-          this.form.createTime = null;
-        }
+        packingUnit: [
+          { required: true, message: '请选择包装单位', trigger: 'change' }
+        ],
 
-        this.$forceUpdate();
+        netWeight: [
+          { required: true, message: '请输入净重', trigger: 'blur' }
+        ]
       },
-      // 判断字段类型并赋值
-      judgeSet(info) {
-        console.log('info-------', info);
-
-        if (typeof info.categoryAps == 'string') {
-          this.categoryAps = {};
+      PathInfo: {},
+      id: null,
+
+      ruleCode: null,
+      codeShow: false,
+
+      status: null
+    };
+  },
+  watch: {
+    '$route.query.id': {
+      handler(id) {
+        if (id) {
+          this._getDetails();
         } else {
-          this.categoryAps = info.categoryAps;
-        }
-        if (typeof info.categoryMes == 'string') {
+          this.form = {
+            categoryLevelGroupName: '',
+            // categoryLevelName: '',
+            isConsumable: 1,
+            measuringUnit: '',
+            weightUnit: '',
+            packingUnit: '',
+            extField: {}
+          };
+          this.categorySales = {};
+          this.purchaseInfo = {};
+          this.remarkform = {
+            remarkAttach: []
+          };
+          this.categoryAps = {};
           this.categoryMes = {};
-        } else {
-          this.categoryMes = info.categoryMes;
-        }
-        if (typeof info.categoryMold == 'string') {
           this.categoryMold = {};
-        } else {
-          this.categoryMold = info.categoryMold;
-        }
-        if (typeof info.categoryPallet == 'string') {
           this.categoryPallet = {};
-        } else {
-          this.categoryPallet = info.categoryPallet;
-        }
-        if (typeof info.categorySales == 'string') {
-          this.categorySales = {};
-        } else {
-          this.categorySales = info.categorySales;
-        }
-
-        if (typeof info.categoryPurchase == 'string') {
-          this.categoryPurchase = {};
-        } else {
-          this.categoryPurchase = info.categoryPurchase;
-        }
-        if (typeof info.categoryQms == 'string') {
           this.categoryQms = {};
-        } else {
-          this.categoryQms = info.categoryQms;
-        }
-        if (typeof info.categoryVehicle == 'string') {
           this.categoryVehicle = {};
-        } else {
-          this.categoryVehicle = info.categoryVehicle;
-        }
-        if (typeof info.categoryWms == 'string') {
-          this.categoryWms = {};
-        } else {
-          this.categoryWms = info.categoryWms;
-        }
-        if (typeof info.packageDispositionVOList == 'string') {
+          this.categoryWms = {
+            isUnpack: 1,
+            isWarn: 1,
+            inventoryMode: this.form.isConsumable
+          };
           this.packageDispositionVOList = [];
-        } else {
-          this.packageDispositionVOList = info.packageDispositionVOList;
-          console.log(
-            'this.packageDispositionVOList---!!!----',
-            this.packageDispositionVOList
-          );
-        }
-      },
-
-      getFieldModel() {
-        fieldModel({ relevance: 't_main_category' }).then((res) => {
-          this.fileList = res;
+          this.categoryLevelPathId = null;
 
-          this.fileList.forEach((f) => {
-            this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
-          });
-        });
-      },
+          this.dictList = [];
 
-      // 确定分类
-      async confirmCategory(node, title, PathInfo, ruleCode) {
-        if (this.status != 0) {
-          this.$set(this.form, 'code', null);
+          this.fileList = [];
         }
-        this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
+      },
+      deep: true,
+      immediate: true
+    }
+  },
+  async activated() {
+    this.status = this.$route.query.status;
+    this.form.categoryLevelId = this.$route.query.categoryLevelId;
+    this.form.categoryLevelName = this.$route.query.categoryLevelName;
+    this.form.categoryLevelPath = this.$route.query.categoryLevelPath;
+    this.form.categoryLevelPathId = this.$route.query.categoryLevelPathId;
+
+    this.ruleCode = this.$route.query.ruleCode;
+    if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
+      const code = await getCode(this.ruleCode);
+      this.$set(this.form, 'code', code);
+    }
 
-        if (title == '选择产品分类') {
-          this.$set(this.form, 'productCategoryLevelName', node.name);
-          this.$set(this.form, 'productCategoryLevelId', node.id);
-        } else {
-          this.$set(this.form, 'categoryLevelName', node.name);
-          this.$set(this.form, 'categoryLevelId', node.id);
-          this.$set(this.form, 'categoryLevelPath', node.name);
-          this.$set(this.form, 'categoryLevelPathId', node.id);
-          this.PathInfo = PathInfo;
+    this.getFieldModel();
+
+    this.getDictList('productionType');
+  },
+  async created() {
+    //新增
+
+    this.$set(
+      this.form,
+      'categoryLevelId',
+      this.$route.query.categoryLevelId
+    );
+    this.$set(
+      this.form,
+      'categoryLevelName',
+      this.$route.query.categoryLevelName
+    );
+    this.$set(
+      this.form,
+      'categoryLevelPath',
+      this.$route.query.categoryLevelPath
+    );
+    this.$set(
+      this.form,
+      'categoryLevelPathId',
+      this.$route.query.categoryLevelPathId
+    );
+    this.status = this.$route.query.status;
+    this.ruleCode = this.$route.query.ruleCode;
+    if (this.ruleCode && this.ruleCode != '自定义' && this.status != 0) {
+      const code = await getCode(this.ruleCode);
+      this.$set(this.form, 'code', code);
+    }
 
-          this.ruleCode = ruleCode;
+    this.getFieldModel();
 
-          if (ruleCode && ruleCode != '自定义' && this.status != 0) {
-            const code = await getCode(ruleCode);
-            this.$set(this.form, 'code', code);
+    this.getDictList('productionType');
+  },
+  methods: {
+    handleInput(value) {
+      this.form.volume = this.$handleInputPublicHasPoint(value);
+    },
+    handleInput2(value) {
+      this.form.roughWeight = this.$handleInputPublicHasPoint(value);
+    },
+    handleInput3(value) {
+      this.form.netWeight = this.$handleInputPublicHasPoint(value);
+    },
+    changeConsumable() {
+      this.categoryWms.inventoryMode = this.form.isConsumable;
+    },
+    changeUnit() {
+      if (this.$route.query.id == '' || this.$route.query.id == null) {
+        if (this.form.measuringUnit) {
+          this.categoryPurchase.measuringUnit = this.form.measuringUnit;
+          console.log(this.categoryPurchase.measuringUnit, '采购信息');
+          // 如果有计量单位和包装单位 默认添加包装组
+          if (this.form.packingUnit) {
+            this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+          }
+        }
+      } else {
+        this.isShow = false;
+        if (this.form.measuringUnit) {
+          this.categoryPurchase.measuringUnit = this.form.measuringUnit;
+
+          if (this.form.packingUnit) {
+            console.log(this.form.measuringUnit, 'this.form.measuringUnit');
+            console.log(this.form.packingUnit, 'this.form.packingUnit');
+            if (this.packageDispositionVOList.length === 0) {
+              console.log('如果没有包装组');
+              this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+            }
           }
         }
+        this.isShow = true;
+      }
+    },
+    changePackagingSpecification(val) {
+      console.log('changePackagingSpecification---', val);
+      this.packagingSpecificationList = val;
+    },
+    async _getDetails() {
+      const data = await getDetails(this.$route.query.id);
+      const info = deepClone(data);
 
-        this.$forceUpdate();
-      },
+      this.form = {
+        ...info.category
+      };
 
-      async getDictList(code) {
-        let { data: res } = await getByCode(code);
-        this.dictList = res.map((item) => {
-          let values = Object.keys(item);
-          return {
-            value: Number(values[0]),
-            label: item[values[0]]
-          };
+      // if (this.form.measuringUnit && this.form.packingUnit) {
+      //   this.$refs.warehouseRefs.defaultBuild(this.form.packingUnit);
+      // }
+      this.categoryLevelPathId = info.category.categoryLevelPathIdParent;
+      this.judgeSet(info);
+
+      if (this.status == 1) {
+        rootCategoryCode(this.categoryLevelPathId).then((res) => {
+          this.$set(this.form, 'code', res);
         });
-      },
 
-      openCategory() {
-        this.$refs.categoryRefs.open();
-      },
+        this.form.createTime = null;
+      }
 
-      openCode() {
-        this.codeShow = true;
-      },
+      this.$forceUpdate();
+    },
+    // 判断字段类型并赋值
+    judgeSet(info) {
+      console.log('info-------', info);
+
+      if (typeof info.categoryAps == 'string') {
+        this.categoryAps = {};
+      } else {
+        this.categoryAps = info.categoryAps;
+      }
+      if (typeof info.categoryMes == 'string') {
+        this.categoryMes = {};
+      } else {
+        this.categoryMes = info.categoryMes;
+      }
+      if (typeof info.categoryMold == 'string') {
+        this.categoryMold = {};
+      } else {
+        this.categoryMold = info.categoryMold;
+      }
+      if (typeof info.categoryPallet == 'string') {
+        this.categoryPallet = {};
+      } else {
+        this.categoryPallet = info.categoryPallet;
+      }
+      if (typeof info.categorySales == 'string') {
+        this.categorySales = {};
+      } else {
+        this.categorySales = info.categorySales;
+      }
 
-      chooseCode(code) {
-        this.$set(this.form, 'code', code);
-        this.codeShow = false;
-        this.$forceUpdate();
-      },
+      if (typeof info.categoryPurchase == 'string') {
+        this.categoryPurchase = {};
+      } else {
+        this.categoryPurchase = info.categoryPurchase;
+      }
+      if (typeof info.categoryQms == 'string') {
+        this.categoryQms = {};
+      } else {
+        this.categoryQms = info.categoryQms;
+      }
+      if (typeof info.categoryVehicle == 'string') {
+        this.categoryVehicle = {};
+      } else {
+        this.categoryVehicle = info.categoryVehicle;
+      }
+      if (typeof info.categoryWms == 'string') {
+        this.categoryWms = {};
+      } else {
+        this.categoryWms = info.categoryWms;
+      }
+      if (typeof info.packageDispositionVOList == 'string') {
+        this.packageDispositionVOList = [];
+      } else {
+        this.packageDispositionVOList = info.packageDispositionVOList;
+        console.log(
+          'this.packageDispositionVOList---!!!----',
+          this.packageDispositionVOList
+        );
+      }
+    },
 
-      cancel() {
-        // finishPageTab();
-        // this.$router.go(-1);
-        if (this.$route.query.rootTreeId == 9) {
-          this.$router.push({
-            path: '/product/oneProduct',
-            query: {
-              categoryLevelId: this.form.categoryLevelId
-            }
-          });
-        } else {
-          this.$router.push({
-            path: '/material/product',
-            query: {
-              categoryLevelId: this.form.categoryLevelId
-            }
-          });
+    getFieldModel() {
+      fieldModel({ relevance: 't_main_category' }).then((res) => {
+        this.fileList = res;
+
+        this.fileList.forEach((f) => {
+          this.$set(this.form.extField, f.prop, ''); // 初始化动态模型属性
+        });
+      });
+    },
+
+    // 确定分类
+    async confirmCategory(node, title, PathInfo, ruleCode) {
+      if (this.status != 0) {
+        this.$set(this.form, 'code', null);
+      }
+      this.categoryLevelPathId = PathInfo.categoryLevelPathId.split(',')[0];
+
+      if (title == '选择产品分类') {
+        this.$set(this.form, 'productCategoryLevelName', node.name);
+        this.$set(this.form, 'productCategoryLevelId', node.id);
+      } else {
+        this.$set(this.form, 'categoryLevelName', node.name);
+        this.$set(this.form, 'categoryLevelId', node.id);
+        this.$set(this.form, 'categoryLevelPath', node.name);
+        this.$set(this.form, 'categoryLevelPathId', node.id);
+        this.PathInfo = PathInfo;
+
+        this.ruleCode = ruleCode;
+
+        if (ruleCode && ruleCode != '自定义' && this.status != 0) {
+          const code = await getCode(ruleCode);
+          this.$set(this.form, 'code', code);
         }
-      },
+      }
 
-      // 保存
-      submit() {
-        this.$refs.manageForm.validate(async (valid) => {
-          let productionValid = await this.$refs.productionRefs.getFormValid();
-          let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
+      this.$forceUpdate();
+    },
 
-          if (!valid || !productionValid || !warehouseValid) {
-            return false;
-          }
+    async getDictList(code) {
+      let { data: res } = await getByCode(code);
+      this.dictList = res.map((item) => {
+        let values = Object.keys(item);
+        return {
+          value: Number(values[0]),
+          label: item[values[0]]
+        };
+      });
+    },
 
-          let packageDispositionVOList = [];
-          if (this.packagingSpecificationList.length > 0) {
-            packageDispositionVOList = this.packagingSpecificationList.map(
-              (item) => {
-                let obj = {
-                  code: item.code,
-                  name: item.name
-                };
-                return [
-                  {
-                    ...obj,
-                    id: item.id0,
-                    sort: 0,
-                    status: item.status,
-                    packageCell: 1,
-                    packageUnit: item.packageUnit,
-                    conversionUnit: item.packageUnit
-                  },
-                  {
-                    ...obj,
-                    id: item.id1,
-                    sort: 1,
-                    packageCell: item.minPackageCell,
-                    packageUnit: item.packageUnit,
-                    conversionUnit: item.minConversionUnit,
-                    status: item.status
-                  },
-                  {
-                    ...obj,
-                    id: item.id2,
-                    sort: 2,
-                    packageCell: item.inPackageCell,
-                    packageUnit: item.minConversionUnit,
-                    conversionUnit: item.inConversionUnit,
-                    status: item.status
-                  },
-                  {
-                    ...obj,
-                    id: item.id3,
-                    sort: 3,
-                    packageCell: item.outPackageCell,
-                    packageUnit: item.inConversionUnit,
-                    conversionUnit: item.outConversionUnit,
-                    status: item.status
-                  }
-                ];
-              }
-            );
-            let packagingSpecificationList =
-              this.packagingSpecificationList.filter(
-                (item) => item.status == 1
-              );
-            this.form.extField.packingSpecification = packagingSpecificationList
-              .map((item) => {
-                return [
-                  `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
-                  `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
-                  `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
-                ];
-              })
-              .flat()
-              .join(',');
-          } else {
-            this.form.extField.packingSpecification = '';
-          }
+    openCategory() {
+      this.$refs.categoryRefs.open();
+    },
 
-          this.loading = true;
-          // const imgList = this.remarkform.imgList;
-          // const arr = [];
-          // if (imgList.length) {
-          //   imgList.map((item) => {
-          //     arr.push(item.storePath);
-          //   });
-          //   this.form.remarkAttach = arr.join(',');
-          // }
-          // this.form.remark = this.remarkform.remark
-          //   ? this.remarkform.remark
-          //   : '';
-
-          const data = {
-            categorySales: this.categorySales,
-            categoryPurchase: this.categoryPurchase,
-            categoryWms: this.categoryWms,
-            categoryAps: this.categoryAps,
-            categoryMes: this.categoryMes,
-            categoryMold: this.categoryMold,
-            categoryPallet: this.categoryPallet,
-            categoryQms: this.categoryQms,
-            categoryVehicle: this.categoryVehicle,
-            category: {
-              ...this.form,
-              ...this.remarkform,
-              ...this.PathInfo
-            },
-            packageDispositionVOList: packageDispositionVOList.flat()
-          };
+    openCode() {
+      this.codeShow = true;
+    },
 
-          if (this.$route.query.status == 1) {
-            data.categorySales.id = null;
-            data.categoryPurchase.id = null;
-            data.category.id = null;
-            data.categoryWms.id = null;
-            data.categoryAps.id = null;
-            data.categoryMes.id = null;
-            data.categoryMold.id = null;
-            data.categoryPallet.id = null;
-            data.categoryQms.id = null;
-            data.categoryVehicle.id = null;
-            data.packageDispositionVOList = data.packageDispositionVOList.map(
-              (item) => {
-                return {
-                  ...item,
-                  id: null
-                };
-              }
-            );
+    chooseCode(code) {
+      this.$set(this.form, 'code', code);
+      this.codeShow = false;
+      this.$forceUpdate();
+    },
+
+    cancel() {
+      // finishPageTab();
+      // this.$router.go(-1);
+      if (this.$route.query.rootTreeId == 9) {
+        this.$router.push({
+          path: '/product/oneProduct',
+          query: {
+            categoryLevelId: this.form.categoryLevelId
+          }
+        });
+      } else {
+        this.$router.push({
+          path: '/material/product',
+          query: {
+            categoryLevelId: this.form.categoryLevelId
           }
-          console.log('保存', data);
-          addMaterial(data)
-            .then((msg) => {
-              this.loading = false;
-              this.$message.success(msg);
-              // reloadPageTab({ fullPath: '/material/product' });
-              // this.$router.go(-1);
-              this.cancel();
-              // if (this.$route.query.rootTreeId == 9) {
-              //   this.$router.push({
-              //     path: '/product/oneProduct',
-              //     query: {
-              //       categoryLevelId: this.form.categoryLevelId
-              //     }
-              //   });
-              // } else {
-              //   this.$router.push({
-              //     path: '/material/product',
-              //     query: {
-              //       categoryLevelId: this.form.categoryLevelId
-              //     }
-              //   });
-              // }
-            })
-            .catch((e) => {
-              this.loading = false;
-            });
         });
       }
+    },
+
+    // 保存
+    submit() {
+      this.$refs.manageForm.validate(async (valid) => {
+        let productionValid = await this.$refs.productionRefs.getFormValid();
+        let warehouseValid = await this.$refs.warehouseRefs.getFormValid();
+
+        if (!valid || !productionValid || !warehouseValid) {
+          return false;
+        }
+
+        let packageDispositionVOList = [];
+        if (this.packagingSpecificationList.length > 0) {
+          packageDispositionVOList = this.packagingSpecificationList.map(
+            (item) => {
+              let obj = {
+                code: item.code,
+                name: item.name
+              };
+              return [
+                {
+                  ...obj,
+                  id: item.id0,
+                  sort: 0,
+                  status: item.status,
+                  packageCell: 1,
+                  packageUnit: item.packageUnit,
+                  conversionUnit: item.packageUnit
+                },
+                {
+                  ...obj,
+                  id: item.id1,
+                  sort: 1,
+                  packageCell: item.minPackageCell,
+                  packageUnit: item.packageUnit,
+                  conversionUnit: item.minConversionUnit,
+                  status: item.status
+                },
+                {
+                  ...obj,
+                  id: item.id2,
+                  sort: 2,
+                  packageCell: item.inPackageCell,
+                  packageUnit: item.minConversionUnit,
+                  conversionUnit: item.inConversionUnit,
+                  status: item.status
+                },
+                {
+                  ...obj,
+                  id: item.id3,
+                  sort: 3,
+                  packageCell: item.outPackageCell,
+                  packageUnit: item.inConversionUnit,
+                  conversionUnit: item.outConversionUnit,
+                  status: item.status
+                }
+              ];
+            }
+          );
+          let packagingSpecificationList =
+            this.packagingSpecificationList.filter(
+              (item) => item.status == 1
+            );
+          this.form.extField.packingSpecification = packagingSpecificationList
+            .map((item) => {
+              return [
+                `${item.minPackageCell}${item.packageUnit}/${item.minConversionUnit}`,
+                `${item.inPackageCell}${item.minConversionUnit}/${item.inConversionUnit}`,
+                `${item.outPackageCell}${item.inConversionUnit}/${item.outConversionUnit}`
+              ];
+            })
+            .flat()
+            .join(',');
+        } else {
+          this.form.extField.packingSpecification = '';
+        }
+
+        this.loading = true;
+        // const imgList = this.remarkform.imgList;
+        // const arr = [];
+        // if (imgList.length) {
+        //   imgList.map((item) => {
+        //     arr.push(item.storePath);
+        //   });
+        //   this.form.remarkAttach = arr.join(',');
+        // }
+        // this.form.remark = this.remarkform.remark
+        //   ? this.remarkform.remark
+        //   : '';
+
+        const data = {
+          categorySales: this.categorySales,
+          categoryPurchase: this.categoryPurchase,
+          categoryWms: this.categoryWms,
+          categoryAps: this.categoryAps,
+          categoryMes: this.categoryMes,
+          categoryMold: this.categoryMold,
+          categoryPallet: this.categoryPallet,
+          categoryQms: this.categoryQms,
+          categoryVehicle: this.categoryVehicle,
+          category: {
+            ...this.form,
+            ...this.remarkform,
+            ...this.PathInfo
+          },
+          packageDispositionVOList: packageDispositionVOList.flat()
+        };
+
+        if (this.$route.query.status == 1) {
+          data.categorySales.id = null;
+          data.categoryPurchase.id = null;
+          data.category.id = null;
+          data.categoryWms.id = null;
+          data.categoryAps.id = null;
+          data.categoryMes.id = null;
+          data.categoryMold.id = null;
+          data.categoryPallet.id = null;
+          data.categoryQms.id = null;
+          data.categoryVehicle.id = null;
+          data.packageDispositionVOList = data.packageDispositionVOList.map(
+            (item) => {
+              return {
+                ...item,
+                id: null
+              };
+            }
+          );
+        }
+        console.log('保存', data);
+        addMaterial(data)
+          .then((msg) => {
+            this.loading = false;
+            this.$message.success(msg);
+            // reloadPageTab({ fullPath: '/material/product' });
+            // this.$router.go(-1);
+            this.cancel();
+            // if (this.$route.query.rootTreeId == 9) {
+            //   this.$router.push({
+            //     path: '/product/oneProduct',
+            //     query: {
+            //       categoryLevelId: this.form.categoryLevelId
+            //     }
+            //   });
+            // } else {
+            //   this.$router.push({
+            //     path: '/material/product',
+            //     query: {
+            //       categoryLevelId: this.form.categoryLevelId
+            //     }
+            //   });
+            // }
+          })
+          .catch((e) => {
+            this.loading = false;
+          });
+      });
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .ele-page-header {
-    border: none;
-  }
+.ele-page-header {
+  border: none;
+}
+
+.body-top {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  background: #fff;
 
-  .body-top {
+  .top-left {
     display: flex;
     align-items: center;
-    justify-content: space-between;
-    background: #fff;
+    justify-content: flex-start;
+    margin-left: -25px;
 
-    .top-left {
-      display: flex;
-      align-items: center;
-      justify-content: flex-start;
-      margin-left: -25px;
-
-      .el-form-item {
-        margin-bottom: 0;
-      }
+    .el-form-item {
+      margin-bottom: 0;
     }
   }
+}
 
-  .divider {
-    margin: 20px 0;
-
-    .title {
-      display: flex;
-      align-items: center;
-      margin-bottom: 10px;
+.divider {
+  margin: 20px 0;
 
-      div {
-        width: 8px;
-        height: 20px;
-        margin-right: 10px;
-      }
+  .title {
+    display: flex;
+    align-items: center;
+    margin-bottom: 10px;
 
-      span {
-        font-size: 20px;
-      }
+    div {
+      width: 8px;
+      height: 20px;
+      margin-right: 10px;
     }
 
-    .ele-width {
-      width: 100%;
-      height: 2px;
+    span {
+      font-size: 20px;
     }
   }
 
-  .form-line {
-    display: flex;
-    align-items: center;
-    justify-content: space-between;
+  .ele-width {
+    width: 100%;
+    height: 2px;
+  }
+}
 
-    .line-select {
-      margin-left: 15px;
-    }
+.form-line {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+
+  .line-select {
+    margin-left: 15px;
   }
+}
 </style>