|
|
@@ -111,12 +111,19 @@
|
|
|
// 获取树形数据
|
|
|
const getTree = async () => {
|
|
|
try {
|
|
|
- // 调用API获取数据 - 根据你的实际API调用方式调整
|
|
|
const response = await GetWfpDataLeft()
|
|
|
const data = response.data
|
|
|
|
|
|
+ // 获取所有年月键并排序(降序,最近的在上方)
|
|
|
+ const sortedYearMonths = Object.keys(data).sort((a, b) => {
|
|
|
+ const yearMonthA = parseInt(a);
|
|
|
+ const yearMonthB = parseInt(b);
|
|
|
+ // 降序排列(最近的在上方)
|
|
|
+ return yearMonthB - yearMonthA;
|
|
|
+ });
|
|
|
+
|
|
|
// 转换数据为el-tree需要的格式
|
|
|
- treeData.value = Object.keys(data).map(yearMonth => {
|
|
|
+ treeData.value = sortedYearMonths.map(yearMonth => {
|
|
|
return {
|
|
|
label: `${yearMonth}`,
|
|
|
children: data[yearMonth].map(customer => {
|