Jelajahi Sumber

最后接口修复编辑时拿到的顺序和页面顺序

pm 1 tahun lalu
induk
melakukan
cf1bc9a41f

File diff ditekan karena terlalu besar
+ 282 - 278
src/views/mes/job/jobm/NewOperations.vue


+ 10 - 10
src/views/mes/job/jobm/lookWork.vue

@@ -1077,22 +1077,22 @@ export default {
     },
     // 定义一个排序函数,根据 orderTableData 中 pointName 的顺序对 tableData 进行排序
     sortTableDataByOrder(tableData, orderTableData) {
-      // 构建 orderMap,使用 pointId 作为键,索引作为值
-      const orderMap = new Map(orderTableData.map((item, index) => [item.pointId, index]));
+      // 构建 orderMap,使用 pointName 作为键,索引作为值
+      const orderMap = new Map(orderTableData.map((item, index) => [item.pointName, index]))
 
       return tableData.sort((a, b) => {
-        // 如果 pointId 在 orderMap 中,按 orderMap 的索引排序
-        // 如果 pointId 不在 orderMap 中,排在最后,并按 pointId 的自然顺序排列
-        const indexA = orderMap.has(a.pointId) ? orderMap.get(a.pointId) : Infinity;
-        const indexB = orderMap.has(b.pointId) ? orderMap.get(b.pointId) : Infinity;
+        // 如果 pointName 在 orderMap 中,按 orderMap 的索引排序
+        // 如果 pointName 不在 orderMap 中,排在最后,并按 pointName 的自然顺序排列
+        const indexA = orderMap.has(a.pointName) ? orderMap.get(a.pointName) : Infinity
+        const indexB = orderMap.has(b.pointName) ? orderMap.get(b.pointName) : Infinity
 
         if (indexA === indexB) {
-          // 当两者都不在 orderMap 中时,按 pointId 的自然顺序排列
-          return a.pointId - b.pointId;
+          // 当两者都不在 orderMap 中时,按 pointName 的自然顺序排列
+          return a.pointName.localeCompare(b.pointName)
         }
 
-        return indexA - indexB;
-      });
+        return indexA - indexB
+      })
     },
     // 子组件逆向传递选中的隔离点
     handleSelectPoint(points) {

+ 11 - 11
src/views/mes/sop/sopm/NewSop.vue

@@ -845,22 +845,22 @@ export default {
     },
 // 定义一个排序函数,根据 orderTableData 中 pointName 的顺序对 tableData 进行排序
     sortTableDataByOrder(tableData, orderTableData) {
-      // 构建 orderMap,使用 pointId 作为键,索引作为值
-      const orderMap = new Map(orderTableData.map((item, index) => [item.pointId, index]));
+      // 构建 orderMap,使用 pointName 作为键,索引作为值
+      const orderMap = new Map(orderTableData.map((item, index) => [item.pointName, index]))
 
       return tableData.sort((a, b) => {
-        // 如果 pointId 在 orderMap 中,按 orderMap 的索引排序
-        // 如果 pointId 不在 orderMap 中,排在最后,并按 pointId 的自然顺序排列
-        const indexA = orderMap.has(a.pointId) ? orderMap.get(a.pointId) : Infinity;
-        const indexB = orderMap.has(b.pointId) ? orderMap.get(b.pointId) : Infinity;
+        // 如果 pointName 在 orderMap 中,按 orderMap 的索引排序
+        // 如果 pointName 不在 orderMap 中,排在最后,并按 pointName 的自然顺序排列
+        const indexA = orderMap.has(a.pointName) ? orderMap.get(a.pointName) : Infinity
+        const indexB = orderMap.has(b.pointName) ? orderMap.get(b.pointName) : Infinity
 
         if (indexA === indexB) {
-          // 当两者都不在 orderMap 中时,按 pointId 的自然顺序排列
-          return a.pointId - b.pointId;
+          // 当两者都不在 orderMap 中时,按 pointName 的自然顺序排列
+          return a.pointName.localeCompare(b.pointName)
         }
 
-        return indexA - indexB;
-      });
+        return indexA - indexB
+      })
     },
     // 子组件选中的隔离点逆传递拿到的数据
     handleSelectPoint(points) {
@@ -878,7 +878,7 @@ export default {
         this.tableData = this.sortTableDataByOrder(uniquePoints, this.orderTableData);//去重并排序
 
       }
-      console.log(this.tableData,'排序之后')
+      console.log(this.tableData,this.orderTableData,'排序之后')
       // this.tableData = uniquePoints; // 子组件传递过来的选中节点(去重后)
 
       // 使用 Set 来存储传递过来的点值

+ 10 - 10
src/views/mes/sop/sopm/sopmLook.vue

@@ -950,22 +950,22 @@ export default {
     },
     // 定义一个排序函数,根据 orderTableData 中 pointName 的顺序对 tableData 进行排序
     sortTableDataByOrder(tableData, orderTableData) {
-      // 构建 orderMap,使用 pointId 作为键,索引作为值
-      const orderMap = new Map(orderTableData.map((item, index) => [item.pointId, index]));
+      // 构建 orderMap,使用 pointName 作为键,索引作为值
+      const orderMap = new Map(orderTableData.map((item, index) => [item.pointName, index]))
 
       return tableData.sort((a, b) => {
-        // 如果 pointId 在 orderMap 中,按 orderMap 的索引排序
-        // 如果 pointId 不在 orderMap 中,排在最后,并按 pointId 的自然顺序排列
-        const indexA = orderMap.has(a.pointId) ? orderMap.get(a.pointId) : Infinity;
-        const indexB = orderMap.has(b.pointId) ? orderMap.get(b.pointId) : Infinity;
+        // 如果 pointName 在 orderMap 中,按 orderMap 的索引排序
+        // 如果 pointName 不在 orderMap 中,排在最后,并按 pointName 的自然顺序排列
+        const indexA = orderMap.has(a.pointName) ? orderMap.get(a.pointName) : Infinity
+        const indexB = orderMap.has(b.pointName) ? orderMap.get(b.pointName) : Infinity
 
         if (indexA === indexB) {
-          // 当两者都不在 orderMap 中时,按 pointId 的自然顺序排列
-          return a.pointId - b.pointId;
+          // 当两者都不在 orderMap 中时,按 pointName 的自然顺序排列
+          return a.pointName.localeCompare(b.pointName)
         }
 
-        return indexA - indexB;
-      });
+        return indexA - indexB
+      })
     },
 
 

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini