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
ec8b8b3f
Commit
ec8b8b3f
authored
Aug 22, 2023
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 增加统计查看
parent
b307f61f
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
674 additions
and
82 deletions
+674
-82
config.js
config/config.js
+1
-0
package.json
packages/extend-components/EC_ConfigurationView/package.json
+0
-1
RealModel.js
...s/extend-components/EC_ConfigurationView/src/RealModel.js
+46
-2
index.js
.../extend-components/EC_ConfigurationView/src/apis/index.js
+1
-1
index.js
...urationView/src/component/StatisticalHistoryView/index.js
+0
-69
index.less
...ationView/src/component/StatisticalHistoryView/index.less
+0
-0
Basic.tsx
...xtend-components/EC_ConfigurationView/src/demos/Basic.tsx
+9
-9
README.md
...ges/extend-components/EC_StatisticalHistoryView/README.md
+11
-0
package.json
.../extend-components/EC_StatisticalHistoryView/package.json
+38
-0
EC_StatisticalHistoryView.md
...C_StatisticalHistoryView/src/EC_StatisticalHistoryView.md
+44
-0
index.js
...nd-components/EC_StatisticalHistoryView/src/apis/index.js
+15
-0
Basic.tsx
...-components/EC_StatisticalHistoryView/src/demos/Basic.tsx
+28
-0
index.js
.../extend-components/EC_StatisticalHistoryView/src/index.js
+418
-0
index.less
...xtend-components/EC_StatisticalHistoryView/src/index.less
+63
-0
No files found.
config/config.js
View file @
ec8b8b3f
...
...
@@ -130,6 +130,7 @@ export default {
'EC_RealTimeInfo'
,
'EC_ConfigurationView'
,
'EC_HistoryView'
,
'EC_StatisticalHistoryView'
,
],
},
],
...
...
packages/extend-components/EC_ConfigurationView/package.json
View file @
ec8b8b3f
...
...
@@ -33,7 +33,6 @@
},
"dependencies"
:
{
"@babel/runtime"
:
"^7.17.9"
,
"@wisdom-components/ec_historyview"
:
"1.21.0"
,
"@wisdom-components/empty"
:
"^1.3.9"
,
"@wisdom-components/loadbox"
:
"^1.1.5"
,
"@wisdom-components/mqttview"
:
"^1.3.7"
,
...
...
packages/extend-components/EC_ConfigurationView/src/RealModel.js
View file @
ec8b8b3f
...
...
@@ -18,6 +18,7 @@ import {
import
MqttView
from
'@wisdom-components/mqttview'
;
import
PropTypes
from
'prop-types'
;
import
HistoryView
from
'@wisdom-components/ec_historyview'
;
import
StatisticalHistoryView
from
'@wisdom-components/ec_statisticalhistoryview'
;
import
*
as
go
from
'./js/go'
;
import
GuidedDraggingTool
from
'./js/GuidedDraggingTool'
;
import
TopRotatingTool
from
'./js/RotatingTool'
;
...
...
@@ -57,6 +58,7 @@ let jumpModalProps = null;
let
modalProps
=
{};
let
modalWidth
=
520
;
let
historyInfoParams
=
[];
let
statisticalInfoParams
=
{};
let
nodeData
=
null
;
// 选中节点的数据
let
twoID
=
''
;
...
...
@@ -75,6 +77,7 @@ const ConfigurationView = (props) => {
const
[
isModalVisible
,
setIsModalVisible
]
=
useState
(
false
);
const
[
isAuModalVisible
,
setIsAuModalVisible
]
=
useState
(
false
);
// 登录模态框
const
[
isHIModalVisible
,
setIsHIModalVisible
]
=
useState
(
false
);
// 历史曲线模态框
const
[
isSTHIModalVisible
,
setIsSTHIModalVisible
]
=
useState
(
false
);
// 统计历史曲线模态框
const
[
isJumpModalVisible
,
setIsJumpModalVisible
]
=
useState
(
false
);
// 画板跳转模态框
const
[
spinning
,
setSpinning
]
=
useState
(
true
);
// 画板loading
const
[
isEmpty
,
setIsEmpty
]
=
useState
(
false
);
// 画板无数据状态
...
...
@@ -1104,6 +1107,20 @@ const ConfigurationView = (props) => {
setIsHIModalVisible(true);
};
/** **************************************统计历史模态渲染****************************************** */
const statisticalModalRender = (data, list) => {
const opRule = JSON.parse(data.opRule);
const stType = opRule && opRule.stType ? opRule.stType : '';
if (!data.shName) return false;
statisticalInfoParams = {
deviceCode: list.code,
sensors: data.shName,
deviceType: list.type,
statisticType: stType,
};
setIsSTHIModalVisible(true);
};
/** **************************************渲染按钮控制****************************************** */
const renderSwitchControlModal = () => {
return (
...
...
@@ -2267,7 +2284,13 @@ const ConfigurationView = (props) => {
// define a tooltip for each node that displays the color as text
toolTip: goJS(
'ToolTip',
goJS(go.TextBlock, { margin: 2 }, new go.Binding('text', 'timeStr'),new go.Binding('visible', 'toolTip')),new go.Binding('visible', 'toolTip'),
goJS(
go.TextBlock,
{ margin: 2 },
new go.Binding('text', 'timeStr'),
new go.Binding('visible', 'toolTip'),
),
new go.Binding('visible', 'toolTip'),
),
},
),
...
...
@@ -2394,7 +2417,11 @@ const ConfigurationView = (props) => {
return false;
}
// 历史查看
if (data.opType && data.shName) historyModalRender(data, list);
if (data.opType && data.opType === '历史查看' && data.shName)
historyModalRender(data, list);
// 统计历史查看
if (data.opType && data.opType === '统计查看' && data.shName)
statisticalModalRender(data, list);
},
},
),
...
...
@@ -3025,11 +3052,28 @@ const ConfigurationView = (props) => {
onOk={() => setIsHIModalVisible(false)}
onCancel={() => setIsHIModalVisible(false)}
getContainer={ConfigurationRef.current}
title={historyInfoParams.length ? historyInfoParams[0].sensors || '' : ''}
wrapClassName={classNames(`
$
{
prefixCls
}
-
historyInfoModal
`)}
>
<HistoryView deviceParams={historyInfoParams} />
</Modal>
)}
{/* 统计历史曲线 */}
{isSTHIModalVisible && (
<Modal
centered
width={1200}
footer={null}
open={isSTHIModalVisible}
onOk={() => setIsSTHIModalVisible(false)}
onCancel={() => setIsSTHIModalVisible(false)}
getContainer={ConfigurationRef.current}
title={statisticalInfoParams.sensors || ''}
wrapClassName={classNames(`
$
{
prefixCls
}
-
historyInfoModal
`)}
>
<StatisticalHistoryView deviceParams={statisticalInfoParams} />
</Modal>
)}
{/* 画板跳转 */}
{isJumpModalVisible && jumpModalProps && (
<DragModal
...
...
packages/extend-components/EC_ConfigurationView/src/apis/index.js
View file @
ec8b8b3f
import
{
request
}
from
'@wisdom-utils/utils
/es
'
;
import
{
request
}
from
'@wisdom-utils/utils'
;
const
REQUEST_METHOD_GET
=
'get'
;
const
REQUEST_METHOD_POST
=
'post'
;
...
...
packages/extend-components/EC_ConfigurationView/src/component/StatisticalHistoryView/index.js
deleted
100644 → 0
View file @
b307f61f
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
;
import
classNames
from
'classnames'
;
import
moment
from
'moment'
;
import
axios
from
'axios'
;
import
Empty
from
'@wisdom-components/empty'
;
import
TimeRangePicker
from
'@wisdom-components/timerangepicker'
;
import
LoadBox
from
'@wisdom-components/loadbox'
;
import
{
Input
,
message
,
Modal
,
Form
,
ConfigProvider
,
Button
}
from
'antd'
;
import
{
ExclamationCircleOutlined
,
DoubleLeftOutlined
,
LeftOutlined
,
RightOutlined
,
DoubleRightOutlined
,
}
from
'@ant-design/icons'
;
import
{
getStatisticsInfo
}
from
'./apis'
;
const
StatisticalHistoryView
=
(
props
)
=>
{
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'statistical-history-view'
);
const
componentPrefix
=
getPrefixCls
(
''
);
const
[
dateValue
,
setDateValue
]
=
useState
(
null
);
const
[
timeValue
,
setTimeValue
]
=
useState
(
null
);
const
[
data
,
setData
]
=
useState
({
startDate
:
''
,
endDate
:
''
});
const
[
time
,
setTime
]
=
useState
({
startTime
:
''
,
endTime
:
''
});
const
onDateChange
=
()
=>
{
}
return
(
<
div
className
=
{
classNames
(
prefixCls
)}
>
<
div
className
=
{
classNames
(
'historyView'
)}
>
<
div
className
=
{
classNames
(
'historyViewHeader'
)}
>
<
span
>
时间选择:
<
/span
>
<
TimeRangePicker
value
=
{
dateValue
}
onChange
=
{
onDateChange
}
defaultValue
=
{
dateList
[
0
].
key
}
dataSource
=
{
dateList
}
layout
=
{
'horizontal'
}
/
>
<
/div
>
<
/div
>
<
/div
>
);
};
export
default
StatisticalHistoryView
;
const
dateList
=
[
{
key
:
'today'
,
name
:
'今日'
,
},
{
key
:
'thisWeek'
,
name
:
'本周'
,
},
{
key
:
'thisMonth'
,
name
:
'本月'
,
},
{
key
:
'customer'
,
name
:
'自定义'
,
},
];
packages/extend-components/EC_ConfigurationView/src/component/StatisticalHistoryView/index.less
deleted
100644 → 0
View file @
b307f61f
packages/extend-components/EC_ConfigurationView/src/demos/Basic.tsx
View file @
ec8b8b3f
...
...
@@ -3,9 +3,9 @@ import { Button } from 'antd';
import
PandaConfiguration
from
'../index'
;
// import PandaConfigurationView from '../../es/index';
const
Demo
=
()
=>
{
const
[
name
,
setName
]
=
useState
(
'
水厂工艺流程段
'
);
const
[
name
,
setName
]
=
useState
(
'
调度
'
);
const
[
devices
,
setDevices
]
=
useState
(
'
EQZT00000008,EQZT00000007,CPDA00000001,JYBZ00000003,JYBZ00000005,JYBZ00000004,SC00000003
'
,
'
QSBF00000001,CGS00000001,SZ00000001,SZ00000008,SZ00000006,SZ00000010,SZ00000007,YLB00000019,YLB00000018,YLB00000031,YLB00000036,YLB00000006,YLB00000029,YLB00000038,YLB00000033,YLB00000027,YLB00000044,YLB00000030,YLB00000035,YLB00000013,YLB00000041,YLB00000042,JFJ00000001,XNCDC00000001,SLC00000001,TLC00000001,SC00000023,SZ00000005,SZ00000004,SZ00000015,SZ00000014,SZ00000011,SZ00000012,YLB00000039,YLB00000034,YLB00000040,SB00000014,SB00000007,SB00000006,SB00000004,SB00000018,SB00000027,SB00000026,SB00000019,SB00000048,SB00000302,SB00000045,SB00000047,SB00000041,SB00000036,SB00000029,SC00000023,SB00000288,SB00000028,SB00000030,SZ00000016,LLJ00000002,LLJ00000003,LLJ00000004,LLJ00000001
'
,
);
return
(
<>
...
...
@@ -44,18 +44,18 @@ export default Demo;
const
globalConfig
=
{
token
:
'a1372ef0ce7b4e4884d31cfd99fe92f6'
,
mqtt_iotIP
:
'
emqttd10.panda-water.cn:44
3'
,
mqtt_iotIP
:
'
221.229.200.85:808
3'
,
mqtt_path
:
'/mqtt'
,
mqtt_IsSSL
:
tru
e
,
mqtt_site_code
:
'site_
dc8302ni
'
,
mqtt_IsSSL
:
fals
e
,
mqtt_site_code
:
'site_
qd5880vd
'
,
mqtt_mess
:
{
MessageLevel
:
'1.0'
,
TcpIP
:
'
emqttd10.panda-water.cn
'
,
TcpPort
:
44
3
,
site_code
:
'site_
dc8302ni
'
,
TcpIP
:
'
221.229.200.85
'
,
TcpPort
:
808
3
,
site_code
:
'site_
qd5880vd
'
,
},
userInfo
:
{
LocalSite
:
'site_
dc8302ni
'
,
LocalSite
:
'site_
qd5880vd
'
,
site
:
''
,
},
};
packages/extend-components/EC_StatisticalHistoryView/README.md
0 → 100644
View file @
ec8b8b3f
# `@wisdom-components/EC_StatisticalHistoryView`
> TODO: description
## Usage
```
const ecStatisticalHistoryView = require('@wisdom-components/ec_statisticalhistoryview');
// TODO: DEMONSTRATE API
```
packages/extend-components/EC_StatisticalHistoryView/package.json
0 → 100644
View file @
ec8b8b3f
{
"name"
:
"@wisdom-components/ec_statisticalhistoryview"
,
"version"
:
"1.0.0"
,
"description"
:
"> TODO: description"
,
"author"
:
"lijiwen <961370825@qq.com>"
,
"homepage"
:
""
,
"license"
:
"ISC"
,
"sideEffects"
:
[
"*.less"
],
"module"
:
"es/index.js"
,
"main"
:
"lib/index.js"
,
"files"
:
[
"lib"
,
"es"
,
"dist"
],
"directories"
:
{
"lib"
:
"lib"
,
"es"
:
"es"
,
"dist"
:
"dist"
,
"test"
:
"__tests__"
},
"publishConfig"
:
{
"registry"
:
"https://g.civnet.cn:4873/"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"https://g.civnet.cn:8443/ReactWeb5/wisdom-components.git"
},
"scripts"
:
{
"test"
:
"echo
\"
Error: run tests from root
\"
&& exit 1"
},
"dependencies"
:
{
"@babel/runtime"
:
"^7.17.9"
}
}
\ No newline at end of file
packages/extend-components/EC_StatisticalHistoryView/src/EC_StatisticalHistoryView.md
0 → 100644
View file @
ec8b8b3f
---
title
:
EC_StatisticalHistoryView - 统计查看
nav
:
title
:
业务组件
path
:
/extend-components
group
:
path
:
/
---
# EC_StatisticalHistoryView 统计查看
基础业务组件
-
统计查看
## 何时使用
-
在统计查看时。
## 代码演示
<code
src=
"./demos/Basic.tsx"
>
## API
| 参数 | 说明 | 类型 | 默认值 |
| -------------- | -------------------------------- | ---------------- | ------ |
| name
`必需`
| 画板名称 | string | '' |
| devices
`必需`
| 画板设备 | array |
[
] |
| deviceName | 画板设备名称 | array |
[
] |
| config | 全局 globalConfig,没有时需要传递 | object | {} |
| isZoom | 是否可缩放(手持上建议设置 true) | boolean | false |
| flowShow | 是否水流效果(无数据表现) | boolean | true |
| customBack | 自定义交互的回调,返回点击的模型 | function(node){} | - |
### 工艺回放
| 参数 | 说明 | 类型 | 默认值 |
| -------- | ---------------------- | ------------------------------------ | ------ |
| speed | 历史数据播放当前进度值 | number | 0 |
| play | 历史数据是否播放 | boolean | false |
| times | 历史数据播放速度(s) | number | 2 |
| params | 历史数据服务参数 | object | {} |
| callback | 历史数据播放的回调 | function(speed, total, play, time){} | - |
packages/extend-components/EC_StatisticalHistoryView/src/apis/index.js
0 → 100644
View file @
ec8b8b3f
import
{
request
}
from
'@wisdom-utils/utils'
;
const
REQUEST_METHOD_GET
=
'get'
;
const
REQUEST_METHOD_POST
=
'post'
;
// eslint-disable-next-line no-undef
const
baseURI
=
typeof
DUMI_TYPE
!==
'undefined'
&&
DUMI_TYPE
===
'dumi'
?
'/api'
:
''
;
// 获取统计数据
export
function
getStatisticsInfo
(
data
)
{
return
request
({
url
:
`
${
baseURI
}
/PandaMonitor/Monitor/Device/EquipmentDataReport`
,
method
:
REQUEST_METHOD_POST
,
data
,
});
}
packages/extend-components/EC_StatisticalHistoryView/src/demos/Basic.tsx
0 → 100644
View file @
ec8b8b3f
import
React
,
{
useState
}
from
'react'
;
import
{
Button
}
from
'antd'
;
import
StatisticalHistoryView
from
'../index'
;
// import PandaConfigurationView from '../../es/index';
const
Demo
=
()
=>
{
// const params = {
// deviceCode: 'JYBZ00000004',
// sensors: '出水实际压力',
// deviceType: '加压泵站',
// statisticType: '',
// }
const
params
=
{
deviceCode
:
'SC00000023'
,
sensors
:
'出水累计流量'
,
deviceType
:
'水厂'
,
statisticType
:
''
,
}
return
(
<>
<
div
style=
{
{
width
:
'100%'
,
height
:
'600px'
}
}
>
<
StatisticalHistoryView
deviceParams=
{
params
}
/>
</
div
>
</>
);
};
export
default
Demo
;
\ No newline at end of file
packages/extend-components/EC_StatisticalHistoryView/src/index.js
0 → 100644
View file @
ec8b8b3f
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
;
import
classNames
from
'classnames'
;
import
moment
from
'moment'
;
import
Empty
from
'@wisdom-components/empty'
;
import
LoadBox
from
'@wisdom-components/loadbox'
;
import
BasicTable
from
'@wisdom-components/basictable'
;
import
{
ConfigProvider
,
Select
,
DatePicker
,
Radio
}
from
'antd'
;
import
{
BasicChart
}
from
'@wisdom-components/basicchart'
;
import
{
getStatisticsInfo
}
from
'./apis'
;
import
'./index.less'
;
const
StatisticalHistoryView
=
(
props
)
=>
{
const
{
getPrefixCls
}
=
useContext
(
ConfigProvider
.
ConfigContext
);
const
prefixCls
=
getPrefixCls
(
'ec-statistical-history-view'
);
const
componentPrefix
=
getPrefixCls
(
''
);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
historyRender
,
setHistoryRender
]
=
useState
(
true
);
const
[
historyParams
,
setHistoryParams
]
=
useState
({});
const
[
columns
,
setColumns
]
=
useState
([
{
title
:
'时间'
,
dataIndex
:
'pt'
,
align
:
'center'
,
width
:
100
,
fixed
:
'left'
,
},
]);
const
[
dataSource
,
setDataSource
]
=
useState
([]);
const
[
options
,
setOptions
]
=
useState
({});
const
[
dateValue
,
setDateValue
]
=
useState
(
'today'
);
const
[
picker
,
setPicker
]
=
useState
(
'day'
);
const
[
time
,
setTime
]
=
useState
({
startTime
:
''
,
endTime
:
''
});
const
[
dateTime
,
setDateTime
]
=
useState
(
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
));
// 时间切换筛选
const
onTimeChange
=
(
e
)
=>
{
setDateValue
(
e
.
target
.
value
);
};
// 自定义时间类型
const
onPickerChange
=
(
value
)
=>
{
setPicker
(
value
);
const
start
=
moment
(
dateTime
).
subtract
(
2
,
value
).
format
(
'YYYY-MM-DD 00:00:00'
);
const
end
=
moment
(
dateTime
).
format
(
'YYYY-MM-DD 23:59:59'
);
setTime
({
startDate
:
start
,
endDate
:
end
});
};
// 自定义时间选择
const
onDateChange
=
(
value
,
dateString
)
=>
{
setDateTime
(
dateString
);
const
start
=
moment
(
value
).
subtract
(
2
,
picker
).
format
(
'YYYY-MM-DD 00:00:00'
);
const
end
=
moment
(
value
).
format
(
'YYYY-MM-DD 23:59:59'
);
setTime
({
startDate
:
start
,
endDate
:
end
});
};
// 获取历史统计数据
const
getHistoryData
=
async
()
=>
{
const
{
deviceCode
=
''
,
sensors
=
''
,
deviceType
=
''
,
statisticType
=
''
}
=
historyParams
;
const
nameTypeList
=
[];
if
(
!
deviceCode
||
!
sensors
)
return
setHistoryRender
(
false
);
nameTypeList
.
push
({
name
:
sensors
,
type
:
statisticType
||
'Sub'
,
});
const
params
=
{
pageIndex
:
1
,
pageSize
:
999
,
nameTypeList
:
nameTypeList
,
accountName
:
deviceType
,
dateFrom
:
time
.
startDate
,
dateTo
:
time
.
endDate
,
deviceCode
:
deviceCode
,
dateType
:
picker
,
};
setLoading
(
true
);
const
results
=
await
getStatisticsInfo
(
params
);
setLoading
(
false
);
const
list
=
results
?.
data
?.
list
||
[];
const
dataList
=
list
.
length
?
list
[
0
]
:
{};
const
dNameDataList
=
dataList
.
dNameDataList
?
dataList
.
dNameDataList
:
[];
const
data
=
dNameDataList
.
length
?
dNameDataList
[
0
]
:
null
;
if
(
!
data
)
return
setHistoryRender
(
false
);
dataMenthod
(
data
);
};
const
dataMenthod
=
(
data
)
=>
{
const
{
nameDate
}
=
data
;
let
time0
=
''
,
time1
=
''
,
time2
=
''
;
let
data0
=
[],
data1
=
[],
data2
=
[];
let
timeName
=
[];
switch
(
dateValue
)
{
case
'today'
:
time0
=
moment
(
time
.
endDate
).
subtract
(
0
,
'day'
).
format
(
'YYYY-MM-DD'
);
time1
=
moment
(
time
.
endDate
).
subtract
(
1
,
'day'
).
format
(
'YYYY-MM-DD'
);
time2
=
moment
(
time
.
endDate
).
subtract
(
2
,
'day'
).
format
(
'YYYY-MM-DD'
);
timeName
=
[].
concat
(
dayName
);
nameDate
.
forEach
((
item
)
=>
{
const
times
=
moment
(
item
.
time
).
format
(
'YYYY-MM-DD'
);
const
pt
=
moment
(
item
.
time
).
format
(
'HH时'
);
if
(
times
===
time0
)
data0
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time1
)
data1
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time2
)
data2
.
push
({
...
item
,
pt
:
pt
});
});
break
;
case
'thisWeek'
:
time0
=
moment
(
time
.
endDate
).
subtract
(
0
,
'week'
).
format
(
'WW'
);
time1
=
moment
(
time
.
endDate
).
subtract
(
1
,
'week'
).
format
(
'WW'
);
time2
=
moment
(
time
.
endDate
).
subtract
(
2
,
'week'
).
format
(
'WW'
);
timeName
=
[].
concat
(
weekName
);
nameDate
.
forEach
((
item
)
=>
{
const
times
=
moment
(
item
.
time
).
format
(
'WW'
);
const
pt
=
getWeek
(
item
.
time
);
if
(
times
===
time0
)
data0
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time1
)
data1
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time2
)
data2
.
push
({
...
item
,
pt
:
pt
});
});
break
;
case
'thisMonth'
:
time0
=
moment
(
time
.
endDate
).
subtract
(
0
,
'month'
).
format
(
'YYYY-MM'
);
time1
=
moment
(
time
.
endDate
).
subtract
(
1
,
'month'
).
format
(
'YYYY-MM'
);
time2
=
moment
(
time
.
endDate
).
subtract
(
2
,
'month'
).
format
(
'YYYY-MM'
);
timeName
=
[].
concat
(
monthName
);
nameDate
.
forEach
((
item
)
=>
{
const
times
=
moment
(
item
.
time
).
format
(
'YYYY-MM'
);
const
pt
=
moment
(
item
.
time
).
format
(
'DD日'
);
if
(
times
===
time0
)
data0
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time1
)
data1
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time2
)
data2
.
push
({
...
item
,
pt
:
pt
});
});
break
;
case
'customer'
:
const
style
=
picker
===
'day'
?
'HH时'
:
picker
===
'month'
?
'DD日'
:
'MM月'
;
const
format
=
picker
===
'day'
?
'YYYY-MM-DD'
:
picker
===
'month'
?
'YYYY-MM'
:
'YYYY'
;
time0
=
moment
(
time
.
endDate
).
subtract
(
0
,
picker
).
format
(
format
);
time1
=
moment
(
time
.
endDate
).
subtract
(
1
,
picker
).
format
(
format
);
time2
=
moment
(
time
.
endDate
).
subtract
(
2
,
picker
).
format
(
format
);
timeName
=
[].
concat
([
time0
,
time1
,
time2
]);
nameDate
.
forEach
((
item
)
=>
{
const
times
=
moment
(
item
.
time
).
format
(
format
);
const
pt
=
moment
(
item
.
time
).
format
(
style
);
if
(
times
===
time0
)
data0
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time1
)
data1
.
push
({
...
item
,
pt
:
pt
});
if
(
times
===
time2
)
data2
.
push
({
...
item
,
pt
:
pt
});
});
break
;
}
const
dataChart
=
{
data
:
[
data0
,
data1
,
data2
],
name
:
timeName
,
};
const
dataTable
=
data0
.
map
((
item
,
index
)
=>
{
return
{
...
item
,
value1
:
data1
[
index
]?.
value
,
value2
:
data1
[
index
]?.
value
,
};
});
renderChart
(
dataChart
,
data
);
renderTable
(
dataTable
,
timeName
);
};
const
renderChart
=
(
dataInfo
,
data
)
=>
{
if
(
!
dataInfo
)
return
setOptions
(
null
);
const
{
unit
,
dName
}
=
data
;
const
series
=
[];
dataInfo
.
data
.
forEach
((
item
,
index
)
=>
{
const
config
=
dName
.
indexOf
(
'流量'
)
>
-
1
?
{
areaStyle
:
{}
}
:
{};
const
list
=
{
name
:
dataInfo
.
name
[
index
],
type
:
'line'
,
...
config
,
data
:
item
.
map
((
arr
)
=>
{
return
{
name
:
arr
.
pt
,
value
:
arr
.
value
,
};
}),
};
series
.
push
(
list
);
});
const
option
=
{
title
:
{
show
:
false
,
text
:
''
,
},
tooltip
:
{
trigger
:
'axis'
,
axisPointer
:
{
type
:
'cross'
,
},
},
grid
:
{
containLabel
:
true
,
left
:
10
,
right
:
10
,
top
:
10
,
bottom
:
10
},
toolbox
:
{
show
:
false
,
},
legend
:
{
left
:
'center'
,
},
xAxis
:
[
{
type
:
'category'
,
axisTick
:
{
alignWithLabel
:
true
,
},
},
],
yAxis
:
[
{
type
:
'value'
,
name
:
unit
,
position
:
'left'
,
alignTicks
:
true
,
axisLine
:
{
show
:
true
,
},
axisLabel
:
{
formatter
:
'{value}'
,
},
},
],
series
:
series
,
};
setOptions
(
option
);
};
const
renderTable
=
(
dataInfo
,
timeName
)
=>
{
const
dataIndex
=
[
'value'
,
'value1'
,
'value2'
];
const
column1
=
[
{
title
:
'时间'
,
dataIndex
:
'pt'
,
align
:
'center'
,
width
:
100
,
fixed
:
'left'
,
},
];
const
column2
=
timeName
.
map
((
item
,
index
)
=>
{
return
{
title
:
item
,
dataIndex
:
dataIndex
[
index
],
align
:
'center'
,
// width: 60,
};
});
const
column
=
column1
.
concat
(
column2
);
setColumns
(
column
);
setDataSource
(
dataInfo
);
};
const
getWeek
=
(
date
)
=>
{
const
weekTime
=
moment
(
date
).
day
();
switch
(
weekTime
)
{
case
1
:
return
'周一'
;
break
;
case
2
:
return
'周二'
;
break
;
case
3
:
return
'周三'
;
break
;
case
4
:
return
'周四'
;
break
;
case
5
:
return
'周五'
;
break
;
case
6
:
return
'周六'
;
break
;
case
0
:
return
'周日'
;
break
;
}
};
useEffect
(()
=>
{
setHistoryParams
(
props
.
deviceParams
||
{});
},
[
props
.
deviceParams
]);
useEffect
(()
=>
{
let
start
=
''
,
end
=
''
;
switch
(
dateValue
)
{
case
'today'
:
start
=
moment
().
subtract
(
2
,
'day'
).
format
(
'YYYY-MM-DD 00:00:00'
);
end
=
moment
().
format
(
'YYYY-MM-DD 23:59:59'
);
setPicker
(
'day'
);
break
;
case
'thisWeek'
:
start
=
moment
().
startOf
(
'week'
).
subtract
(
2
,
'week'
).
format
(
'YYYY-MM-DD 00:00:00'
);
end
=
moment
().
endOf
(
'week'
).
format
(
'YYYY-MM-DD 23:59:59'
);
setPicker
(
'month'
);
break
;
case
'thisMonth'
:
start
=
moment
().
startOf
(
'month'
).
subtract
(
2
,
'month'
).
format
(
'YYYY-MM-DD 00:00:00'
);
end
=
moment
().
endOf
(
'month'
).
format
(
'YYYY-MM-DD 23:59:59'
);
setPicker
(
'month'
);
break
;
case
'customer'
:
start
=
moment
().
startOf
(
picker
).
subtract
(
2
,
picker
).
format
(
'YYYY-MM-DD 00:00:00'
);
end
=
moment
().
endOf
(
picker
).
format
(
'YYYY-MM-DD 23:59:59'
);
break
;
}
setTime
({
startDate
:
start
,
endDate
:
end
});
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
dateValue
]);
useEffect
(()
=>
{
getHistoryData
();
// eslint-disable-next-line react-hooks/exhaustive-deps
},
[
time
,
historyParams
,
picker
]);
return
(
<
div
className
=
{
classNames
(
prefixCls
)}
>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-box`
)}
>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-header`
)}
>
<
span
>
时间选择:
<
/span
>
<
Radio
.
Group
value
=
{
dateValue
}
defaultValue
=
{
dateList
[
0
].
key
}
onChange
=
{
onTimeChange
}
>
{
dateList
.
map
((
item
)
=>
(
<
Radio
.
Button
key
=
{
item
.
key
}
value
=
{
item
.
key
}
>
{
item
.
name
}
<
/Radio.Button
>
))}
<
/Radio.Group
>
{
dateValue
===
'customer'
&&
(
<>
<
Select
defaultValue
=
"day"
value
=
{
picker
}
options
=
{
timeList
}
onChange
=
{
onPickerChange
}
className
=
{
classNames
(
`
${
prefixCls
}
-select`
)}
/
>
<
DatePicker
onChange
=
{
onDateChange
}
value
=
{
moment
(
dateTime
)}
picker
=
{
picker
}
/
>
<
/
>
)}
<
/div
>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-content`
)}
>
{
<>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-chart`
)}
>
<
BasicChart
option
=
{
options
}
notMerge
style
=
{{
width
:
'100%'
,
height
:
'100%'
}}
/
>
<
/div
>
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-table`
)}
>
<
BasicTable
dataSource
=
{
dataSource
}
columns
=
{
columns
}
pagination
=
{
false
}
bordered
=
{
true
}
scroll
=
{{
x
:
'100%'
,
y
:
'calc(100% - 40px)'
}}
/
>
<
/div
>
<
/
>
}
<
/div
>
<
/div
>
{
loading
&&
(
<
div
className
=
{
classNames
(
`
${
prefixCls
}
-load-box`
)}
>
<
LoadBox
spinning
=
{
loading
}
/
>
<
/div
>
)}
<
/div
>
);
};
export
default
StatisticalHistoryView
;
const
dateList
=
[
{
key
:
'today'
,
name
:
'今日'
,
},
{
key
:
'thisWeek'
,
name
:
'本周'
,
},
{
key
:
'thisMonth'
,
name
:
'本月'
,
},
{
key
:
'customer'
,
name
:
'自定义'
,
},
];
const
timeList
=
[
{
value
:
'day'
,
label
:
'日'
,
},
{
value
:
'month'
,
label
:
'月'
,
},
{
value
:
'year'
,
label
:
'年'
,
},
];
const
dayName
=
[
'今日'
,
'昨日'
,
'前日'
];
const
weekName
=
[
'本周'
,
'上周'
,
'上上周'
];
const
monthName
=
[
'本月'
,
'上月'
,
'上上月'
];
packages/extend-components/EC_StatisticalHistoryView/src/index.less
0 → 100644
View file @
ec8b8b3f
@root-entry-name: 'default';
@import '~antd/es/style/themes/index.less';
@ec-statistical-history-view-prefix-cls: ~'@{ant-prefix}-ec-statistical-history-view';
.@{ec-statistical-history-view-prefix-cls} {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
position: relative;
&-load-box {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
}
&-empty {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
&-box {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
}
&-header {
flex: none;
margin-bottom: 10px;
}
&-select {
margin: 0 10px;
width: 100px;
}
&-content {
flex: 1;
display: flex;
overflow: hidden;
}
&-chart {
flex: 3;
overflow: hidden;
}
&-table {
flex: 2;
overflow: hidden;
}
}
\ No newline at end of file
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