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 {
url
:
`/calendar/del/info/
${
id
}
`
})
}
/**
添加设备组
*/
getGroupList
(
page
:
number
=
1
,
limit
:
number
=
1000000
)
{
/**
获取组列表
*/
getGroupList
(
page
:
number
=
1
,
limit
:
number
=
1000000
00
)
{
return
this
.
request
({
method
:
'post'
,
url
:
`/calendar/get/list?p=
${
page
}
&c=
${
limit
}
`
,
data
:
{}
method
:
'get'
,
url
:
`/myequipmentgroup/get/list?p=
${
page
}
&c=
${
limit
}
`
})
}
/** 添加设备组 */
addGroup
(
id
)
{
addGroup
(
equipmentGroupName
:
string
)
{
return
this
.
request
({
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipmentgroup/add/info`
,
data
:
{
equipmentGroupName
}
})
}
/**
编辑设备组
*/
getGroupDevice
(
id
)
{
/**
获取组下设备
*/
getGroupDevice
(
equipmentGroupId
:
string
=
''
,
equipmentGroupName
:
string
=
''
)
{
return
this
.
request
({
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
({
method
:
'post'
,
url
:
`/calendar/del/info/
${
id
}
`
url
:
`/myequipmentgroup/update/info`
,
data
:
{
equipmentGroupId
,
equipmentGroupName
}
})
}
/** 删除设备组 */
deleteGroup
(
id
)
{
return
this
.
request
({
method
:
'
post
'
,
url
:
`/
calendar/del/info
/
${
id
}
`
method
:
'
GET
'
,
url
:
`/
myequipmentgroup/del
/
${
id
}
`
})
}
/** 删除设备组,摸个设备 */
deleteGroupDevice
(
id
)
{
deleteGroupDevice
(
equipmentGroupId
:
string
,
equipmentId
:
string
)
{
return
this
.
request
({
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
{
ComponentClass
}
from
'react'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
connect
}
from
'@tarojs/redux'
import
ListView
from
'@/conpoments/list_view'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
}
from
'@tarojs/components'
import
DeviceItem
from
'@/conpoments/device_item'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
{
showMyToast
}
from
'@/common/utils'
import
'./index.scss'
...
...
@@ -36,10 +34,10 @@ type PageOwnProps = {
}
type
PageState
=
{
deviceCode
:
string
showModal
:
boolean
deviceList
:
IDeviceItem
[]
groupId
:
string
|
''
list
:
any
[]
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
...
@@ -49,17 +47,6 @@ interface DeviceGroup {
state
:
PageState
}
@
connect
(
({
counter
})
=>
{
const
{
list
,
count
}
=
counter
.
filmData
return
{
list
,
count
}
},
dispacth
=>
({
getFilmListData
(
page
:
number
)
{
dispacth
(
getFilmList
(
page
))
}
})
)
class
DeviceGroup
extends
Component
{
config
:
Config
=
{
navigationBarTitleText
:
'组详情'
...
...
@@ -69,10 +56,10 @@ class DeviceGroup extends Component {
super
(
props
)
const
{
id
}
=
this
.
$router
.
params
this
.
state
=
{
deviceCode
:
''
,
deviceList
:
[],
showModal
:
false
,
groupId
:
id
groupId
:
id
,
list
:
[]
}
this
.
selectAddDevice
=
this
.
selectAddDevice
.
bind
(
this
)
Taro
.
setNavigationBarTitle
({
...
...
@@ -89,7 +76,12 @@ class DeviceGroup extends Component {
this
.
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
()
{
...
...
@@ -100,16 +92,17 @@ class DeviceGroup extends Component {
async
handleItem
(
item
:
IDeviceItem
,
info
)
{
const
{
text
}
=
info
const
{
equipmentId
}
=
item
const
{
id
}
=
this
.
$router
.
params
if
(
text
===
'删除'
)
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
if
(
confirm
)
{
try
{
await
api
.
common
.
deleteGroupDevice
(
equipmentId
)
await
api
.
common
.
deleteGroupDevice
(
id
,
equipmentId
)
this
.
getDate
()
showMyToast
({
title
:
'删除成功~'
})
}
catch
(
error
)
{
console
.
error
(
error
)
showMyToast
({
result
:
error
,
title
:
'失败
成功
~'
})
showMyToast
({
result
:
error
,
title
:
'失败~'
})
}
}
})
...
...
@@ -134,7 +127,8 @@ class DeviceGroup extends Component {
Taro
.
navigateTo
({
url
:
`/pages/home/device/device_detail/index?equipmentId=
${
equipmentId
}
`
})
}
render
()
{
const
{
list
,
count
,
height
}
=
this
.
props
const
{
count
,
height
}
=
this
.
props
const
{
list
}
=
this
.
state
return
(
<
View
className=
"device-list"
>
<
ListView
...
...
src/pages/home/device/group_device_bind/index.scss
View file @
c1292415
...
...
@@ -13,7 +13,7 @@
flex
:
1
;
&
-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 = {
page
:
number
filmId
:
string
checked
:
Set
<
string
>
searchValue
:
string
|
''
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
...
@@ -56,10 +57,12 @@ class DeviceSelect extends Component {
this
.
state
=
{
filmId
,
page
:
1
,
checked
:
new
Set
()
checked
:
new
Set
(),
searchValue
:
''
}
this
.
updateBind
=
this
.
updateBind
.
bind
(
this
)
this
.
changeAllCheck
=
this
.
changeAllCheck
.
bind
(
this
)
this
.
searchChange
=
this
.
searchChange
.
bind
(
this
)
}
componentWillMount
()
{
...
...
@@ -120,7 +123,12 @@ class DeviceSelect extends Component {
}
}
searchChange
()
{}
searchChange
(
target
)
{
console
.
log
(
target
)
this
.
setState
({
searchValue
:
target
})
}
shouldComponentUpdate
(
nextProps
:
IProps
,
nextState
:
PageState
)
{
const
{
checked
}
=
this
.
state
...
...
@@ -132,11 +140,11 @@ class DeviceSelect extends Component {
render
()
{
const
{
list
}
=
this
.
props
const
{
checked
}
=
this
.
state
const
{
checked
,
searchValue
}
=
this
.
state
const
{
size
}
=
checked
return
(
<
View
className=
"device-bind"
>
<
AtSearchBar
value=
{
''
}
onChange=
{
this
.
searchChange
}
/>
<
AtSearchBar
showActionButton
value=
{
searchValue
}
onChange=
{
this
.
searchChange
}
/>
<
View
className=
"device-bind-scroll"
>
<
ScrollView
className=
"device-bind-scroll-view"
>
{
list
.
map
(
item
=>
(
...
...
src/pages/home/device/group_list/index.tsx
View file @
c1292415
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
AtSwipeAction
}
from
'taro-ui'
import
{
connect
}
from
'@tarojs/redux'
import
ListView
from
'@/conpoments/list_view'
import
Taro
,
{
Component
}
from
'@tarojs/taro'
import
{
View
,
Text
,
Input
}
from
'@tarojs/components'
import
Modal
from
'@/conpoments/modal'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
{
showMyToast
}
from
'@/common/utils'
import
Ble
from
'@/common/bluetooth'
import
'./index.scss'
import
template
from
'@/api/template'
export
interface
IDeviceItem
{
filmId
:
any
filmName
:
any
...
...
@@ -29,19 +25,17 @@ type PageStateProps = {
count
:
number
}
type
PageDispatchProps
=
{
getFilmListData
:
(
page
:
number
)
=>
void
}
type
PageDispatchProps
=
{}
type
PageOwnProps
=
{
height
:
number
}
type
PageState
=
{
deviceCode
:
string
showModal
:
boolean
temp
:
any
deviceList
:
IDeviceItem
[]
list
:
any
[]
}
type
IProps
=
PageStateProps
&
PageDispatchProps
&
PageOwnProps
...
...
@@ -51,27 +45,16 @@ interface DeviceGroup {
state
:
PageState
}
@
connect
(
({
counter
})
=>
{
const
{
list
,
count
}
=
counter
.
filmData
return
{
list
,
count
}
},
dispacth
=>
({
getFilmListData
(
page
:
number
)
{
dispacth
(
getFilmList
(
page
))
}
})
)
class
DeviceGroup
extends
Component
{
protected
page
=
1
constructor
(
props
:
any
)
{
super
(
props
)
this
.
state
=
{
deviceCode
:
''
,
deviceList
:
[],
list
:
[],
showModal
:
false
,
temp
:
{
n
ame
:
''
equipmentGroupN
ame
:
''
}
}
this
.
cancelModal
=
this
.
cancelModal
.
bind
(
this
)
...
...
@@ -89,14 +72,20 @@ class DeviceGroup extends Component {
}
async
getDate
()
{
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
()
{
this
.
setState
({
showModal
:
!
this
.
state
.
showModal
,
temp
:
{
n
ame
:
''
equipmentGroupN
ame
:
''
}
})
}
...
...
@@ -112,18 +101,18 @@ class DeviceGroup extends Component {
async
handleItem
(
item
,
info
)
{
const
{
text
}
=
info
const
{
equipmentId
}
=
item
const
{
equipment
Group
Id
}
=
item
if
(
text
===
'编辑'
)
{
// console.log('')
this
.
setState
({
showModal
:
true
,
temp
:
Object
.
assign
({
n
ame
:
'测试组名'
},
item
)
temp
:
Object
.
assign
({
equipmentGroupN
ame
:
'测试组名'
},
item
)
})
}
else
if
(
text
===
'删除'
)
{
Taro
.
showModal
({
content
:
'确定要删除?'
}).
then
(
async
({
confirm
})
=>
{
if
(
confirm
)
{
try
{
await
api
.
common
.
deleteGroup
(
equipmentId
)
await
api
.
common
.
deleteGroup
(
equipment
Group
Id
)
this
.
getDate
()
showMyToast
({
title
:
'删除成功~'
})
}
catch
(
error
)
{
...
...
@@ -156,16 +145,18 @@ class DeviceGroup extends Component {
inputConfirm
()
{
console
.
log
()
const
{
temp
}
=
this
.
state
if
(
!
temp
.
n
ame
)
{
if
(
!
temp
.
equipmentGroupN
ame
)
{
showMyToast
({
title
:
'请输入设备组名称'
})
return
}
if
(
temp
.
equipmentId
)
{
if
(
temp
.
equipment
Group
Id
)
{
console
.
log
(
'更新'
)
api
.
common
.
editGroup
(
temp
.
n
ame
)
.
editGroup
(
temp
.
equipmentGroupId
,
temp
.
equipmentGroupN
ame
)
.
then
(()
=>
{
showMyToast
({
title
:
'更新成功'
})
this
.
cancelModal
()
this
.
getDate
()
})
.
catch
(()
=>
{
showMyToast
({
title
:
'更新失败'
})
...
...
@@ -173,13 +164,15 @@ class DeviceGroup extends Component {
}
else
{
console
.
log
(
'创建'
)
api
.
common
.
addGroup
(
temp
.
n
ame
)
.
addGroup
(
temp
.
equipmentGroupN
ame
)
.
then
(()
=>
{
showMyToast
({
title
:
'创建成功'
})
this
.
getDate
()
})
.
catch
(()
=>
{
showMyToast
({
title
:
'创建失败'
})
})
this
.
cancelModal
()
}
}
...
...
@@ -187,15 +180,15 @@ class DeviceGroup extends Component {
let
value
=
target
.
value
this
.
setState
({
temp
:
Object
.
assign
(
this
.
state
.
temp
,
{
n
ame
:
value
equipmentGroupN
ame
:
value
})
})
}
render
()
{
const
{
list
,
count
,
height
}
=
this
.
props
const
{
showModal
,
temp
}
=
this
.
state
let
name
=
temp
&&
temp
.
n
ame
?
'设备组信息'
:
'新建设备组'
const
{
count
,
height
}
=
this
.
props
const
{
showModal
,
temp
,
list
}
=
this
.
state
let
name
=
temp
&&
temp
.
equipmentGroupN
ame
?
'设备组信息'
:
'新建设备组'
return
(
<
View
className=
"device-list"
>
<
ListView
...
...
@@ -225,8 +218,10 @@ class DeviceGroup extends Component {
}
]
}
>
<
View
className=
"group-item"
onClick=
{
()
=>
this
.
goDetail
(
item
.
equipmentId
)
}
>
<
View
className=
"group-item-content"
>
{
item
.
equipmentName
}
</
View
>
<
View
className=
"group-item"
onClick=
{
()
=>
this
.
goDetail
(
item
.
equipmentGroupId
)
}
>
<
View
className=
"group-item-content"
>
{
item
.
equipmentGroupName
}
(
{
item
.
equipmentCount
}
)
</
View
>
</
View
>
</
AtSwipeAction
>
))
}
...
...
@@ -250,7 +245,7 @@ class DeviceGroup extends Component {
<
Input
placeholder=
"请输入设备组名称"
className=
"film-modal-input"
value=
{
temp
.
n
ame
}
value=
{
temp
.
equipmentGroupN
ame
}
onInput=
{
this
.
changeName
}
/>
</
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