Commit 70d5d2ca authored by 涂茜's avatar 涂茜

fix: bug

parent 3fa41239
Pipeline #29899 canceled with stages
...@@ -138,8 +138,9 @@ ...@@ -138,8 +138,9 @@
"registry": "https://g.civnet.cn:4873" "registry": "https://g.civnet.cn:4873"
}, },
"dependencies": { "dependencies": {
"@wisdom-components/basictable": "^1.5.11", "@wisdom-components/basictable": "^1.5.12",
"@wisdom-components/empty": "^1.3.9", "@wisdom-components/empty": "^1.3.9",
"@wisdom-components/exportexcel": "^1.1.2",
"@wisdom-components/timerangepicker": "^1.3.4", "@wisdom-components/timerangepicker": "^1.3.4",
"@wisdom-utils/utils": "0.0.46", "@wisdom-utils/utils": "0.0.46",
"classnames": "^2.2.6", "classnames": "^2.2.6",
......
{ {
"name": "@wisdom-components/basictable", "name": "@wisdom-components/basictable",
"version": "1.5.11", "version": "1.5.12",
"description": "> TODO: description", "description": "> TODO: description",
"author": "tuqian <webtuqian@163.com>", "author": "tuqian <webtuqian@163.com>",
"homepage": "", "homepage": "",
......
...@@ -30,6 +30,14 @@ ...@@ -30,6 +30,14 @@
border-bottom: 2px solid #dbe7fb; border-bottom: 2px solid #dbe7fb;
} }
.ant-table-thead > tr > th .ant-table-column-sorters {
padding: 0;
}
.ant-table-thead > tr > th .ant-table-column-sorter-full {
margin-top: -0.5em;
}
.ant-table-thead > tr > th, .ant-table-thead > tr > th,
.ant-table-tbody > tr > td, .ant-table-tbody > tr > td,
.ant-table tfoot > tr > th, .ant-table tfoot > tr > th,
......
...@@ -24,6 +24,9 @@ const DeviceTree = (props) => { ...@@ -24,6 +24,9 @@ const DeviceTree = (props) => {
const [params, setParams] = useState({}); const [params, setParams] = useState({});
const [totalCount, setTotalCount] = useState(0); const [totalCount, setTotalCount] = useState(0);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [expandedKeys, setExpandedKeys] = useState([]);
const [checkedKeys, setCheckedKeys] = useState([]);
const [selectedKeys, setSelectedKeys] = useState([]);
useEffect(() => { useEffect(() => {
setParams(serviceParams); setParams(serviceParams);
...@@ -52,11 +55,15 @@ const DeviceTree = (props) => { ...@@ -52,11 +55,15 @@ const DeviceTree = (props) => {
: [] : []
: []; : [];
const newData = handleData(data); const newData = handleData(data);
const keys = newData.length > 0 ? [newData[0].key] : [];
setLoading(false); setLoading(false);
setTreeData(newData); setTreeData(newData);
setTotalCount(response.data.totalCount); setTotalCount(response.data.totalCount);
onTreeCheck(newData.length > 0 ? [newData[0]] : []); onTreeCheck(newData.length > 0 ? [newData[0]] : []);
onTreeSelect(newData.length > 0 ? [newData[0]] : []); onTreeSelect(newData.length > 0 ? [newData[0]] : []);
setCheckedKeys(keys);
setExpandedKeys(keys);
setSelectedKeys(keys);
} else { } else {
message.error(response.msg); message.error(response.msg);
} }
...@@ -77,7 +84,8 @@ const DeviceTree = (props) => { ...@@ -77,7 +84,8 @@ const DeviceTree = (props) => {
}; };
// 选中复选框 // 选中复选框
const onCheck = ({ checked }) => { const onCheck = (checkedKeysValue) => {
const { checked } = checkedKeysValue;
const checkedTree = []; const checkedTree = [];
treeData.forEach((item) => { treeData.forEach((item) => {
if (checked.includes(item.key)) { if (checked.includes(item.key)) {
...@@ -91,13 +99,19 @@ const DeviceTree = (props) => { ...@@ -91,13 +99,19 @@ const DeviceTree = (props) => {
}); });
} }
}); });
setCheckedKeys(checked);
onTreeCheck(checkedTree); onTreeCheck(checkedTree);
}; };
const onSelect = (selectedKeysValue, info) => { const onSelect = (selectedKeysValue, info) => {
setSelectedKeys(selectedKeysValue);
onTreeSelect(info.selectedNodes); onTreeSelect(info.selectedNodes);
}; };
const onExpand = (expandedKeysValue) => {
setExpandedKeys(expandedKeysValue);
};
const onPaginationChange = (page) => { const onPaginationChange = (page) => {
setParams({ ...params, pageIndex: page }); setParams({ ...params, pageIndex: page });
}; };
...@@ -116,10 +130,11 @@ const DeviceTree = (props) => { ...@@ -116,10 +130,11 @@ const DeviceTree = (props) => {
<Spin spinning={loading}> <Spin spinning={loading}>
{!!treeData.length && ( {!!treeData.length && (
<Tree <Tree
defaultCheckedKeys={[treeData[0].key]} checkedKeys={checkedKeys}
defaultExpandedKeys={[treeData[0].key]} expandedKeys={expandedKeys}
defaultSelectedKeys={[treeData[0].key]} selectedKeys={selectedKeys}
treeData={treeData} treeData={treeData}
onExpand={onExpand}
onCheck={onCheck} onCheck={onCheck}
onSelect={onSelect} onSelect={onSelect}
checkStrictly checkStrictly
......
...@@ -14,7 +14,7 @@ const GET_DICTIONARY_LIST = ...@@ -14,7 +14,7 @@ const GET_DICTIONARY_LIST =
// const GET_HISTORY_INFO = '/api/PandaCore/GCK/Device/SensorsDataForStation'; //获取历史信息 // const GET_HISTORY_INFO = '/api/PandaCore/GCK/Device/SensorsDataForStation'; //获取历史信息
// const GET_DICTIONARY_LIST = '/api/PandaCore/OMS/Data/GetDataDictionaryList'; //获取数据字典信息 // const GET_DICTIONARY_LIST = '/api/PandaCore/OMS//DataManger/GetDataDictionaryList'; //获取数据字典信息
const historyInfoService = { const historyInfoService = {
getHistoryInfo: { getHistoryInfo: {
...@@ -39,7 +39,7 @@ const Demo = () => { ...@@ -39,7 +39,7 @@ const Demo = () => {
<div style={{ height: '800px' }}> <div style={{ height: '800px' }}>
<HistoryInfo <HistoryInfo
title={'指标曲线'} title={'指标曲线'}
tableProps={{ bordered: true, pagination: { pageSize: 20 } }} tableProps={{ bordered: true }}
historyInfoService={getHistoryInfo} historyInfoService={getHistoryInfo}
historyInfoParams={initialParams} historyInfoParams={initialParams}
dictionaryService={getDictionaryList} dictionaryService={getDictionaryList}
...@@ -54,19 +54,19 @@ export default Demo; ...@@ -54,19 +54,19 @@ export default Demo;
const initialParams = { const initialParams = {
stream: [ stream: [
{ {
stationCode: 'EGBF00000006', stationCode: 'EGBF00000022',
sensors: '出水瞬时流量,今日供水量,今日用电量', sensors: '进水压力,今日供水量',
pointVersions: '二供泵房', pointVersions: '二供泵房',
dateFrom: '2021-05-09 15:01:21', dateFrom: '2021-06-16 13:01:37',
dateTo: '2021-05-09 16:01:21', dateTo: '2021-06-16 14:01:37',
},
{
stationCode: 'EGJZ00007117',
sensors: '进水压力,出水压力,泵1状态',
pointVersions: '二供机组',
dateFrom: '2021-05-09 15:01:21',
dateTo: '2021-05-09 16:01:21',
}, },
// {
// stationCode: 'EGJZ00000044',
// sensors: '进水压力,今日供水量',
// pointVersions: '二供机组',
// dateFrom: '2021-06-16 13:01:37',
// dateTo: '2021-06-16 14:01:37',
// },
], ],
ignoreOutliers: false, // 过滤异常值 ignoreOutliers: false, // 过滤异常值
isVertical: false, // 是否展示竖表 isVertical: false, // 是否展示竖表
......
...@@ -4,11 +4,12 @@ import classNames from 'classnames'; ...@@ -4,11 +4,12 @@ import classNames from 'classnames';
import Highcharts from 'highcharts/highstock'; import Highcharts from 'highcharts/highstock';
import HighchartsReact from 'highcharts-react-official'; import HighchartsReact from 'highcharts-react-official';
import HighchartsBoost from 'highcharts/modules/boost'; import HighchartsBoost from 'highcharts/modules/boost';
import { Tabs, Select, Radio, Checkbox, ConfigProvider, DatePicker, Spin } from 'antd'; import { Button, Tabs, Select, Radio, Checkbox, ConfigProvider, DatePicker, Spin } from 'antd';
import { PlusCircleOutlined, CloseCircleFilled } from '@ant-design/icons'; import { PlusCircleOutlined, CloseCircleFilled, DownloadOutlined } from '@ant-design/icons';
import TimeRangePicker from '@wisdom-components/timerangepicker'; import TimeRangePicker from '@wisdom-components/timerangepicker';
import BasicTable from '@wisdom-components/basictable'; import BasicTable from '@wisdom-components/basictable';
import Empty from '@wisdom-components/empty'; import Empty from '@wisdom-components/empty';
import { ExportExcel } from '@wisdom-components/exportexcel';
import moment from 'moment'; import moment from 'moment';
import './index.less'; import './index.less';
...@@ -230,6 +231,7 @@ const HistoryInfo = (props) => { ...@@ -230,6 +231,7 @@ const HistoryInfo = (props) => {
width: 160, width: 160,
fixed: 'left', fixed: 'left',
ellipsis: true, ellipsis: true,
align: 'center',
}, },
]); ]);
...@@ -241,19 +243,21 @@ const HistoryInfo = (props) => { ...@@ -241,19 +243,21 @@ const HistoryInfo = (props) => {
const handleSeries = (v) => { const handleSeries = (v) => {
const resData = v; const resData = v;
const seriesData = []; const seriesData = [];
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
resData.forEach((item) => { resData.forEach((item) => {
const data = []; const data = [];
if (item.dataModel.length) { const dataModel = ignoreOutliers ? item.dataModelAbnormal : item.dataModel;
if (dataModel.length) {
if (timeValue === 'contrast') { if (timeValue === 'contrast') {
// 同期对比 // 同期对比
item.dataModel.forEach((child) => { dataModel.forEach((child) => {
const formatTime = moment(child.pt).format( const formatTime = moment(child.pt).format(
contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00', contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00',
); );
data.push([moment(formatTime).valueOf(), child.pv]); data.push([moment(formatTime).valueOf(), child.pv]);
}); });
} else { } else {
item.dataModel.forEach((child) => { dataModel.forEach((child) => {
data.push([moment(child.pt).valueOf(), child.pv]); data.push([moment(child.pt).valueOf(), child.pv]);
}); });
} }
...@@ -265,8 +269,8 @@ const HistoryInfo = (props) => { ...@@ -265,8 +269,8 @@ const HistoryInfo = (props) => {
unit: item.unit, unit: item.unit,
data: data, data: data,
}; };
if (timeValue === 'contrast' && item.dataModel[0]) { if (timeValue === 'contrast' && dataModel[0]) {
const time = item.dataModel[0].pt.slice(0, contrastOption === 'day' ? 10 : 7); const time = dataModel[0].pt.slice(0, contrastOption === 'day' ? 10 : 7);
obj.name = obj.name + '-' + time; obj.name = obj.name + '-' + time;
} }
seriesData.push(obj); seriesData.push(obj);
...@@ -277,6 +281,7 @@ const HistoryInfo = (props) => { ...@@ -277,6 +281,7 @@ const HistoryInfo = (props) => {
// 处理表格的数据 // 处理表格的数据
const handleTableData = (resData) => { const handleTableData = (resData) => {
let timeData = []; let timeData = [];
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const timeSort = (dataArray) => { const timeSort = (dataArray) => {
// 处理时间排序 // 处理时间排序
return dataArray.sort((a, b) => { return dataArray.sort((a, b) => {
...@@ -295,7 +300,8 @@ const HistoryInfo = (props) => { ...@@ -295,7 +300,8 @@ const HistoryInfo = (props) => {
} }
// 处理采集时间 // 处理采集时间
resData.forEach((item) => { resData.forEach((item) => {
item.dataModel.forEach((data) => { const dataModel = ignoreOutliers ? item.dataModelAbnormal : item.dataModel;
dataModel.forEach((data) => {
const formatTime = moment(data.pt).format(format); const formatTime = moment(data.pt).format(format);
if (!timeData.includes(formatTime)) { if (!timeData.includes(formatTime)) {
timeData.push(formatTime); timeData.push(formatTime);
...@@ -310,6 +316,7 @@ const HistoryInfo = (props) => { ...@@ -310,6 +316,7 @@ const HistoryInfo = (props) => {
dataIndex: `value${index + 1}`, dataIndex: `value${index + 1}`,
key: `value${index + 1}`, key: `value${index + 1}`,
ellipsis: true, ellipsis: true,
align: 'center',
}; };
}); });
// 处理表格数据 // 处理表格数据
...@@ -323,9 +330,13 @@ const HistoryInfo = (props) => { ...@@ -323,9 +330,13 @@ const HistoryInfo = (props) => {
// 处理表格数据 // 处理表格数据
tableData.forEach((item, i) => { tableData.forEach((item, i) => {
resData.forEach((child, index) => { resData.forEach((child, index) => {
child.dataModel.forEach((value, j) => { item[`value${index + 1}`] = '--';
const dataModel = ignoreOutliers ? child.dataModelAbnormal : child.dataModel;
dataModel.forEach((value, j) => {
const formatTime = moment(value.pt).format(format); const formatTime = moment(value.pt).format(format);
if (timeData[i] === formatTime) item[`value${index + 1}`] = value.pv || '--'; if (timeData[i] === formatTime) {
item[`value${index + 1}`] = value.pv === null ? '--' : value.pv;
}
}); });
}); });
}); });
...@@ -337,7 +348,6 @@ const HistoryInfo = (props) => { ...@@ -337,7 +348,6 @@ const HistoryInfo = (props) => {
const onChangeParams = (value = []) => { const onChangeParams = (value = []) => {
const { dateRange, ignoreOutliers, zoom, unit } = value; const { dateRange, ignoreOutliers, zoom, unit } = value;
const requestArr = []; const requestArr = [];
console.log(dateRange, 'dateRange');
dateRange.forEach((item) => { dateRange.forEach((item) => {
const param = { const param = {
...historyInfoParams, ...historyInfoParams,
...@@ -430,18 +440,14 @@ const HistoryInfo = (props) => { ...@@ -430,18 +440,14 @@ const HistoryInfo = (props) => {
}; };
const onCustomerRangeChange = (value) => { const onCustomerRangeChange = (value) => {
console.log(value, 'value');
// customerChecked
setCustomerChecked(null); setCustomerChecked(null);
setCustomerTime(value); setCustomerTime(value);
dispatch({ type: UPDATE_TIME.UPDATE_TIME, payload: value }); dispatch({ type: UPDATE_TIME.UPDATE_TIME, payload: value });
}; };
const onCustomerTimeChange = (key) => { const onCustomerTimeChange = (key) => {
console.log(key, 'key');
setCustomerChecked(key); setCustomerChecked(key);
!!customerTime && setCustomerTime(null); !!customerTime && setCustomerTime(null);
// dispatch({ type: UPDATE_TIME.UPDATE_TIME, payload: key });
}; };
const onContrastPickerChange = (date, dateString, item) => { const onContrastPickerChange = (date, dateString, item) => {
...@@ -770,6 +776,27 @@ const HistoryInfo = (props) => { ...@@ -770,6 +776,27 @@ const HistoryInfo = (props) => {
return result; return result;
}; };
const exportExcelBtn = () => {
let data = JSON.parse(JSON.stringify(tableData));
const keys = Object.keys(data[0]).filter((item) => item !== 'key');
const sheetData = data.map((item) => {
delete item.key;
return item;
});
ExportExcel({
name: '历史曲线表格',
content: [
{
sheetData: sheetData,
sheetName: '历史曲线表格',
sheetFilter: keys,
sheetHeader: columns.map((item) => item.title),
columnWidths: columns.map((item) => 20),
},
],
});
};
return ( return (
<div className={classNames(prefixCls)}> <div className={classNames(prefixCls)}>
<Tabs <Tabs
...@@ -777,6 +804,13 @@ const HistoryInfo = (props) => { ...@@ -777,6 +804,13 @@ const HistoryInfo = (props) => {
centered centered
tabBarExtraContent={{ tabBarExtraContent={{
left: <h3 className="tabs-extra-demo-button">{title}</h3>, left: <h3 className="tabs-extra-demo-button">{title}</h3>,
right:
activeTabKey === 'table' ? (
<Button onClick={exportExcelBtn}>
<DownloadOutlined />
下载
</Button>
) : null,
}} }}
onChange={(key) => setActiveTabKey(key)} onChange={(key) => setActiveTabKey(key)}
> >
...@@ -784,7 +818,7 @@ const HistoryInfo = (props) => { ...@@ -784,7 +818,7 @@ const HistoryInfo = (props) => {
<TabPane tab={item.tab} key={item.key}> <TabPane tab={item.tab} key={item.key}>
<div className={classNames(`${prefixCls}-content`)}> <div className={classNames(`${prefixCls}-content`)}>
{renderOptions(item)} {renderOptions(item)}
<Spin spinning={loading}> <Spin spinning={loading} wrapperClassName={classNames(`${prefixCls}-spin`)}>
{!tableData.length && ( {!tableData.length && (
<div className={classNames(`${prefixCls}-empty`)}> <div className={classNames(`${prefixCls}-empty`)}>
<Empty /> <Empty />
......
...@@ -14,21 +14,22 @@ ...@@ -14,21 +14,22 @@
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
padding: 10px 0 0 0; padding: 10px 0 0 0;
}
.ant-spin-nested-loading { &-spin {
display: flex; display: flex;
flex: 1; flex: 1;
} height: calc(100% - 108px);
}
.ant-spin-container { &-spin > .ant-spin-container {
display: flex; display: flex;
flex: 1; flex: 1;
overflow: hidden; overflow: hidden;
} }
.ant-spin-nested-loading > div > .ant-spin { &-spin > div > .ant-spin {
max-height: none; max-height: none;
}
} }
&-empty { &-empty {
......
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