From cddd23855c7731627b0f6c2ca4d59b23078ca970 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Thu, 18 Apr 2024 14:47:14 +0800 Subject: [PATCH] update fto data --- src/store/getters.js | 5 +- src/views/dashboard/charts/Fto.vue | 73 ++++++++++++++++++------------ 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/src/store/getters.js b/src/store/getters.js index 79cdf2c..0748b1c 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -18,6 +18,9 @@ const getters = { defaultRoutes:state => state.permission.defaultRoutes, sidebarRouters:state => state.permission.sidebarRouters, // 数据字典 - dict_datas: state => state.dict.dictDatas + dict_datas: state => state.dict.dictDatas, + // 驾驶舱和首页 + home: state => state.copilot.home, + copilot: state => state.copilot.copilot, } export default getters diff --git a/src/views/dashboard/charts/Fto.vue b/src/views/dashboard/charts/Fto.vue index a1a3516..d856655 100644 --- a/src/views/dashboard/charts/Fto.vue +++ b/src/views/dashboard/charts/Fto.vue @@ -20,38 +20,51 @@ import LeftChartBase from "./LeftChartBase.vue"; export default { name: "FtoChart", components: { LeftChartBase }, - props: { - legend: { - type: Array, - default: () => [ - { label: "2023年", color: "#12f7f1" }, - { label: "2024年", color: "#58adfa" }, + data() { + const year = new Date().getFullYear(); + // 城市数组的顺序必须是固定的 + const cities = ["瑞昌", "邯郸", "株洲", "佳木斯", "成都", "凯盛", "蚌埠"]; + return { + legend: [ + { label: `${year - 1}年`, color: "#12f7f1" }, + { label: `${year}年`, color: "#58adfa" }, ], - }, - xAxis: { - type: Array, - default: () => ["成都", "邯郸", "株洲", "瑞昌", "heels", "socks"], - }, - series: { - type: Array, - default: () => [ - { - name: "2023年", - data: Array.from({ length: 7 }, () => - Math.floor(Math.random() * 1000) - ), - }, - { - name: "2024年", - data: Array.from({ length: 7 }, () => - Math.floor(Math.random() * 1000) - ), - }, - ], - }, + xAxis: cities, + }; }, - mounted() { - console.log("FTO created..."); + computed: { + series() { + const ftoInvest = this.$store.getters.home.ftoInvest; + console.log("FTO ==> ", ftoInvest); + + if (!ftoInvest || !ftoInvest.current || !ftoInvest.previous) { + return [ + { + name: "样例数据--2023年", + data: Array.from({ length: 7 }, () => + Math.floor(Math.random() * 1000) + ), + }, + { + name: "样例数据--2024年", + data: Array.from({ length: 7 }, () => + Math.floor(Math.random() * 1000) + ), + }, + ]; + } + + return [ + { + name: `${new Date().getFullYear() - 1}年`, + data: ftoInvest.previous, + }, + { + name: `${new Date().getFullYear()}年`, + data: ftoInvest.current, + }, + ]; + }, }, };