<template>
|
<div class="app-container">
|
<div class="filter-container">
|
<div class="basic_search">
|
<span>任务单元名称:</span>
|
<el-input v-model="listQuery.taskUnitName" style="width:200px">
|
</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 prop="taskUnitName" label="任务单元名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="note" label="任务单元说明" show-overflow-tooltip></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="onDelcheckUnit(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="taskUnitName">
|
<el-input class="input-length" v-model.trim="inspectionTaskForm.taskUnitName" 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="note">
|
<el-input class="input-length" v-model.trim="inspectionTaskForm.note" placeholder="请输入任务单元说明" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
|
|
<el-divider></el-divider>
|
|
<div class="inspectionTask_point">
|
<el-tabs class="active" v-model="activeName">
|
<el-tab-pane label="检查项信息" name="inspectionPoint">
|
<inspection-point @giveToForm="receiveToForm" ref="inspectionPoint" :title="title" :inspectionTaskForm="inspectionTaskForm"></inspection-point>
|
</el-tab-pane>
|
</el-tabs>
|
</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, taskToUser
|
} from "../../../../api/inspectionTask";
|
import {getAllDepartment, getDepartmentList} from "../../../../api/departmentManage";
|
import {safetyInspectionItemName} from "../../../../api/safetySelfInspection";
|
import {addCheckUnit, deleteCheckUnit, getCheckUnit, updateCheckUnit} from "../../../../api/checkUnit";
|
export default {
|
name: 'index',
|
components: {
|
inspectionPoint
|
},
|
data() {
|
return {
|
tableKey: 0,
|
ifShow:true,
|
activeName:'inspectionPoint',
|
inspectionTaskData: [],
|
departmentList:[],
|
userList:[],
|
// noticeUidList:[],
|
execUidList:[],
|
listLoading: false,
|
pageSize: 10,
|
recordTotal: 0,
|
currentPage: 1,
|
pageTotal: 0,
|
title:'',
|
company:'',
|
code:'',
|
// noticeDepartment:'',
|
execDepartment:'',
|
inspectionTaskVisible:false,
|
inspectionTaskFormRules:{
|
taskUnitName: [{ required: true, message: '请填写任务单元名称', trigger: 'blur' }],
|
note: [{ required: true, message: '请填写任务单元说明', trigger: 'change' }]
|
},
|
inspectionTaskForm:{
|
taskUnitName: null,
|
note: null,
|
measureList: [
|
],
|
|
},
|
listQuery:{
|
pageIndex: 1,
|
pageSize: 10,
|
taskUnitId: null
|
},
|
}
|
},
|
created() {
|
this.getInspectionTaskData()
|
this.getDepartment()
|
this.getUser()
|
},
|
methods: {
|
async getInspectionTaskData(){
|
this.listLoading = true
|
let res = await getCheckUnit(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 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'
|
})
|
}
|
},
|
showAnalyseUnitForm(value,type){
|
this.inspectionTaskVisible = true
|
this.$nextTick(() =>{
|
this.$refs["inspectionTaskForm"].clearValidate()
|
})
|
if(type === '新增'){
|
this.title = '新建隐患排查单元'
|
this.inspectionTaskForm = {
|
taskUnitName: null,
|
note: null,
|
measureList: [
|
],
|
}
|
setTimeout(() => {
|
this.$refs.inspectionPoint.inspectionPointData = []
|
this.$refs.inspectionPoint.ifEdit = false
|
});
|
}else{
|
this.title = '编辑隐患排查单元'
|
this.inspectionTaskForm.taskUnitName = JSON.parse(JSON.stringify(value)).taskUnitName
|
this.inspectionTaskForm.note = JSON.parse(JSON.stringify(value)).note
|
this.inspectionTaskForm.id = JSON.parse(JSON.stringify(value)).id
|
this.inspectionTaskForm.measureList = []
|
if(value.measureList !== null){
|
this.inspectionTaskForm.measureList = JSON.parse(JSON.stringify(value.measureList.map( item => {
|
return item.id
|
|
})))
|
}
|
|
// this.inspectionTaskForm.noticeUid = value.noticeUname
|
setTimeout(() => {
|
this.$refs.inspectionPoint.inspectionPointData = JSON.parse(JSON.stringify(value)).measureList
|
});
|
}
|
},
|
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 === '新建隐患排查单元'){
|
addCheckUnit(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{
|
updateCheckUnit(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:'请完善基本信息'
|
})
|
}
|
})
|
|
},
|
|
onDelcheckUnit(val){
|
|
this.$confirm('此操作将删除该隐患单元,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deleteCheckUnit({ 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
|
})
|
}
|
})
|
})
|
|
},
|
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){
|
if(val.status !== 2){
|
this.$message({
|
type:'warning',
|
message:'当前状态不可删除'
|
})
|
return
|
}
|
this.$confirm('删除此条信息,是否继续','提示',{
|
confirmButtonText:'确定',
|
cancelButtonText:'取消',
|
type:'warning',
|
}).then(()=> {
|
deleteInspectionTask(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
|
})
|
}
|
})
|
})
|
},
|
receiveToForm(value) {
|
this.inspectionTaskForm.measureList = []
|
this.inspectionTaskForm.measureList = 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:320px;
|
}
|
/deep/.el-divider--horizontal {
|
margin-top: 0px !important;
|
}
|
|
/deep/.el-dialog__body {
|
padding-top: 10px !important;
|
}
|
</style>
|