Your Name
2022-08-26 b1bdac435d4aa9fe34bde1a859490842166b47f7
src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue
@@ -2,133 +2,85 @@
    <div class="app-container">
        <div class="filter-container">
            <div class="basic_search">
                <span>开始时间:</span>
                <el-date-picker v-model="listQuery.startTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="巡检开始时间"></el-date-picker>
                <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-date-picker v-model="listQuery.endTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="巡检结束时间"></el-date-picker>
                <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 v-model="listQuery.type">
                   <el-option
                        v-for="item in typeList"
                        :key="item.id"
                        :value="item.id"
                        :label="item.name"
                    ></el-option>
                <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 v-model="listQuery.statusList" filterable clearable multiple>
                    <el-option
                        v-for="item in statusListList"
                        :key="item.id"
                        :value="item.id"
                        :label="item.name"
                    ></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>巡检任务创建人员:</span>
                <el-select v-model="listQuery.createUid" filterable clearable>
                    <el-option
                        v-for="item in userList"
                        :key="item.id"
                        :value="item.id"
                        :label="item.realname"
                    ></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>执行巡检人员:</span>
                <el-select v-model="listQuery.execUid" filterable clearable>
                    <el-option
                        v-for="item in userList"
                        :key="item.id"
                        :value="item.id"
                        :label="item.realname"
                    ></el-option>
                <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 :data="inspectionRecordData" style="width: 100%">
                <el-table-column type="expand">
                    <template slot-scope="scope">
                        <el-table
                            v-loading="listLoading"
                            :key="tableKey"
                            :data="scope.row.unitList"
                            border
                            fit
                            highlight-current-row
                            style="width: 100%;"
                        >
                            <el-table-column label="序号" type="index" width="150" align="center">
                            </el-table-column>
                            <el-table-column label="隐患排查内容" prop="content" align="center">
                            </el-table-column>
                            <el-table-column label="上报说明" prop="info" align="center">
                            </el-table-column>
                            <el-table-column label="上报照片" prop="img" align="center">
                            </el-table-column>
                            <el-table-column label="状态" prop="status" align="center">
                        <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">
                                     {{ scope.row.status | parseUnitStatus}}
                                    <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 type="text" @click="showInspectionRecordDetailForm(scope.row,'上报')" v-show="scope.row.status === 1">上报</el-button>
                                    <el-button type="text" @click="showInspectionRecordDetailForm(scope.row,'查看')">查看</el-button>
                                    <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="title" 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="type" align="center">
                <el-table-column prop="taskStatus" label="状态" show-overflow-tooltip>
                    <template slot-scope="scope">
                        {{ scope.row.type | parseType}}
                        {{ parseNumber(scope.row.taskStatus, '状态') }}
                    </template>
                </el-table-column>
                <el-table-column label="巡检人" prop="execUname" align="center">
                </el-table-column>
                <el-table-column label="巡检开始时间" prop="expTime" align="center">
                </el-table-column>
                <el-table-column label="巡检结束时间" prop="endTime" align="center">
                </el-table-column>
                <el-table-column label="巡检提交时间" prop="execTime" align="center">
                </el-table-column>
                <el-table-column label="任务状态" prop="status" align="center">
                     <template slot-scope="scope">
                        {{ scope.row.status | parseStatusList}}
                <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" @click="submitInspectionRecordForm(scope.row,'上报')">提交</el-button>
                        <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="listQuery.page"
                :current-page="listQuery.pageIndex"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="listQuery.pageSize"
                :total="recordTotal"
@@ -140,33 +92,7 @@
            />
            <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"></detail>
        <detail ref="detail" @refreshRecord="getInspectionRecordData"></detail>
    </div>
</template>
@@ -178,9 +104,8 @@
    import { getInspectionRecord } from '@/api/inspectionTask'
    import {getAllDepartment, getDepartmentList} from "../../../../api/departmentManage";
    import {safetyInspectionItemName} from "../../../../api/safetySelfInspection";
    import {submitTask} from "../../../../api/inspectionTask";
    import {deleteInspectionTask, submitTask, taskToUser} from "../../../../api/inspectionTask";
    export default {
  components: { detail },
        name: 'index',
        filters: {
            parseType(type){
@@ -231,6 +156,27 @@
                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,
@@ -239,21 +185,16 @@
                title:'',
                company:'',
                code:'',
                inspectionRecordVisible:false,
                inspectionRecordForm:{
                },
                listQuery:{
                createUid: null,
                endTime: null,
                execUid: null,
                execUname: null,
                page: 1,
                pageSize: 10,
                result: null,
                startTime: null,
                statusList: null,
                type: null
                    pageIndex: 1,
                    pageSize: 10,
                    result: null,
                    taskStatus: null,
                    execDepId: null,
                    taskType: null
                },
            }
        },
@@ -270,8 +211,8 @@
                this.listLoading = true
                let res = await getInspectionRecord(this.listQuery)
                if(res.data.code === '200'){
                    this.recordTotal = JSON.parse(res.data.message).total
                    this.inspectionRecordData = res.data.result
                    this.recordTotal = res.data.count
                    this.inspectionRecordData = res.data.data
                }else{
                    this.$message({
                        message:res.data.message,
@@ -302,11 +243,39 @@
                    })
                }
            },
            showInspectionRecordForm(value){
                this.$refs.detail.showInspectionRecordForm(value)
            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.$refs.detail.showInspectionRecordDetailForm(value,type,this.userList,this.departmentList)
            },
            async submitInspectionRecordForm(value){
                if(value.unitList.find(item => item.status === 1) === undefined){
@@ -319,6 +288,7 @@
                        taskId: value.id
                    })
                    if(res.data.code === '200'){
                        this.getInspectionRecordData()
                        this.$message({
                            type:'success',
                            message:'提交成功',
@@ -338,6 +308,33 @@
                    })
                }
            },
            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()
            },
@@ -346,7 +343,7 @@
                this.getInspectionRecordData()
            },
            handleCurrentChange(val){
                this.listQuery.page = val
                this.listQuery.pageIndex = val
                this.getInspectionRecordData()
            },
        }
@@ -359,6 +356,9 @@
        padding-left: 10px;
    }
    .analyseUnit_input{
        width:90%;
    }
    .analyseUnit_box{
        width:200px;
    }
</style>