guoshilong
2023-10-27 2311b03aee9db1bebacdd2ced13c071efda6a011
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
<template>
    <view class="u-page">
        <view class="tab">
            <u-tabs :itemStyle="{width: '160rpx' ,height: '88rpx' }" :activeStyle="{color: '#99bada' }" lineWidth="60"
                :current="current" :list="tabList" @click="tabClick">
            </u-tabs>
        </view>
        <!-- 外呼报讯 -->
        <view v-if="current==0">
            <view v-if="historyList.length<=0" class="line-center">
                <u-empty mode="data" />
            </view>
            <u-list @scrolltolower="scrolltolower" v-else>
                <u-list-item v-for="(item, index) in historyList" :key="item.id">
                    <u-cell isLink :url='`./detail/index?data=${encodeURIComponent(JSON.stringify(item))}`'
                        :title="`${item.waterName}-${item.realName}`" :value='item.createTime'>
                    </u-cell>
                </u-list-item>
            </u-list>
        </view>
        <view v-else>
            <view v-if="patrolList.length<=0" class="line-center">
                <u-empty mode="data" />
            </view>
            <u-list @scrolltolower="scrolltolower" v-else>
                <u-list-item v-for="(item, index) in patrolList" :key="item.id">
                    <u-cell isLink
                        :url='`../../realtimeMonitor/reservoir/reportFlood?reservoirId=${item.reservoirId}&id=${item.id}`'
                        :title="`${item.reservoirName}`" :value='item.createTime'>
                    </u-cell>
                </u-list-item>
            </u-list>
        </view>
    </view>
</template>
 
<script>
    import {
        getHistotyList,
        reportFloodRecord
    } from "@/api/history"
    export default {
        data() {
            return {
                historyList: [],
                query: {
                    current: 0,
                    pageSize: 14,
                    size: 14,
                    account: uni.getStorageSync("userInfo").account,
                    createUser: uni.getStorageSync("userInfo").user_id
                },
                total: 0,
                tabList: [{
                        name: "外呼报汛"
                    },
                    {
                        name: "巡查报汛"
                    },
                ],
                current: 1,
                //巡查报讯列表
                patrolList: [],
            }
        },
        onLoad() {
            // this.loadmore()
            if (this.current == 0) {
                this.initList()
            } else {
                this.getReportFloodRecord()
            }
        },
        methods: {
            //外呼报讯初始化
            async initList(query = this.query) {
                //通过当前账号字段判断是否登录
                if (!this.query.account) {
                    uni.showModal({
                        title: "提示",
                        content: "您当前未登录,请登陆后查看!",
                        showCancel: false,
                        success(res) {
                            if (res.confirm) {
                                uni.clearStorageSync()
                                uni.navigateTo({
                                    url: "../../../pages/login/index"
                                })
                            }
                        }
                    })
                }
                this.query.current += 1
                if (this.historyList.length >= this.total && this.historyList.length != 0) return
                const {
                    code,
                    data,
                    msg
                } = await getHistotyList(query)
                if (code != 200) {
                    uni.showToast({
                        title: msg,
                        icon: "none"
                    })
                    return
                }
                this.total = data.total
                if (this.historyList.length === 0) {
                    this.historyList = data.records
                } else {
                    this.query.current += 1
                    this.historyList = [...this.historyList, ...data.records]
                }
            },
            //巡查报讯初始化
            async getReportFloodRecord() {
                this.query.current += 1
                if (this.patrolList.length >= this.total && this.patrolList.length != 0) return
                const res = await reportFloodRecord(this.query)
                if (res.code != 200) return
                this.total = res.data.total
                if (this.patrolList.length === 0) {
                    this.patrolList = res.data.records
                } else {
                    this.patrolList = [...this.patrolList, ...res.data.records]
                }
            },
            tabClick(e) {
                this.query.current = 0
                this.current = e.index
                if (this.current == 0) {
                    this.patrolList = []
                    this.initList()
                } else if (this.current == 1) {
                    this.historyList = []
                    this.getReportFloodRecord()
                }
            },
            scrolltolower() {
                if (this.current == 0) {
                    this.initList()
                } else if (this.current == 1) {
                    this.getReportFloodRecord()
                }
            },
        },
    }
</script>
 
<style lang="scss" scoped>
    .u-page {
        .tab {
            display: flex;
            flex-direction: column;
            justify-content: space-evenly;
            width: 100%;
            background-color: #ffffff;
            align-items: center;
        }
    }
 
    .line-center {
        height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }
</style>