linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<template>
    <view class="">
        <view class="header bgc-ff">
            <view class="filter-box">
                <chenchuang-CCDropDownFilter :filterData='filterData' :defaultIndex='defaultIndex'
                    @onSelected='handleSelect'></chenchuang-CCDropDownFilter>
            </view>
            <view class="search-box">
                <u-search placeholder="请输入租户名" v-model="keyword" :clearabled="true" :showAction="true" :animation="true"
                    @search="search" @clear="clear"></u-search>
            </view>
        </view>
 
        <view class="content">
            <view class="row flex  j-c-s-b a-i-c" v-if="tenantList.length">
                <!-- <view class="row-item bgc-ff flex a-i-c">
                    <view class="dot bgc-green"></view>
                    <text class="f-24">长期3户 (3)人</text>
                </view>
                <view class="row-item bgc-ff flex a-i-c">
                    <view class="dot bgc-main"></view>
                    <text class="f-24">中期3户 (3)人</text>
                </view>
                <view class="row-item bgc-ff flex a-i-c">
                    <view class="dot bgc-orange"></view>
                    <text class="f-24">短期3户 (3)人</text>
                </view> -->
                <view v-for="(item,index) in statistics" :key="index" class="row-item bgc-ff flex a-i-c"  >
                    <view v-if="item.term =='shortTerm' " class="dot bgc-orange"></view>
                    <view v-if="item.term =='middleTerm' " class="dot bgc-main"></view>
                    <view v-if="item.term =='longTerm' " class="dot bgc-green"></view>
                    <text class="f-24">{{formatTerm(item.term)}}{{item.total}}户 ({{item.personNum}})人</text>
                </view>
            </view>
 
            <view class="list bgc-ff" v-for="(records,index) in tenantList"  :key="index">
                <view class="flex j-c-s-b a-i-c">
                    <view class="flex a-i-c">
                        <text class="f-32 mr-50">{{ records.tenantName }}</text>
                        <view class="flex a-i-c">
                            <u-icon name="phone-fill" color="#017BFC"></u-icon>
                            <text class="f-28 ml-10">{{ records.phone || '未填写' }}</text>
                        </view>
                    </view>
                    <u-tag text="未到期" type="success" plain plainFill></u-tag>
                </view>
                <view class="list-address f-28 c-99">
                    {{ records.houseName }}
                </view>
                <view class="list-action flex ">
                    <view class="action-item" @click="tenantManage(records)">
                        <u-icon name="/static/icon/list-02.png" width="40rpx" height="40rpx"></u-icon>
                        <text class="f-28 c-main ml-10">租客管理</text>
                    </view>
                    <view class="action-item">
                        <u-icon name="/static/icon/list-01.png" width="40rpx" height="40rpx"></u-icon>
                        <text class="f-28 c-main ml-10">走访日志</text>
                    </view>
                </view>
            </view>
        </view>
        <u-toast ref="uToast"></u-toast>
        <u-loadmore :status="loadingStatus" loadmoreText="开始加载" loadingText="数据加载中" nomoreText="已经到底了" line />
    </view>
</template>
 
