Commit e25e69c0 by hank

fix bug

parent c6f733b7
......@@ -54,7 +54,7 @@ class DeviceGroup extends Component {
protected page = 1
constructor(props: any) {
super(props)
const { id } = this.$router.params
const { id, name } = this.$router.params
this.state = {
deviceList: [],
showModal: false,
......@@ -63,7 +63,7 @@ class DeviceGroup extends Component {
}
this.selectAddDevice = this.selectAddDevice.bind(this)
Taro.setNavigationBarTitle({
title: '组详情'
title: String(name + '(0)')
})
}
......@@ -76,8 +76,12 @@ class DeviceGroup extends Component {
this.getDate()
}
async getDate() {
const { name } = this.$router.params
api.common.getGroupDevice(this.$router.params.id).then(res => {
const list = res
Taro.setNavigationBarTitle({
title: String(name + `(${res.length})`)
})
this.setState({
list: list || []
})
......
......@@ -138,8 +138,10 @@ class DeviceGroup extends Component {
}, 500)
}
goDetail(id) {
Taro.navigateTo({ url: `/pages/home/device/group_detail/index?id=${id}` })
goDetail(id, equipmentGroupName) {
Taro.navigateTo({
url: `/pages/home/device/group_detail/index?id=${id}&name=${equipmentGroupName}`
})
}
inputConfirm() {
......@@ -218,7 +220,10 @@ class DeviceGroup extends Component {
}
]}
>
<View className="group-item" onClick={() => this.goDetail(item.equipmentGroupId)}>
<View
className="group-item"
onClick={() => this.goDetail(item.equipmentGroupId, item.equipmentGroupName)}
>
<View className="group-item-content">
{item.equipmentGroupName}({item.equipmentCount})
</View>
......
......@@ -26,6 +26,7 @@ type PageState = {
groupList: any[]
list: any[]
activeIndex: number
allCount: string
}
type IProps = PageStateProps & PageDispatchProps & PageOwnProps
......@@ -51,7 +52,8 @@ class DeviceSelect extends Component {
groupList: [{ equipmentGroupName: '全部', equipmentGroupId: '', equipmentCount: 0 }],
activeIndex: 0,
searchName: '',
list: []
list: [],
allCount: ''
}
this.updateBind = this.updateBind.bind(this)
this.changeAllCheck = this.changeAllCheck.bind(this)
......@@ -86,6 +88,11 @@ class DeviceSelect extends Component {
getData(name?: string | '') {
const groupId = this.state.groupList[this.state.activeIndex]['equipmentGroupId']
api.common.getGroupDevice(groupId, name).then(res => {
if (!groupId) {
this.setState({
allCount: res.length
})
}
this.setState({
list: res || []
})
......@@ -244,11 +251,11 @@ class DeviceSelect extends Component {
}
render() {
const { checked, showModal, groupList, list, activeIndex } = this.state
const { checked, showModal, groupList, list, activeIndex, allCount } = this.state
const { size } = checked
let items = groupList.map(item => {
if (item.equipmentGroupName === '全部') {
return item.equipmentGroupName + ` (${list.length})`
return item.equipmentGroupName + ` (${allCount})`
}
return item.equipmentGroupName + ` (${item.equipmentCount})`
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment