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
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
<template>
    <view>
        <view class="tab">
            <u-tabs :itemStyle="{width: '160rpx' ,height: '88rpx' }" :activeStyle="{color: '#99bada' }" lineWidth="60"
                :current="currentIndex" :list="tabList" @click="tabClick">
            </u-tabs>
        </view>
        <view class="list">
 
            <scroll-view scroll-y style="height: 85vh;width: 100%;" @scrolltolower="scrolltolower">
                <card v-for="(item,index) in patrolTaskList" :key="index">
                    <template slot="insideHead">
                        <view class="head">
                            <u-row>
                                <u-col span="9">
                                    <u-text :text="item.title" />
                                </u-col>
                                <u-col span="1">
                                </u-col>
                                <u-col span="3">
                                    <u-text :text="item.patrolTypeName" />
                                </u-col>
                            </u-row>
                        </view>
                    </template>
                    <template slot="content">
                        <u-row>
                            <u-col span="9">
                                <view class="address">
                                    <u-text :text="'描述:'+ item.content" />
                                </view>
                            </u-col>
                            <u-col span="1">
                            </u-col>
                            <u-col span="2">
                                <view class="start-patrol-button">
                                    <u-button v-if="item.state !=3" type="primary" size="small"
                                        :disabled="item.state == 3" :text="item.state=='1'?'开始巡查':'继续巡查'"
                                        @click="startPatrol(item)" />
                                    <u-button v-if="item.state == 3" type="primary" size="small" text="巡查详情"
                                        @click="patrolDetail(item)" />
                                </view>
                            </u-col>
                        </u-row>
                    </template>
                </card>
            </scroll-view>
        </view>
    </view>
</template>
 
<script>
    import card from "@/components/my-components/card.vue"
    import {
        getPatrolTaskList,
        getPatrolTaskStatistic,
        updatePatrolTask
    } from "@/api/patrol/patrol"
    import {
        dateFormat
    } from "@/utils/date"
    export default {
        components: {
            card
        },
        data() {
            return {
                patrolCountList: [],
                patrolTaskList: [],
                searchKey: "",
                page: {
                    pageSize: 20,
                    currentPage: 1,
                    total: 0
                },
                query: {},
                tabList: [{
                        name: "未开始"
                    },
                    {
                        name: "进行中"
                    },
                    {
                        name: "已完成"
                    },
                ],
                currentIndex: 0
            }
        },
        onShow() {},
        created() {
            this.init()
        },
        mounted() {},
        methods: {
            init() {
                this.currentIndex = 0
                this.getList(1)
            },
            //搜索
            search(searchValue) {
                this.query.title = searchValue
                this.getList()
            },
            //清空搜索
            clearSearch() {
                this.query = {}
                this.getList()
            },
            //开始巡查或继续巡查
            startPatrol(item) {
                if (item.state == "1") {
                    item.state = "2"
                    let date = new Date()
                    let realStartTime = dateFormat(date)
                    updatePatrolTask({
                        id: item.id,
                        state: item.state,
                        realStartTime: realStartTime
                    })
                }
 
                let url = "/subPackage/patrol/patrolReport?task=" + JSON.stringify(item)
                this.$u.func.globalNavigator(url, "navTo")
            },
 
            //获取任务列表
            getList(state) {
                // 获取任务列表
                // this.query.currentUserId = this.userInfo.user_id
                this.query.toUserId = this.userInfo.user_id
                this.query.state = state
                getPatrolTaskList(this.page.currentPage, this.page.pageSize, this.query).then(res => {
                    const data = res.data;
                    this.page.total = data.total;
                    this.patrolTaskList = data.records
                })
            },
            //上拉加载更多
            scrolltolower() {
                this.page.currentPage += 1
                // 获取任务列表
                this.query.currentUserId = this.userInfo.user_id
                getPatrolTaskList(this.page.currentPage, this.page.pageSize, this.query).then(res => {
                    const data = res.data;
                    this.page.total = data.total;
                    this.patrolTaskList = this.patrolTaskList.concat(data.records)
                })
            },
            //tab点击事件
            tabClick(item) {
                this.currentIndex = item.index
 
                if (this.currentIndex == 0) {
                    this.page.currentPage = 1
                    this.getList(1)
                } else if (this.currentIndex == 1) {
                    this.page.currentPage = 1
                    this.getList(2)
                } else if (this.currentIndex == 2) {
                    this.page.currentPage = 1
                    this.getList(3)
                }
 
            },
            //巡查详情
            patrolDetail(task) {
                let url = "/subPackage/patrol/patrolDetail?task=" + JSON.stringify(task)
                this.$u.func.globalNavigator(url, "navTo")
            }
        }
    }
</script>
 
<style scoped lang="scss">
    .tab {
        display: flex;
        align-items: center;
        justify-content: space-around;
    }
 
    .search {
        margin: 20rpx 0;
    }
 
    .content {
        display: flex;
    }
 
    .footer {
        display: flex;
        justify-content: space-between;
    }
 
    .footer .icon {
        display: flex;
 
    }
 
    .grid-text {
        font-size: 2rpx;
        color: #ada8a8;
        margin: 20rpx 0;
    }
</style>