diff --git a/.env.dev b/.env.dev index f62007f..e8ccd63 100644 --- a/.env.dev +++ b/.env.dev @@ -5,8 +5,8 @@ ENV = 'development' VUE_APP_TITLE = 芋道管理系统 # 芋道管理系统/开发环境 -# VUE_APP_BASE_API = 'http://192.168.1.61:48080' -VUE_APP_BASE_API = 'http://glass.kszny.picaiba.com' +VUE_APP_BASE_API = 'http://192.168.1.61:48080' +# VUE_APP_BASE_API = 'http://glass.kszny.picaiba.com' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/src/store/modules/home.js b/src/store/modules/home.js index bfab628..ca92d85 100644 --- a/src/store/modules/home.js +++ b/src/store/modules/home.js @@ -18,6 +18,7 @@ const state = { efficiency: {}, }, home: { + /** 主页状态 */ ftoInvest: null, chipInvest: null, chipOutput: null, @@ -65,13 +66,13 @@ const actions = { async initCopilot({ commit }, { period, source }) { const fetcher = { yield: getCopilotYield, - energy: null, - efficiency: null, + energy: getCopilotEnergy, + efficiency: getCopilotEfficiency, }[source]; // 获取产量数据 let { data: factoryList, type } = await fetcher(period); let targetList = null; - if (source === "yield") { + if (source === "yield" || source === "efficiency") { // 获取目标数据 let { data } = await fetcher(period, true); targetList = data; @@ -88,8 +89,8 @@ export default { actions, }; -// utils function function splitCurrentAndPrevious(factoryListResponse, targetListResponse) { + // 初始数据 const { chipInvest, ftoInvest, chipOutput, stdOutput, bipvOutput } = init(); if (factoryListResponse) { for (const factory of factoryListResponse) { @@ -148,6 +149,10 @@ function getFactoryTargetValue(targetList, factoryId) { }; } +/** + * + * @returns 初始化状态值 + */ function init() { const t_ = { current: Array(7).fill(0), @@ -168,11 +173,11 @@ function init() { const bipvOutput = deepClone(chipOutput); return { - chipInvest, - ftoInvest, - chipOutput, - stdOutput, - bipvOutput, + chipInvest, // 芯片投入 + ftoInvest, // FTO投入 + chipOutput, // 芯片产出 + stdOutput, // 标准组件产出 + bipvOutput, // BIPV产出 }; } @@ -210,13 +215,33 @@ async function getHomeTarget() { return null; } -async function fetcher(type = "yield", params) { +function getUrl(copilot_module) { + let url = { + // 对比数据的 URL + comparison: "", + // 目标数据的 URL + target: "", + }; + switch (copilot_module) { + case "yield": + url.comparison = "/ip/prod-output/query-by-date"; + url.target = "/ip/prod-target/query-by-date"; + break; + case "energy": + break; + case "efficiency": + url.comparison = "/ip/prod-output/query-Rate-List"; + url.target = "/ip/prod-target/query-rate-target"; + break; + } + + return url; +} + +async function doFetch(copilot_module = "yield", fetch_target, params) { + const url = getUrl(copilot_module); const { code, data } = await axios.post( - type == "yield" - ? // 产量 数据 - "/ip/prod-output/query-by-date" - : // 目标数据 - "/ip/prod-target/query-by-date", + fetch_target ? url.target : url.comparison, { ...params, } @@ -224,17 +249,36 @@ async function fetcher(type = "yield", params) { if (code == 0) { return data; } - console.warn("getCopilotYield failed, code: ", code); + console.warn("[doFetch] failed, code: ", code); return null; } +/** + * + * @param {*} period 日周月年1,2,3,4 + * @param {*} target 是否获取目标数据 + * @returns + */ +function getCopilotYield(period, target = false) { + return getCopilotData("yield", period, target); +} + +function getCopilotEnergy(period, target = false) { + return getCopilotData("energy", period, target); +} + +function getCopilotEfficiency(period, target = false) { + return getCopilotData("efficiency", period, target); +} + /** * * @param {*} period 周期: 日周月年 * @param {*} target 是否获取目标数据:默认 否 * @returns */ -async function getCopilotYield(period, target = false) { +async function getCopilotData(copilot_module, period, target = false) { + if (!copilot_module) copilot_module = "yield"; // 请求参数,直接一次性获取所有工厂 let queryParams = { factorys: [], @@ -260,7 +304,7 @@ async function getCopilotYield(period, target = false) { } return { - data: await fetcher(target ? "target" : "yield", queryParams), - type: "yield", + data: await doFetch(copilot_module, target ? true : false, queryParams), + type: copilot_module, }; } diff --git a/src/views/copilot/components/ChartContainer.vue b/src/views/copilot/components/ChartContainer.vue new file mode 100644 index 0000000..2dec009 --- /dev/null +++ b/src/views/copilot/components/ChartContainer.vue @@ -0,0 +1,69 @@ + + + + + + + diff --git a/src/views/copilot/components/charts/base/fetcherDoubleRing.js b/src/views/copilot/components/charts/base/fetcherDoubleRing.js deleted file mode 100644 index 6f452a6..0000000 --- a/src/views/copilot/components/charts/base/fetcherDoubleRing.js +++ /dev/null @@ -1,10 +0,0 @@ -export default { - getData: async function (url) { - // - return await new Promise((resolve, reject) => { - setTimeout(() => { - resolve([90119, 40801, 44028]); - }, 1200); - }); - }, -}; diff --git a/src/views/copilot/components/name.vue b/src/views/copilot/components/name.vue deleted file mode 100644 index e69de29..0000000 diff --git a/src/views/copilot/efficiency/index.vue b/src/views/copilot/efficiency/index.vue index 55a1d4b..7ea9aab 100644 --- a/src/views/copilot/efficiency/index.vue +++ b/src/views/copilot/efficiency/index.vue @@ -7,23 +7,41 @@ diff --git a/src/views/copilot/components/charts/base/icon.png b/src/views/copilot/yield/assets/icon.png similarity index 100% rename from src/views/copilot/components/charts/base/icon.png rename to src/views/copilot/yield/assets/icon.png diff --git a/src/views/copilot/components/charts/BipvOutput.vue b/src/views/copilot/yield/components/BipvOutput.vue similarity index 88% rename from src/views/copilot/components/charts/BipvOutput.vue rename to src/views/copilot/yield/components/BipvOutput.vue index dba836b..1f77c21 100644 --- a/src/views/copilot/components/charts/BipvOutput.vue +++ b/src/views/copilot/yield/components/BipvOutput.vue @@ -10,7 +10,7 @@