|
|
@@ -1,20 +1,164 @@ |
|
|
|
import axios from "@/utils/request"; |
|
|
|
|
|
|
|
function random_default() { |
|
|
|
return 0; |
|
|
|
let a = Math.floor(Math.random() * 1000); |
|
|
|
while (a < 600) { |
|
|
|
a = Math.floor(Math.random() * 1000); |
|
|
|
} |
|
|
|
return a; |
|
|
|
} |
|
|
|
|
|
|
|
/* 接口 */ |
|
|
|
async function getHomeInfo() { |
|
|
|
const { code, data } = await axios.post("/ip/prod-output/query-by-date", { |
|
|
|
factorys: [], |
|
|
|
date: 4, |
|
|
|
}); |
|
|
|
if (code == 0) { |
|
|
|
return data; |
|
|
|
} |
|
|
|
console.warn("getHomeInfo failed, code: ", code); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
async function getHomeTarget() { |
|
|
|
const { code, data } = await axios.post("/ip/prod-target/query-by-date", { |
|
|
|
factorys: [], |
|
|
|
date: 4, |
|
|
|
}); |
|
|
|
if (code == 0) { |
|
|
|
return data; |
|
|
|
} |
|
|
|
console.warn("getHomeTarget failed, code: ", code); |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/* 状态 */ |
|
|
|
const state = { |
|
|
|
info: null |
|
|
|
copilot: { |
|
|
|
/* 产量驾驶舱 */ |
|
|
|
yield: {}, |
|
|
|
/* 能源驾驶舱 */ |
|
|
|
energy: {}, |
|
|
|
/* 效率驾驶舱 */ |
|
|
|
efficiency: {}, |
|
|
|
}, |
|
|
|
home: { |
|
|
|
ftoInvest: null, |
|
|
|
chipInvest: null, |
|
|
|
chipOutput: null, |
|
|
|
stdOutput: null, |
|
|
|
bipvOutput: null, |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
const mutations = { |
|
|
|
SET_INFO: (state) => { |
|
|
|
state.info = state |
|
|
|
}, |
|
|
|
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) => {}, |
|
|
|
}; |
|
|
|
|
|
|
|
const actions = { |
|
|
|
setInfo({ commit }, ) { |
|
|
|
commit("SET_INFO", ); |
|
|
|
}, |
|
|
|
closeSideBar({ commit }, { withoutAnimation }) { |
|
|
|
commit("CLOSE_SIDEBAR", withoutAnimation); |
|
|
|
/** 初始化首页数据 */ |
|
|
|
async initHome({ commit }) { |
|
|
|
const dataArr = await getHomeInfo(); |
|
|
|
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), |
|
|
|
}; // 芯片产出 |
|
|
|
const stdOutput = []; // 标准组件产出 |
|
|
|
const bipvOutput = { |
|
|
|
current: Array(7).fill(0), |
|
|
|
previous: Array(7).fill(0), |
|
|
|
}; // BIPV产出 |
|
|
|
|
|
|
|
if (dataArr) { |
|
|
|
console.log("copilot init home--->", dataArr); |
|
|
|
for (const factory of dataArr) { |
|
|
|
/* 工厂索引 */ |
|
|
|
const factoryId = factory.factory; |
|
|
|
/* 收集芯片投入数据 */ |
|
|
|
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: |
|
|
|
// 标准组件 产出 |
|
|
|
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 }) {}, |
|
|
|
}; |
|
|
|
|
|
|
|
export default { |
|
|
|