From 30af8faa4916cb45261f1de15f374dee1eec3eb1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Wed, 24 Apr 2024 16:31:27 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BA=A7=E9=87=8F=E9=A9=BE=E9=A9=B6?= =?UTF-8?q?=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/home.js | 73 ++++- .../copilot/components/charts/FtoInvest.vue | 121 +++++++++ .../copilot/components/charts/StdOutput.vue | 11 +- .../components/charts/base/BarChartBase.vue | 253 ++++++++++++++++++ .../components/charts/base/CityData.vue | 96 +++++++ .../components/charts/base/CityItem.vue | 81 ++++++ .../charts/base/DoubleRingChart.vue | 52 +++- .../charts/base/DoubleRingWrapper.vue | 36 ++- .../components/charts/base/GradientText.vue | 56 ++++ src/views/copilot/components/select.vue | 12 +- src/views/copilot/yield/index.vue | 30 ++- 11 files changed, 793 insertions(+), 28 deletions(-) create mode 100644 src/views/copilot/components/charts/FtoInvest.vue create mode 100644 src/views/copilot/components/charts/base/BarChartBase.vue create mode 100644 src/views/copilot/components/charts/base/CityData.vue create mode 100644 src/views/copilot/components/charts/base/CityItem.vue create mode 100644 src/views/copilot/components/charts/base/GradientText.vue diff --git a/src/store/modules/home.js b/src/store/modules/home.js index e9f8163..c9342ba 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -34,6 +34,17 @@ async function getHomeTarget() { return null; } +async function getCopilotYield(params) { + const { code, data } = await axios.post("/ip/prod-output/query-by-date", { + ...params, + }); + if (code == 0) { + return data; + } + console.warn("getCopilotYield failed, code: ", code); + return null; +} + /* 状态 */ const state = { copilot: { @@ -61,7 +72,19 @@ const mutations = { state.home.stdOutput = payload.stdOutput; state.home.bipvOutput = payload.bipvOutput; }, - SET_COPILOT_INFO: (state) => {}, + SET_COPILOT_INFO: (state, payload) => { + switch (payload.type) { + case "yield": + state.copilot.yield = payload.data; + break; + case "energy": + state.copilot.energy = payload.data; + break; + case "efficiency": + state.copilot.efficiency = payload.data; + break; + } + }, }; const actions = { @@ -104,7 +127,11 @@ const actions = { if (target) { chipOutput.target.splice(factoryId, 1, target.chipYield ?? 0); stdOutput.target.splice(factoryId, 1, target.componentYield ?? 0); - bipvOutput.target.splice(factoryId, 1, target.bipvProductOutput ?? 0); + bipvOutput.target.splice( + factoryId, + 1, + target.bipvProductOutput ?? 0 + ); } } /* 收集芯片投入数据 */ @@ -184,7 +211,47 @@ const actions = { } }, /** 初始化驾驶舱数据 */ - async initCopilot({ commit }) {}, + async initCopilot({ commit }, payload) { + const { period } = payload; + let dummyData = null; + let type = null; + // 请求参数,直接一次性获取所有工厂 + let queryParams = { + factorys: [], + date: 4, + }; + + switch (period) { + case "日": + queryParams.date = 1; + break; + case "周": + queryParams.date = 2; + break; + case "月": + queryParams.date = 3; + break; + case "年": + queryParams.date = 4; + break; + default: + queryParams.date = 1; + break; + } + + const data = await getCopilotYield(queryParams); + if (data) { + dummyData = data; + type = "yield"; + } + + console.log("[copilot yield data]: ", dummyData, type); + // commit + // commit('SET_COPILOT_INFO', { + // type, + // data: dummyData + // }) + }, }; export default { diff --git a/src/views/copilot/components/charts/FtoInvest.vue b/src/views/copilot/components/charts/FtoInvest.vue new file mode 100644 index 0000000..fc490dc --- /dev/null +++ b/src/views/copilot/components/charts/FtoInvest.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/views/copilot/components/charts/StdOutput.vue b/src/views/copilot/components/charts/StdOutput.vue index e09df94..97c787b 100644 --- a/src/views/copilot/components/charts/StdOutput.vue +++ b/src/views/copilot/components/charts/StdOutput.vue @@ -6,7 +6,7 @@ --> diff --git a/src/views/copilot/components/charts/base/BarChartBase.vue b/src/views/copilot/components/charts/base/BarChartBase.vue new file mode 100644 index 0000000..77d693e --- /dev/null +++ b/src/views/copilot/components/charts/base/BarChartBase.vue @@ -0,0 +1,253 @@ + + + + + + + diff --git a/src/views/copilot/components/charts/base/CityData.vue b/src/views/copilot/components/charts/base/CityData.vue new file mode 100644 index 0000000..502388c --- /dev/null +++ b/src/views/copilot/components/charts/base/CityData.vue @@ -0,0 +1,96 @@ + + + + + + + diff --git a/src/views/copilot/components/charts/base/CityItem.vue b/src/views/copilot/components/charts/base/CityItem.vue new file mode 100644 index 0000000..6978a48 --- /dev/null +++ b/src/views/copilot/components/charts/base/CityItem.vue @@ -0,0 +1,81 @@ + + + + + + + diff --git a/src/views/copilot/components/charts/base/DoubleRingChart.vue b/src/views/copilot/components/charts/base/DoubleRingChart.vue index 15b90d5..be15fca 100644 --- a/src/views/copilot/components/charts/base/DoubleRingChart.vue +++ b/src/views/copilot/components/charts/base/DoubleRingChart.vue @@ -33,19 +33,19 @@ export default { type: Number, default: 24, }, - legendItems: { - type: Array, - default: () => [ - { label: "2023年累计", value: 88002 }, - { label: "2024年累计", value: 88002 }, - { label: "2025年累计", value: 88002 }, - ], + period: { + type: String, + default: "日", }, }, data() { return {}; }, - computed: {}, + computed: { + legendItems() { + return calculateItems(this.period); + }, + }, mounted() { this.initOptions(options); }, @@ -56,6 +56,42 @@ export default { }, }, }; + +function calculateItems(period) { + let items = []; + const today = new Date().getDate(); + const month = new Date().getMonth() + 1; + const year = new Date().getFullYear(); + switch (period) { + case "日": + items = [ + { label: `${month}月${today}日累计`, value: 24 }, + { label: `去年${month}月${today}日累计`, value: 33 }, + ]; + break; + case "周": + items = [ + { label: `本周累计`, value: 32 }, + { label: `去年本周累计`, value: 12 }, + ]; + break; + case "月": + items = [ + { label: `${month}月累计`, value: 24 }, + { label: `去年${month}月累计`, value: 33 }, + { label: `${month}月目标`, value: 12334 }, + ]; + break; + case "年": + items = [ + { label: `${year - 1}年累计`, value: 23234 }, + { label: `${year}年累计`, value: 4324 }, + { label: `${year}年目标`, value: 12334 }, + ]; + break; + } + return items; +} diff --git a/src/views/copilot/components/select.vue b/src/views/copilot/components/select.vue index 4ecf30f..58e9814 100644 --- a/src/views/copilot/components/select.vue +++ b/src/views/copilot/components/select.vue @@ -33,9 +33,17 @@ export default { }, data() { return { - currentActive: '', + currentActive: this.options[0], }; }, + watch: { + currentActive: { + handler(val) { + this.$emit("update:active", val); + }, + immediate: true, + }, + }, computed: {}, methods: {}, }; @@ -55,7 +63,7 @@ button { padding: 8px 12px; cursor: pointer; position: relative; - transition: all .3s; + transition: all 0.3s; } button.active, diff --git a/src/views/copilot/yield/index.vue b/src/views/copilot/yield/index.vue index 2bc0134..9a08a72 100644 --- a/src/views/copilot/yield/index.vue +++ b/src/views/copilot/yield/index.vue @@ -9,7 +9,7 @@
- + @@ -19,7 +19,9 @@
- + + +