lct123456
2022-04-21 dfc35ece9ae09ad910538f0b181275e0e6c8a00c
src/views/doublePreventAction/hiddenDanger/inspectionTask/index.vue
@@ -12,11 +12,11 @@
            <div class="basic_search">
                <span>巡检任务类型:</span>
                <el-select v-model="listQuery.type">
                    <el-option
                        v-for="item in departmentList"
                   <el-option
                        v-for="item in typeList"
                        :key="item.id"
                        :value="item.department"
                        :label="item.department"
                        :value="item.id"
                        :label="item.name"
                    ></el-option>
                </el-select>
            </div>
@@ -24,43 +24,43 @@
                <span>巡检任务状态:</span>
                <el-select v-model="listQuery.status">
                    <el-option
                        v-for="item in departmentList"
                        v-for="item in statusList"
                        :key="item.id"
                        :value="item.department"
                        :label="item.department"
                        :value="item.id"
                        :label="item.name"
                    ></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>巡检任务创建人员:</span>
                <el-select v-model="listQuery.createUid">
                <el-select v-model="listQuery.createUid" filterable clearable>
                    <el-option
                        v-for="item in departmentList"
                        v-for="item in userList"
                        :key="item.id"
                        :value="item.department"
                        :label="item.department"
                        :value="item.id"
                        :label="item.realname"
                    ></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>异常通知人员:</span>
                <el-select v-model="listQuery.noticeUid">
                    <el-option
                        v-for="item in departmentList"
                <el-select v-model="listQuery.noticeUid" filterable clearable>
                   <el-option
                        v-for="item in userList"
                        :key="item.id"
                        :value="item.department"
                        :label="item.department"
                        :value="item.id"
                        :label="item.realname"
                    ></el-option>
                </el-select>
            </div>
            <div class="basic_search">
                <span>执行巡检人员:</span>
                <el-select v-model="listQuery.execUid">
                <el-select v-model="listQuery.execUid" filterable clearable>
                    <el-option
                        v-for="item in departmentList"
                        v-for="item in userList"
                        :key="item.id"
                        :value="item.department"
                        :label="item.department"
                        :value="item.id"
                        :label="item.realname"
                    ></el-option>
                </el-select>
            </div>
@@ -114,16 +114,16 @@
            <br>
            <el-pagination
                v-show="recordTotal>0"
                :current-page="currentPage"
                :current-page="listQuery.page"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageSize"
                :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>
@@ -143,7 +143,7 @@
                        </el-col>
                        <el-col :span="12">
                            <el-form-item label="巡检任务类型" prop="type">
                                <el-select v-model="inspectionTaskForm.type" class="analyseUnit_input">
                                <el-select v-model="inspectionTaskForm.type" class="analyseUnit_input" :disabled="ifShow">
                                    <el-option
                                        v-for="item in typeList"
                                        :key="item.id"
@@ -262,8 +262,8 @@
            <div class="inspectionTask_point">
                <el-tabs class="active" v-model="activeName">
                    <el-tab-pane label="巡检点信息" name="inspectionPoint">
                        <inspection-point @giveToForm="receiveToForm" ref="inspectionPoint"></inspection-point>
                    <el-tab-pane label="检查项信息" name="inspectionPoint">
                        <inspection-point @giveToForm="receiveToForm" ref="inspectionPoint" :title="title" :inspectionTaskForm="inspectionTaskForm"></inspection-point>
                    </el-tab-pane>
                </el-tabs>
            </div>
@@ -319,12 +319,14 @@
        data() {
            return {
                tableKey: 0,
                ifShow:true,
                activeName:'inspectionPoint',
                inspectionTaskData: [],
                departmentList:[],
                userList:[],
                noticeUidList:[],
                execUidList:[],
                statusList:[{name:'任务开启',id:1},{id:2,name:'任务关闭'}],
                intervalSecondsList:[{id:7200,name:'2小时'},{id:21600,name:'6小时'},{id:43200,name:'12小时'},{id:86400,name:'1天'},{id:17280,name:'2天'}],
                noticeSecondsList:[{id:600,name:'10分'},{id:3600,name:'1小时'},{id:7200,name:'2小时'},{id:21600,name:'6小时'},{id:43200,name:'12小时'},{id:86400,name:'1天'}],
                effectSecondsList:[{id:1800,name:'30分'},{id:3600,name:'1小时'},{id:7200,name:'2小时'},{id:21600,name:'6小时'},{id:43200,name:'12小时'},{id:86400,name:'1天'}],
@@ -366,7 +368,10 @@
                    noticeUid: "",
                    startTime: "",
                    status:"",
                    type: ""
                    type: "",
                    page: 1,
                    pageSize: 10,
                },
            }
        },
@@ -380,10 +385,7 @@
                this.listLoading = true
                let res = await getInspectionTask(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.recordTotal = JSON.parse(res.data.message).total
                    this.inspectionTaskData = res.data.result
                }else if(res.data.code === '300'){
                    this.inspectionTaskData = []
@@ -433,13 +435,15 @@
                }
            },
            showAnalyseUnitForm(value,type){
                debugger
                this.inspectionTaskVisible = true
                this.$nextTick(() =>{
                    this.$refs["inspectionTaskForm"].clearValidate()
                })
                if(type === '新增'){
                    this.ifShow = false
                    this.title = '新建巡检计划设定'
                    this.noticeDepartment = ''
                    this.execDepartment = ''
                    this.inspectionTaskForm = {
                        type:null,
                        createUid: parseInt(Cookies.get('userId')),
@@ -455,55 +459,96 @@
                    }
                    setTimeout(() => {
                        this.$refs.inspectionPoint.inspectionPointData = []
                        this.$refs.inspectionPoint.ifEdit = false
                    });
           }else{
                }else{
                    this.ifShow = true
                    this.title = '编辑巡检计划设定'
                    this.noticeDepartment = this.handleDepartment(JSON.parse(JSON.stringify(value)).noticeUid)
                    this.changeNotice()
                    this.execDepartment = this.handleDepartment(JSON.parse(JSON.stringify(value)).execUid)
                     this.changeExec()
                    this.inspectionTaskForm = JSON.parse(JSON.stringify(value))
                    // this.inspectionTaskForm.execUid = value.execUname
                    // this.inspectionTaskForm.noticeUid = value.noticeUname
                     setTimeout(() => {
                        this.$refs.inspectionPoint.inspectionPointData =  this.inspectionTaskForm.checkContents
                    });
                        this.$refs.inspectionPoint.ifEdit = true
                    });
                }
            },
            handleDepartment(value){
                let department = ''
                for(let i in this.userList){
                    if(this.userList[i].id === value){
                        department = this.userList[i].department
                    }
                }
                department = this.departmentList.find(item => item.department === department)
                return department.department
            },
            submitAnalyseUnit(){
                this.$refs["inspectionTaskForm"].validate((valid) =>{
                    if(valid){
                        if(this.title === '新建巡检计划设定'){
                            addInspectionTask(this.inspectionTaskForm).then((res)=>{
                                if(res.data.code === '200'){
                                    this.inspectionTaskVisible = false
                                    this.getInspectionTaskData()
                                    this.$notify({
                                        type:'success',
                                        duration:2000,
                                        message:'新增成功',
                                        title:'成功'
                                    })
                                }else{
                                    this.$message({
                                        type:'warning',
                                        message:res.data.message
                                    })
                                }
                        if(this.inspectionTaskForm.noticeSeconds >= this.inspectionTaskForm.intervalSeconds){
                            this.$message({
                                type:'warning',
                                 message:'提前通知时间不能大于检查频次'
                            })
                        }else if(this.inspectionTaskForm.intervalSeconds <= this.inspectionTaskForm.effectSeconds){
                                this.$message({
                                type:'warning',
                                 message:'任务持续时间不能大于检查频次'
                            })
                        }else{
                            updateInspectionTask(this.inspectionTaskForm).then((res)=>{
                                if(res.data.code === '200'){
                                    this.inspectionTaskVisible = false
                                    this.getInspectionTaskData()
                                    this.$notify({
                                        type:'success',
                                        duration:2000,
                                        title:'成功',
                                        message:'编辑成功'
                                    })
                                }else{
                                    this.$message({
                                        type:'warning',
                                        message:res.data.message
                                    })
                                }
                            })
                            if(this.title === '新建巡检计划设定'){
                                addInspectionTask(this.inspectionTaskForm).then((res)=>{
                                    if(res.data.code === '200'){
                                        this.inspectionTaskVisible = false
                                        this.getInspectionTaskData()
                                        this.$notify({
                                            type:'success',
                                            duration:2000,
                                            message:'新增成功',
                                            title:'成功'
                                        })
                                    }else{
                                        this.$message({
                                            type:'warning',
                                            message:res.data.message
                                        })
                                    }
                                })
                            }else{
                                updateInspectionTask({
                                    effectSeconds: this.inspectionTaskForm.effectSeconds,
                                    execUid: this.inspectionTaskForm.execUid,
                                    intervalSeconds: this.inspectionTaskForm.intervalSeconds,
                                    noticeSeconds: this.inspectionTaskForm.noticeSeconds,
                                    noticeUid: this.inspectionTaskForm.noticeUid,
                                    startTime: this.inspectionTaskForm.startTime,
                                    status: this.inspectionTaskForm.status,
                                    workId: this.inspectionTaskForm.workId
                                    }).then((res)=>{
                                    if(res.data.code === '200'){
                                        this.inspectionTaskVisible = false
                                        this.getInspectionTaskData()
                                        this.$notify({
                                            type:'success',
                                            duration:2000,
                                            title:'成功',
                                            message:'编辑成功'
                                        })
                                    }else{
                                        this.$message({
                                            type:'warning',
                                            message:res.data.message
                                        })
                                    }
                                })
                            }
                        }
                    }else{
                        this.$message({
                            type:'warning',
@@ -531,7 +576,6 @@
                })
            },
            receiveToForm(value) {
                debugger
                this.inspectionTaskForm.riskControlMeasureIdList = []
                this.inspectionTaskForm.riskControlMeasureIdList = value.map( item => {
                    return item.id
@@ -545,7 +589,7 @@
                this.getInspectionTaskData()
            },
            handleCurrentChange(val){
                this.listQuery.pageIndex = val
                this.listQuery.page = val
                this.getInspectionTaskData()
            },
        }