update gas

This commit is contained in:
lb 2023-07-13 16:56:01 +08:00
parent eddf31332f
commit e531907301
6 changed files with 38 additions and 36 deletions

View File

@ -1,3 +1,4 @@
//
import cls from './index.module.css'; import cls from './index.module.css';
import BottomBarItem from '../BottomBarItem'; import BottomBarItem from '../BottomBarItem';
import ReactECharts from 'echarts-for-react'; import ReactECharts from 'echarts-for-react';
@ -26,7 +27,7 @@ function GasI(props) {
let options = null; let options = null;
if (showChart) { if (showChart) {
// keys() sort() // keys() sort()
hisState?.combustionAir seriesData = hisState?.combustionAir
? Object.keys(hisState.combustionAir) ? Object.keys(hisState.combustionAir)
.sort() .sort()
.map((key) => hisState.combustionAir[key]) .map((key) => hisState.combustionAir[key])
@ -35,7 +36,11 @@ function GasI(props) {
.map((_) => Array(7).fill(0)); .map((_) => Array(7).fill(0));
// debug // debug
console.log('gasI series data', hisState?.combustionAir, seriesData); console.log(
'助燃风 chart series data',
hisState?.combustionAir,
seriesData,
);
options = { options = {
color: colors, color: colors,
grid: { top: 32, right: 12, bottom: 20, left: 48 }, grid: { top: 32, right: 12, bottom: 20, left: 48 },
@ -74,7 +79,6 @@ function GasI(props) {
axisLabel: { axisLabel: {
color: '#fff', color: '#fff',
fontSize: 12, fontSize: 12,
formatter: '{value} %',
}, },
axisLine: { axisLine: {
show: true, show: true,
@ -87,14 +91,15 @@ function GasI(props) {
color: '#213259a0', color: '#213259a0',
}, },
}, },
interval: 10, // interval: 10,
min: 0, // min: 0,
max: 100, // max: 100,
}, },
series: seriesData.map((v, i) => ({ series: seriesData.map((v, i) => ({
name: i + 1 + '#助燃风', name: i + 1 + '#助燃风',
data: v, data: v,
type: 'line', type: 'line',
symbol: 'circle',
areaStyle: { areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: colors[i] + '40' }, { offset: 0, color: colors[i] + '40' },
@ -108,7 +113,7 @@ function GasI(props) {
}, },
}; };
} else { } else {
runState?.combustionAirFlow dataList = runState?.combustionAirPressureArr
? [ ? [
{ id: 1, name: '1#助燃风', value: '0m³/h' }, { id: 1, name: '1#助燃风', value: '0m³/h' },
{ id: 2, name: '2#助燃风', value: '0m³/h' }, { id: 2, name: '2#助燃风', value: '0m³/h' },
@ -120,7 +125,7 @@ function GasI(props) {
{ id: 8, name: '8#助燃风', value: '0m³/h' }, { id: 8, name: '8#助燃风', value: '0m³/h' },
].map((item, index) => ({ ].map((item, index) => ({
...item, ...item,
value: runState.combustionAirFlow[index], value: runState.combustionAirPressureArr[index] ?? '/',
})) }))
: [ : [
{ id: 1, name: '1#助燃风', value: '0m³/h' }, { id: 1, name: '1#助燃风', value: '0m³/h' },
@ -133,7 +138,7 @@ function GasI(props) {
{ id: 8, name: '8#助燃风', value: '0m³/h' }, { id: 8, name: '8#助燃风', value: '0m³/h' },
]; ];
// debug // debug
console.log('gasI grid data', runState?.combustionAirFlow); console.log('助燃风 实时 data', runState?.combustionAirPressureArr);
} }
function handleSwitchChange(val) { function handleSwitchChange(val) {
@ -148,7 +153,8 @@ function GasI(props) {
<div className={cls.headWidget}> <div className={cls.headWidget}>
<div className="flex items-center"> <div className="flex items-center">
<Switch size="small" defaultChecked onChange={handleSwitchChange} /> <Switch size="small" defaultChecked onChange={handleSwitchChange} />
<span className={cls.switchLabel}>历史详情</span> {showChart && <span className={cls.switchLabel}>历史详情</span>}
{!showChart && <span className={cls.switchLabel}>实时流量</span>}
</div> </div>
</div> </div>

View File

@ -6,23 +6,23 @@ function getData(type) {
switch (type) { switch (type) {
case 'gas-i': case 'gas-i':
data = [ data = [
{ id: 1, name: '1#天然气I', value: '122m³/h' }, { id: 1, name: '1#天然气I', value: '0m³/h' },
{ id: 2, name: '2#天然气I', value: '200m³/h' }, { id: 2, name: '2#天然气I', value: '0m³/h' },
{ id: 3, name: '3#天然气I', value: '112m³/h' }, { id: 3, name: '3#天然气I', value: '0m³/h' },
{ id: 4, name: '4#天然气I', value: '189m³/h' }, { id: 4, name: '4#天然气I', value: '0m³/h' },
{ id: 5, name: '5#天然气I', value: '109m³/h' }, { id: 5, name: '5#天然气I', value: '0m³/h' },
{ id: 6, name: '6#天然气I', value: '167m³/h' }, { id: 6, name: '6#天然气I', value: '0m³/h' },
{ id: 7, name: '7#天然气I', value: '172m³/h' }, { id: 7, name: '7#天然气I', value: '0m³/h' },
{ id: 8, name: '8#天然气I', value: '145m³/h' }, { id: 8, name: '8#天然气I', value: '0m³/h' },
]; ];
break; break;
case 'gas-ii': case 'gas-ii':
data = [ data = [
{ id: 11, name: '1#天然气II', value: '85m³/h' }, { id: 11, name: '1#天然气II', value: '0m³/h' },
{ id: 12, name: '2#天然气II', value: '45m³/h' }, { id: 12, name: '2#天然气II', value: '0m³/h' },
{ id: 13, name: '3#天然气II', value: '6m³/h' }, { id: 13, name: '3#天然气II', value: '0m³/h' },
{ id: 14, name: '4#天然气II', value: '72m³/h' }, { id: 14, name: '4#天然气II', value: '0m³/h' },
{ id: 15, name: '5#天然气II', value: '83m³/h' }, { id: 15, name: '5#天然气II', value: '0m³/h' },
]; ];
break; break;
} }

View File

@ -1,3 +1,4 @@
//
import cls from './index.module.css'; import cls from './index.module.css';
import BottomBarItem from '../BottomBarItem'; import BottomBarItem from '../BottomBarItem';
@ -35,7 +36,8 @@ function GasII(props) {
<div className={cls.headWidget}> <div className={cls.headWidget}>
<div className="flex items-center"> <div className="flex items-center">
<Switch size="small" defaultChecked onChange={handleSwitchChange} /> <Switch size="small" defaultChecked onChange={handleSwitchChange} />
<span className={cls.switchLabel}>历史详情</span> {showChart && <span className={cls.switchLabel}>历史详情</span>}
{!showChart && <span className={cls.switchLabel}>实时流量</span>}
</div> </div>
<Radio.Group <Radio.Group

View File

@ -9,7 +9,7 @@ const Slider = (props) => {
}; };
return ( return (
<div id="slider" className="slider"> <div id="slider" className="slider">
<input type="range" value={v} onInput={handleInput} /> <input type="range" value={v} onInput={handleInput} onChange={() => {}} />
</div> </div>
); );
}; };

View File

@ -1,6 +1,4 @@
import React from 'react';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import './global.less'; import './global.less';
import './index.less'; import './index.less';
import Head from '../components/Head'; import Head from '../components/Head';
@ -9,15 +7,12 @@ import BottomBar from '../components/BottomBar';
import RightBar from '../components/RightBar'; import RightBar from '../components/RightBar';
import CenterTopData from '../components/CenterTopData'; import CenterTopData from '../components/CenterTopData';
import Slider from '../components/Slider'; import Slider from '../components/Slider';
import V3DBG from '../assets/V3DBG.png';
import V3D from './V3D';
import { SocketContextProvider } from '../store/socket-data-provider'; import { SocketContextProvider } from '../store/socket-data-provider';
import V3DBG from '../assets/V3DBG.png';
// import V3D from './V3D';
export default function index() { export default function index() {
const [width, setWidth] = useState(window.innerWidth);
const [value, setValue] = useState(100); const [value, setValue] = useState(100);
const v = (value / 100).toFixed(2); const v = (value / 100).toFixed(2);

View File

@ -21,12 +21,11 @@ export const SocketContextProvider = (props) => {
let incommingData = JSON.parse(e.data); let incommingData = JSON.parse(e.data);
switch (incommingData.type) { switch (incommingData.type) {
case 'RunData': case 'RunData':
console.log('run data arrived, set RunData'); console.log('run data arrived, set 运行时数据');
setRunState(incommingData.data); setRunState(incommingData.data);
break; break;
case 'HisData': case 'HisData':
console.log('his data arrived, set HisData'); console.log('his data arrived, set 历史数据');
// setHisState(prevHisState => ({ ...prevHisState, ...incommingData.data }));
setHisState(incommingData.data); setHisState(incommingData.data);
break; break;
} }