<template>
|
<div class="app-container">
|
<div class="filter-container">
|
<div class="basic_search">
|
<span>排查作业类型:</span>
|
<el-select class="analyseUnit_box" v-model="listQuery.checkWorkType" placeholder="排查作业类型" filterable clearable>
|
<el-option v-for="item in checkWorkTypeList" :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.checkWorkStatus" placeholder="排查作业状态" filterable clearable>
|
<el-option v-for="item in checkWorkStatusList" :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>
|
<div class="basic_search">
|
<span>排查作业名称:</span>
|
<el-input class="analyseUnit_box" v-model="listQuery.checkWorkName" placeholder="排查作业名称" clearable> </el-input>
|
</div>
|
<el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" icon="el-icon-refresh" @click="refreshHandle">搜索</el-button>
|
<el-button class="filter-item" style="margin-left: 10px;margin-top: 10px" type="primary" icon="el-icon-plus" @click="showAnalyseUnitForm('','新增')">新增</el-button>
|
</div>
|
|
<div class="table_content">
|
<el-table
|
v-loading="listLoading"
|
:key="tableKey"
|
:data="inspectionTaskData"
|
border
|
fit
|
highlight-current-row
|
style="width: 100%;"
|
>
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="checkWorkName" label="排查名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="checkWorkType" label="排查类型" show-overflow-tooltip>
|
<template slot-scope="scope">
|
{{ parseNumber(scope.row.checkWorkType, '排查类型') }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="taskUnitName" label="任务单元" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="execDep" label="执行部门" show-overflow-tooltip>
|
</el-table-column>
|
<el-table-column prop="checkCycle" label="排查周期" show-overflow-tooltip>
|
<template slot-scope="scope">
|
<span>
|
{{ scope.row.checkCycle }}
|
</span>
|
<span>
|
{{ parseNumber(scope.row.checkCycleUnit, '排查周期') }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="validTime" label="有效时间" show-overflow-tooltip>
|
<template slot-scope="scope">
|
<span>
|
{{ scope.row.validTime }}
|
</span>
|
<span>
|
{{ parseNumber(scope.row.validTimeUnit, '排查周期') }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="validTime" label="提醒时间" show-overflow-tooltip>
|
<template slot-scope="scope">
|
<span>
|
{{ scope.row.noticeTime }}
|
</span>
|
<span>
|
{{ parseNumber(scope.row.noticeTimeUnit, '排查周期') }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createByUserName" 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="showAnalyseUnitForm(scope.row,'编辑')">编辑</el-button>
|
<el-button type="text" style="color: red" @click="deleteById(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>
|
|
<el-dialog :title="title" :visible.sync="inspectionTaskVisible" append-to-body :close-on-click-modal="false" width="55%">
|
|
|
<el-divider></el-divider>
|
|
<div class="inspectionTask_form">
|
<el-form ref="inspectionTaskForm" :rules="inspectionTaskFormRules" :model="inspectionTaskForm" label-position="right" label-width="120px">
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="排查类型" prop="checkWorkType">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.checkWorkType" placeholder="请输入排查类型" clearable> <el-option v-for="item in checkWorkTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option></el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="排查名称" prop="checkWorkName">
|
<el-input class="analyseUnit_input" v-model.trim="inspectionTaskForm.checkWorkName" placeholder="请输入排查名称" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="排查周期" prop="checkCycle">
|
<el-input class="analyseUnit_input" type="number" v-model.trim="inspectionTaskForm.checkCycle" placeholder="请输入排查周期" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="时间单位" prop="checkCycleUnit">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.checkCycleUnit" placeholder="请输入时间单位" clearable>
|
<el-option v-for="item in timeType" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="有效时间" prop="validTime">
|
<el-input class="analyseUnit_input" type="number" v-model.trim="inspectionTaskForm.validTime" placeholder="请输入有效时间" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="时间单位" prop="validTimeUnit">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.validTimeUnit" placeholder="请输入时间单位" clearable>
|
<el-option v-for="item in timeType" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="提醒时间" prop="noticeTime">
|
<el-input class="analyseUnit_input" type="number" v-model.trim="inspectionTaskForm.noticeTime" placeholder="请输入提醒时间" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="时间单位" prop="noticeTimeUnit">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.noticeTimeUnit" placeholder="请输入时间单位" clearable>
|
<el-option v-for="item in timeType" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="执行部门" prop="execDepId">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.execDepId" clearable filterable >
|
<el-option
|
v-for="item in departmentList"
|
:key="item.id"
|
:label="item.department"
|
:value="item.id"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="任务单元" prop="taskUnitId">
|
<el-select class="analyseUnit_input" v-model="inspectionTaskForm.taskUnitId" placeholder="请输入任务单元" clearable filterable>
|
<el-option v-for="item in taskUnitList" :key="item.taskUnitName" :label="item.taskUnitName" :value="item.id"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="首次任务开始时间" prop="firstStartTime">
|
<el-date-picker class="analyseUnit_input" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" v-model="inspectionTaskForm.firstStartTime" placeholder="请选择首次任务开始时间" clearable></el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
|
|
|
|
<div align="right">
|
<el-button @click="inspectionTaskVisible = false">取消</el-button>
|
<el-button type="primary" @click="submitAnalyseUnit()">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import Cookies from "js-cookie";
|
import { mapGetters } from 'vuex'
|
import { computePageCount } from '@/utils'
|
import inspectionPoint from './components/inpectionPoint'
|
import {
|
getInspectionTask,
|
addInspectionTask,
|
updateInspectionTask,
|
deleteInspectionTask, closeInspectionTask
|
} from "../../../../api/inspectionTask";
|
import {getAllDepartment, getDepartmentList} from "../../../../api/departmentManage";
|
import {safetyInspectionItemName} from "../../../../api/safetySelfInspection";
|
import {getAllCheckUnitList} from "../../../../api/checkUnit";
|
export default {
|
name: 'index',
|
filters: {
|
parseHours(seconds){
|
let arg1 = parseFloat(seconds)
|
let arg2 = parseFloat(3600)
|
let t1 = 0
|
let t2 = 0
|
let r1
|
let r2
|
try {
|
t1 = arg1.toString().split(".")[1].length;
|
}catch (e){
|
|
}
|
try {
|
t2 = arg2.toString().split(".")[1].length;
|
}catch (e){
|
}
|
r1 = Number(arg1.toString().replace(".",""))
|
r2 = Number(arg2.toString().replace(".",""))
|
return r1/r2*Math.pow(10,t2-t1)
|
},
|
},
|
computed: {
|
...mapGetters([
|
'userType'
|
])
|
},
|
components: {
|
inspectionPoint
|
},
|
data() {
|
return {
|
tableKey: 0,
|
ifShow:true,
|
activeName:'inspectionPoint',
|
inspectionTaskData: [],
|
departmentList:[],
|
userList:[],
|
// noticeUidList:[],
|
execUidList:[],
|
statusList:[{name:'任务开启',id:1},{id:2,name:'任务关闭'},{id:3,name:'删除'},{id:4,name:'过期'}],
|
intervalSecondsList:[{id:3600,name:'1小时'},{id:7200,name:'2小时'},{id:21600,name:'6小时'},{id:28800,name:'8小时'},{id:43200,name:'12小时'},{id:86400,name:'1天'},{id:17280,name:'2天'},{id:604800,name:'每周'},{id:2592000,name:'每月'},{id:7862400,name:'每季度'}],
|
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天'}],
|
typeList:[{id:1,name:'日常检查'},{id:2,name:'周期检查'}],
|
listLoading: false,
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
title:'',
|
company:'',
|
code:'',
|
// noticeDepartment:'',
|
execDepartment:'',
|
inspectionTaskVisible:false,
|
inspectionTaskFormRules:{
|
checkWorkType: [{ required: true, message: '请填写排查作业类型', trigger: 'change' }],
|
checkWorkName: [{ required: true, message: '请选择排查作业名称', trigger: 'blur' }],
|
taskUnitId: [{ required: true, message: '请选择任务单元', trigger: 'change' }],
|
execUserId: [{ required: true, message: '请选择执行人', trigger: 'change' }],
|
checkCycle: [{ required: true, message: '请填写排查周期', trigger: 'blur' }],
|
checkCycleUnit: [{ required: true, message: '请选择时间单位', trigger: 'change' }],
|
validTime: [{ required: true, message: '请填写有效时间', trigger: 'blur' }],
|
validTimeUnit: [{ required: true, message: '请选择时间单位', trigger: 'change' }],
|
noticeTime: [{ required: true, message: '请填写提醒时间', trigger: 'blur' }],
|
noticeTimeUnit: [{ required: true, message: '请选择时间单位', trigger: 'change' }],
|
firstStartTime: [{ required: true, message: '请填写首次排查任务开始时间', trigger: 'blur' }],
|
depId: [{ required: true, message: '请选择部门', trigger: 'change' }]
|
},
|
inspectionTaskForm:{
|
checkWorkType: null,
|
checkWorkName: null,
|
taskUnitId: null,
|
execDepId: null,
|
checkCycle: null,
|
checkCycleUnit: null,
|
validTime: null,
|
validTimeUnit: null,
|
noticeTime: null,
|
noticeTimeUnit: null,
|
firstStartTime: null
|
},
|
listQuery:{
|
checkWorkType: null,
|
checkWorkStatus: null,
|
checkWorkName: null,
|
execDepId: null,
|
pageIndex: 1,
|
pageSize: 10,
|
|
},
|
checkWorkTypeList: [
|
{ id: 1, name: '周期作业' },
|
{ id: 2, name: '日常作业' }
|
],
|
checkWorkStatusList: [
|
{ id: 1, name: '开启' },
|
{ id: 2, name: '关闭' }
|
],
|
timeType: [
|
{ id: 2, name: '小时' },
|
{ id: 3, name: '日' },
|
{ id: 4, name: '月' },
|
{ id: 5, name: '年' }
|
],
|
taskUnitList:[],
|
}
|
},
|
created() {
|
this.getInspectionTaskData()
|
this.getDepartment()
|
this.getUser()
|
this.getCheckUnitData()
|
},
|
methods: {
|
async getInspectionTaskData(){
|
this.listLoading = true
|
let res = await getInspectionTask(this.listQuery)
|
if(res.data.code === '200'){
|
this.recordTotal = res.data.count
|
this.inspectionTaskData = res.data.data
|
}else if(res.data.code === '300'){
|
this.inspectionTaskData = []
|
}
|
else{
|
this.$message({
|
message:res.data.message,
|
type:'warning'
|
})
|
}
|
this.listLoading = false
|
},
|
|
async getCheckUnitData(){
|
let res = await getAllCheckUnitList();
|
if (res.data.code === '200') {
|
this.taskUnitList = JSON.parse(JSON.stringify(res.data.data));
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
},
|
|
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'
|
})
|
}
|
},
|
// changeNotice(){
|
// if(this.noticeDepartment === '') {
|
// this.noticeUidList = []
|
// this.inspectionTaskForm.noticeUid = ''
|
// }
|
// this.noticeUidList = this.userList.filter( item => item.department === this.noticeDepartment)
|
// },
|
changeExec(){
|
if(this.execDepartment === '') {
|
this.execUidList = []
|
this.inspectionTaskForm.execUid = ''
|
}
|
this.execUidList = this.userList.filter ( item => item.departmentname === this.execDepartment)
|
},
|
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'
|
})
|
}
|
},
|
|
parseNumber(value, type) {
|
if (type === '排查类型') {
|
return this.checkWorkTypeList.find((item) => item.id === value).name;
|
} else if (type === '排查周期') {
|
return this.timeType.find((item) => item.id == value).name;
|
}
|
},
|
|
showAnalyseUnitForm(value,type){
|
this.inspectionTaskVisible = true
|
this.$nextTick(() =>{
|
this.$refs["inspectionTaskForm"].clearValidate()
|
})
|
if(type === '新增'){
|
this.ifShow = false
|
this.title = '新建巡检计划设定'
|
this.inspectionTaskForm = {
|
checkWorkType: null,
|
checkWorkName: null,
|
taskUnitId: null,
|
execDepId: null,
|
checkCycle: null,
|
checkCycleUnit: null,
|
validTime: null,
|
validTimeUnit: null,
|
noticeTime: null,
|
noticeTimeUnit: null,
|
firstStartTime: null
|
}
|
}else{
|
this.ifShow = true
|
this.title = '编辑巡检计划设定'
|
// this.noticeDepartment = this.handleDepartment(JSON.parse(JSON.stringify(value)).noticeUid)
|
// this.changeNotice()
|
for( let key in this.inspectionTaskForm){
|
this.inspectionTaskForm[key] = JSON.parse(JSON.stringify(value))[key]
|
}
|
this.inspectionTaskForm.id = JSON.parse(JSON.stringify(value)).id
|
}
|
},
|
handleDepartment(value){
|
let department = ''
|
for(let i in this.userList){
|
if(this.userList[i].id === value){
|
department = this.userList[i].departmentname
|
}
|
}
|
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
|
})
|
}
|
})
|
}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
|
})
|
}
|
})
|
}
|
|
}else{
|
this.$message({
|
type:'warning',
|
message:'请完善基本信息'
|
})
|
}
|
})
|
|
},
|
justifyTime(time,interval) {
|
let timeStr = new Date(time.replace(/-/g,'/'))
|
let date = parseInt(timeStr.getTime()/1000)
|
let newTimeStr = new Date()
|
let newDate = parseInt(newTimeStr.getTime()/1000)
|
if(date - newDate - interval - 1800 >= 0){
|
return false
|
}else{
|
return true
|
}
|
},
|
|
openTask(val,type){
|
if(val.status !== 2){
|
this.$message({
|
type:'warning',
|
message:'当前状态不可开启'
|
})
|
return
|
}
|
this.showAnalyseUnitForm(val,type)
|
this.inspectionTaskForm.status = 1
|
},
|
|
closeTask(val){
|
if(val.status !== 1){
|
this.$message({
|
type:'warning',
|
message:'当前状态不可关闭'
|
})
|
return
|
}
|
this.$confirm('关闭此条任务,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
closeInspectionTask(val.workId).then( (res)=>{
|
if(res.data.code === '200'){
|
this.getInspectionTaskData()
|
this.$notify({
|
title:'成功',
|
message:'关闭成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
},
|
|
deleteById(val){
|
this.$confirm('删除此条信息,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deleteInspectionTask({ id: val.id }).then( (res)=>{
|
if(res.data.code === '200'){
|
this.getInspectionTaskData()
|
this.$notify({
|
title:'成功',
|
message:'删除成功',
|
type:'success',
|
duration:2000,
|
})
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
})
|
})
|
},
|
receiveToForm(value) {
|
this.inspectionTaskForm.riskControlMeasureIdList = []
|
this.inspectionTaskForm.riskControlMeasureIdList = value.map( item => {
|
return item.id
|
})
|
// this.inspectionTaskForm.riskControlMeasureIdList.push({id:value.id})
|
},
|
refreshHandle(){
|
this.getInspectionTaskData()
|
},
|
handleSizeChange(val){
|
this.listQuery.pageSize = val
|
this.getInspectionTaskData()
|
},
|
handleCurrentChange(val){
|
this.listQuery.pageIndex = val
|
this.getInspectionTaskData()
|
},
|
}
|
}
|
</script>
|
<style scoped>
|
.basic_search{
|
display:inline-block;
|
padding-bottom: 10px;
|
padding-left: 10px;
|
}
|
.analyseUnit_input{
|
width:90%;
|
}
|
.analyseUnit_box{
|
width:200px;
|
}
|
/deep/.el-divider--horizontal {
|
margin-top: 0px !important;
|
}
|
|
/deep/.el-dialog__body {
|
padding-top: 10px !important;
|
}
|
</style>
|