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

物品管理存货属性调整为使用字典

yanghe17378 пре 11 месеци
родитељ
комит
1474d4f2d9
1 измењених фајлова са 14 додато и 6 уклоњено
  1. 14 6
      src/views/material/product/components/index-data.vue

+ 14 - 6
src/views/material/product/components/index-data.vue

@@ -309,7 +309,8 @@
   import { produceTypeList } from '@/enum/dict.js';
   import request from '@/utils/request';
   import { download } from '@/utils/file';
-  const attributeList = [
+  import { getByCode } from '@/api/system/dictionary-data';
+  /*const attributeList = [
     {
       label: '总装',
       value: 1
@@ -326,7 +327,7 @@
       label: '原材料',
       value: 4
     }
-  ];
+  ];*/
   const measureTypeList = [
     {
       label: '数量',
@@ -380,6 +381,7 @@
     },
     data() {
       return {
+        attributeList: [],
         exportLoading: false,
         moudleName: 'mainCategory',
 
@@ -530,9 +532,10 @@
             label: '存货类型',
             showOverflowTooltip: true,
             formatter: (row, column) => {
-              return attributeList.find(
-                (item) => item.value == row.attributeType
-              )?.label;
+              const item = this.attributeList.find(
+                (item) => item[row.attributeType] !== undefined
+              );
+              return item ? item[row.attributeType] : null; // 如果找不到返回 null
             }
           },
           {
@@ -608,7 +611,12 @@
       };
     },
 
-    created() {
+    created: function () {
+      getByCode('inventory_type').then((res) => {
+        if (res.code === '0') {
+          this.attributeList = res.data;
+        }
+      });
       this.requestDict('生产类型');
       this.getFieldModel();
     },