Commit 3f662052 authored by 陈龙's avatar 陈龙

feat: 完善移动端适配

parent 6a5da773
...@@ -146,6 +146,7 @@ ...@@ -146,6 +146,7 @@
}, },
"dependencies": { "dependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6", "@babel/plugin-proposal-private-methods": "^7.18.6",
"@wisdom-components/VmsVideo": "1.1.13",
"@wisdom-components/basictable": "^1.5.14", "@wisdom-components/basictable": "^1.5.14",
"@wisdom-components/ec_historyview": "^1.4.3", "@wisdom-components/ec_historyview": "^1.4.3",
"@wisdom-components/empty": "^1.3.9", "@wisdom-components/empty": "^1.3.9",
...@@ -153,8 +154,8 @@ ...@@ -153,8 +154,8 @@
"@wisdom-components/loadbox": "1.1.4", "@wisdom-components/loadbox": "1.1.4",
"@wisdom-components/timerangepicker": "^1.3.4", "@wisdom-components/timerangepicker": "^1.3.4",
"@wisdom-components/videoslidermodal": "1.1.2", "@wisdom-components/videoslidermodal": "1.1.2",
"@wisdom-components/VmsVideo": "1.1.13",
"@wisdom-utils/utils": "0.0.46", "@wisdom-utils/utils": "0.0.46",
"antd-mobile": "5.10.4",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"cross-spawn": "^7.0.3", "cross-spawn": "^7.0.3",
"echarts": "^5.4.0", "echarts": "^5.4.0",
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"test": "echo \"Error: run tests from root\" && exit 1" "test": "echo \"Error: run tests from root\" && exit 1"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.17.9" "@babel/runtime": "^7.17.9",
"antd-mobile": "5.10.4"
} }
} }
...@@ -24,9 +24,13 @@ path: / ...@@ -24,9 +24,13 @@ path: /
<code src="./demos/index.js"> <code src="./demos/index.js">
## 移动端
<code src="./demos/mobile.js">
## 多图表 ## 多图表
<code src="./demos/GridDemo.js"> [//]: # (<code src="./demos/GridDemo.js">)
## API ## API
......
...@@ -32,7 +32,7 @@ const SimgleChart = memo((props) => { ...@@ -32,7 +32,7 @@ const SimgleChart = memo((props) => {
showBoxOption, showBoxOption,
}; };
return optionGenerator(dataSource, null, contrast, contrastOption, smooth, config); return optionGenerator(dataSource, null, contrast, contrastOption, smooth, config);
}, [dataSource, smooth, curveCenter]); }, [dataSource, smooth, curveCenter,chartType]);
useEffect(() => { useEffect(() => {
chartRef.current?.resize?.(); chartRef.current?.resize?.();
......
...@@ -13,6 +13,7 @@ const deviceParams = [ ...@@ -13,6 +13,7 @@ const deviceParams = [
// deviceCode: 'EGBF00000002', // deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018', // deviceCode: 'EGBF00000018',
deviceCode: 'XMYL00000345', deviceCode: 'XMYL00000345',
// deviceCode: 'XMYL00000000',
// deviceCode: 'EGBF00000014', // deviceCode: 'EGBF00000014',
// sensors: '今日供水量,今日用电量,1#水箱液位,是否在线', // sensors: '今日供水量,今日用电量,1#水箱液位,是否在线',
sensors: '进水压力', sensors: '进水压力',
...@@ -32,9 +33,6 @@ const Demo = () => { ...@@ -32,9 +33,6 @@ const Demo = () => {
<div style={{height: 700}}> <div style={{height: 700}}>
<HistoryView deviceParams={deviceParams} defaultModel="curve"/> <HistoryView deviceParams={deviceParams} defaultModel="curve"/>
</div> </div>
<div style={{height: 300}}>
<MobileHistoryChart deviceParams={deviceParams} chartType={'boxChart'}/>
</div>
</div> </div>
); );
......
import React from 'react';
import {MobileHistoryChart} from "../mobile";
const deviceParams = [
/* {
deviceCode: 'EGBF00000141',
sensors: '今日供水量,今日用电量',
deviceType: '二供泵房',
pointAddressID: 208,
}, */
{
deviceCode: 'EGBF00000141',
sensors: '今日供水量',
deviceType: '二供泵房',
pointAddressID: 208,
},
];
const Demo = () => {
return (
<div>
<div style={{height: 400}}>
<MobileHistoryChart deviceParams={deviceParams}/>
</div>
</div>
);
};
export default Demo;
...@@ -199,3 +199,9 @@ ...@@ -199,3 +199,9 @@
opacity: 1; opacity: 1;
} }
} }
.@{history-view}-item {
display: flex;
align-items: center;
margin-bottom: 10px;
}
import React, {useEffect, useMemo, useState, useContext} from 'react'; import React, {useEffect, useMemo, useState, useContext} from 'react';
import GridChart from "./GridChart";
import {ConfigProvider} from "antd"; import {ConfigProvider} from "antd";
import {Selector, Checkbox, Space} from 'antd-mobile/es';
import moment from "moment"; import moment from "moment";
import {getDeviceAlarmScheme, getHistoryInfo} from "./apis"; import {getDeviceAlarmScheme, getHistoryInfo} from "./apis";
import SimgleChart from "./SingleChart"; import SimgleChart from "./SingleChart";
import {handlePx} from "./utils";
import styles from './index.less';
// deviceAlarmSchemes 用来获取对应的 方案的最大值/最小值 标记状态 const DATE_FORMAT = 'YYYY-MM-DD HH:mm:ss';
// dataSource 获取的报警信息
// deviceParams,
// defaultDate,
// {
// deviceCode: 'XMYL00000345',
// sensors: '进水压力',
// deviceType: '熊猫压力表',
// pointAddressID: 4,
// },
//{
// "isDilute": true, // 抽稀
// "zoom": "30",// 抽稀
// "unit": "min",// 抽稀
// "ignoreOutliers": false, // 滤波
// "dateFrom": "2023-07-09 16:38:32",
// "dateTo": "2023-07-10 16:38:32",
// "acrossTables": [
// {
// "deviceCode": "XMYL00000297",
// "sensors": "进水压力,是否在线",
// "deviceType": "熊猫压力表"
// }
// ],
// "isBoxPlots": true // 箱线图
// }
const DATE_FORMAT = 'YYYY-MM-DD';
const MobileHistoryChart = ( const MobileHistoryChart = (
{ {
date = { date = {
dateFrom: moment().format(`${DATE_FORMAT} 00:00:00`), dateFrom: moment().subtract(1, 'days').format(`${DATE_FORMAT}`),
dateTo: moment().format(`${DATE_FORMAT} 23:59:59`) dateTo: moment().format(`${DATE_FORMAT}`)
},// 默认当天 },// 默认当天
deviceParams = [], // 设备参数,必传 deviceParams = [], // 设备参数,必传
chartType='lineChart', // lineChart boxChart chartType = 'lineChart', // lineChart boxChart
ignoreOutliers = true, // 滤波 // ignoreOutliers = true, // 滤波
isDilute = true, // 抽稀去重 isDilute = true, // 抽稀去重
needMarkLine = true, needMarkLine = true,
showBoxOption = true, // 开启箱线图配置,默认开启 showBoxOption = true, // 开启箱线图配置,默认开启
chartGrid = true, // 开启网格 chartGrid = true, // 开启网格
...rest
} }
) => { ) => {
const [deviceAlarmSchemes, setDeviceAlarmSchemes] = useState(null); const [deviceAlarmSchemes, setDeviceAlarmSchemes] = useState(null);
const [chartDataSource, setChartDataSource] = useState(null); const [chartDataSource, setChartDataSource] = useState(null);
const [options, setOptions] = useState({
curveCenter: true,
ignoreOutliers: true
});
const checkBoxOptions = useMemo(() => {
return Object.keys(options).reduce((final, cur) => {
if (options[cur]) final.push(cur);
return final
}, []);
}, [options]);
const [lineType, setLineType] = useState([chartType]);
const {getPrefixCls} = useContext(ConfigProvider.ConfigContext); const {getPrefixCls} = useContext(ConfigProvider.ConfigContext);
const prefixCls = getPrefixCls('history-view'); const prefixCls = getPrefixCls('history-view');
const isBoxPlots = const isBoxPlots =
...@@ -87,7 +72,7 @@ const MobileHistoryChart = ( ...@@ -87,7 +72,7 @@ const MobileHistoryChart = (
let _params = { let _params = {
...date, ...date,
isBoxPlots, isBoxPlots,
ignoreOutliers, ignoreOutliers: options.ignoreOutliers,
isDilute, isDilute,
...thinKey, ...thinKey,
acrossTables acrossTables
...@@ -139,20 +124,57 @@ const MobileHistoryChart = ( ...@@ -139,20 +124,57 @@ const MobileHistoryChart = (
}); });
} }
useEffect(() => { useEffect(() => {
getDataSource();
getScheme(); getScheme();
}, []) }, [])
return deviceAlarmSchemes && chartDataSource ? <SimgleChart useEffect(() => {
showBoxOption={showBoxOption} getDataSource();
curveCenter={true} }, [options.ignoreOutliers])
chartGrid={chartGrid} return deviceAlarmSchemes && chartDataSource ? <div style={{}}>
prefixCls={prefixCls} {
dataSource={chartDataSource} chartDataSource.length === 1 ? <div className={styles[`${prefixCls}-item`]}>
chartType={isBoxPlots ? chartType : null} <span style={{fontSize: handlePx(16)}}>曲线形态:</span>
deviceAlarmSchemes={deviceAlarmSchemes} <Selector
/> : null options={[
{label: '线形图', value: 'lineChart'},
{label: '箱线图', value: 'boxChart'}
]}
defaultValue={lineType}
onChange={(arr, extend) => setLineType(arr)}
/>
</div> : ''
}
<div className={styles[`${prefixCls}-item`]}>
<span style={{fontSize: handlePx(16)}}>曲线设置:</span>
<Checkbox.Group
value={checkBoxOptions}
onChange={val => {
let _arr = Object.keys(options);
let _options = _arr.reduce((final, cur) => {
final[cur] = !!val.includes(cur);
return final;
}, {})
setOptions(_options);
}}
>
<Space direction='horizontal'>
<Checkbox value='curveCenter'>曲线居中</Checkbox>
<Checkbox value='ignoreOutliers'>滤波</Checkbox>
</Space>
</Checkbox.Group>
</div>
<div style={{height: rest.height || '10rem', width: rest.width || '100%'}}>
<SimgleChart
showBoxOption={showBoxOption}
curveCenter={options.curveCenter}
showGridLine={chartGrid}
prefixCls={prefixCls}
dataSource={chartDataSource}
chartType={isBoxPlots ? lineType[0] : null}
deviceAlarmSchemes={deviceAlarmSchemes}
/>
</div>
</div> : null
} }
export { export {
MobileHistoryChart MobileHistoryChart
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment