Commit e25e69c0 by hank

fix bug

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