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
77b124ae
authored
Nov 08, 2019
by
hank
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更改修改设备逻辑
parent
4c966f9f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
47 deletions
+120
-47
src/pages/home/film/schedule_add/components/device/index.tsx
+120
-47
No files found.
src/pages/home/film/schedule_add/components/device/index.tsx
View file @
77b124ae
import
api
from
'@/api/index'
import
api
from
'@/api/index'
import
{
ComponentClass
}
from
'react'
import
{
ComponentClass
}
from
'react'
import
{
connect
}
from
'@tarojs/redux'
import
{
showMyToast
}
from
'@/common/utils'
import
{
showMyToast
}
from
'@/common/utils'
import
DeviceItem
from
'@/conpoments/device_item'
import
DeviceItem
from
'@/conpoments/device_item'
import
{
getFilmList
}
from
'@/actions/asyncCounter'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
Taro
,
{
Component
,
Config
}
from
'@tarojs/taro'
import
{
View
,
Text
,
ScrollView
,
Button
,
Checkbox
,
Label
,
Input
}
from
'@tarojs/components'
import
{
View
,
Text
,
ScrollView
,
Button
,
Checkbox
,
Label
,
Input
}
from
'@tarojs/components'
import
{
AtDrawer
}
from
'taro-ui'
import
{
AtDrawer
}
from
'taro-ui'
...
@@ -15,18 +13,18 @@ type PageStateProps = {
...
@@ -15,18 +13,18 @@ type PageStateProps = {
count
:
number
count
:
number
}
}
type
PageDispatchProps
=
{
type
PageDispatchProps
=
{}
getFilmListData
:
(
page
:
number
)
=>
void
}
type
PageOwnProps
=
{}
type
PageOwnProps
=
{}
type
PageState
=
{
type
PageState
=
{
page
:
number
page
:
number
filmId
:
string
filmId
:
string
searchName
:
string
checked
:
Set
<
string
>
checked
:
Set
<
string
>
showModal
:
boolean
showModal
:
boolean
groupList
:
any
[]
groupList
:
any
[]
list
:
any
[]
activeIndex
:
number
activeIndex
:
number
}
}
...
@@ -37,17 +35,6 @@ interface DeviceSelect {
...
@@ -37,17 +35,6 @@ interface DeviceSelect {
state
:
PageState
state
:
PageState
}
}
@
connect
(
({
counter
})
=>
{
const
{
list
,
count
}
=
counter
.
filmData
return
{
list
,
count
}
},
dispatch
=>
({
getFilmListData
(
page
:
number
)
{
dispatch
(
getFilmList
(
page
))
}
})
)
class
DeviceSelect
extends
Component
{
class
DeviceSelect
extends
Component
{
config
:
Config
=
{
config
:
Config
=
{
navigationBarTitleText
:
'设备管理'
navigationBarTitleText
:
'设备管理'
...
@@ -61,12 +48,15 @@ class DeviceSelect extends Component {
...
@@ -61,12 +48,15 @@ class DeviceSelect extends Component {
page
:
1
,
page
:
1
,
checked
:
new
Set
(),
checked
:
new
Set
(),
showModal
:
false
,
showModal
:
false
,
groupList
:
[],
groupList
:
[{
equipmentGroupName
:
'全部'
,
equipmentGroupId
:
''
,
equipmentCount
:
0
}],
activeIndex
:
0
activeIndex
:
0
,
searchName
:
''
,
list
:
[]
}
}
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
.
showModalView
=
this
.
showModalView
.
bind
(
this
)
this
.
showModalView
=
this
.
showModalView
.
bind
(
this
)
this
.
onItemClick
=
this
.
onItemClick
.
bind
(
this
)
this
.
setState
({
this
.
setState
({
checked
:
new
Set
(),
checked
:
new
Set
(),
showTempalte
:
'HORIZONTAL'
showTempalte
:
'HORIZONTAL'
...
@@ -90,13 +80,39 @@ class DeviceSelect extends Component {
...
@@ -90,13 +80,39 @@ class DeviceSelect extends Component {
componentWillMount
()
{
componentWillMount
()
{
this
.
getData
()
this
.
getData
()
this
.
getGroupList
()
this
.
getGroupList
()
this
.
getCDetail
()
}
}
getData
()
{
getData
(
name
?:
string
|
''
)
{
const
{
page
}
=
this
.
state
const
groupId
=
this
.
state
.
groupList
[
this
.
state
.
activeIndex
][
'equipmentGroupId'
]
this
.
props
.
getFilmListData
(
page
)
api
.
common
.
getGroupDevice
(
groupId
,
name
).
then
(
res
=>
{
this
.
setState
({
list
:
res
||
[]
})
})
}
}
getCDetail
()
{
/**
* 获取日程详情
*/
const
{
cId
}
=
this
.
$router
.
params
cId
&&
api
.
common
.
getScheduleDetail
(
cId
).
then
(
res
=>
{
console
.
log
(
res
)
const
{
equipmentInfos
}
=
res
let
arr
=
equipmentInfos
.
map
(
item
=>
{
return
item
.
equipmentId
})
this
.
setState
({
checked
:
new
Set
(
arr
)
})
})
}
getGroupList
()
{
getGroupList
()
{
/**
* 获取分组列表
*/
api
.
common
.
getGroupList
().
then
(
res
=>
{
api
.
common
.
getGroupList
().
then
(
res
=>
{
this
.
setState
({
this
.
setState
({
groupList
:
[{
equipmentGroupName
:
'全部'
,
equipmentGroupId
:
''
,
equipmentCount
:
0
}].
concat
(
groupList
:
[{
equipmentGroupName
:
'全部'
,
equipmentGroupId
:
''
,
equipmentCount
:
0
}].
concat
(
...
@@ -126,70 +142,127 @@ class DeviceSelect extends Component {
...
@@ -126,70 +142,127 @@ class DeviceSelect extends Component {
})
})
}
}
onItemClick
(
index
)
{
onItemClick
(
index
)
{
console
.
log
(
index
)
/**
this
.
setState
({
* 子项被点击
activeIndex
:
index
*/
})
this
.
setState
(
{
activeIndex
:
index
},
()
=>
{
this
.
getData
(
this
.
state
.
searchName
)
}
)
}
}
showModalView
()
{
showModalView
()
{
this
.
setState
({
this
.
setState
({
showModal
:
true
showModal
:
true
})
})
}
}
searchName
({
target
})
{
console
.
log
(
target
.
value
)
this
.
setState
({
searchName
:
target
.
value
})
this
.
getData
(
target
.
value
)
}
async
updateBind
()
{
async
updateBind
()
{
const
{
checked
}
=
this
.
state
// 更新设备绑定
const
{
list
}
=
this
.
props
const
{
checked
,
list
}
=
this
.
state
const
{
cId
,
fId
}
=
this
.
$router
.
params
let
checkedArr
:
any
=
[]
let
checkedArr
:
any
=
[]
const
equipmentsIds
=
[]
const
equipmentTopicList
=
[]
list
.
map
(
item
=>
{
list
.
map
(
item
=>
{
if
(
checked
.
has
(
item
.
equipmentId
))
{
if
(
checked
.
has
(
item
.
equipmentId
))
{
checkedArr
.
push
(
item
)
checkedArr
.
push
(
item
)
if
(
cId
)
{
equipmentsIds
.
push
(
item
.
equipmentId
)
equipmentTopicList
.
push
(
item
.
mqttTopic
)
}
}
}
})
})
Taro
.
setStorage
({
if
(
cId
)
{
key
:
'schedule-add-device'
,
let
obj
=
{
data
:
JSON
.
stringify
([...
checkedArr
])
calendarName
:
'DEFAULstring'
,
})
filmInfos
:
[
Taro
.
navigateBack
()
{
filmId
:
fId
,
time
:
'00:00'
}
],
equipmentsIds
:
equipmentsIds
,
equipmentTopicList
:
equipmentTopicList
,
calendarType
:
cId
?
'CUSTOME'
:
'DEFAUL'
,
calendarId
:
''
}
if
(
!
cId
)
{
delete
obj
.
calendarId
api
.
common
.
createdSchedule
(
obj
).
then
(()
=>
{
Taro
.
navigateBack
()
})
}
else
{
obj
.
calendarId
=
cId
api
.
common
.
updateSchedule
(
obj
).
then
(()
=>
{
Taro
.
navigateBack
()
})
}
}
else
{
Taro
.
setStorage
({
key
:
'schedule-add-device'
,
data
:
JSON
.
stringify
([...
checkedArr
])
})
Taro
.
navigateBack
()
}
}
}
changeAllCheck
()
{
changeAllCheck
()
{
const
{
list
}
=
this
.
props
let
{
checked
,
list
}
=
this
.
state
const
{
checked
}
=
this
.
state
if
(
list
.
length
===
0
)
return
if
(
list
.
length
===
0
)
return
if
(
checked
.
size
!==
list
.
length
)
{
let
arr
=
[]
// 没全选
let
noArr
=
[]
const
checkedId
=
list
.
reduce
((
previous
,
{
equipmentId
})
=>
{
list
.
map
(
item
=>
{
previous
.
push
(
equipmentId
)
if
(
checked
.
has
(
item
.
equipmentId
))
{
return
previous
arr
.
push
(
item
.
equipmentId
)
},
[])
}
else
{
noArr
.
push
(
item
.
equipmentId
)
}
})
if
(
arr
.
length
!==
list
.
length
)
{
this
.
setState
({
this
.
setState
({
checked
:
new
Set
([...
checked
Id
]
)
checked
:
new
Set
([...
checked
].
concat
(
noArr
)
)
})
})
}
else
{
}
else
{
// 已全选
arr
.
map
(
item
=>
{
this
.
setState
({
checked
.
delete
(
item
)
checked
:
new
Set
()
this
.
setState
({
checked
:
checked
})
})
})
}
}
}
}
render
()
{
render
()
{
const
{
list
}
=
this
.
props
const
{
checked
,
showModal
,
groupList
,
list
,
activeIndex
}
=
this
.
state
const
{
checked
,
showModal
,
groupList
}
=
this
.
state
const
{
size
}
=
checked
const
{
size
}
=
checked
let
items
=
groupList
.
map
(
item
=>
{
let
items
=
groupList
.
map
(
item
=>
{
if
(
item
.
equipmentGroupName
===
'全部'
)
{
return
item
.
equipmentGroupName
+
` (
${
list
.
length
}
)`
}
return
item
.
equipmentGroupName
+
` (
${
item
.
equipmentCount
}
)`
return
item
.
equipmentGroupName
+
` (
${
item
.
equipmentCount
}
)`
})
})
return
(
return
(
<
View
className=
"device-bind"
>
<
View
className=
"device-bind"
>
<
View
className=
"search-bar-container"
>
<
View
className=
"search-bar-container"
>
<
View
className=
"search-bar-container-left"
onClick=
{
this
.
showModalView
}
>
<
View
className=
"search-bar-container-left"
onClick=
{
this
.
showModalView
}
>
<
Text
>
全部(
{
1
}
)
</
Text
>
<
Text
>
{
items
[
activeIndex
]
}
</
Text
>
<
Text
className=
"triangle"
/>
<
Text
className=
"triangle"
/>
</
View
>
</
View
>
<
Input
<
Input
className=
"search-bar-container-input"
className=
"search-bar-container-input"
placeholder=
"输入设备名称进行搜索"
placeholder=
"输入设备名称进行搜索"
onInput=
{
this
.
searchName
}
type=
"text"
type=
"text"
/>
/>
</
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