张诺
6 小时以前 ba65f3383951a27ee44163aea36d48f5c22b8fff
feat(PIMTable): 支持列动态显示控制

- 在 PIMTable 组件中添加 visibleColumns 计算属性,根据列的 visible 属性过滤显示列
- 添加 resolveColumnVisible 函数,支持 visible 为布尔值或函数形式
- 在指标维护页面中,为 processId 列添加 visible 控制,使其仅在特定标签页显示
- 为 inspectType 列添加最小宽度以改善布局
已修改2个文件
24 ■■■■ 文件已修改
src/components/PIMTable/PIMTable.vue 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/qualityManagement/metricMaintenance/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PIMTable/PIMTable.vue
@@ -30,7 +30,7 @@
    <el-table-column align="center" label="序号" type="index" width="60" />
    <el-table-column
      v-for="(item, index) in column"
      v-for="(item, index) in visibleColumns"
      :key="index"
      :column-key="item.columnKey"
      :filter-method="item.filterHandler"
@@ -226,7 +226,7 @@
<script setup>
import pagination from "./Pagination.vue";
import { ref, inject, getCurrentInstance } from "vue";
import { ref, inject, getCurrentInstance, computed, unref } from "vue";
import { ElMessage } from "element-plus";
// 获取全局的 uploadHeader
@@ -334,6 +334,23 @@
  },
});
const resolveColumnVisible = (visible) => {
  if (visible === undefined) return true;
  if (typeof visible === "function") {
    try {
      return !!visible();
    } catch (error) {
      console.warn("PIMTable column visible function error:", error);
      return true;
    }
  }
  return !!unref(visible);
};
const visibleColumns = computed(() => {
  return (props.column || []).filter((item) => resolveColumnVisible(item?.visible));
});
// Data
const uploadRefs = ref([]);
const currentFiles = ref({});
src/views/qualityManagement/metricMaintenance/index.vue
@@ -303,6 +303,7 @@
    prop: 'inspectType',
    align: 'center',
    dataType: 'tag',
    minWidth: 120,
    formatData: (val) => {
      const map = {
        0: '原材料检验',
@@ -317,6 +318,7 @@
    prop: 'processId',
    align: 'center',
    dataType: 'tag',
    visible: visible => activeTab.value === '1',
    formatData: (val) => {
      const target = processOptions.value.find(
        (item) => String(item.value) === String(val)
@@ -392,7 +394,6 @@
    ]
  }
])
const handleTabChange = () => {
  searchForm.value.standardNo = ''
  searchForm.value.standardName = ''