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

fix: bug

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