From dd43c95c5a020c1a828263cc5944ed6fb644b65d Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期五, 05 五月 2023 08:53:18 +0800
Subject: [PATCH] Merge branch 'master' of https://sinanoaq.cn:8888/r/~mayuhao/HazardInvestigationSystem

---
 src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue |  330 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 245 insertions(+), 85 deletions(-)

diff --git a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue
index 6b5d2b6..44ca664 100644
--- a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue
+++ b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue
@@ -1,46 +1,88 @@
 <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
-                v-loading="listLoading"
-                :key="tableKey"
-                :data="inspectionRecordData"
-                border
-                fit
-                highlight-current-row
-                style="width: 100%;"
-            >
-                <el-table-column label="任务名称" prop="title" align="center">
+            <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 label="检查类型" prop="type" align="center">
+                <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 label="检查频次" prop="intervalSeconds" align="center">
+                <el-table-column prop="taskStatus" label="状态" show-overflow-tooltip>
+                    <template slot-scope="scope">
+                        {{ parseNumber(scope.row.taskStatus, '状态') }}
+                    </template>
                 </el-table-column>
-                <el-table-column label="任务开始时间" prop="startTime" align="center">
+                <el-table-column prop="taskBelong" label="是否认领" show-overflow-tooltip>
+                    <template slot-scope="scope">
+                        {{ parseNumber(scope.row.taskBelong, '认领状态') }}
+                    </template>
                 </el-table-column>
-                <el-table-column label="任务结束时间" prop="endTime" align="center">
-                </el-table-column>
-                <el-table-column label="异常通知人" prop="noticeUname" align="center">
-                </el-table-column>
-                <el-table-column label="巡检人" prop="execUname" align="center">
-                </el-table-column>
-                <el-table-column label="检查日期时间" prop="updateTime" align="center">
-                </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" @click="showInspectionRecordForm(scope.row,'编辑')">查看</el-button>
+                        <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="currentPage"
+                :current-page="listQuery.pageIndex"
                 :page-sizes="[10, 20, 30, 50]"
-                :page-size="pageSize"
+                :page-size="listQuery.pageSize"
                 :total="recordTotal"
                 layout="total, sizes, prev, pager, next, jumper"
                 background
@@ -50,50 +92,56 @@
             />
             <br>
         </div>
-        <el-dialog :title="title" :visible.sync="inspectionRecordVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="600px">
-            <el-form ref="inspectionRecordForm"  :model="inspectionRecordForm" label-position="right" label-width="165px">
-                <el-form-item label="责任部门" prop="hazardDep">
-                    <el-select v-model="inspectionRecordForm.hazardDep" class="analyseUnit_input">
-                        <el-option
-                            v-for="item in departmentList"
-                            :key="item.id"
-                            :value="item.department"
-                            :label="item.department"
-                        ></el-option>
-                    </el-select>
-                </el-form-item>
-                <el-form-item label="责任人" prop="hazardLiablePerson">
-                    <el-input v-model="inspectionRecordForm.hazardLiablePerson" class="analyseUnit_input"></el-input>
-                </el-form-item>
-                <el-form-item label="安全风险分析对象编码" prop="hazardCode">
-                    <el-input v-model="inspectionRecordForm.hazardCode" class="analyseUnit_input"></el-input>
-                </el-form-item>
-                <el-form-item label="安全风险分析单元名称" prop="riskUnitName">
-                    <el-input v-model="inspectionRecordForm.riskUnitName" class="analyseUnit_input"></el-input>
-                </el-form-item>
-            </el-form>
-            <div  align="right">
-                <el-button @click="unitFormVisible = false">取消</el-button>
-            </div>
-        </el-dialog>
+        <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: {
-            parseMain(type){
+            parseType(type){
                 if(type === 1){
-                    return "是"
-                }else if(type === 0){
-                    return "否"
+                    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([
@@ -105,6 +153,30 @@
                 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,
@@ -113,38 +185,34 @@
                 title:'',
                 company:'',
                 code:'',
-                inspectionRecordVisible:false,
                 inspectionRecordForm:{
-          
+
                 },
                 listQuery:{
-                    createUid: null,
-                    endTime: null,
-                    execUid: null,
-                    noticeUid: null,
-                    page: 1,
-                    pageSize:10,
-                    startTime: null,
-                    result:null,
-                    statusList: null,
-                    type: null
+                    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.result.total
-                    this.pageSize = res.data.result.size
-                    this.pageTotal = computePageCount(res.data.result.total, res.data.result.size)
-                    this.currentPage = res.data.result.current
-                    this.analyseUnitData = res.data.result.records
+                    this.recordTotal = res.data.count
+                    this.inspectionRecordData = res.data.data
                 }else{
                     this.$message({
                         message:res.data.message,
@@ -164,21 +232,109 @@
                     })
                 }
             },
-            showAnalyseUnitForm(value,type){
-                this.inspectionRecordVisible = true
-                this.$nextTick(() =>{
-                    this.$refs["analyseUnitForm"].clearValidate()
-                })
-                if(type === '新增'){
-                    this.title = '新增'
-                    this.inspectionRecordData = {
-            
-                    }
+            async getUser(){
+                let res = await safetyInspectionItemName()
+                if(res.data.code === '200'){
+                    this.userList = res.data.result
                 }else{
-                    this.title = '修改'
-                    this.inspectionRecordData = value
+                    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()
             },
@@ -187,7 +343,7 @@
                 this.getInspectionRecordData()
             },
             handleCurrentChange(val){
-                this.listQuery.page = val
+                this.listQuery.pageIndex = val
                 this.getInspectionRecordData()
             },
         }
@@ -197,8 +353,12 @@
     .basic_search{
         display:inline-block;
         padding-bottom: 10px;
+        padding-left: 10px;
     }
     .analyseUnit_input{
-        width:320px;
+        width:90%;
+    }
+    .analyseUnit_box{
+        width:200px;
     }
 </style>

--
Gitblit v1.9.2