From cb0de3b5d03c354946a67b23ad4c18e377e4daa1 Mon Sep 17 00:00:00 2001 From: lb Date: Mon, 11 Dec 2023 16:04:46 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E9=80=80=E7=81=AB-=E9=A3=8E=E6=9C=BA?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Common/FanInfo/index.jsx | 3 +- .../Modules/FireCheck/RightSide/index.jsx | 2 +- src/store/features/annealFanInfoSlice.js | 23 +++++++++++ src/store/features/fanInfo.js | 6 +-- src/store/index.js | 3 ++ src/utils/index.js | 40 +++++++++++-------- 6 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 src/store/features/annealFanInfoSlice.js diff --git a/src/components/Common/FanInfo/index.jsx b/src/components/Common/FanInfo/index.jsx index af06bda..e16b663 100644 --- a/src/components/Common/FanInfo/index.jsx +++ b/src/components/Common/FanInfo/index.jsx @@ -23,7 +23,8 @@ function attachStyle(data) { function FanInfo(props) { const rowNum = props.rows || 8; - const fanInfo = useSelector((state) => state.fanInfo.fanInfo); + // 默认使用风机信息,可以使用 source 来调整该组件使用 annealFanInfo 的数据 + const fanInfo = useSelector((state) => state[props.source ?? "fanInfo"].data); const data = Object.keys(fanInfo).map((key, index) => { return [ diff --git a/src/components/Modules/FireCheck/RightSide/index.jsx b/src/components/Modules/FireCheck/RightSide/index.jsx index 887cf77..cae4b09 100644 --- a/src/components/Modules/FireCheck/RightSide/index.jsx +++ b/src/components/Modules/FireCheck/RightSide/index.jsx @@ -18,7 +18,7 @@ export default function index() { transition={{ type: 'tween' }} >
- +
); diff --git a/src/store/features/annealFanInfoSlice.js b/src/store/features/annealFanInfoSlice.js new file mode 100644 index 0000000..184b22d --- /dev/null +++ b/src/store/features/annealFanInfoSlice.js @@ -0,0 +1,23 @@ +// 风机信息 +import { createSlice } from "@reduxjs/toolkit"; + +export const initialState = { + data: { + 正常数据: "运行", + 故障数据: "故障", + 其他数据: "其他", + }, +}; + +const annealFanInfoSlice = createSlice({ + name: "annealFanInfo", + initialState, + reducers: { + setInfo: (state, action) => { + state.data = action.payload; + }, + }, +}); + +export default annealFanInfoSlice.reducer; +export const { setInfo } = annealFanInfoSlice.actions; diff --git a/src/store/features/fanInfo.js b/src/store/features/fanInfo.js index 5ccf3c2..c824ead 100644 --- a/src/store/features/fanInfo.js +++ b/src/store/features/fanInfo.js @@ -2,8 +2,8 @@ import { createSlice } from "@reduxjs/toolkit"; export const initialState = { - fanInfo: { - 测试001: "正常", + data: { + 测试001: "运行", }, }; @@ -12,7 +12,7 @@ const fanInfoSlice = createSlice({ initialState, reducers: { setInfo: (state, action) => { - state.fanInfo = action.payload.fanInfo; + state.data = action.payload; }, }, }); diff --git a/src/store/index.js b/src/store/index.js index f0d9b45..5b66b65 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -10,6 +10,7 @@ import annealTemperatureReducer from "./features/annealTemperatureSlice"; import fanInfoReducer from "./features/fanInfo"; import energySlice from "./features/EnergySlice"; import annealFanFrequenceReducer from "./features/annealFanFrequenceSlice"; +import annealFanInfoReducer from "./features/annealFanInfoSlice"; export const store = configureStore({ reducer: { @@ -21,6 +22,8 @@ export const store = configureStore({ fireInfo: fireReducer, // 风机信息 fanInfo: fanInfoReducer, + // 风机信息 + annealFanInfo: annealFanInfoReducer, // 风机运行频率 fanFrequence: fanFrequenceReducer, // 退火-风机运行频率 diff --git a/src/utils/index.js b/src/utils/index.js index c9e1426..6af2523 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -94,14 +94,6 @@ new XClient( // 风机运行频率 历史 暂无 break; } - case "AnnealFanFrequencyInfo": { - // 退火页面,风机运行频率 暂时只有实时数据 - store.dispatch({ - type: "annealFanFrequence/setRuntime", - payload: serializedData.data.AnnealFanFrequencyInfo, - }); - break; - } case "TopTempInfo": { // 碹顶温度列表 store.dispatch({ @@ -118,14 +110,6 @@ new XClient( }); break; } - case "AnnealTempInfo": { - // 退火监测温度列表 - store.dispatch({ - type: "annealTemperature/setTemp", - payload: serializedData.data, - }); - break; - } case "FeederInfo": { // 投料机信息 store.dispatch({ @@ -146,10 +130,34 @@ new XClient( // 风机信息 store.dispatch({ type: "fanInfo/setInfo", + payload: serializedData.data.fanInfo, + }); + break; + } + case "AnnealFanFrequencyInfo": { + // 退火-风机运行频率 + store.dispatch({ + type: "annealFanFrequence/setRuntime", + payload: serializedData.data.AnnealFanFrequencyInfo, + }); + break; + } + case "AnnealTempInfo": { + // 退火-温度列表 + store.dispatch({ + type: "annealTemperature/setTemp", payload: serializedData.data, }); break; } + case "AnnealFanInfo": { + // 退火-风机故障信息 + store.dispatch({ + type: "annealFanInfo/setInfo", + payload: serializedData.data.annealFanInfo, + }); + break; + } default: { console.log("websocket message: [unknown] ---> ", msg.data); }