From 30af8faa4916cb45261f1de15f374dee1eec3eb1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Wed, 24 Apr 2024 16:31:27 +0800 Subject: [PATCH 1/7] =?UTF-8?q?update=20=E4=BA=A7=E9=87=8F=E9=A9=BE?= =?UTF-8?q?=E9=A9=B6=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 @@
- + + + From bb399835e7a37d78d8b8425f7834d8bdf001c6c7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Thu, 25 Apr 2024 14:55:23 +0800 Subject: [PATCH 2/7] =?UTF-8?q?update=20=E4=BA=A7=E9=87=8F=E9=A9=BE?= =?UTF-8?q?=E9=A9=B6=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../copilot/components/charts/BipvOutput.vue | 11 +- .../copilot/components/charts/ChipInvest.vue | 121 +++++++++++++++++ .../copilot/components/charts/ChipOutput.vue | 11 +- .../components/charts/base/CityData.vue | 19 ++- .../components/charts/base/CityItem.vue | 41 ++---- .../components/charts/base/CityName.vue | 55 ++++++++ .../components/charts/base/CityValue.vue | 127 ++++++++++++++++++ .../components/charts/base/GradientText.vue | 14 +- .../copilot/components/charts/base/icon.png | Bin 0 -> 5165 bytes src/views/copilot/container.vue | 8 ++ src/views/copilot/yield/index.vue | 16 +-- 11 files changed, 371 insertions(+), 52 deletions(-) create mode 100644 src/views/copilot/components/charts/ChipInvest.vue create mode 100644 src/views/copilot/components/charts/base/CityName.vue create mode 100644 src/views/copilot/components/charts/base/CityValue.vue create mode 100644 src/views/copilot/components/charts/base/icon.png diff --git a/src/views/copilot/components/charts/BipvOutput.vue b/src/views/copilot/components/charts/BipvOutput.vue index 174c704..fd40bef 100644 --- a/src/views/copilot/components/charts/BipvOutput.vue +++ b/src/views/copilot/components/charts/BipvOutput.vue @@ -6,7 +6,7 @@ --> diff --git a/src/views/copilot/components/charts/ChipInvest.vue b/src/views/copilot/components/charts/ChipInvest.vue new file mode 100644 index 0000000..f6ede7d --- /dev/null +++ b/src/views/copilot/components/charts/ChipInvest.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/views/copilot/components/charts/ChipOutput.vue b/src/views/copilot/components/charts/ChipOutput.vue index 539720b..498c72e 100644 --- a/src/views/copilot/components/charts/ChipOutput.vue +++ b/src/views/copilot/components/charts/ChipOutput.vue @@ -6,7 +6,7 @@ --> diff --git a/src/views/copilot/components/charts/base/CityData.vue b/src/views/copilot/components/charts/base/CityData.vue index 502388c..f285aae 100644 --- a/src/views/copilot/components/charts/base/CityData.vue +++ b/src/views/copilot/components/charts/base/CityData.vue @@ -9,7 +9,10 @@
-
凯盛光伏
+
+ + +
@@ -27,9 +30,16 @@ + + diff --git a/src/views/copilot/components/charts/base/CityValue.vue b/src/views/copilot/components/charts/base/CityValue.vue new file mode 100644 index 0000000..9c42ab7 --- /dev/null +++ b/src/views/copilot/components/charts/base/CityValue.vue @@ -0,0 +1,127 @@ + + + + + + + diff --git a/src/views/copilot/components/charts/base/GradientText.vue b/src/views/copilot/components/charts/base/GradientText.vue index 111cda9..bb45881 100644 --- a/src/views/copilot/components/charts/base/GradientText.vue +++ b/src/views/copilot/components/charts/base/GradientText.vue @@ -6,7 +6,7 @@ --> @@ -37,6 +35,7 @@ import StdOutputVue from "../components/charts/StdOutput.vue"; import ChipOutputVue from "../components/charts/ChipOutput.vue"; import FtoInvestVue from "../components/charts/FtoInvest.vue"; import BipvOutputVue from "../components/charts/BipvOutput.vue"; +import ChipInvestVue from "../components/charts/ChipInvest.vue"; export default { name: "YieldCopilot", @@ -45,7 +44,8 @@ export default { StdOutput: StdOutputVue, ChipOutput: ChipOutputVue, BipvOutput: BipvOutputVue, - FtoInvest: FtoInvestVue + FtoInvest: FtoInvestVue, + ChipInvest: ChipInvestVue, }, props: { period: { From 752df8417d6171c719221f4cdedf7ac8f4b1c2e6 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Thu, 25 Apr 2024 17:07:44 +0800 Subject: [PATCH 3/7] =?UTF-8?q?update=20=E9=A9=BE=E9=A9=B6=E8=88=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/store/modules/home.js | 408 +++++++++--------- .../copilot/components/charts/StdOutput.vue | 4 +- .../components/charts/base/CityData.vue | 67 ++- .../charts/base/DoubleRingWrapper.vue | 6 +- src/views/copilot/yield/index.vue | 4 +- 6 files changed, 255 insertions(+), 235 deletions(-) diff --git a/package.json b/package.json index 0a67be3..d920609 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "highlight.js": "^11.9.0", "js-beautify": "^1.15.1", "jsencrypt": "3.3.1", + "lodash": "^4.17.21", "mockjs": "^1.1.0", "moment": "^2.30.1", "nprogress": "0.2.0", diff --git a/src/store/modules/home.js b/src/store/modules/home.js index c9342ba..ea4d46a 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -1,4 +1,172 @@ import axios from "@/utils/request"; +import { deepClone } from "../../utils"; + +/* 状态 */ +const state = { + copilot: { + /* 产量驾驶舱 */ + yield: { + ftoInvest: null, + chipInvest: null, + chipOutput: null, + stdOutput: null, + bipvOutput: null, + }, + /* 能源驾驶舱 */ + energy: {}, + /* 效率驾驶舱 */ + efficiency: {}, + }, + home: { + ftoInvest: null, + chipInvest: null, + chipOutput: null, + stdOutput: null, + bipvOutput: null, + }, +}; + +const mutations = { + SET_HOME_INFO: (state, payload) => { + state.home.ftoInvest = payload.ftoInvest; + state.home.chipInvest = payload.chipInvest; + state.home.chipOutput = payload.chipOutput; + state.home.stdOutput = payload.stdOutput; + state.home.bipvOutput = payload.bipvOutput; + }, + SET_COPILOT_INFO: (state, { type, payload }) => { + switch (type) { + case "yield": + state.copilot.yield.ftoInvest = payload.ftoInvest; + state.copilot.yield.chipInvest = payload.chipInvest; + state.copilot.yield.chipOutput = payload.chipOutput; + state.copilot.yield.stdOutput = payload.stdOutput; + state.copilot.yield.bipvOutput = payload.bipvOutput; + break; + case "energy": + state.copilot.energy = payload.data; + break; + case "efficiency": + state.copilot.efficiency = payload.data; + break; + } + }, +}; + +const actions = { + /** 初始化首页数据 */ + async initHome({ commit }) { + const dataArr = await getHomeInfo(); + const targetArr = await getHomeTarget(); + const payload = splitCurrentAndPrevious(dataArr, targetArr); + commit("SET_HOME_INFO", payload); + }, + /** 初始化驾驶舱数据 */ + async initCopilot({ commit }, { period, source }) { + const fetcher = { + yield: getCopilotYield, + energy: null, + efficiency: null, + }[source]; + let { data: factoryList, type } = await fetcher(period); + + const payload = splitCurrentAndPrevious(factoryList); + commit("SET_COPILOT_INFO", { type, payload }); + }, +}; + +export default { + namespaced: true, + state, + mutations, + actions, +}; + +// utils function +function splitCurrentAndPrevious(factoryListResponse, targetListResponse) { + const { chipInvest, ftoInvest, chipOutput, stdOutput, bipvOutput } = init(); + if (factoryListResponse) { + for (const factory of factoryListResponse) { + debugger; + const fId = getFactoryId(factory); + // 获取目标值 + if (targetListResponse) { + const { chipYield, componentYield, bipvProductOutput } = + getFactoryTargetValue(targetListResponse, fId); + chipOutput.target[fId] = chipYield; + stdOutput.target[fId] = componentYield; + bipvOutput.target[fId] = bipvProductOutput; + } + // 芯片投入 + chipInvest.current[fId] = factory.inputNumber; + chipInvest.previous[fId] = factory.previousYearInputNumber; + // FTO投入 + ftoInvest.current[fId] = factory.chipInput; + ftoInvest.previous[fId] = factory.previousYearChipInput; + // 产出数据, 0 - (玻璃)芯片产出, 1 - 标准组件产出, 2 - BIPV产出 + const _t = [chipOutput, stdOutput, bipvOutput][factory.glassType]; + _t.current[fId] = factory.outputNumber; + _t.previous[fId] = factory.previousYearOutputNumber; + } + + return { + chipInvest, + ftoInvest, + chipOutput, + stdOutput, + bipvOutput, + }; + } +} + +function getFactoryId(factory) { + return factory.factory; +} + +function getFactoryTargetValue(targetList, factoryId) { + const target = targetList.find((item) => item.factory === factoryId); + if (target) { + return { + // 自带模拟数据了.... random_default + chipYield: target.chipYield ?? random_default(), + componentYield: target.componentYield ?? random_default(), + bipvProductOutput: target.bipvProductOutput ?? random_default(), + }; + } + return { + chipYield: random_default(), + componentYield: random_default(), + bipvProductOutput: random_default(), + }; +} + +function init() { + const t_ = { + current: Array(7).fill(0), + previous: Array(7).fill(0), + }; + // 芯片投入 + const chipInvest = deepClone(t_); + // FTO投入 + const ftoInvest = deepClone(t_); + // 芯片产出 + const chipOutput = { + ...deepClone(t_), + target: Array(7).fill(0), + }; + // 标准组件产出 + const stdOutput = deepClone(chipOutput); + // BIPV产出 + const bipvOutput = deepClone(chipOutput); + + return { + chipInvest, + ftoInvest, + chipOutput, + stdOutput, + bipvOutput, + }; +} function random_default() { return 0; @@ -34,7 +202,7 @@ async function getHomeTarget() { return null; } -async function getCopilotYield(params) { +async function fetcher(params) { const { code, data } = await axios.post("/ip/prod-output/query-by-date", { ...params, }); @@ -45,218 +213,30 @@ async function getCopilotYield(params) { return null; } -/* 状态 */ -const state = { - copilot: { - /* 产量驾驶舱 */ - yield: {}, - /* 能源驾驶舱 */ - energy: {}, - /* 效率驾驶舱 */ - efficiency: {}, - }, - home: { - ftoInvest: null, - chipInvest: null, - chipOutput: null, - stdOutput: null, - bipvOutput: null, - }, -}; +async function getCopilotYield(period) { + // 请求参数,直接一次性获取所有工厂 + let queryParams = { + factorys: [], + date: 4, + }; -const mutations = { - SET_HOME_INFO: (state, payload) => { - state.home.ftoInvest = payload.ftoInvest; - state.home.chipInvest = payload.chipInvest; - state.home.chipOutput = payload.chipOutput; - state.home.stdOutput = payload.stdOutput; - state.home.bipvOutput = payload.bipvOutput; - }, - 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; - } - }, -}; + 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 actions = { - /** 初始化首页数据 */ - async initHome({ commit }) { - const dataArr = await getHomeInfo(); - const targetArr = await getHomeTarget(); - - const chipInvest = { - current: Array(7).fill(0), - previous: Array(7).fill(0), - }; // 芯片投入 - const ftoInvest = { - current: Array(7).fill(0), - previous: Array(7).fill(0), - }; // FTO投入 - const chipOutput = { - current: Array(7).fill(0), - previous: Array(7).fill(0), - target: Array(7).fill(0), - }; // 芯片产出 - const stdOutput = { - current: Array(7).fill(0), - previous: Array(7).fill(0), - target: Array(7).fill(0), - }; // 标准组件产出 - const bipvOutput = { - current: Array(7).fill(0), - previous: Array(7).fill(0), - target: Array(7).fill(0), - }; // BIPV产出 - - if (dataArr) { - for (const factory of dataArr) { - /* 工厂索引 */ - const factoryId = factory.factory; - /* 收集目标数据 */ - if (targetArr) { - const target = targetArr.find((item) => item.factory === factoryId); - 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 - ); - } - } - /* 收集芯片投入数据 */ - chipInvest.current.splice( - factoryId, - 1, - factory.inputNumber ?? random_default() - ); - chipInvest.previous.splice( - factoryId, - 1, - factory.previousYearInputNumber ?? random_default() - ); - /* 收集FTO投入数据 */ - ftoInvest.current.splice( - factoryId, - 1, - factory.chipInput ?? random_default() - ); - ftoInvest.previous.splice( - factoryId, - 1, - factory.previousYearChipInput ?? random_default() - ); - /* 收集产出数据 */ - switch (factory.glassType) { - case 0: - // 玻璃芯片 产出 - chipOutput.current.splice( - factoryId, - 1, - factory.outputNumber ?? random_default() - ); - chipOutput.previous.splice( - factoryId, - 1, - factory.previousYearOutputNumber ?? random_default() - ); - break; - case 1: - // 标准组件 产出 - stdOutput.current.splice( - factoryId, - 1, - factory.outputNumber ?? random_default() - ); - stdOutput.previous.splice( - factoryId, - 1, - factory.previousYearOutputNumber ?? random_default() - ); - break; - case 2: - // BIPV 产出 - bipvOutput.current.splice( - factoryId, - 1, - factory.outputNumber ?? random_default() - ); - bipvOutput.previous.splice( - factoryId, - 1, - factory.previousYearOutputNumber ?? random_default() - ); - break; - } - } - - /* 更新 state */ - commit("SET_HOME_INFO", { - ftoInvest, - chipInvest, - chipOutput, - stdOutput, - bipvOutput, - }); - } - }, - /** 初始化驾驶舱数据 */ - 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 { - namespaced: true, - state, - mutations, - actions, -}; + return { data: await fetcher(queryParams), type: "yield" }; +} diff --git a/src/views/copilot/components/charts/StdOutput.vue b/src/views/copilot/components/charts/StdOutput.vue index 97c787b..9ff5e7d 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/CityData.vue b/src/views/copilot/components/charts/base/CityData.vue index f285aae..47e0dc9 100644 --- a/src/views/copilot/components/charts/base/CityData.vue +++ b/src/views/copilot/components/charts/base/CityData.vue @@ -11,7 +11,7 @@
- +
@@ -42,8 +42,8 @@ export default { }, props: { dataSource: { - type: Object, - default: () => ({}), + type: String, + default: null, }, period: { type: String, @@ -51,18 +51,57 @@ export default { }, }, data() { - return { - cities: [ - { name: "蚌埠兴科", value: 93111 }, - { name: "成都", value: 32212 }, - { name: "邯郸", value: 7732 }, - { name: "株洲", value: 71732 }, - { name: "瑞昌", value: 23421 }, - { name: "佳木斯", value: 340 }, - ], - }; + return {}; + }, + computed: { + headquarterValue() { + let getterName = ""; + switch (this.dataSource) { + case "标准组件输出": + getterName = "stdOutput"; + break; + case "芯片输出": + getterName = "chipOutput"; + break; + case "BIPV输出": + getterName = "bipvOutput"; + break; + } + return ( + "" + (this.$store.getters.copilot.yield[getterName]?.current?.[5] ?? 0) + ); + }, + cities() { + let getterName = ""; + switch (this.dataSource) { + case "标准组件输出": + getterName = "stdOutput"; + break; + case "芯片输出": + getterName = "chipOutput"; + break; + case "BIPV输出": + getterName = "bipvOutput"; + break; + } + const _cities = [ + { name: "瑞昌", value: 0 }, + { name: "邯郸", value: 0 }, + { name: "株洲", value: 0 }, + { name: "佳木斯", value: 0 }, + { name: "成都", value: 0 }, + { name: "凯盛光伏", value: 0 }, + { name: "蚌埠兴科", value: 0 }, + ]; + this.$store.getters.copilot.yield[getterName]?.current?.forEach( + (v, idx) => { + _cities[idx].value = v ?? 0; + } + ); + _cities.splice(4, 1); + return _cities; + }, }, - computed: {}, mounted() {}, methods: {}, }; diff --git a/src/views/copilot/components/charts/base/DoubleRingWrapper.vue b/src/views/copilot/components/charts/base/DoubleRingWrapper.vue index 10d3fc7..be95762 100644 --- a/src/views/copilot/components/charts/base/DoubleRingWrapper.vue +++ b/src/views/copilot/components/charts/base/DoubleRingWrapper.vue @@ -26,15 +26,15 @@ import CopilotSelect from "../../select.vue"; import fetcher from "./fetcherDoubleRing"; import DoubleRingChartVue from "./DoubleRingChart.vue"; -import CityData from './CityData.vue'; +import CityData from "./CityData.vue"; export default { name: "DoubleRingWrapper", components: { CopilotSelect, DoubleRingChartVue, CityData }, props: { dataSource: { - type: Object, - default: () => ({}), + type: String, + default: null, }, period: { type: String, diff --git a/src/views/copilot/yield/index.vue b/src/views/copilot/yield/index.vue index 40ad7b8..b35ed84 100644 --- a/src/views/copilot/yield/index.vue +++ b/src/views/copilot/yield/index.vue @@ -56,7 +56,6 @@ export default { data() { return {}; }, - computed: {}, watch: { period: { handler(val) { @@ -67,7 +66,8 @@ export default { }, methods: { fetchData(period = "日") { - this.$store.dispatch("copilot/initCopilot", { period }); + console.log(`产量驾驶舱,获取${period}数据`); + this.$store.dispatch("copilot/initCopilot", { period, source: "yield" }); }, }, }; From e8cc80495f66ce4b92d38b66b174b7cc087c86fa Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Fri, 26 Apr 2024 11:23:40 +0800 Subject: [PATCH 4/7] =?UTF-8?q?update=20=E4=BA=A7=E9=87=8Ffto=E6=8A=95?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/home.js | 1 - .../copilot/components/charts/BipvOutput.vue | 4 +- .../copilot/components/charts/ChipOutput.vue | 4 +- .../copilot/components/charts/FtoInvest.vue | 90 ++++++++----------- .../copilot/components/charts/StdOutput.vue | 2 +- .../components/charts/base/BarChartBase.vue | 4 +- .../components/charts/base/CityData.vue | 12 +-- 7 files changed, 51 insertions(+), 66 deletions(-) diff --git a/src/store/modules/home.js b/src/store/modules/home.js index ea4d46a..669f429 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -87,7 +87,6 @@ function splitCurrentAndPrevious(factoryListResponse, targetListResponse) { const { chipInvest, ftoInvest, chipOutput, stdOutput, bipvOutput } = init(); if (factoryListResponse) { for (const factory of factoryListResponse) { - debugger; const fId = getFactoryId(factory); // 获取目标值 if (targetListResponse) { diff --git a/src/views/copilot/components/charts/BipvOutput.vue b/src/views/copilot/components/charts/BipvOutput.vue index fd40bef..dba836b 100644 --- a/src/views/copilot/components/charts/BipvOutput.vue +++ b/src/views/copilot/components/charts/BipvOutput.vue @@ -6,7 +6,7 @@ --> diff --git a/src/views/copilot/components/charts/ChipOutput.vue b/src/views/copilot/components/charts/ChipOutput.vue index 498c72e..099dd42 100644 --- a/src/views/copilot/components/charts/ChipOutput.vue +++ b/src/views/copilot/components/charts/ChipOutput.vue @@ -6,7 +6,7 @@ --> diff --git a/src/views/copilot/components/charts/FtoInvest.vue b/src/views/copilot/components/charts/FtoInvest.vue index fc490dc..7971edc 100644 --- a/src/views/copilot/components/charts/FtoInvest.vue +++ b/src/views/copilot/components/charts/FtoInvest.vue @@ -44,8 +44,8 @@ export default { const year = new Date().getFullYear(); const month = new Date().getMonth() + 1; return [ - { label: `${year}年${month}月`, color: "#12f7f1" }, - { label: `${year - 1}年${month}月`, color: "#58adfa" }, + { label: `${year - 1}年${month}月`, color: "#12f7f1" }, + { label: `${year}年${month}月`, color: "#58adfa" }, ]; } case "年": { @@ -63,59 +63,45 @@ export default { } }, series() { - const template = - this.period == "日" || this.period == "周" - ? [ - { - name: "样例数据--2023年", - data: Array.from({ length: 7 }, () => - Math.floor(Math.random() * 1000) - ), - }, - ] - : [ - { - name: "样例数据--2023年", - data: Array.from({ length: 7 }, () => - Math.floor(Math.random() * 1000) - ), - }, - { - name: "样例数据--2024年", - data: Array.from({ length: 7 }, () => - Math.floor(Math.random() * 1000) - ), - }, - ]; - const ftoInvest = this.$store.getters.home.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) - ), - }, - ]; + const { ftoInvest } = this.$store.getters.copilot.yield; + let dataList = null; + + switch (this.period) { + case "日": + case "周": + dataList = ftoInvest?.current; + break; + default: + dataList = []; + dataList[0] = ftoInvest?.pervious; + dataList[1] = ftoInvest?.current; } - return [ - { - name: `${new Date().getFullYear() - 1}年`, - data: ftoInvest.previous, - }, - { - name: `${new Date().getFullYear()}年`, - data: ftoInvest.current, - }, - ]; + return getTemplate(this.period, dataList); }, }, }; + +function getTemplate(period, dataList) { + const year = new Date().getFullYear(); + const month = new Date().getMonth() + 1; + return period == "日" || period == "周" + ? [ + { + name: period == "日" ? "昨天" : "本周", + data: dataList ?? [], + }, + ] + : [ + { + name: period == "年" ? `${year - 1}年` : `${year - 1}年${month}月`, + data: dataList ? dataList[0] : [], + }, + { + name: period == "年" ? `${year}年` : `${year}年${month}月`, + data: dataList ? dataList[1] : [], + // : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)), + }, + ]; +} diff --git a/src/views/copilot/components/charts/StdOutput.vue b/src/views/copilot/components/charts/StdOutput.vue index 9ff5e7d..064b8b6 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/FtoInvest.vue b/src/views/copilot/components/charts/FtoInvest.vue index 7971edc..a825691 100644 --- a/src/views/copilot/components/charts/FtoInvest.vue +++ b/src/views/copilot/components/charts/FtoInvest.vue @@ -10,6 +10,7 @@ :legend="legend" :series="series" :xAxis="xAxis" + in="ftoInvest" class="fto-chart" /> @@ -88,7 +89,7 @@ function getTemplate(period, dataList) { return period == "日" || period == "周" ? [ { - name: period == "日" ? "昨天" : "本周", + name: period == "日" ? "昨日" : "本周", data: dataList ?? [], }, ] diff --git a/src/views/copilot/components/charts/base/BarChartBase.vue b/src/views/copilot/components/charts/base/BarChartBase.vue index 18d188a..f136dd3 100644 --- a/src/views/copilot/components/charts/base/BarChartBase.vue +++ b/src/views/copilot/components/charts/base/BarChartBase.vue @@ -52,6 +52,10 @@ export default { type: Array, required: true, }, + in: { + type: String, + default: "" + } }, data() { return { @@ -190,6 +194,8 @@ export default { this.initOptions(this.actualOptions); }, series(val) { + debugger; + console.log(`[BarChartBase] [${this.in}] should update component`, val); if (!val) { this.initOptions(this.options); return; @@ -198,7 +204,7 @@ export default { actualOptions.series[0].data = val[0].data; actualOptions.series[0].name = val[0].name; actualOptions.series[1].data = val?.[1]?.data || []; - actualOptions.series[1].name = val?.[1]?.name || ''; + actualOptions.series[1].name = val?.[1]?.name || ""; this.actualOptions = actualOptions; this.initOptions(actualOptions); }, From 08c9cf8dd66bcf9f36978045c28c48f124fdbfb1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Fri, 26 Apr 2024 17:05:26 +0800 Subject: [PATCH 6/7] =?UTF-8?q?update=20=E6=A0=87=E5=87=86=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E4=BA=A7=E5=87=BA=20=E7=8E=AF=E5=BD=A2=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/home.js | 40 ++++++++++++---- .../components/charts/base/BarChartBase.vue | 6 +-- .../charts/base/DoubleRingChart.vue | 32 ++++++++++--- .../charts/base/DoubleRingWrapper.vue | 13 ++---- .../charts/base/double-ring-chart-options.js | 46 ++++++++++++------- src/views/copilot/components/select.vue | 13 +++++- 6 files changed, 103 insertions(+), 47 deletions(-) diff --git a/src/store/modules/home.js b/src/store/modules/home.js index c0a68a8..bfab628 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -68,9 +68,15 @@ const actions = { energy: null, efficiency: null, }[source]; + // 获取产量数据 let { data: factoryList, type } = await fetcher(period); - - const payload = splitCurrentAndPrevious(factoryList); + let targetList = null; + if (source === "yield") { + // 获取目标数据 + let { data } = await fetcher(period, true); + targetList = data; + } + const payload = splitCurrentAndPrevious(factoryList, targetList); commit("SET_COPILOT_INFO", { type, payload }); }, }; @@ -104,7 +110,7 @@ function splitCurrentAndPrevious(factoryListResponse, targetListResponse) { ftoInvest.previous[fId] = factory.previousYearChipInput; // 产出数据, 0 - (玻璃)芯片产出, 1 - 标准组件产出, 2 - BIPV产出 // 因为后端写的垃圾数据,所以这里要做一下判断 - if (!([0, 1, 2].includes(factory.glassType))) continue; + if (![0, 1, 2].includes(factory.glassType)) continue; const _t = [chipOutput, stdOutput, bipvOutput][factory.glassType]; _t.current[fId] = factory.outputNumber; _t.previous[fId] = factory.previousYearOutputNumber; @@ -204,10 +210,17 @@ async function getHomeTarget() { return null; } -async function fetcher(params) { - const { code, data } = await axios.post("/ip/prod-output/query-by-date", { - ...params, - }); +async function fetcher(type = "yield", params) { + const { code, data } = await axios.post( + type == "yield" + ? // 产量 数据 + "/ip/prod-output/query-by-date" + : // 目标数据 + "/ip/prod-target/query-by-date", + { + ...params, + } + ); if (code == 0) { return data; } @@ -215,7 +228,13 @@ async function fetcher(params) { return null; } -async function getCopilotYield(period) { +/** + * + * @param {*} period 周期: 日周月年 + * @param {*} target 是否获取目标数据:默认 否 + * @returns + */ +async function getCopilotYield(period, target = false) { // 请求参数,直接一次性获取所有工厂 let queryParams = { factorys: [], @@ -240,5 +259,8 @@ async function getCopilotYield(period) { break; } - return { data: await fetcher(queryParams), type: "yield" }; + return { + data: await fetcher(target ? "target" : "yield", queryParams), + type: "yield", + }; } diff --git a/src/views/copilot/components/charts/base/BarChartBase.vue b/src/views/copilot/components/charts/base/BarChartBase.vue index f136dd3..54768a9 100644 --- a/src/views/copilot/components/charts/base/BarChartBase.vue +++ b/src/views/copilot/components/charts/base/BarChartBase.vue @@ -54,8 +54,8 @@ export default { }, in: { type: String, - default: "" - } + default: "", + }, }, data() { return { @@ -194,8 +194,6 @@ export default { this.initOptions(this.actualOptions); }, series(val) { - debugger; - console.log(`[BarChartBase] [${this.in}] should update component`, val); if (!val) { this.initOptions(this.options); return; diff --git a/src/views/copilot/components/charts/base/DoubleRingChart.vue b/src/views/copilot/components/charts/base/DoubleRingChart.vue index be15fca..d61cebe 100644 --- a/src/views/copilot/components/charts/base/DoubleRingChart.vue +++ b/src/views/copilot/components/charts/base/DoubleRingChart.vue @@ -23,7 +23,7 @@