Your Name
2022-08-26 b1bdac435d4aa9fe34bde1a859490842166b47f7
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
<template>
    <div class="app-container">
        <div class="filter-container">
            <div class="basic_search">
                <span>排查结果:</span>
                <el-select class="analyseUnit_box" v-model="listQuery.result" placeholder="排查结果" filterable clearable>
                    <el-option v-for="item in resultList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>排查任务状态:</span>
                <el-select class="analyseUnit_box" v-model="listQuery.taskStatus" placeholder="排查任务状态" filterable clearable>
                    <el-option v-for="item in taskStatusList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>任务类型:</span>
                <el-select class="analyseUnit_box" v-model="listQuery.taskType" placeholder="任务类型" filterable clearable>
                    <el-option v-for="item in taskTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>部门名称:</span>
                <el-select class="analyseUnit_box" v-model="listQuery.execDepId" placeholder="部门名称" filterable clearable>
                    <el-option v-for="item in departmentList" :key="item.id" :label="item.department" :value="item.id"></el-option>
                </el-select>
            </div>
            <el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" icon="el-icon-refresh" @click="refreshHandle">搜索</el-button>
        </div>
        <div class="table_content">
            <el-table :data="inspectionRecordData" style="width: 100%">
                <el-table-column type="expand">
                    <template slot-scope="scope">
                        <el-table :data="scope.row.checkContent" style="width: 100%">
                            <el-table-column label="序号" type="index" width="150" align="center"> </el-table-column>
                            <el-table-column label="检查内容" prop="checkContent" align="center"> </el-table-column>
                            <el-table-column label="检查结果" prop="checkResult" align="center">
                                <template slot-scope="scope">
                                    <el-tag :type="scope.row.checkResult === 1 ? 'success' : scope.row.checkResult === 2 ? 'danger' : 'info'">
                                        {{ parseNumber(scope.row.checkResult, '检查结果') }}
                                    </el-tag>
                                </template>
                            </el-table-column>
                            <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
                                <template slot-scope="scope">
                                    <el-button size="small" type="text"  @click="onOpenDialogRef('查看', scope.row)">查看</el-button>
                                    <el-button size="small" type="text"  @click="onOpenDialogRef('提交', scope.row)">提交</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                    </template>
                </el-table-column>
                <el-table-column type="index" label="序号" width="60" />
                <el-table-column prop="taskCode" label="排查名称" show-overflow-tooltip></el-table-column>
                <el-table-column prop="execDep" label="执行部门" show-overflow-tooltip>
                </el-table-column>
                <el-table-column prop="taskStatus" label="状态" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ parseNumber(scope.row.taskStatus, '状态') }}
                    </template>
                </el-table-column>
                <el-table-column prop="taskBelong" label="是否认领" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ parseNumber(scope.row.taskBelong, '认领状态') }}
                    </template>
                </el-table-column>
                <el-table-column prop="startTime" label="开始时间" show-overflow-tooltip></el-table-column>
                <el-table-column prop="validTime" label="有效时间" show-overflow-tooltip></el-table-column>
                <el-table-column prop="execUserName" label="执行人" show-overflow-tooltip></el-table-column>
                <el-table-column prop="createUserName" label="创建人" show-overflow-tooltip></el-table-column>
                <el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column>
                <el-table-column prop="lastEditUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
                <el-table-column prop="gmtModitify" label="最后修改时间" show-overflow-tooltip></el-table-column>
                <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                        <el-button type="text" v-show="(scope.row.taskStatus === 1 || scope.row.taskStatus === 4) && scope.row.taskBelong === 1" @click="onHandleTask(scope.row)">任务认领</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <br>
            <el-pagination
                v-show="recordTotal>0"
                :current-page="listQuery.pageIndex"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="listQuery.pageSize"
                :total="recordTotal"
                layout="total, sizes, prev, pager, next, jumper"
                background
                style="float:right;"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            />
            <br>
        </div>
        <detail ref="detail" @refreshRecord="getInspectionRecordData"></detail>
    </div>
</template>
 
