Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
Iot_mobile
Project
Project
Details
Activity
Releases
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
wuhao
Iot_mobile
Commits
1ac6b91f
Commit
1ac6b91f
authored
Feb 22, 2023
by
wuhao
🎯
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asder
parent
8b44ded0
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
774 additions
and
116 deletions
+774
-116
authRoutes.js
config/authRoutes.js
+6
-0
index.jsx
src/components/AutoTable/index.jsx
+18
-10
global.less
src/global.less
+3
-0
BasicLayout.jsx
src/layouts/BasicLayout.jsx
+67
-51
detail.jsx
src/pages/home/detail.jsx
+657
-0
index.jsx
src/pages/home/index.jsx
+23
-55
No files found.
config/authRoutes.js
View file @
1ac6b91f
...
...
@@ -18,6 +18,12 @@ export default [
component
:
'./home'
,
icon
:
'HomeOutlined'
,
},
{
name
:
'设备详情'
,
path
:
'/home/detail'
,
component
:
'./home/detail'
,
icon
:
'HomeOutlined'
,
},
],
},
...
...
src/components/AutoTable/index.jsx
View file @
1ac6b91f
...
...
@@ -40,7 +40,7 @@ export default (props) => {
children
,
}
=
props
;
const
[
data
,
setData
]
=
useState
(
[]
);
const
[
data
,
setData
]
=
useState
();
const
[
hasMore
,
setHasMore
]
=
useState
(
true
);
const
[
pageinfo
,
setpageinfo
]
=
useState
({
pageIndex
:
1
,
...
...
@@ -60,7 +60,7 @@ export default (props) => {
});
const
page
=
append
?.
data
?.
page
;
const
dataes
=
page
?.
records
??
append
?.
data
?.
dataList
??
[];
setData
((
val
)
=>
[...
val
,
...
dataes
]);
setData
((
val
)
=>
[...
(
val
??
[])
,
...
dataes
]);
return
page
?
{
...
page
,
...
...
@@ -83,7 +83,7 @@ export default (props) => {
...
s
,
pageIndex
:
1
,
}));
await
setData
(
[]
);
await
setData
(
null
);
}
//额外参数改变后重置
...
...
@@ -128,13 +128,15 @@ export default (props) => {
<
div
></
div
>
</
div
>
</
div
>
{
data
.
length
>
0
?
(
{
data
?
.
length
>
0
?
(
<
PullToRefresh
onRefresh=
{
async
()
=>
{
await
reFresh
();
}
}
>
{
data
.
map
((
item
,
index
)
=>
cloneElement
(
children
,
{
item
,
columns
}))
}
{
data
?.
map
((
item
,
index
)
=>
cloneElement
(
children
,
{
item
,
columns
}),
)
}
<
InfiniteScroll
loadMore=
{
loadMore
}
hasMore=
{
hasMore
}
/>
</
PullToRefresh
>
)
:
(
...
...
@@ -144,11 +146,17 @@ export default (props) => {
}
}
>
<
div
style=
{
{
minHeight
:
'calc(100vh - 172px)'
}
}
>
<
Empty
style=
{
{
padding
:
'64px 0'
}
}
imageStyle=
{
{
width
:
'30vw'
}
}
description=
"暂无数据"
/>
{
data
?.
length
===
0
?
(
<
Empty
style=
{
{
padding
:
'64px 0'
}
}
imageStyle=
{
{
width
:
'120px'
}
}
description=
"暂无数据"
/>
)
:
(
<
div
className=
'center'
style=
{
{
fontSize
:
16
}
}
>
<
DotLoading
/>
</
div
>
)
}
</
div
>
</
PullToRefresh
>
)
}
...
...
src/global.less
View file @
1ac6b91f
...
...
@@ -143,4 +143,7 @@ a:active{
*{
color: #fff !important;
}
}
.adm-floating-panel{
z-index: 9999999;
}
\ No newline at end of file
src/layouts/BasicLayout.jsx
View file @
1ac6b91f
...
...
@@ -54,6 +54,7 @@ function BasicLayout() {
icon
:
<
PieChartFilled
/>,
},
];
const
location
=
useLocation
();
const
{
pathname
}
=
location
;
...
...
@@ -83,7 +84,7 @@ function BasicLayout() {
if
(
distancey
>
10
||
distancey
<
-
10
)
{
return
;
}
if
(
distance
>
20
)
{
if
(
distance
>
20
&&
menulist
.
includes
(
pathname
)
)
{
// 执行左滑操作
setdrawer
((
s
)
=>
({
...
s
,
...
...
@@ -91,7 +92,8 @@ function BasicLayout() {
}));
}
}
const
handler
=
useRef
(),
formRef
=
useRef
();
const
handler
=
useRef
(),
formRef
=
useRef
();
const
[
visible1
,
setVisible1
]
=
useState
(
false
);
const
[
type
,
settype
]
=
useState
({});
...
...
@@ -118,7 +120,7 @@ function BasicLayout() {
onMaskClick=
{
()
=>
{
setVisible1
(
false
);
}
}
bodyStyle=
{
{
height
:
type
?.
val
===
'info'
?
'330px'
:
'430px'
}
}
bodyStyle=
{
{
height
:
type
?.
val
===
'info'
?
'330px'
:
'430px'
}
}
position=
"top"
>
{
type
?.
val
===
'info'
?
(
...
...
@@ -159,54 +161,59 @@ function BasicLayout() {
formRef=
{
formRef
}
fields=
{
[
{
"title"
:
"原始密码"
,
"dataIndex"
:
"oldPassword"
,
"key"
:
"oldPassword"
,
"formItemProps"
:
{
"rules"
:
[
title
:
'原始密码'
,
dataIndex
:
'oldPassword'
,
key
:
'oldPassword'
,
formItemProps
:
{
rules
:
[
{
"required"
:
true
,
"message"
:
"此项为必填项"
}
]
}
required
:
true
,
message
:
'此项为必填项'
,
}
,
]
,
}
,
},
{
"title"
:
"新密码"
,
"dataIndex"
:
"password"
,
"key"
:
"password"
,
"formItemProps"
:
{
"rules"
:
[
title
:
'新密码'
,
dataIndex
:
'password'
,
key
:
'password'
,
formItemProps
:
{
rules
:
[
{
"required"
:
true
,
"message"
:
"此项为必填项"
}
]
required
:
true
,
message
:
'此项为必填项'
,
}
,
]
,
},
"valueType"
:
"password"
valueType
:
'password'
,
},
{
"title"
:
"确认新密码"
,
"dataIndex"
:
"confirmPassword"
,
"key"
:
"confirmPassword"
,
"formItemProps"
:
{
"rules"
:
[
title
:
'确认新密码'
,
dataIndex
:
'confirmPassword'
,
key
:
'confirmPassword'
,
formItemProps
:
{
rules
:
[
{
"required"
:
true
,
"message"
:
"此项为必填项"
required
:
true
,
message
:
'此项为必填项'
,
},
({
getFieldValue
})
=>
({
validator
(
_
,
value
)
{
if
(
!
value
||
getFieldValue
(
'password'
)
===
value
)
{
if
(
!
value
||
getFieldValue
(
'password'
)
===
value
)
{
return
Promise
.
resolve
();
}
return
Promise
.
reject
(
new
Error
(
'两次输入的密码不一致!'
));
return
Promise
.
reject
(
new
Error
(
'两次输入的密码不一致!'
),
);
},
}),
]
]
,
},
"valueType"
:
"password"
}
valueType
:
'password'
,
}
,
]
}
onFinish=
{
async
(
vals
)
=>
{
let
res
=
await
doFetch
({
...
...
@@ -222,8 +229,6 @@ function BasicLayout() {
</
div
>
)
}
</
Popup
>
<
Avatar
size=
{
56
}
icon=
{
<
UserOutlined
/>
}
></
Avatar
>
<
div
...
...
@@ -264,8 +269,17 @@ function BasicLayout() {
>
公司
</
List
.
Item
>
<
div
style=
{
{
alignItems
:
"flex-end"
,
paddingLeft
:
8
}
}
className=
"center"
>
<
Divider
style=
{
{
minWidth
:
120
,
width
:
"calc(100% - 0px)"
,
marginBottom
:
16
}
}
></
Divider
>
<
div
style=
{
{
alignItems
:
'flex-end'
,
paddingLeft
:
8
}
}
className=
"center"
>
<
Divider
style=
{
{
minWidth
:
120
,
width
:
'calc(100% - 0px)'
,
marginBottom
:
16
,
}
}
></
Divider
>
</
div
>
<
List
.
Item
prefix=
{
<
LockOutlined
/>
}
...
...
@@ -320,7 +334,7 @@ function BasicLayout() {
</
Button
>
</
div
>
</
Drawer
>
<
div
className=
"top"
>
<
div
className=
"top"
style=
{
{
zIndex
:
menulist
.
includes
(
pathname
)?
999
:
99999999
}
}
>
<
NavBar
backArrow=
{
menulist
.
includes
(
pathname
)
?
(
...
...
@@ -343,22 +357,24 @@ function BasicLayout() {
{
currouter
?.
name
}
</
NavBar
>
</
div
>
<
div
style=
{
{
height
:
94
}
}
></
div
>
<
div
style=
{
{
height
:
menulist
.
includes
(
pathname
)
?
94
:
58
}
}
></
div
>
<
div
onTouchStart=
{
handleTouchStart
}
onTouchMove=
{
handleTouchMove
}
>
<
Outlet
></
Outlet
>
</
div
>
<
div
style=
{
{
height
:
66
}
}
></
div
>
<
div
className=
"bottom"
>
<
TabBar
activeKey=
{
pathname
}
onChange=
{
(
value
)
=>
setRouteActive
(
value
)
}
>
{
tabs
.
map
((
item
)
=>
(
<
TabBar
.
Item
key=
{
item
.
key
}
icon=
{
item
.
icon
}
title=
{
item
.
title
}
/>
))
}
</
TabBar
>
</
div
>
{
menulist
.
includes
(
pathname
)
&&
(
<
div
className=
"bottom"
>
<
TabBar
activeKey=
{
pathname
}
onChange=
{
(
value
)
=>
setRouteActive
(
value
)
}
>
{
tabs
.
map
((
item
)
=>
(
<
TabBar
.
Item
key=
{
item
.
key
}
icon=
{
item
.
icon
}
title=
{
item
.
title
}
/>
))
}
</
TabBar
>
</
div
>
)
}
</
div
>
);
}
...
...
src/pages/home/detail.jsx
0 → 100644
View file @
1ac6b91f
This diff is collapsed.
Click to expand it.
src/pages/home/index.jsx
View file @
1ac6b91f
...
...
@@ -3,12 +3,13 @@ import * as React from 'react';
import
{
useState
,
useMemo
,
useRef
}
from
'react'
;
import
DrawerPro
from
'@/components/DrawerPro'
;
import
AutoTable
from
'@/components/AutoTable'
;
import
{
Badge
}
from
'antd'
;
import
{
Badge
,
Skeleton
}
from
'antd'
;
import
getcolumns
from
'./columns'
;
import
{
useAsyncEffect
,
useRequest
}
from
'ahooks'
;
import
{
doFetch
}
from
'@/utils/doFetch'
;
import
ReactECharts
from
'echarts-for-react'
;
import
Settings
from
'../../../config/defaultSettings'
;
import
{
history
}
from
'@umijs/max'
;
const
{
proxypath
}
=
Settings
;
...
...
@@ -51,7 +52,9 @@ function cropImage(url) {
const
Cards
=
({
item
,
columns
})
=>
{
const
[
option
,
setoption
]
=
useState
({});
const
{
statusColorList
,
deviceStatusDurationList
}
=
item
;
const
[
loading
,
setloading
]
=
useState
(
false
);
useAsyncEffect
(
async
()
=>
{
setloading
(
true
)
let
img
=
item
?.
image
?.
length
>
0
?
proxypath
+
item
.
image
?.[
0
]?.
url
...
...
@@ -80,7 +83,6 @@ const Cards = ({ item, columns }) => {
},
},
];
const
options
=
{
series
:
[
{
...
...
@@ -109,24 +111,28 @@ const Cards = ({ item, columns }) => {
],
},
};
set
option
(
options
);
await
setoption
(
options
);
set
loading
(
false
)
},
[
item
]);
return
(
<
div
className=
"split"
>
<
div
className=
"split"
onClick=
{
()
=>
{
history
.
push
(
'/home/detail'
,
{
id
:
item
.
id
,
deviceId
:
item
.
deviceId
});
}
}
style=
{
{
minHeight
:
169
}
}
>
<
Skeleton
loading=
{
loading
}
active
>
<
div
className=
"spread"
style=
{
{
justifyContent
:
'flex-start'
}
}
>
<
Badge
count=
{
item
.
alarmNum
}
overflowCount=
{
99
}
offset=
{
[
-
10
,
10
]
}
color=
{
item
.
alarmNum
<
10
?
'#108ee9'
:
item
.
alarmNum
<
30
?
'#f76e1e'
:
'red'
}
color=
"red"
>
<
div
style=
{
{
width
:
120
,
height
:
120
,
flexShrink
:
0
}
}
>
<
ReactECharts
option=
{
option
}
style=
{
{
height
:
'100%'
}
}
/>
...
...
@@ -156,40 +162,29 @@ const Cards = ({ item, columns }) => {
})
}
</
div
>
</
div
>
</
Skeleton
>
</
div
>
);
};
function
Home
(
props
)
{
const
actionRef
=
useRef
(),
formRef
=
useRef
();
const
[
drawer
,
setdrawer
]
=
useState
({
open
:
false
,
}),
[
activeTabKey
,
setactiveTabKey
]
=
useState
(
'1'
);
const
actionRef
=
useRef
();
const
{
run
,
loading
}
=
useRequest
(
doFetch
,
{
manual
:
true
,
onSuccess
:
(
res
,
params
)
=>
{
if
(
res
?.
code
===
'0000'
)
{
actionRef
?.
current
?.
reload
();
setdrawer
((
s
)
=>
({
...
s
,
open
:
false
,
}));
}
},
});
const
columns
=
useMemo
(()
=>
{
let
defcolumn
=
getcolumns
(
setdrawer
)?.
columns
;
let
defcolumn
=
getcolumns
()?.
columns
;
return
defcolumn
;
},
[
activeTabKey
]);
},
[]);
const
pathconfig
=
useMemo
(()
=>
{
let
defpath
=
getcolumns
()?.
pathconfig
??
{};
return
defpath
;
},
[
activeTabKey
]);
return
(
<
div
style=
{
{
position
:
'relative'
}
}
>
...
...
@@ -200,33 +195,6 @@ function Home(props) {
>
<
Cards
/>
</
AutoTable
>
<
DrawerPro
fields=
{
columns
}
detailpath=
{
pathconfig
?.
detail
||
null
}
detailData=
{
drawer
?.
item
}
defaultFormValue=
{
drawer
?.
item
}
params=
{
{
id
:
drawer
?.
item
?.
id
}
}
formRef=
{
formRef
}
placement=
"right"
onClose=
{
()
=>
{
setdrawer
((
s
)
=>
({
...
s
,
open
:
false
,
}));
}
}
{
...
drawer
}
onFinish=
{
(
vals
)
=>
{
if
(
drawer
?.
val
===
'add'
)
{
run
({
url
:
pathconfig
?.
add
||
'/add'
,
params
:
{
...
vals
}
});
}
else
if
(
drawer
?.
val
===
'edit'
)
{
run
({
url
:
pathconfig
?.
edit
||
'/edit'
,
params
:
{
...
vals
,
id
:
drawer
?.
item
?.
id
},
});
}
}
}
/>
</
div
>
);
}
...
...
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