Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
visualcloud
/
Vmatrix-client-taro
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c1292415
authored
Nov 07, 2019
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设备组功能开发
parent
3f344ec8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
89 additions
and
78 deletions
+89
-78
src/api/common.ts
+30
-16
src/pages/home/device/group_detail/index.tsx
+14
-20
src/pages/home/device/group_device_bind/index.scss
+1
-1
src/pages/home/device/group_device_bind/index.tsx
+12
-4
src/pages/home/device/group_list/index.tsx
+32
-37
No files found.
src/api/common.ts
View file @
c1292415
...
@@ -231,46 +231,60 @@ class UsersApi extends ApiClient {
...
@@ -231,46 +231,60 @@ class UsersApi extends ApiClient {
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/calendar/del/info/
${
id
}
`
})
})
}
}
/**
添加设备组
*/
/**
获取组列表
*/
getGroupList
(
page
:
number
=
1
,
limit
:
number
=
1000000
)
{
getGroupList
(
page
:
number
=
1
,
limit
:
number
=
1000000
00
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'post'
,
method
:
'get'
,
url
:
`/calendar/get/list?p=
${
page
}
&c=
${
limit
}
`
,
url
:
`/myequipmentgroup/get/list?p=
${
page
}
&c=
${
limit
}
`
data
:
{}
})
})
}
}
/** 添加设备组 */
/** 添加设备组 */
addGroup
(
id
)
{
addGroup
(
equipmentGroupName
:
string
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'post'
,
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipmentgroup/add/info`
,
data
:
{
equipmentGroupName
}
})
})
}
}
/**
编辑设备组
*/
/**
获取组下设备
*/
getGroupDevice
(
id
)
{
getGroupDevice
(
equipmentGroupId
:
string
=
''
,
equipmentGroupName
:
string
=
''
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'post'
,
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipment/get/filter/list`
,
data
:
{
equipmentGroupId
,
equipmentGroupName
}
})
})
}
}
editGroup
(
id
)
{
editGroup
(
equipmentGroupId
:
string
,
equipmentGroupName
:
string
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'post'
,
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipmentgroup/update/info`
,
data
:
{
equipmentGroupId
,
equipmentGroupName
}
})
})
}
}
/** 删除设备组 */
/** 删除设备组 */
deleteGroup
(
id
)
{
deleteGroup
(
id
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'
post
'
,
method
:
'
GET
'
,
url
:
`/
calendar/del/info
/
${
id
}
`
url
:
`/
myequipmentgroup/del
/
${
id
}
`
})
})
}
}
/** 删除设备组,摸个设备 */
/** 删除设备组,摸个设备 */
deleteGroupDevice
(
id
)
{
deleteGroupDevice
(
equipmentGroupId
:
string
,
equipmentId
:
string
)
{
return
this
.
request
({
return
this
.
request
({
method
:
'post'
,
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipmentgroup/del/equipment`
,
data
:
{
equipmentGroupId
:
equipmentGroupId
,
equipmentId
:
equipmentId
}
})
})
}
}
}
}
...
...
src/pages/home/device/group_detail/index.tsx
View file @
c1292415
import
api
from
'@/api/index'
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
ComponentClass
}
from
'react'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
connect
}
from
'@tarojs/redux'
import
ListView
from
'@/conpoments/list_view'
import
ListView
from
'@/conpoments/list_view'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
}
from
'@tarojs/components'
import
{
View
,
Text
}
from
'@tarojs/components'
import
DeviceItem
from
'@/conpoments/device_item'
import
DeviceItem
from
'@/conpoments/device_item'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
{
showMyToast
}
from
'@/common/utils'
import
{
showMyToast
}
from
'@/common/utils'
import
'./index.scss'
import
'./index.scss'
...
@@ -36,10 +34,10 @@ type PageOwnProps = {
...
@@ -36,10 +34,10 @@ type PageOwnProps = {
}
}
type
PageState
=
{
type
PageState
=
{
deviceCode
:
string
showModal
:
boolean
showModal
:
boolean
deviceList
:
IDeviceItem
[]
deviceList
:
IDeviceItem
[]
groupId
:
string
|
''
groupId
:
string
|
''
list
:
any
[]
}
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
@@ -49,17 +47,6 @@ interface DeviceGroup {
...
@@ -49,17 +47,6 @@ interface DeviceGroup {
state
:
PageState
state
:
PageState
}
}
@
connect
(
({
counter
})
=>
{
const
{
list
,
count
}
=
counter
.
filmData
return
{
list
,
count
}
},
dispacth
=>
({
getFilmListData
(
page
:
number
)
{
dispacth
(
getFilmList
(
page
))
}
})
)
class
DeviceGroup
extends
Component
{
class
DeviceGroup
extends
Component
{
config
:
Config
=
{
config
:
Config
=
{
navigationBarTitleText
:
'组详情'
navigationBarTitleText
:
'组详情'
...
@@ -69,10 +56,10 @@ class DeviceGroup extends Component {
...
@@ -69,10 +56,10 @@ class DeviceGroup extends Component {
super
(
props
)
super
(
props
)
const
{
id
}
=
this
.
$router
.
params
const
{
id
}
=
this
.
$router
.
params
this
.
state
=
{
this
.
state
=
{
deviceCode
:
''
,
deviceList
:
[],
deviceList
:
[],
showModal
:
false
,
showModal
:
false
,
groupId
:
id
groupId
:
id
,
list
:
[]
}
}
this
.
selectAddDevice
=
this
.
selectAddDevice
.
bind
(
this
)
this
.
selectAddDevice
=
this
.
selectAddDevice
.
bind
(
this
)
Taro
.
setNavigationBarTitle
({
Taro
.
setNavigationBarTitle
({
...
@@ -89,7 +76,12 @@ class DeviceGroup extends Component {
...
@@ -89,7 +76,12 @@ class DeviceGroup extends Component {
this
.
getDate
()
this
.
getDate
()
}
}
async
getDate
()
{
async
getDate
()
{
this
.
props
.
getFilmListData
(
this
.
page
)
api
.
common
.
getGroupDevice
(
this
.
$router
.
params
.
id
).
then
(
res
=>
{
const
list
=
res
this
.
setState
({
list
:
list
||
[]
})
})
}
}
selectAddDevice
()
{
selectAddDevice
()
{
...
@@ -100,16 +92,17 @@ class DeviceGroup extends Component {
...
@@ -100,16 +92,17 @@ class DeviceGroup extends Component {
async
handleItem
(
item
:
IDeviceItem
,
info
)
{
async
handleItem
(
item
:
IDeviceItem
,
info
)
{
const
{
text
}
=
info
const
{
text
}
=
info
const
{
equipmentId
}
=
item
const
{
equipmentId
}
=
item
const
{
id
}
=
this
.
$router
.
params
if
(
text
===
'删除'
)
{
if
(
text
===
'删除'
)
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
if
(
confirm
)
{
if
(
confirm
)
{
try
{
try
{
await
api
.
common
.
deleteGroupDevice
(
equipmentId
)
await
api
.
common
.
deleteGroupDevice
(
id
,
equipmentId
)
this
.
getDate
()
this
.
getDate
()
showMyToast
({
title
:
'删除成功~'
})
showMyToast
({
title
:
'删除成功~'
})
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
)
console
.
error
(
error
)
showMyToast
({
result
:
error
,
title
:
'失败
成功
~'
})
showMyToast
({
result
:
error
,
title
:
'失败~'
})
}
}
}
}
})
})
...
@@ -134,7 +127,8 @@ class DeviceGroup extends Component {
...
@@ -134,7 +127,8 @@ class DeviceGroup extends Component {
Taro
.
navigateTo
({
url
:
`/pages/home/device/device_detail/index?equipmentId=
${
equipmentId
}
`
})
Taro
.
navigateTo
({
url
:
`/pages/home/device/device_detail/index?equipmentId=
${
equipmentId
}
`
})
}
}
render
()
{
render
()
{
const
{
list
,
count
,
height
}
=
this
.
props
const
{
count
,
height
}
=
this
.
props
const
{
list
}
=
this
.
state
return
(
return
(
<
View
className=
"device-list"
>
<
View
className=
"device-list"
>
<
ListView
<
ListView
...
...
src/pages/home/device/group_device_bind/index.scss
View file @
c1292415
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
flex
:
1
;
flex
:
1
;
&
-view
{
&
-view
{
height
:
100%
;
height
:
calc
(
100vh
-
200px
)
;
}
}
}
}
...
...
src/pages/home/device/group_device_bind/index.tsx
View file @
c1292415
...
@@ -25,6 +25,7 @@ type PageState = {
...
@@ -25,6 +25,7 @@ type PageState = {
page
:
number
page
:
number
filmId
:
string
filmId
:
string
checked
:
Set
<
string
>
checked
:
Set
<
string
>
searchValue
:
string
|
''
}
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
@@ -56,10 +57,12 @@ class DeviceSelect extends Component {
...
@@ -56,10 +57,12 @@ class DeviceSelect extends Component {
this
.
state
=
{
this
.
state
=
{
filmId
,
filmId
,
page
:
1
,
page
:
1
,
checked
:
new
Set
()
checked
:
new
Set
(),
searchValue
:
''
}
}
this
.
updateBind
=
this
.
updateBind
.
bind
(
this
)
this
.
updateBind
=
this
.
updateBind
.
bind
(
this
)
this
.
changeAllCheck
=
this
.
changeAllCheck
.
bind
(
this
)
this
.
changeAllCheck
=
this
.
changeAllCheck
.
bind
(
this
)
this
.
searchChange
=
this
.
searchChange
.
bind
(
this
)
}
}
componentWillMount
()
{
componentWillMount
()
{
...
@@ -120,7 +123,12 @@ class DeviceSelect extends Component {
...
@@ -120,7 +123,12 @@ class DeviceSelect extends Component {
}
}
}
}
searchChange
()
{}
searchChange
(
target
)
{
console
.
log
(
target
)
this
.
setState
({
searchValue
:
target
})
}
shouldComponentUpdate
(
nextProps
:
IProps
,
nextState
:
PageState
)
{
shouldComponentUpdate
(
nextProps
:
IProps
,
nextState
:
PageState
)
{
const
{
checked
}
=
this
.
state
const
{
checked
}
=
this
.
state
...
@@ -132,11 +140,11 @@ class DeviceSelect extends Component {
...
@@ -132,11 +140,11 @@ class DeviceSelect extends Component {
render
()
{
render
()
{
const
{
list
}
=
this
.
props
const
{
list
}
=
this
.
props
const
{
checked
}
=
this
.
state
const
{
checked
,
searchValue
}
=
this
.
state
const
{
size
}
=
checked
const
{
size
}
=
checked
return
(
return
(
<
View
className=
"device-bind"
>
<
View
className=
"device-bind"
>
<
AtSearchBar
value=
{
''
}
onChange=
{
this
.
searchChange
}
/>
<
AtSearchBar
showActionButton
value=
{
searchValue
}
onChange=
{
this
.
searchChange
}
/>
<
View
className=
"device-bind-scroll"
>
<
View
className=
"device-bind-scroll"
>
<
ScrollView
className=
"device-bind-scroll-view"
>
<
ScrollView
className=
"device-bind-scroll-view"
>
{
list
.
map
(
item
=>
(
{
list
.
map
(
item
=>
(
...
...
src/pages/home/device/group_list/index.tsx
View file @
c1292415
import
api
from
'@/api/index'
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
ComponentClass
}
from
'react'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
connect
}
from
'@tarojs/redux'
import
ListView
from
'@/conpoments/list_view'
import
ListView
from
'@/conpoments/list_view'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Input
}
from
'@tarojs/components'
import
{
View
,
Text
,
Input
}
from
'@tarojs/components'
import
Modal
from
'@/conpoments/modal'
import
Modal
from
'@/conpoments/modal'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
{
showMyToast
}
from
'@/common/utils'
import
{
showMyToast
}
from
'@/common/utils'
import
Ble
from
'@/common/bluetooth'
import
'./index.scss'
import
'./index.scss'
import
template
from
'@/api/template'
export
interface
IDeviceItem
{
export
interface
IDeviceItem
{
filmId
:
any
filmId
:
any
filmName
:
any
filmName
:
any
...
@@ -29,19 +25,17 @@ type PageStateProps = {
...
@@ -29,19 +25,17 @@ type PageStateProps = {
count
:
number
count
:
number
}
}
type
PageDispatchProps
=
{
type
PageDispatchProps
=
{}
getFilmListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{
type
PageOwnProps
=
{
height
:
number
height
:
number
}
}
type
PageState
=
{
type
PageState
=
{
deviceCode
:
string
showModal
:
boolean
showModal
:
boolean
temp
:
any
temp
:
any
deviceList
:
IDeviceItem
[]
deviceList
:
IDeviceItem
[]
list
:
any
[]
}
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
@@ -51,27 +45,16 @@ interface DeviceGroup {
...
@@ -51,27 +45,16 @@ interface DeviceGroup {
state
:
PageState
state
:
PageState
}
}
@
connect
(
({
counter
})
=>
{
const
{
list
,
count
}
=
counter
.
filmData
return
{
list
,
count
}
},
dispacth
=>
({
getFilmListData
(
page
:
number
)
{
dispacth
(
getFilmList
(
page
))
}
})
)
class
DeviceGroup
extends
Component
{
class
DeviceGroup
extends
Component
{
protected
page
=
1
protected
page
=
1
constructor
(
props
:
any
)
{
constructor
(
props
:
any
)
{
super
(
props
)
super
(
props
)
this
.
state
=
{
this
.
state
=
{
deviceCode
:
''
,
deviceList
:
[],
deviceList
:
[],
list
:
[],
showModal
:
false
,
showModal
:
false
,
temp
:
{
temp
:
{
n
ame
:
''
equipmentGroupN
ame
:
''
}
}
}
}
this
.
cancelModal
=
this
.
cancelModal
.
bind
(
this
)
this
.
cancelModal
=
this
.
cancelModal
.
bind
(
this
)
...
@@ -89,14 +72,20 @@ class DeviceGroup extends Component {
...
@@ -89,14 +72,20 @@ class DeviceGroup extends Component {
}
}
async
getDate
()
{
async
getDate
()
{
this
.
cancelModal
()
this
.
cancelModal
()
this
.
props
.
getFilmListData
(
this
.
page
)
// this.props.getFilmListData(this.page)
api
.
common
.
getGroupList
().
then
(
res
=>
{
const
list
=
res
.
list
this
.
setState
({
list
:
list
})
})
}
}
AddGroup
()
{
AddGroup
()
{
this
.
setState
({
this
.
setState
({
showModal
:
!
this
.
state
.
showModal
,
showModal
:
!
this
.
state
.
showModal
,
temp
:
{
temp
:
{
n
ame
:
''
equipmentGroupN
ame
:
''
}
}
})
})
}
}
...
@@ -112,18 +101,18 @@ class DeviceGroup extends Component {
...
@@ -112,18 +101,18 @@ class DeviceGroup extends Component {
async
handleItem
(
item
,
info
)
{
async
handleItem
(
item
,
info
)
{
const
{
text
}
=
info
const
{
text
}
=
info
const
{
equipmentId
}
=
item
const
{
equipment
Group
Id
}
=
item
if
(
text
===
'编辑'
)
{
if
(
text
===
'编辑'
)
{
// console.log('')
// console.log('')
this
.
setState
({
this
.
setState
({
showModal
:
true
,
showModal
:
true
,
temp
:
Object
.
assign
({
n
ame
:
'测试组名'
},
item
)
temp
:
Object
.
assign
({
equipmentGroupN
ame
:
'测试组名'
},
item
)
})
})
}
else
if
(
text
===
'删除'
)
{
}
else
if
(
text
===
'删除'
)
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
if
(
confirm
)
{
if
(
confirm
)
{
try
{
try
{
await
api
.
common
.
deleteGroup
(
equipmentId
)
await
api
.
common
.
deleteGroup
(
equipment
Group
Id
)
this
.
getDate
()
this
.
getDate
()
showMyToast
({
title
:
'删除成功~'
})
showMyToast
({
title
:
'删除成功~'
})
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -156,16 +145,18 @@ class DeviceGroup extends Component {
...
@@ -156,16 +145,18 @@ class DeviceGroup extends Component {
inputConfirm
()
{
inputConfirm
()
{
console
.
log
()
console
.
log
()
const
{
temp
}
=
this
.
state
const
{
temp
}
=
this
.
state
if
(
!
temp
.
n
ame
)
{
if
(
!
temp
.
equipmentGroupN
ame
)
{
showMyToast
({
title
:
'请输入设备组名称'
})
showMyToast
({
title
:
'请输入设备组名称'
})
return
return
}
}
if
(
temp
.
equipmentId
)
{
if
(
temp
.
equipment
Group
Id
)
{
console
.
log
(
'更新'
)
console
.
log
(
'更新'
)
api
.
common
api
.
common
.
editGroup
(
temp
.
n
ame
)
.
editGroup
(
temp
.
equipmentGroupId
,
temp
.
equipmentGroupN
ame
)
.
then
(()
=>
{
.
then
(()
=>
{
showMyToast
({
title
:
'更新成功'
})
showMyToast
({
title
:
'更新成功'
})
this
.
cancelModal
()
this
.
getDate
()
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
showMyToast
({
title
:
'更新失败'
})
showMyToast
({
title
:
'更新失败'
})
...
@@ -173,13 +164,15 @@ class DeviceGroup extends Component {
...
@@ -173,13 +164,15 @@ class DeviceGroup extends Component {
}
else
{
}
else
{
console
.
log
(
'创建'
)
console
.
log
(
'创建'
)
api
.
common
api
.
common
.
addGroup
(
temp
.
n
ame
)
.
addGroup
(
temp
.
equipmentGroupN
ame
)
.
then
(()
=>
{
.
then
(()
=>
{
showMyToast
({
title
:
'创建成功'
})
showMyToast
({
title
:
'创建成功'
})
this
.
getDate
()
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
showMyToast
({
title
:
'创建失败'
})
showMyToast
({
title
:
'创建失败'
})
})
})
this
.
cancelModal
()
}
}
}
}
...
@@ -187,15 +180,15 @@ class DeviceGroup extends Component {
...
@@ -187,15 +180,15 @@ class DeviceGroup extends Component {
let
value
=
target
.
value
let
value
=
target
.
value
this
.
setState
({
this
.
setState
({
temp
:
Object
.
assign
(
this
.
state
.
temp
,
{
temp
:
Object
.
assign
(
this
.
state
.
temp
,
{
n
ame
:
value
equipmentGroupN
ame
:
value
})
})
})
})
}
}
render
()
{
render
()
{
const
{
list
,
count
,
height
}
=
this
.
props
const
{
count
,
height
}
=
this
.
props
const
{
showModal
,
temp
}
=
this
.
state
const
{
showModal
,
temp
,
list
}
=
this
.
state
let
name
=
temp
&&
temp
.
n
ame
?
'设备组信息'
:
'新建设备组'
let
name
=
temp
&&
temp
.
equipmentGroupN
ame
?
'设备组信息'
:
'新建设备组'
return
(
return
(
<
View
className=
"device-list"
>
<
View
className=
"device-list"
>
<
ListView
<
ListView
...
@@ -225,8 +218,10 @@ class DeviceGroup extends Component {
...
@@ -225,8 +218,10 @@ class DeviceGroup extends Component {
}
}
]
}
]
}
>
>
<
View
className=
"group-item"
onClick=
{
()
=>
this
.
goDetail
(
item
.
equipmentId
)
}
>
<
View
className=
"group-item"
onClick=
{
()
=>
this
.
goDetail
(
item
.
equipmentGroupId
)
}
>
<
View
className=
"group-item-content"
>
{
item
.
equipmentName
}
</
View
>
<
View
className=
"group-item-content"
>
{
item
.
equipmentGroupName
}
(
{
item
.
equipmentCount
}
)
</
View
>
</
View
>
</
View
>
</
AtSwipeAction
>
</
AtSwipeAction
>
))
}
))
}
...
@@ -250,7 +245,7 @@ class DeviceGroup extends Component {
...
@@ -250,7 +245,7 @@ class DeviceGroup extends Component {
<
Input
<
Input
placeholder=
"请输入设备组名称"
placeholder=
"请输入设备组名称"
className=
"film-modal-input"
className=
"film-modal-input"
value=
{
temp
.
n
ame
}
value=
{
temp
.
equipmentGroupN
ame
}
onInput=
{
this
.
changeName
}
onInput=
{
this
.
changeName
}
/>
/>
</
View
>
</
View
>
...
...
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