<script>
    import {
        getRentalHouseContent,
        getStatistics
    } from '@/api/houseRental/houseRental.js'
    export default {
        data() {
            return {
                filterData: [
                    [{
                            name: '全部',
                            value: ''
                        },
                        {
                            name: '待确认',
                            value: '0'
                        },
                        {
                            name: '已确认',
                            value: '1'
                        },
                        // {
                        //     name: '审核不通过',
                        //     value: '2'
                        // },
                        {
                            name: '未到期',
                            value: '10'
                        },
                        {
                            name: '即将到期',
                            value: '20'
                        },
                        {
                            name: '已到期',
                            value: '30'
                        }
                    ],
                    [{
                            name: '楼层',
                            value: ''
                        },
                        {
                            name: '1楼',
                            value: '1'
                        },
                        {
                            name: '2楼',
                            value: '2'
                        },
                        {
                            name: '3楼',
                            value: '3'
                        }
                    ]
                ],
                defaultIndex: [0, 0],
                keyword: "",
                statistics: [],
                tenantList: [],
                loadingStatus: 'nomore',
                pagingParams: {
                    current: 1,
                    size: 10
                },
                selectParams: {},
                tenantStatus: [{
                        name: '未到期',
                        value: 0
                    },
                    {
                        name: '已到期',
                        value: 1
                    },
                    {
                        name: '已终止',
                        value: 2
                    },
                ],
            }
        },
        computed: {
            formatTerm() {
                return (term => {
                    if (term == 'longTerm') {
                        return "长期"
                    } else if (term == 'middleTerm') {
                        return "中期"
                    } else if (term == 'shortTerm') {
                        return "短期"
                    }
                })
            }
        },
        onLoad() {
            this.currentRole = uni.getStorageSync('activeRole')
            this.getStatistics()
        },
        onShow() {
            this.tenantList = []
            this.getRentalHouseInfo()
        },
        onReachBottom() {
            this.pagingParams.current++
            this.getRentalHouseInfo()
        },
        methods: {
            handleSelect(res) {
                const [auditStatus, floor] = res
                this.resetParams()
                let params = {}
                if (auditStatus[0].value !== '') {
                    params = {
                        auditStatus: auditStatus[0].value
                    }
                }
                if (floor[0].value !== '') {
                    params = {
                        ...params,
                        floor: floor[0].value
                    }
                }
                this.selectParams = params
                this.getRentalHouseInfo()
                this.getStatistics(auditStatus[0].value)
                // 回到顶部,避免触发触底加载
                uni.pageScrollTo({
                    scrollTop: 0, // 滚动到页面的目标位置(单位px)
                });
            },
            getStatistics(auditStatus = '') {
                const {
                    roleName
                } = this.currentRole
                let params = {
                    roleName
                }
                if (auditStatus) {
                    params = {
                        auditStatus,
                        roleName
                    }
                }
                getStatistics(params).then(res => {
                    this.statistics = res.data
                })
            },
            findObjValue(value, obj) {
                const res = obj.find(item => {
                    return item.value == value
                })
                return res.name
            },
            async getRentalHouseInfo(params = {}) {
                this.$nextTick(() => {
                    this.loadingStatus = 'loadmore'
                    this.$refs.uToast.show({
                        type: 'loading',
                        message: '正在加载',
                        duration: 9999999
                    })
                })
                const {
                    roleName
                } = this.currentRole
                const {
                    code,
                    data: {
                        records
                    }
                } = await getRentalHouseContent({
                    tenantName: this.keyword,
                    ...this.pagingParams,
                    roleName,
                    ...this.selectParams
                })
                if (code !== 200) {
                    uni.showToast({
                        title: "数据请求错误",
                        icon: "error"
                    })
                    return
                }
                this.tenantList = [...this.tenantList, ...records]
                this.$nextTick(() => {
                    this.$refs.uToast.isShow = false
                })
                this.loadingStatus = 'nomore'
            },
            search() {
                this.resetParams()
                this.getRentalHouseInfo()
            },
            clear() {
                this.keyword = ''
                this.resetParams()
                this.search()
            },
            tenantManage({
                houseCode,
                id
            }) {
                this.$u.func.globalNavigator(`/subPackage/bs/views/rentDetail?houseCode=${houseCode}&id=${id}`)
            },
            resetParams() {
                this.tenantList = []
                this.pagingParams = {
                    current: 1,
                    size: 10
                }
            }
        }
    }
</script>
 
<style lang="scss">
    page {
        background-color: #F5F5F5;
    }
 
    .header {
        width: 100%;
        position: fixed;
        /*#ifdef H5*/
        top: 88rpx;
        /*#endif*/
        /*#ifdef MP-WEIXIN*/
        top: 0;
        /*#endif*/
        left: 0;
        z-index: 10;
    }
 
    .filter-box {
        width: 100%;
        height: 100rpx;
 
    }
 
    .search-box {
        padding: 20rpx 24rpx 30rpx;
    }
 
    .content {
        width: 100%;
        margin-top: 220rpx;
        padding: 0 30rpx;
        box-sizing: border-box;
 
        .row {
            width: 100%;
            padding: 20rpx 0;
        }
 
        .row-item {
            width: calc(100% / 3 - 10rpx);
            height: 46rpx;
            border-radius: 30rpx;
            padding: 0 20rpx;
            box-sizing: border-box;
        }
 
        .dot {
            width: 10rpx;
            height: 10rpx;
            border-radius: 50%;
            margin-right: 18rpx;
        }
 
        .bgc-green {
            background-color: #30D17C;
        }
 
        .bgc-orange {
            background-color: #FFAC3D;
        }
 
        .list {
            width: 100%;
            padding: 30rpx 30rpx 0;
            box-sizing: border-box;
            margin-bottom: 20rpx;
            border-radius: 8rpx;
 
            .list-address {
                padding: 30rpx 0;
            }
 
            .list-action {
                padding: 22rpx 0 30rpx;
                border-top: 1px solid #F5F5F5;
            }
 
            .action-item {
                display: flex;
                flex: 1;
                justify-content: center;
            }
 
            .action-item:first-child {
                border-right: 1px solid #DBDBDB;
            }
 
            .mr-50 {
                margin-right: 50rpx;
            }
        }
    }
</style>