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
fb4c9a27
Commit
fb4c9a27
authored
Dec 14, 2022
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 发布历史曲线
parent
e6ad7ff7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
43 deletions
+64
-43
package.json
packages/extend-components/EC_HistoryView/package.json
+3
-0
index.js
packages/extend-components/EC_HistoryView/src/index.js
+61
-43
No files found.
packages/extend-components/EC_HistoryView/package.json
View file @
fb4c9a27
...
...
@@ -22,5 +22,8 @@
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"@babel/runtime"
:
"^7.17.9"
}
}
packages/extend-components/EC_HistoryView/src/index.js
View file @
fb4c9a27
...
...
@@ -108,8 +108,8 @@ const timeIntervalList = [
];
const
updateTime
=
(
key
)
=>
{
let
start
=
''
,
end
=
''
;
let
start
=
''
;
let
end
=
''
;
if
(
Array
.
isArray
(
key
))
{
start
=
moment
(
key
[
0
]).
format
(
timeFormat
);
end
=
moment
(
key
[
1
]).
format
(
timeFormat
);
...
...
@@ -180,7 +180,7 @@ const timeColumn = {
align
:
'center'
,
};
const
HistoryView
=
props
=>
{
const
HistoryView
=
(
props
)
=>
{
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'history-view'
);
...
...
@@ -193,11 +193,11 @@ const HistoryView = props => {
const
[
timeValue
,
setTimeValue
]
=
useState
(
'customer'
);
// 自定义模式
const
[
customerChecked
,
setCustomerChecked
]
=
useState
(
defaultChecked
);
// 时间快速选择类型值
const
[
customerChecked
,
setCustomerChecked
]
=
useState
(
defaultChecked
);
// 时间快速选择类型值
const
[
customerTime
,
setCustomerTime
]
=
useState
();
// 自定义时间选择值
// 同期对比模式
const
[
contrastOption
,
setContrastOption
]
=
useState
(
'day'
);
// 对比时间类型: 日/月
const
[
contrastOption
,
setContrastOption
]
=
useState
(
'day'
);
// 对比时间类型: 日/月
const
[
datePickerArr
,
setDatePickerArr
]
=
useState
(
DefaultDatePicker
(
'day'
));
// 对比时间段配置值
const
[
checkboxData
,
setCheckboxData
]
=
useState
(
CheckboxData
);
// 曲线设置项
...
...
@@ -225,21 +225,24 @@ const HistoryView = props => {
unit
:
''
,
// 数据抽稀时间单位
};
// 曲线居中,过滤异常值,数据抽稀
const
config
=
checkboxData
.
reduce
((
pre
,
item
)
=>
((
item
.
key
!==
'curveCenter'
&&
(
pre
[
item
.
key
]
=
item
.
checked
)),
pre
),
initial
);
const
config
=
checkboxData
.
reduce
(
(
pre
,
item
)
=>
(
item
.
key
!==
'curveCenter'
&&
(
pre
[
item
.
key
]
=
item
.
checked
),
pre
),
initial
,
);
// 数据抽稀时间单位
const
dataThin
=
timeIntervalList
.
find
(
item
=>
item
.
key
===
dataThinKey
);
config
.
zoom
=
activeTabKey
===
'curve'
?
''
:
(
dataThin
?.
zoom
??
''
)
;
config
.
unit
=
activeTabKey
===
'curve'
?
''
:
(
dataThin
?.
unit
??
''
)
;
const
dataThin
=
timeIntervalList
.
find
(
(
item
)
=>
item
.
key
===
dataThinKey
);
config
.
zoom
=
activeTabKey
===
'curve'
?
''
:
dataThin
?.
zoom
??
''
;
config
.
unit
=
activeTabKey
===
'curve'
?
''
:
dataThin
?.
unit
??
''
;
config
.
dataThin
=
activeTabKey
===
'curve'
?
true
:
config
.
dataThin
;
// 曲线强制抽稀
return
config
;
},
[
checkboxData
,
dataThinKey
,
activeTabKey
]);
// 图表居中
const
curveCenter
=
useMemo
(()
=>
checkboxData
.
find
(
item
=>
item
.
key
===
'curveCenter'
)?.
checked
,
[
checkboxData
]);
const
curveCenter
=
useMemo
(
()
=>
checkboxData
.
find
((
item
)
=>
item
.
key
===
'curveCenter'
)?.
checked
,
[
checkboxData
],
);
// 自定义模式: 快速选择
const
onCustomerTimeChange
=
(
key
)
=>
{
...
...
@@ -341,9 +344,7 @@ const HistoryView = props => {
<
DatePicker
picker
=
{
contrastOption
}
value
=
{
child
.
value
}
onChange
=
{(
date
,
dateString
)
=>
onContrastPickerChange
(
date
,
dateString
,
child
)
}
onChange
=
{(
date
,
dateString
)
=>
onContrastPickerChange
(
date
,
dateString
,
child
)}
/
>
{
datePickerArr
.
length
>
2
&&
(
<
div
...
...
@@ -383,10 +384,7 @@ const HistoryView = props => {
};
const
renderCheckbox
=
(
child
)
=>
(
<
Checkbox
checked
=
{
child
.
checked
}
onChange
=
{(
e
)
=>
onCheckboxChange
(
e
,
child
.
key
)}
>
<
Checkbox
checked
=
{
child
.
checked
}
onChange
=
{(
e
)
=>
onCheckboxChange
(
e
,
child
.
key
)}
>
{
child
.
label
}
<
/Checkbox
>
);
...
...
@@ -402,7 +400,12 @@ const HistoryView = props => {
<
/div
>
))}
{
activeTabKey
===
'table'
&&
(
<
Select
value
=
{
dataThinKey
}
style
=
{{
width
:
90
}}
onChange
=
{
onTimeIntervalChange
}
disabled
=
{
!
dataConfig
.
dataThin
}
>
<
Select
value
=
{
dataThinKey
}
style
=
{{
width
:
90
}}
onChange
=
{
onTimeIntervalChange
}
disabled
=
{
!
dataConfig
.
dataThin
}
>
{
timeIntervalList
.
map
((
child
)
=>
(
<
Option
key
=
{
child
.
key
}
unit
=
{
child
.
unit
}
value
=
{
child
.
key
}
>
{
child
.
name
}
...
...
@@ -411,11 +414,10 @@ const HistoryView = props => {
<
/Select
>
)}
<
/div
>
)
)
;
};
const
exportExcelBtn
=
()
=>
{
};
const
exportExcelBtn
=
()
=>
{};
const
handleTableData
=
(
data
)
=>
{
const
ignoreOutliers
=
checkboxData
.
find
((
item
)
=>
item
.
key
===
'ignoreOutliers'
).
checked
;
...
...
@@ -459,13 +461,13 @@ const HistoryView = props => {
const
dataIndex
=
dataIndexAccess
(
item
,
index
);
obj
[
dataIndex
]
=
'--'
;
});
return
obj
}
return
obj
;
}
;
data
.
forEach
((
item
,
index
)
=>
{
const
{
stationCode
,
sensorName
,
dataModel
}
=
item
;
dataModel
.
forEach
((
data
)
=>
{
const
formatTime
=
moment
(
data
.
pt
).
format
(
format
);
let
time
=
formatTime
;
if
(
timeValue
===
'contrast'
)
{
time
=
time
.
slice
(
contrastOption
===
'day'
?
11
:
8
,
16
);
...
...
@@ -526,7 +528,7 @@ const HistoryView = props => {
results
.
forEach
((
res
,
index
)
=>
{
const
{
dateFrom
,
dateTo
}
=
dateRange
?.[
index
]
??
{};
if
(
res
.
code
===
0
&&
res
.
data
.
length
)
{
res
.
data
.
forEach
(
d
=>
{
res
.
data
.
forEach
(
(
d
)
=>
{
d
.
dateFrom
=
dateFrom
;
d
.
dateTo
=
dateTo
;
});
...
...
@@ -569,7 +571,7 @@ const HistoryView = props => {
</Button>
)} */
}
<
/div
>
)
)
,
}}
>
<
Tabs
.
TabPane
key
=
"curve"
tab
=
"曲线"
>
...
...
@@ -578,17 +580,25 @@ const HistoryView = props => {
{
renderCurveOption
()}
<
/div
>
<
div
className
=
{
`
${
prefixCls
}
-content`
}
>
{
grid
===
true
?
(
<
GridChart
prefixCls
=
{
prefixCls
}
dataSource
=
{
chartDataSource
}
contrast
=
{
timeValue
===
'contrast'
}
contrastOption
=
{
contrastOption
}
/
>
)
:
(
<
SimgleChart
prefixCls
=
{
prefixCls
}
dataSource
=
{
chartDataSource
}
contrast
=
{
timeValue
===
'contrast'
}
contrastOption
=
{
contrastOption
}
/
>
)
}
{
grid
===
true
?
(
<
GridChart
prefixCls
=
{
prefixCls
}
dataSource
=
{
chartDataSource
}
contrast
=
{
timeValue
===
'contrast'
}
contrastOption
=
{
contrastOption
}
/
>
)
:
(
<
SimgleChart
prefixCls
=
{
prefixCls
}
dataSource
=
{
chartDataSource
}
contrast
=
{
timeValue
===
'contrast'
}
contrastOption
=
{
contrastOption
}
/
>
)}
<
/div
>
<
/Tabs.TabPane
>
<
Tabs
.
TabPane
key
=
"table"
tab
=
"表格"
>
<
div
className
=
{
`
${
prefixCls
}
-options`
}
>
<
div
className
=
{
`
${
prefixCls
}
-options`
}
>
{
renderTimeOption
()}
{
renderCurveOption
()}
<
/div
>
...
...
@@ -613,13 +623,21 @@ const HistoryView = props => {
HistoryView
.
propTypes
=
{
grid
:
PropTypes
.
bool
,
title
:
PropTypes
.
string
,
defaultChecked
:
PropTypes
.
oneOf
([
'oneHour'
,
'fourHour'
,
'twelveHours'
,
'roundClock'
,
'yesterday'
]),
defaultChecked
:
PropTypes
.
oneOf
([
'oneHour'
,
'fourHour'
,
'twelveHours'
,
'roundClock'
,
'yesterday'
,
]),
tableProps
:
PropTypes
.
object
,
deviceParams
:
PropTypes
.
arrayOf
(
PropTypes
.
objectOf
({
deviceCode
:
PropTypes
.
string
,
sensors
:
PropTypes
.
string
,
deviceType
:
PropTypes
.
string
,
}))
deviceParams
:
PropTypes
.
arrayOf
(
PropTypes
.
objectOf
({
deviceCode
:
PropTypes
.
string
,
sensors
:
PropTypes
.
string
,
deviceType
:
PropTypes
.
string
,
}),
),
};
HistoryView
.
defaultProps
=
{
...
...
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