Jelajahi Sumber

fix: 更新质检清单列宽处理逻辑,避免与主表列宽互相污染

xieyong 1 Minggu lalu
induk
melakukan
600ba3d619

+ 34 - 8
src/views/purchasingManage/purchaseOrder/invoice/components/detailDialog.vue

@@ -126,12 +126,12 @@
         v-if="detailData.resultList?.length > 0"
         ref="table"
         :needPage="false"
-        :columns="columns"
+        :columns="qcColumns"
         :toolkit="[]"
         :datasource="detailData.resultList"
         row-key="id"
         height="300px"
-        @header-dragend="handleHeaderDragend"
+        @header-dragend="onQcHeaderDragend"
       >
         <template v-slot:technicalDrawings="{ row }">
           <fileMain v-model="row.technicalDrawings" type="view"></fileMain>
@@ -201,12 +201,32 @@
     created() {
       this.requestDict('产地');
       this.requestDict('生产类型');
+      // 副表(质检清单)列宽缓存,独立 key
+      this.loadScopedColumnWidth('qc');
     },
     computed: {
+      // 主表:收货单物品清单(v=1)
+      // 标准 mixin 列宽持久化流程:列宽由 cacheKeyUrl+'Cols' 缓存 + applyColumnWidth 应用
       columns() {
-        // 标准 mixin 列宽持久化流程:列宽由 cacheKeyUrl+'Cols' 缓存 + applyColumnWidth 应用
         this.columnsVersion;  // mixin 触发重算
-        return this.applyColumnWidth([
+        return this.applyColumnWidth(
+          this.buildColumns(1).filter((col) => col.show !== false)
+        );
+      },
+      // 副表:质检清单(v=2)——独立 scope 缓存,避免与主表列宽互相污染
+      qcColumns() {
+        this.columnsVersion;  // mixin 触发重算
+        return this.applyScopedColumnWidth(
+          this.buildColumns(2).filter((col) => col.show !== false),
+          'qc'
+        );
+      }
+    },
+    methods: {
+      // 列定义工厂:v=1 收货单物品清单,v=2 质检清单
+      // show: v != 2 → 只在物品清单显示;show: v == 2 → 只在质检清单显示
+      buildColumns(v) {
+        return [
           {
             width: 45,
             type: 'index',
@@ -665,10 +685,16 @@
                   : '';
               }
             }
-          ]);
-      }
-    },
-    methods: {
+        ];
+      },
+      // 质检清单(副表)表头拖拽列宽:只写本表 scope 的本地缓存,不污染主表列配置
+      onQcHeaderDragend(newWidth, oldWidth, column) {
+        this.persistScopedColumnWidth(
+          'qc',
+          column && (column.property || column.columnKey),
+          newWidth
+        );
+      },
       async open(row) {
         this.form = row;
         this.activeComp = 'main';