张晓波
2023-12-11 0d0968ec2d1a39c21e15e447c4f2227f70d6a11b
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
<!-- 安全管理 ==> 风险分级管控 => 区域巡检(任务打卡)-->
<template>
    <div class="wrap">
        <div class="main_header">
            <div class="header_item">
                <span class="header_label">巡检人:</span>
                <el-input size="mini" v-model="queryInfo.realName" placeholder="请输入巡检人" clearable></el-input>
            </div>
            <div class="header_item">
                <span class="header_label">巡检状态:</span>
                <el-select size="mini" v-model="queryInfo.status" clearable>
                    <el-option v-for="item in queryStatus" :key="item.value" :label="item.label" :value="item.value"
                        placeholder="请选择巡检状态"></el-option>
                </el-select>
            </div>
            <div class="header_item">
                <span class="header_label">时间范围:</span>
                <el-date-picker type="daterange" v-model="times" value-format="yyyy-MM-dd" start-placeholder="起始时间"
                    end-placeholder="结束时间" @change="changeTime" clear></el-date-picker>
            </div>
            <div class="header_item">
                <el-button icon="el-icon-search" v-permission="'search'" @click="queryReset">查询</el-button>
                <el-button icon="el-icon-plus" v-permission="'export'" @click="exportExcel">导出Excel</el-button>
            </div>
        </div>
        <div class="main_content">
            <cpn-table :table-index="true" :table-loading="tableConfig.loading" :table-data="tableConfig.tableData"
                :table-columns="tableConfig.tableColumns" :page-total="tableConfig.total" :page-num.sync="queryInfo.pageNum"
                :page-size.sync="queryInfo.pageSize" :page-change="pageChange">
            </cpn-table>
        </div>
 
        <!-- 详情dialog -->
        <el-dialog width="400px" class="prop_dialog" v-if="isRenderDialog" title="详情" :visible.sync="asyncVisible">
 
            <el-form class="rule_form" label-width="auto">
 
                <div class="divider"></div>
 
                <el-form-item label="巡检任务:">{{ info.task }}</el-form-item>
 
                <el-form-item label="巡检标准:">{{ info.standard }}</el-form-item>
 
                <el-form-item label="巡检人员:">{{ info.name }}</el-form-item>
 
                <div class="divider"><span>巡检路线</span></div>
 
                <div class="regions">
                    <div class="region" v-for="item in info.regions" :key="item.regionId"
                        @click="regionClick(item.regionId)">{{
                            item.region }}
                    </div>
                </div>
            </el-form>
        </el-dialog>
 
        <!-- 区域信息dialog -->
        <el-dialog width="400px" class="prop_dialog" v-if="regionInfos.isRenderDialog" title="详情"
            :visible.sync="regionInfos.asyncVisible">
 
            <el-form class="rule_form" label-width="auto">
 
                <div class="divider"></div>
 
                <el-form-item label="巡检时间:">{{ regionInfos.time }}</el-form-item>
 
                <el-form-item label="巡检区域:">{{ regionInfos.region }}</el-form-item>
 
                <el-form-item label="巡检结果:">{{ regionInfos.res }}</el-form-item>
 
                <el-form-item label="上传图片:">
                    <el-image class="image" v-for="(item, index) in regionInfos.img" :key="index" :src="item" fit="contain"
                        :preview-src-list="regionInfos.img"></el-image>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
</template>
<script>
import cpnTable from '@/components/element/Table'
import {downFiles} from '@/plugins/public'
export default {
    data() {
        return {
            isRenderDialog: false,
            asyncVisible: false,
            info: { // 详情信息
                task: '',
                standard: '',
                name: '',
                regions: [],
            },
            userId: '', // 存储点击后的用户id
            taskId: '', // 存储点击后的巡检任务id
            times: [], // 时间范围
            queryStatus: [
                {value: '0', label: '待巡检'},
                {value: '1', label: '已完成'},
            ],
            queryInfo: {
                pageNum: 1,
                pageSize: 10,
                status: '',
                realName: '',
                startTime: '',
                endTime: '',
            },
            tableConfig: {
                loading: '',
                tableData: [],
                tableColumns: [],
                total: 0,
            },
            regionInfos: { // 巡检路线详情
                isRenderDialog: false,
                asyncVisible: false,
                time: '', // 巡检时间
                region: '', // 巡检区域
                res: '', // 巡检结果
                img: '', // 上传的图片
            }
        }
    },
    components: {
        cpnTable,
    },
    beforeCreate() {
        this.$http = this.$api.Safety.RiskGrad.polling
    },
    created() {
        this.setTableColumn()
        this.getLists()
    },
    methods: {
        // 获取table列表数据
        getLists() {
            let params = this.queryInfo
            let tableConfig = this.tableConfig
            tableConfig.loading = true
            this.$http.taskcardGetlists(params).then(res => {
                if (res.statusMsg === 'ok') {
                    tableConfig.total = res.data.total
                    tableConfig.tableData = res.data.list
                }
                tableConfig.loading = false
            })
        },
        // 获取巡检路线的id (用来点击展示详情)
        getRegionId() {
 
        },
        // 初始化 table 配置
        setTableColumn() {
            this.tableConfig.tableColumns = [
                {index: true},
                {name: "巡检时间", key: "inspectionTime"},
                {name: "巡检任务", key: "task"},
                {
                    name: "巡检路线", align: 'left', key: "region", formatter: row => {
                        return row.region.replace(/,/g, ',\n')
                    }
                },
                {name: "巡检人", key: "realName"},
                {
                    name: "巡检状态", key: "status", width: 120, formatter: row => {
                        return row.status === 1 ? '已完成' : '待巡检'
                    }
                },
                {
                    operation: true, name: "操作", width: 120, value: [
                        {name: "详情", handleRow: this.detailRow}]
                },
            ]
        },
        // 查询按钮列表信息
        queryReset() {
            this.queryInfo.pageNum = 1
            this.queryInfo.pageSize = 10
            this.getLists()
        },
        showDialog() {
            if (!this.isRenderDialog) {
                this.isRenderDialog = true
            }
            this.asyncVisible = true
        },
        showRegionDialog() {
            if (!this.regionInfos.isRenderDialog) {
                this.regionInfos.isRenderDialog = true
            }
            this.regionInfos.asyncVisible = true
        },
        detailRow(row) {
            this.info.task = row.task
            this.info.standard = row.standard
            this.info.name = row.realName
            this.info.regions = []
 
            this.userId = row.userId
            this.taskId = row.regionInspectionId
            const params = {
                userId: row.userId,
                regionInspectionId: row.regionInspectionId,
            }
            this.$http.taskcardGetregions(params).then(res => {
                if (res.statusMsg === 'ok') {
                    let regions = []
                    res.data.regionList.forEach(item => {
                        regions.push({
                            regionId: item.regionHazardInformId,
                            region: item.region,
                        })
                    })
                    this.info.regions.push(...regions)
                }
            })
            this.showDialog()
        },
        regionClick(regionId) {
            const params = {
                userId: this.userId,
                regionInspectionId: this.taskId,
                regionHazardInformId: regionId,
            }
            this.$http.taskcardGetregionInfo(params).then(res => {
                if (res.statusMsg === 'ok') {
                    this.regionInfos.time = res.data.inspectionTime
                    this.regionInfos.region = res.data.region
                    this.regionInfos.res = res.data.result
                    this.regionInfos.img = []
 
                    if (res.data.imgPaths) {
                        let arr = []
                        res.data.imgPaths.split(',').forEach(item => {
                            arr.push('https://szpipe.thhy-tj.com/' + item) // 是生产地址
                        })
                        this.regionInfos.img.push(...arr)
                    }
                }
                this.showRegionDialog()
            })
        },
        exportExcel() {
            let params = this.queryInfo
            this.$http.taskcardExport(params).then(res => {
                downFiles(res, '任务打卡', 'xls')
            })
        },
        changeTime(times) {
            times = times || ['', '']
            this.queryInfo.startTime = times[0]
            this.queryInfo.endTime = times[1]
        },
        pageChange() {
            this.getLists()
        },
    }
}
</script>
 
<style lang="scss" scoped>
@import '@/style/layout-main.scss';
 
.wrap {
    display: flex;
    flex-direction: column;
    height: 100%;
 
    .main_content {
        overflow: hidden;
        flex: 1;
    }
}
 
.rule_form {
    color: #fff;
 
    ::v-deep .el-form-item__content {
        display: block;
    }
 
    .image {
        flex: none;
        width: 91px;
        height: 120px;
        margin-right: 15px;
        border-radius: 5px;
        border: 1px solid #0c5983;
 
        img {
            width: 100%;
        }
    }
}
 
.regions {
    text-align: center;
 
    .region {
        line-height: 34px;
        margin-bottom: 16px;
        background: rgba(56, 175, 247, .25);
        cursor: pointer;
    }
}
 
.divider {
    position: relative;
    margin-bottom: 30px;
    text-indent: 10px;
    color: #fff;
    border-left: 3px solid #18F6F8;
 
    &::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: -8px;
        width: 100%;
        padding: 20px 0;
        border-bottom: 1px solid #0C4D6F;
    }
}
</style>