<script>
    import Cookies from "js-cookie";
    import detail from './components/detail.vue'
    import { mapGetters } from 'vuex'
    import { computePageCount } from '@/utils'
    import { getInspectionRecord } from '@/api/inspectionTask'
    import {getAllDepartment, getDepartmentList} from "../../../../api/departmentManage";
    import {safetyInspectionItemName} from "../../../../api/safetySelfInspection";
    import {deleteInspectionTask, submitTask, taskToUser} from "../../../../api/inspectionTask";
    export default {
        name: 'index',
        filters: {
            parseType(type){
                if(type === 1){
                    return "日常检查"
                }else{
                    return "周期检查"
                }
            },
            parseStatus(status){
                if(status === 1){
                    return "任务开启"
                }else{
                    return "任务关闭"
                }
            },
            parseUnitStatus(value) {
                if(value === 1){
                    return "待巡检"
                }else if(value === 2) {
                    return "已完成"
                }
            },
            parseStatusList(status) {
                if(status === 1){
                    return "待巡检"
                }else if(status === 2) {
                    return "巡检中"
                }else if(status === 3) {
                    return "已完成"
                }else if(status === 4) {
                    return "超时未巡检"
                }else{
                    return "已取消"
                }
            }
        },
        computed: {
            ...mapGetters([
                'userType'
            ])
        },
        data() {
            return {
                tableKey: 0,
                inspectionRecordData: [],
                departmentList:[],
                userList:[],
                typeList:[{id:1,name:'日常检查'},{id:2,name:'周期检查'}],
                statusListList:[{id:1,name:'待巡检'},{id:2,name:'巡检中'},{id:3,name:'已完成'},{id:4,name:'超时未巡检'},{id:5,name:'已取消'}],
                resultList: [
                    { id: 1, name: '正常' },
                    { id: 2, name: '存在隐患' },
                    { id: 3, name: '未排查' },
                    { id: 4, name: '其他' }
                ],
                checkResultList: [
                    { id: 1, name: '正常' },
                    { id: 2, name: '异常' },
                    { id: 3, name: '未处理' }
                ],
                taskStatusList: [
                    { id: 1, name: '待排查' },
                    { id: 2, name: '已完成' },
                    { id: 3, name: '超时未排查' },
                    { id: 4, name: '排查中' }
                ],
                taskTypeList: [
                    { id: 1, name: '周期任务' },
                    { id: 2, name: '日常任务' }
                ],
                listLoading: false,
                pageSize: 10,
                recordTotal: 0,
                currentPage: 1,
                pageTotal: 0,
                title:'',
                company:'',
                code:'',
                inspectionRecordForm:{
 
                },
                listQuery:{
                    pageIndex: 1,
                    pageSize: 10,
                    result: null,
                    taskStatus: null,
                    execDepId: null,
                    taskType: null
                },
            }
        },
        components: {
            detail
        },
        created() {
            this.getInspectionRecordData()
            this.getDepartment()
            this.getUser()
        },
        methods: {
            async getInspectionRecordData(){
                this.listLoading = true
                let res = await getInspectionRecord(this.listQuery)
                if(res.data.code === '200'){
                    this.recordTotal = res.data.count
                    this.inspectionRecordData = res.data.data
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                }
                this.listLoading = false
            },
            async getDepartment(){
                let res = await getDepartmentList({pageSize:1000,pageIndex:1})
                if(res.data.code === '200'){
                    this.departmentList = res.data.result.result
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                }
            },
            async getUser(){
                let res = await safetyInspectionItemName()
                if(res.data.code === '200'){
                    this.userList = res.data.result
                }else{
                    this.$message({
                        message:res.data.message,
                        type:'warning'
                    })
                }
            },
 
            onHandleTask(val){
 
                    this.$confirm('此操作将认领该任务,是否继续','提示',{
                        confirmButtonText:'确定',
                        cancelButtonText:'取消',
                        type:'warning',
                    }).then(()=> {
                        taskToUser({ id: val.id }).then( (res)=>{
                            if(res.data.code === '200'){
                                this.getInspectionRecordData()
                                this.$notify({
                                    title:'成功',
                                    message:'认领成功',
                                    type:'success',
                                    duration:2000,
                                })
                            }else{
                                this.$message({
                                    type:'warning',
                                    message:res.data.message
                                })
                            }
                        })
                    })
 
            },
 
            onOpenDialogRef(type,value){
                this.$refs.detail.showInspectionRecordForm(type,value)
            },
            showInspectionRecordDetailForm(value,type) {
                this.$refs.detail.showInspectionRecordDetailForm(value,type,this.userList,this.departmentList)
            },
            async submitInspectionRecordForm(value){
                if(value.unitList.find(item => item.status === 1) === undefined){
                    let data = {
 
                    }
                    let res = await submitTask({
                        execUid:Cookies.get('userId'),
                        info:"",
                        taskId: value.id
                    })
                    if(res.data.code === '200'){
                        this.getInspectionRecordData()
                        this.$message({
                            type:'success',
                            message:'提交成功',
                            duration:2000,
                            title:'成功'
                        })
                    }else{
                        this.$message({
                            type:'warning',
                            message:res.data.message
                        })
                    }
                }else{
                    this.$message({
                        type:'warning',
                        message:'请先上报所有巡检单元'
                    })
                }
            },
            downloadFile(value){
                if(value.problem.imageInfoList === null){
                    this.$message({
                        type:'warning',
                        message:'无文件可下载'
                    })
                }else{
                    for(let i in value.problem.imageInfoList){
                        window.open(process.env.IMG_API + value.problem.imageInfoList[i].imgPath, '_blank')
                    }
                }
            },
 
            parseNumber(value, type) {
                if (type === '状态') {
                    return this.taskStatusList.find((item) => item.id === value).name;
                }else if (type === '检查结果') {
                    return this.checkResultList.find((item) => item.id === value).name;
                } else {
                    if (value === 1) {
                        return '未认领';
                    } else {
                        return '已认领';
                    }
                }
            },
 
            refreshHandle(){
                this.getInspectionRecordData()
            },
            handleSizeChange(val){
                this.listQuery.pageSize = val
                this.getInspectionRecordData()
            },
            handleCurrentChange(val){
                this.listQuery.pageIndex = val
                this.getInspectionRecordData()
            },
        }
    }
</script>
<style scoped>
    .basic_search{
        display:inline-block;
        padding-bottom: 10px;
        padding-left: 10px;
    }
    .analyseUnit_input{
        width:90%;
    }
    .analyseUnit_box{
        width:200px;
    }
</style>