Sfoglia il codice sorgente

feat: 添加新列配置方案,支持动态切换展示属性并优化版本显示逻辑(润天)

xieyong 1 settimana fa
parent
commit
d88c2bd7c9
1 ha cambiato i file con 170 aggiunte e 6 eliminazioni
  1. 170 6
      src/views/material/BOMmanage/index.vue

+ 170 - 6
src/views/material/BOMmanage/index.vue

@@ -45,7 +45,10 @@
             >
           </template>
 
-          <template v-slot:versions="{ row }"> V{{ row.versions }}.0 </template>
+          <template v-slot:versions="{ row }">
+            <template v-if="row.versions">V{{ row.versions }}.0</template>
+            <template v-else>无</template>
+          </template>
           <template v-slot:isTemp="{ row }">
             <el-tag size="mini" v-if="row.isTemp == 1">主数据</el-tag>
           </template>
@@ -181,7 +184,7 @@
     withdrawBom
   } from '@/api/material/BOM';
   import LCdetail from './components/LCdetail.vue';
-  import { getByCode } from '@/api/system/dictionary-data';
+  import { getByCode, parameterGetByCode } from '@/api/system/dictionary-data';
   import BomDetailsPop from '../BOMmanage/detailsPop.vue';
   import { mapGetters } from 'vuex';
 
@@ -193,8 +196,8 @@
       return {
         produceTypeList,
         processSubmitDialogFlag: false,
-        // 表格列配置
-        columns: [
+        // 老 columns 方案(默认 20 列全部可见)
+        oldColumnsConfig: [
           {
             label: '序号',
             columnKey: 'index',
@@ -279,7 +282,7 @@
             minWidth: 180
           },
           {
-            prop: 'status ',
+            prop: 'status',
             label: '状态',
             formatter: (row) => {
               return this.statusOpt[+row.status];
@@ -326,6 +329,110 @@
             align: 'center'
           }
         ],
+        // 新 columns 方案(PBOM + is_runtian===1 时使用),内容与 detailedList.vue 的 newColumnsConfig 保持一致
+        newColumnsConfig: [
+          {
+            prop: 'level',
+            label: '零部件层级',
+            align: 'center',
+            showOverflowTooltip: true,
+            width: 100
+          },
+          {
+            prop: 'sn',
+            label: '明细表序号',
+            align: 'center',
+            width: 120,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'code',
+            label: '物料编码',
+            slot: 'code',
+            showOverflowTooltip: true,
+            width: 120
+          },
+          {
+            prop: 'imgCode',
+            label: '零部件图号(规格型号)',
+            showOverflowTooltip: true,
+            width: 150
+          },
+          {
+            prop: 'versions',
+            slot: 'versions',
+            label: '图纸版本',
+            showOverflowTooltip: true,
+            align: 'center',
+            width: 90
+          },
+          {
+            prop: 'updateTime',
+            label: '修改时间',
+            width: 160,
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'name',
+            label: '零件名称',
+            showOverflowTooltip: true,
+            width: 150
+          },
+          {
+            prop: 'dosage',
+            slot: 'dosage',
+            label: '单台用量',
+            width: 100,
+            headerSlot: 'dosageHead'
+          },
+          {
+            prop: 'measuringUnit',
+            label: '计量单位',
+            showOverflowTooltip: true,
+            align: 'center',
+            width: 90
+          },
+          {
+            prop: 'brandNum',
+            label: '材质',
+            showOverflowTooltip: true,
+            width: 100
+          },
+          {
+            prop: 'netWeight',
+            label: '单重',
+            showOverflowTooltip: true,
+            align: 'right',
+            width: 100
+          },
+          {
+            prop: 'totalWeight',
+            label: '总重',
+            showOverflowTooltip: true,
+            align: 'right',
+            width: 100
+          },
+          {
+            prop: 'remark',
+            label: '备注',
+            showOverflowTooltip: true,
+            width: 100
+          },
+          {
+            prop: 'createName',
+            label: '创建人',
+            showOverflowTooltip: true,
+            width: 100
+          },
+          {
+            prop: 'createTime',
+            label: '创建日期',
+            width: 160,
+            showOverflowTooltip: true
+          }
+        ],
+        // 系统参数 is_runtian 原始值(false=未加载/失败,其他=接口返回值)
+        isRuntianValue: false,
         sxtList: [
           {
             label: '自制件',
@@ -454,12 +561,55 @@
       clientEnvironmentId() {
         return this.$store.state.user.info.clientEnvironmentId;
       },
-      ...mapGetters(['user'])
+      ...mapGetters(['user']),
+      // 是否启用新 columns 方案:activeName 为 PBOM (1/'1') 且 is_runtian === 1
+      useNewColumns() {
+        const isPBOM = this.activeName == 1 || this.activeName === '1';
+        const val = this.isRuntianValue;
+        const isRuntianOk = val === '1' || val === 1 || val === true;
+        return isPBOM && isRuntianOk;
+      },
+      // 新方案默认展示的 prop 集合(自动从 newColumnsConfig 推导,避免漏配导致老列覆盖新列)
+      newPropSet() {
+        const set = new Set();
+        this.newColumnsConfig.forEach((c) => {
+          if (c.prop) set.add(c.prop);
+        });
+        return set;
+      },
+      // 操作列:固定右侧,不参与新老的合并
+      actionColumn() {
+        return {
+          columnKey: 'action',
+          slot: 'action',
+          label: '操作',
+          width: 170,
+          align: 'center'
+        };
+      },
+      // 表格列:按 useNewColumns 决定输出老方案还是新方案
+      columns() {
+        if (this.useNewColumns) {
+          // 老方案里独有、且不在新方案里的列 → 追加到末尾,默认隐藏,用户可手动显示
+          const extras = this.oldColumnsConfig
+            .filter((c) => {
+              if (c.columnKey === 'action') return false; // 操作列单独追加
+              if (c.type === 'index' || c.columnKey === 'index') return false;
+              if (c.prop && this.newPropSet.has(c.prop)) return false;
+              return true;
+            })
+            .map((c) => ({ ...c, show: false }));
+          return [...this.newColumnsConfig, ...extras, this.actionColumn];
+        }
+        // 老方案:保持原有顺序
+        return [...this.oldColumnsConfig];
+      }
     },
 
     created() {
       this.getDictList('productionType');
       this.getAttriButeList('inventory_type');
+      this.getRuntianConfig();
     },
     methods: {
       attributeTypeText(v) {
@@ -496,6 +646,20 @@
           };
         });
       },
+
+      // 取系统参数 is_runtian 的原始值(由 computed useNewColumns 配合 activeName 共同判断)
+      // 兼容常见返回:'1' / 1 / { value: 1 } / { paramValue: '1' } / true
+      async getRuntianConfig() {
+        try {
+          const data = await parameterGetByCode({ code: 'is_runtian' });
+          this.isRuntianValue =
+            typeof data === 'object' && data !== null
+              ? data.value ?? data.paramValue ?? data.val
+              : data;
+        } catch (e) {
+          this.isRuntianValue = false;
+        }
+      },
       // 撤回
       handWithdraw(row) {
         const params = {