Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
8c7dd0a4
Commit
8c7dd0a4
authored
Apr 20, 2023
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复被回退的代码
parent
3ec8e3f6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
72 deletions
+67
-72
SingleChart.js
packages/extend-components/EC_HistoryView/src/SingleChart.js
+5
-0
GridDemo.js
...es/extend-components/EC_HistoryView/src/demos/GridDemo.js
+1
-1
index.js
packages/extend-components/EC_HistoryView/src/demos/index.js
+9
-8
index.js
packages/extend-components/EC_HistoryView/src/index.js
+49
-60
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+3
-3
No files found.
packages/extend-components/EC_HistoryView/src/SingleChart.js
View file @
8c7dd0a4
...
...
@@ -13,6 +13,9 @@ const SimgleChart = memo((props) => {
curveCenter
,
showGridLine
=
false
,
deviceAlarmSchemes
,
chartType
,
justLine
}
=
props
;
const
chartRef
=
useRef
();
...
...
@@ -24,6 +27,8 @@ const SimgleChart = memo((props) => {
deviceAlarmSchemes
,
showMarkLine
:
true
,
showPoint
:
true
,
chartType
,
justLine
};
return
optionGenerator
(
dataSource
,
null
,
contrast
,
contrastOption
,
smooth
,
config
);
},
[
dataSource
,
smooth
,
curveCenter
]);
...
...
packages/extend-components/EC_HistoryView/src/demos/GridDemo.js
View file @
8c7dd0a4
...
...
@@ -25,7 +25,7 @@ const deviceParams = [
const
Demo
=
()
=>
{
return
(
<
div
style
=
{{
height
:
700
}}
>
<
HistoryView
deviceParams
=
{
deviceParams
}
grid
/>
{
/*<HistoryView deviceParams={deviceParams} grid />*/
}
<
/div
>
);
};
...
...
packages/extend-components/EC_HistoryView/src/demos/index.js
View file @
8c7dd0a4
...
...
@@ -2,18 +2,19 @@ import React from 'react';
import
HistoryView
from
'../index'
;
const
deviceParams
=
[
// {
// deviceCode: 'EGBF00000146',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
{
deviceCode
:
'EGBF00000146'
,
sensors
:
'进水压力,出水瞬时流量,出水累计流量'
,
// deviceCode: 'EGBF00000002',
deviceCode
:
'EGBF00000082'
,
sensors
:
'进水压力'
,
deviceType
:
'二供泵房'
,
pointAddressID
:
4
,
},
{
deviceCode
:
'EGJZ00001113'
,
sensors
:
'出水瞬时流量,出水压力,泵1状态'
,
deviceType
:
'二供机组'
,
pointAddressID
:
4
,
},
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
...
...
packages/extend-components/EC_HistoryView/src/index.js
View file @
8c7dd0a4
import
React
,
{
useContext
,
useEffect
,
useMemo
,
useState
}
from
'react'
;
import
React
,
{
useContext
,
useEffect
,
useMemo
,
useState
}
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
classNames
from
'classnames'
;
import
{
...
...
@@ -23,21 +23,20 @@ import _ from 'lodash';
import
TimeRangePicker
from
'@wisdom-components/timerangepicker'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
BasicTable
from
'@wisdom-components/basictable'
;
import
{
getHistoryInfo
,
getDeviceAlarmScheme
,
getExportDeviceHistoryUrl
}
from
'./apis'
;
import
{
getHistoryInfo
,
getDeviceAlarmScheme
,
getExportDeviceHistoryUrl
}
from
'./apis'
;
import
SimgleChart
from
'./SingleChart'
;
import
GridChart
from
'./GridChart'
;
import
'./index.less'
;
import
{
globalConfig
}
from
'antd/lib/config-provider'
;
import
{
globalConfig
}
from
'antd/lib/config-provider'
;
const
{
RangePicker
}
=
DatePicker
;
const
{
Option
}
=
Select
;
const
{
RangePicker
}
=
DatePicker
;
const
{
Option
}
=
Select
;
const
startFormat
=
'YYYY-MM-DD 00:00:00'
;
const
endFormat
=
'YYYY-MM-DD 23:59:59'
;
const
timeFormat
=
'YYYY-MM-DD HH:mm:ss'
;
const
dateFormat
=
'YYYYMMDD'
;
// 时间列表
const
timeList
=
[
{
key
:
'twelveHours'
,
...
...
@@ -221,7 +220,7 @@ const timeColumn = {
};
const
HistoryView
=
(
props
)
=>
{
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'history-view'
);
const
{
...
...
@@ -234,8 +233,7 @@ const HistoryView = (props) => {
showModels
,
needMarkLine
,
}
=
props
;
const
isBoxPlots
=
deviceParams
?.
length
===
1
&&
deviceParams
[
0
]?.
sensors
?.
split
(
','
).
length
===
1
;
const
isBoxPlots
=
deviceParams
?.
length
===
1
&&
deviceParams
[
0
]?.
sensors
?.
split
(
','
).
length
===
1
;
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
activeTabKey
,
setActiveTabKey
]
=
useState
(
defaultModel
);
...
...
@@ -390,7 +388,7 @@ const HistoryView = (props) => {
)}
{
timeValue
===
'contrast'
&&
(
// 同期对比
<>
<
Select
value
=
{
contrastOption
}
style
=
{{
width
:
60
}}
onChange
=
{
onContrastChange
}
>
<
Select
value
=
{
contrastOption
}
style
=
{{
width
:
60
}}
onChange
=
{
onContrastChange
}
>
<
Option
value
=
"day"
>
日
<
/Option
>
<
Option
value
=
"month"
>
月
<
/Option
>
<
/Select
>
...
...
@@ -407,7 +405,7 @@ const HistoryView = (props) => {
className
=
{
classNames
(
`
${
prefixCls
}
-contrast-delete`
)}
onClick
=
{()
=>
handleDeleteDatePicker
(
index
)}
>
<
CloseCircleFilled
/>
<
CloseCircleFilled
/>
<
/div
>
)}
<
/div
>
...
...
@@ -416,7 +414,7 @@ const HistoryView = (props) => {
)}
<
/div
>
))}
{
datePickerArr
.
length
<
5
&&
<
PlusCircleOutlined
onClick
=
{
handleAddDatePicker
}
/>
}
{
datePickerArr
.
length
<
5
&&
<
PlusCircleOutlined
onClick
=
{
handleAddDatePicker
}
/>
}
<
/
>
)}
<
/div
>
...
...
@@ -426,8 +424,8 @@ const HistoryView = (props) => {
// 曲线设置项选择/取消
const
onCheckboxChange
=
(
e
,
key
)
=>
{
let
data
=
[...
checkboxData
];
let
_index
=
data
.
findIndex
((
item
)
=>
item
.
key
===
'justLine'
);
// 仅查看曲线会在勾选了数据滤波后展示
let
_index1
=
data
.
findIndex
((
item
)
=>
item
.
key
===
'ignoreOutliers'
);
// 仅查看曲线会在勾选了数据滤波后展示
let
_index
=
data
.
findIndex
(
item
=>
item
.
key
===
'justLine'
);
// 仅查看曲线会在勾选了数据滤波后展示
let
_index1
=
data
.
findIndex
(
item
=>
item
.
key
===
'ignoreOutliers'
);
// 仅查看曲线会在勾选了数据滤波后展示
data
.
forEach
((
item
)
=>
{
if
(
item
.
key
===
key
)
{
item
.
checked
=
e
.
target
.
checked
;
...
...
@@ -465,7 +463,7 @@ const HistoryView = (props) => {
<
/Checkbox
>
{
child
.
tooltip
&&
(
<
Tooltip
title
=
{
child
.
tooltip
}
>
<
QuestionCircleFilled
className
=
{
`
${
prefixCls
}
-question`
}
/
>
<
QuestionCircleFilled
className
=
{
`
${
prefixCls
}
-question`
}
/
>
<
/Tooltip
>
)}
<
/
>
...
...
@@ -475,26 +473,19 @@ const HistoryView = (props) => {
const
renderCurveOption
=
(
isChart
,
isSingle
)
=>
{
return
(
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-cover`
)
}
>
{
isChart
&&
isSingle
?
(
<>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-cover`
)}
style
=
{
isChart
&&
isSingle
?
{
width
:
'100%'
}
:
{}
}
>
{
isChart
&&
isSingle
?
<>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-label`
)}
>
曲线形态
<
/div
>
<
Radio
.
Group
value
=
{
chartType
}
style
=
{{
marginRight
:
16
}}
onChange
=
{(
e
)
=>
{
<
Radio
.
Group
value
=
{
chartType
}
style
=
{{
marginRight
:
16
}}
onChange
=
{(
e
)
=>
{
let
_value
=
e
.
target
.
value
;
setChartType
(
_value
);
onCheckboxChange
({
target
:
{
value
:
_value
!==
'boxChart'
}
},
'chartType'
);
}}
>
onCheckboxChange
({
target
:
{
value
:
_value
!==
'boxChart'
}},
'chartType'
)
}}
>
<
Radio
.
Button
value
=
{
'lineChart'
}
>
线形图
<
/Radio.Button
>
<
Radio
.
Button
value
=
{
'boxChart'
}
>
箱线图
<
/Radio.Button
>
<
/Radio.Group
>
<
/
>
)
:
(
''
)}
<
/Radio.Group></
>
:
''
}
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-label`
)}
>
曲线设置
<
/div
>
{
checkboxData
.
map
((
child
)
=>
{
const
box
=
renderCheckbox
(
child
);
...
...
@@ -508,7 +499,7 @@ const HistoryView = (props) => {
{
activeTabKey
===
'table'
&&
(
<
Select
value
=
{
dataThinKey
}
style
=
{{
width
:
90
}}
style
=
{{
width
:
90
}}
onChange
=
{
onTimeIntervalChange
}
disabled
=
{
!
dataConfig
.
dataThin
}
>
...
...
@@ -546,14 +537,15 @@ const HistoryView = (props) => {
aDom.click();
aDom.remove();
})
.catch((err) => {});
.catch((err) => {
});
});
};
const handleTableData = (data) => {
const ignoreOutliers = checkboxData.find((item) => item.key === 'ignoreOutliers').checked;
const dataIndexAccess = (dataItem, index) => {
const { stationCode, sensorName
} = dataItem;
const {stationCode, sensorName
} = dataItem;
return `
$
{
stationCode
}
-
$
{
sensorName
}
-
$
{
index
}
`;
};
...
...
@@ -564,7 +556,7 @@ const HistoryView = (props) => {
// 处理表头数据
const columnsData = data.map((item, index) => {
const { stationCode, equipmentName, sensorName, unit, dataModel
} = item;
const {stationCode, equipmentName, sensorName, unit, dataModel
} = item;
const dataIndex = dataIndexAccess(item, index);
let col = {
title: `
$
{
equipmentName
}
-
$
{
sensorName
}
$
{
unit
?
`(
${
unit
}
)`
:
''
}
`,
...
...
@@ -587,7 +579,7 @@ const HistoryView = (props) => {
const timeData = {};
const buildDefaultData = (time) => {
const obj = { key: time, time: time
};
const obj = {key: time, time: time
};
data.forEach((item, index) => {
const dataIndex = dataIndexAccess(item, index);
obj[dataIndex] = '';
...
...
@@ -595,7 +587,7 @@ const HistoryView = (props) => {
return obj;
};
data.forEach((item, index) => {
const { stationCode, sensorName, dataModel
} = item;
const {stationCode, sensorName, dataModel
} = item;
dataModel.forEach((data) => {
const formatTime = moment(data.pt).format(format);
...
...
@@ -610,7 +602,7 @@ const HistoryView = (props) => {
// 处理表格数据
data.forEach((child, index) => {
const { dataModel
} = child;
const {dataModel
} = child;
const dataIndex = dataIndexAccess(child, index);
dataModel.forEach((value, j) => {
const formatTime = moment(value.pt).format(format);
...
...
@@ -660,23 +652,23 @@ const HistoryView = (props) => {
const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) {
return { unit: 'h', zoom: '2'
};
return {unit: 'h', zoom: '2'
};
} else if (diffDays >= 15 && diffDays < 30) {
return { unit: 'h', zoom: '4'
};
return {unit: 'h', zoom: '4'
};
} else if (diffDays >= 30) {
return { unit: 'h', zoom: '6'
};
return {unit: 'h', zoom: '6'
};
} else if (diffDays < 7 && diffDays >= 2) {
return { unit: 'min', zoom: '40'
};
return {unit: 'min', zoom: '40'
};
} else if (diffDays < 2 && diffDays >= 1) {
return { unit: 'min', zoom: '30'
};
return {unit: 'min', zoom: '30'
};
} else {
return { unit: 'min', zoom: '10'
};
return {unit: 'min', zoom: '10'
};
}
};
// 处理接口服务参数的变化
const onChangeParams = (value = {}) => {
const { dateRange, isDilute, ignoreOutliers, zoom, unit
} = value;
const {dateRange, isDilute, ignoreOutliers, zoom, unit
} = value;
const requestArr = [];
const acrossTables = [];
deviceParams.forEach((i) => {
...
...
@@ -689,7 +681,7 @@ const HistoryView = (props) => {
return;
}
dateRange.forEach((item) => {
let _showLine = checkboxData.find((item)
=> item.key === 'justLine');
let _showLine = checkboxData.find(item
=> item.key === 'justLine');
const param = {
isDilute,
zoom,
...
...
@@ -699,20 +691,19 @@ const HistoryView = (props) => {
dateFrom: item.dateFrom,
dateTo: item.dateTo,
acrossTables,
isBoxPlots: isBoxPlots,
isBoxPlots: isBoxPlots
};
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
requestArr.push(getHistoryInfo({ ...param, ...zoomParam
}));
requestArr.push(getHistoryInfo({...param, ...zoomParam
}));
});
setLoading(true);
Promise.all(requestArr).then((results) => {
if (results.length) {
let data = [];
results.forEach((res, index) => {
const { dateFrom, dateTo
} = dateRange?.[index] ?? {};
const {dateFrom, dateTo
} = dateRange?.[index] ?? {};
if (res.code === 0 && res.data.length) {
debugger;
res.data.forEach((d) => {
d.dateFrom = dateFrom;
d.dateTo = dateTo;
...
...
@@ -740,7 +731,7 @@ const HistoryView = (props) => {
};
useEffect(() => {
const { dataThin, ignoreOutliers, zoom, unit
} = dataConfig;
const {dataThin, ignoreOutliers, zoom, unit
} = dataConfig;
beforChangeParams().finally(() => {
onChangeParams({
isDilute: dataThin,
...
...
@@ -748,7 +739,7 @@ const HistoryView = (props) => {
zoom,
unit,
dateRange,
isBoxPlots: isBoxPlots,
isBoxPlots: isBoxPlots
});
});
}, [dateRange, dataConfig, deviceParams, chartType]);
...
...
@@ -759,14 +750,11 @@ const HistoryView = (props) => {
<>
<div className={`
$
{
prefixCls
}
-
options
`}>
{renderTimeOption()}
{renderCurveOption(
true,
deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1,
)}
{renderCurveOption(true, (deviceParams?.length === 1 && deviceParams[0]?.sensors?.split(',').length === 1))}
</div>
<div className={`
$
{
prefixCls
}
-
content
`}>
{!chartDataSource.length ? (
<PandaEmpty
/>
<PandaEmpty
/>
) : grid === true ? (
<GridChart
curveCenter={curveCenter}
...
...
@@ -782,7 +770,7 @@ const HistoryView = (props) => {
showGridLine={chartGrid}
prefixCls={prefixCls}
dataSource={chartDataSource}
justLine={!!checkboxData.find((item)
=> item.key === 'justLine' && item.checked)}
justLine={!!checkboxData.find(item
=> item.key === 'justLine' && item.checked)}
chartType={isBoxPlots ? chartType : null}
contrast={timeValue === 'contrast'}
contrastOption={contrastOption}
...
...
@@ -807,10 +795,11 @@ const HistoryView = (props) => {
columns={columns}
{...tableProps}
pagination={false}
onChange={() => {}}
onChange={() => {
}}
/>
) : (
<PandaEmpty
/>
<PandaEmpty
/>
)}
</div>
</>
...
...
@@ -835,7 +824,7 @@ const HistoryView = (props) => {
<div className={`
$
{
prefixCls
}
-
extra
-
right
`}>
{activeTabKey === 'table' && (
<Button type="link" onClick={exportExcelBtn}>
<DownloadOutlined
/>
<DownloadOutlined
/>
下载
</Button>
)}
...
...
packages/extend-components/EC_HistoryView/src/utils.js
View file @
8c7dd0a4
...
...
@@ -459,7 +459,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
let unit = ''
series = series.map(item => {
if (item.unit) unit = item.unit;
let _item = {...item, symbol:
null
};
let _item = {...item, symbol:
'none'
};
_item.data = _item?.data?.map(d => {
return d[1] || null
}) || [];
...
...
@@ -468,7 +468,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
series.push({
type: 'candlestick',
name: '箱线图',
symbol:
null
,
symbol:
'none'
,
data: otherData,
});
tooltip = tooltipAccessor(unit)
...
...
@@ -482,7 +482,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
}); //当存在othersData的时候,只是单曲线
xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD'))};
series = series.map(item => {
let _item = {...item, symbol:
false
};
let _item = {...item, symbol:
'none'
};
_item.data = _item?.data?.map(d => {
return d[1] || null
}) || [];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment