|
|
@@ -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 来存储传递过来的点值
|