Prechádzať zdrojové kódy

Revert "feat: 润天排序"

This reverts commit 1bd5ff9e16b2a16eb3c43b93268c88a6aa1d031d.
wuzh 3 dní pred
rodič
commit
5f4e049ba0

+ 40 - 5
src/views/material/BOMmanage/components/detailedList.vue

@@ -303,6 +303,9 @@
         // 当前分页位置
         currentPage: 1,
         currentLimit: 20,
+        // 层级序号:rowId -> 该行在“同层级”里的序号(跨页连续)
+        levelSeqMap: {},
+        levelSeqKey: '',
         produceTypeList,
         clientEnvironmentId: this.$store.state.user.info.clientEnvironmentId,
         // 是否启用新 columns 方案(true=新方案,false=老方案);序号方案与新 columns 方案绑定
@@ -839,16 +842,43 @@
     },
 
     methods: {
-      // 序号:新方案直接用服务端回填的 rowSeq(同一层级 1、2、3…,跨页连续);
-      // 老方案用连续行号;服务端没给 rowSeq(非润天环境)时退化成当前页内按层级计数。
+      // 序号方案与新 columns 方案绑定:老方案用连续行号,新方案按层级计数
       rowIndexText(row, index) {
         if (!this.useNewColumns) {
           return (this.currentPage - 1) * this.currentLimit + index + 1;
         }
-        if (row && row.rowSeq !== null && row.rowSeq !== undefined && row.rowSeq !== '') {
-          return row.rowSeq;
+        return this.levelSeqMap[row.id] != null
+          ? this.levelSeqMap[row.id]
+          : this.levelSeq(row, index);
+      },
+
+      // 拉整棵树的清单,算出每行在“同层级”里的序号(跨页也连续)
+      async ensureLevelSeqMap(where) {
+        const attr = this.attributeData || {};
+        const key = [attr.id, attr.bomType, JSON.stringify(where || {})].join('|');
+        if (this.levelSeqKey === key) {
+          return;
+        }
+        try {
+          const res = await getBomPageCategoryId({
+            ...(where || {}),
+            pageNum: 1,
+            size: 100000,
+            id: attr.id,
+            bomType: attr.bomType
+          });
+          const map = {};
+          const counters = {};
+          ((res && res.list) || []).forEach((item) => {
+            const level = String(item.level == null ? '' : item.level);
+            counters[level] = (counters[level] || 0) + 1;
+            map[item.id] = counters[level];
+          });
+          this.levelSeqMap = map;
+          this.levelSeqKey = key;
+        } catch (e) {
+          // 取不到就退化成“当前页内按层级计数”
         }
-        return this.levelSeq(row, index);
       },
 
       // 兜底:当前页内按层级计数(同层 1、2、3…,层级变了重新从 1 开始)
@@ -1080,6 +1110,11 @@
           bomType: this.attributeData.bomType
         });
 
+        // 新 columns 方案下序号按层级计数且跨页连续:拉一次整棵树的清单算出每行在同层级里的序号
+        if (this.useNewColumns) {
+          await this.ensureLevelSeqMap(where);
+        }
+
         if (this.isList) {
           data = this.listTow;
         }