|
@@ -4,7 +4,7 @@ import { ScrollView, Input } from '@tarojs/components'
|
4
|
4
|
import '@/assets/css/iconfont.css'
|
5
|
5
|
import { useSelector } from 'react-redux'
|
6
|
6
|
import { fetch } from '@/utils/request'
|
7
|
|
-import { API_MANAGE_CUSTOMER_LIST } from '@/constants/api'
|
|
7
|
+import { API_MANAGE_CUSTOMER_LIST, API_MY_BUILDINGIDS } from '@/constants/api'
|
8
|
8
|
import './index.scss'
|
9
|
9
|
import ResidentListItem from '../components/ResidentListItem/index'
|
10
|
10
|
|
|
@@ -27,11 +27,14 @@ export default withLayout(() => {
|
27
|
27
|
// }
|
28
|
28
|
|
29
|
29
|
const user = useSelector(state => state.user)
|
|
30
|
+ const [BuildingIds, setBuildingIds] = useState([])
|
30
|
31
|
const [PageList, setPageList] = useState([])
|
31
|
32
|
const [IsPull, setPull] = useState(false)
|
32
|
33
|
const [PersonId, setPersonId] = useState(null)
|
33
|
34
|
const [pageNumber, setPageNumber] = useState(1)
|
34
|
35
|
const [HasNextPage, setHasNextPage] = useState(true)
|
|
36
|
+ const [CurrentBuildingId, setCurrentBuildingId] = useState(null)
|
|
37
|
+ const [CurrentBuildingName, setCurrentBuildingName] = useState(null)
|
35
|
38
|
const [FilterData, setFilterData] = useState({})
|
36
|
39
|
|
37
|
40
|
useEffect(() => {
|
|
@@ -42,20 +45,43 @@ export default withLayout(() => {
|
42
|
45
|
|
43
|
46
|
useEffect(() => {
|
44
|
47
|
if (PersonId) {
|
45
|
|
- GetPageList()
|
|
48
|
+ GetMyBuildingIds()
|
46
|
49
|
}
|
47
|
|
- }, [pageNumber, PersonId])
|
|
50
|
+ }, [PersonId])
|
48
|
51
|
|
49
|
52
|
useEffect(() => {
|
50
|
|
- if(FilterData.keywords) {
|
51
|
|
- if(pageNumber === 1) {
|
|
53
|
+ if (FilterData.keywords) {
|
|
54
|
+ if (pageNumber === 1) {
|
52
|
55
|
GetPageList()
|
53
|
56
|
} else {
|
54
|
|
- setPageNumber(2)
|
|
57
|
+ setPageNumber(1)
|
55
|
58
|
}
|
56
|
59
|
}
|
57
|
60
|
}, [FilterData])
|
58
|
61
|
|
|
62
|
+ useEffect(() => {
|
|
63
|
+ if (BuildingIds.length) {
|
|
64
|
+ setCurrentBuildingId(BuildingIds[0].buildingId)
|
|
65
|
+ setCurrentBuildingName(BuildingIds[0].name)
|
|
66
|
+ }
|
|
67
|
+ }, [BuildingIds])
|
|
68
|
+
|
|
69
|
+ useEffect(() => {
|
|
70
|
+ if (CurrentBuildingId) {
|
|
71
|
+ if (pageNumber === 1) {
|
|
72
|
+ GetPageList()
|
|
73
|
+ } else {
|
|
74
|
+ setPageNumber(1)
|
|
75
|
+ }
|
|
76
|
+ }
|
|
77
|
+ }, [CurrentBuildingId])
|
|
78
|
+
|
|
79
|
+ const GetMyBuildingIds = () => {
|
|
80
|
+ fetch({ url: API_MY_BUILDINGIDS, method: 'get' }).then((res) => {
|
|
81
|
+ setBuildingIds(res || [])
|
|
82
|
+ })
|
|
83
|
+ }
|
|
84
|
+
|
59
|
85
|
// useEffect(() => {
|
60
|
86
|
// if(CurrentFilterMenuId) {
|
61
|
87
|
// if(pageNumber === 1) {
|
|
@@ -72,7 +98,7 @@ export default withLayout(() => {
|
72
|
98
|
|
73
|
99
|
const GetPageList = () => {
|
74
|
100
|
setHasNextPage(false)
|
75
|
|
- fetch({ url: API_MANAGE_CUSTOMER_LIST, method: 'get', payload: { pageNumber, pageSize: 10, ...FilterData, buildingId: user.userInfo.person.buildingId } }).then((res) => {
|
|
101
|
+ fetch({ url: API_MANAGE_CUSTOMER_LIST, method: 'get', payload: { pageNumber, pageSize: 10, ...FilterData, buildingId: CurrentBuildingId } }).then((res) => {
|
76
|
102
|
setPageList(pageNumber === 1 ? res.records || [] : PageList.concat(res.records || []))
|
77
|
103
|
setHasNextPage(res.current < res.pages)
|
78
|
104
|
setPull(false)
|
|
@@ -95,6 +121,11 @@ export default withLayout(() => {
|
95
|
121
|
}
|
96
|
122
|
}, [IsPull])
|
97
|
123
|
|
|
124
|
+ const PickerChange = (e) => {
|
|
125
|
+ setCurrentBuildingId(BuildingIds[e.detail.value - 0].buildingId)
|
|
126
|
+ setCurrentBuildingName(BuildingIds[e.detail.value - 0].name)
|
|
127
|
+ }
|
|
128
|
+
|
98
|
129
|
const SearchConfirm = (e) => {
|
99
|
130
|
setFilterData({ ...FilterData, keywords: e.detail.value })
|
100
|
131
|
}
|
|
@@ -102,11 +133,15 @@ export default withLayout(() => {
|
102
|
133
|
return (
|
103
|
134
|
<view className='Page residentManager flex-v'>
|
104
|
135
|
|
105
|
|
- <view className='Search'>
|
106
|
|
- <view>
|
|
136
|
+ <view className='Search flex-h'>
|
|
137
|
+ <view className='flex-item'>
|
107
|
138
|
<text className='iconfont icon-sousuo'></text>
|
108
|
139
|
<Input confirm-type='search' placeholder='请输入关键字搜索' onConfirm={SearchConfirm} onscrolltolower={PageLoadMore}></Input>
|
109
|
140
|
</view>
|
|
141
|
+ <text>{CurrentBuildingName}</text>
|
|
142
|
+ <picker value={0} range-key='name' onChange={PickerChange} range={BuildingIds}>
|
|
143
|
+ <view class='picker'>更换</view>
|
|
144
|
+ </picker>
|
110
|
145
|
</view>
|
111
|
146
|
|
112
|
147
|
<view className='flex-item'>
|