Browse Source

大废品统计左侧排序优化

zck 1 year ago
parent
commit
edc32e1560
1 changed files with 8 additions and 6 deletions
  1. 8 6
      src/view/DecisionSupport/Processwaste.vue

+ 8 - 6
src/view/DecisionSupport/Processwaste.vue

@@ -79,13 +79,15 @@ const _GXGetList = async () => {
 		})),
 	  };
 	});
-	
-	// 对年份进行自定义排序
+
+	// 对年份进行排序
 	formattedTreeData.sort((a, b) => {
-	// 提取年份的后两位作为月份进行比较
-	const monthA = parseInt(a.label.slice(-2), 10);
-	const monthB = parseInt(b.label.slice(-2), 10);
-	return monthB - monthA; // 降序排序
+	// 提取完整的“年份”(实际上是年月组合,但按整数比较会正确排序)
+	const fullYearA = parseInt(a.label, 10);
+	const fullYearB = parseInt(b.label, 10);
+	
+	// 按“年份”降序排序
+	return fullYearB - fullYearA;
 	});
 	treeData.splice(0, treeData.length, ...formattedTreeData);
   } catch (error) {