From cfb7abc64254c471a69c2586ec6221bb5bd5caf9 Mon Sep 17 00:00:00 2001 From: lct123456 <lucht> Date: 星期日, 22 五月 2022 20:13:47 +0800 Subject: [PATCH] '巡检记录' --- src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue | 29 -------------- src/views/doublePreventAction/hiddenDanger/inspectionRecord/components/detail.vue | 71 ++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/components/detail.vue b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/components/detail.vue index fc79069..acd9920 100644 --- a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/components/detail.vue +++ b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/components/detail.vue @@ -70,7 +70,7 @@ <el-row> <el-col :span="24"> <el-form-item label="巡检结果" prop="result"> - <el-select v-model="inspectionRecordDetailForm.result" :disabled="ifShow" class="input" @change="ifNormal = !ifNormal"> + <el-select v-model="inspectionRecordDetailForm.result" :disabled="ifShow" class="input" @change="ifNormal = (inspectionRecordDetailForm.result === 2 ? true : false)"> <el-option v-for="item in resultList" :key="item.id" @@ -84,8 +84,8 @@ <div v-if="ifNormal"> <el-row> <el-col :span="24"> - <el-form-item label="异常通知部门" prop="execDepartment"> - <el-select v-model="inspectionRecordDetailForm.noticeDepId" filterable clearable class="analyseUnit_input" @change="changeExec"> + <el-form-item label="异常通知部门" prop="noticeDepId"> + <el-select v-model="inspectionRecordDetailForm.noticeDepId" filterable clearable class="input" @change="changeDepartment('notice')" :disabled="ifShow"> <el-option v-for="item in departmentList" :key="item.id" @@ -101,7 +101,7 @@ <el-form-item label="异常通知人员" prop="noticeUid"> <el-select v-model="inspectionRecordDetailForm.noticeUid" clearable filterable :disabled="ifShow" class="input"> <el-option - v-for="item in userList" + v-for="item in noticeUserList" :key="item.id" :value="item.id" :label="item.realname" @@ -119,8 +119,8 @@ </el-row> <el-row> <el-col :span="24"> - <el-form-item label="异常整改部门" prop="execDepartment"> - <el-select v-model="inspectionRecordDetailForm.fixDepId" filterable clearable class="analyseUnit_input" @change="changeExec"> + <el-form-item label="异常整改部门" prop="fixDepId"> + <el-select v-model="inspectionRecordDetailForm.fixDepId" filterable clearable class="input" :disabled="ifShow" @change="changeDepartment('fix')"> <el-option v-for="item in departmentList" :key="item.id" @@ -136,7 +136,7 @@ <el-form-item label="整改人" prop="fixUid"> <el-select v-model="inspectionRecordDetailForm.fixUid" clearable filterable :disabled="ifShow" class="input"> <el-option - v-for="item in userList" + v-for="item in fixUserList" :key="item.id" :value="item.id" :label="item.realname" @@ -155,7 +155,7 @@ </el-row> <el-row> <el-col :span="24"> - <el-form-item label="上报图片" prop="img"> + <el-form-item label="上报图片" prop="imgInfoList"> <el-upload accept=".pdf,.jpg,.png" :action="fileRoad" @@ -164,7 +164,7 @@ :headers="header" :data="uploadForm" list-type="picture-card" - :file-list="inspectionRecordDetailForm.imgInfoList" + :file-list="fileList" v-model="inspectionRecordDetailForm.imgInfoList" :on-change="handleChangeFile" :on-success="onFileSuccess" @@ -243,7 +243,7 @@ imgInfoList: [], info: null, noticeUid: null, - result: 1, + result: null, taskId: null, unitId: null, fixDepId:null, @@ -256,11 +256,16 @@ fixTime: [{ required: true, message: '整改时间不能为空', trigger: 'change' }], fixUid: [{ required: true, message: '描整改人员不能为空', trigger: 'change' }], info: [{ required: true, message: '巡检结果备注不能为空', trigger: 'blur' }], + fixDepId: [{ required: true, message: '异常整改部门不能为空', trigger: 'blur' }], + noticeDepId: [{ required: true, message: '异常通知部门不能为空', trigger: 'blur' }], }, inspectionRecordDetailFormVisible:false, ifShow:true, ifNormal:false, userList:[], + noticeUserList:[], + fixUserList:[], + departmentList:[], fileList:[], resultList:[{id:0,name:'未操作'},{id:1,name:'正常'},{id:2,name:'异常'}], typeList:[{id:1,name:'日常检查'},{id:2,name:'周期检查'}], @@ -275,9 +280,10 @@ this.inspectionRecordFormVisible = true this.inspectionRecordForm = JSON.parse(JSON.stringify(value)) }, - showInspectionRecordDetailForm(value,type,userList) { + showInspectionRecordDetailForm(value,type,userList,departmentList) { this.inspectionRecordDetailFormVisible = true this.userList = userList + this.departmentList = departmentList if(type === '查看'){ this.titleDetail = '巡检单元查看' this.ifShow = true @@ -290,32 +296,40 @@ }else{ this.titleDetail = '巡检单元上报' this.ifShow = false + this.ifNormal = false + this.$nextTick(() =>{ + this.$refs["inspectionRecordDetailForm"].clearValidate() + }) this.inspectionRecordDetailForm = { execUid: Cookies.get('userId'), fixTime: null, fixUid: null, - img: null, + imgInfoList: [], info: null, noticeUid: null, - result: 1, + result: null, + fixDepId:null, + noticeDepId:null, taskId: value.taskId, unitId: value.id } } }, submitInspectionRecordDetail() { - if(this.ifNormal = false){ + if(this.ifNormal === false){ this.inspectionRecordDetailForm.noticeUid = null this.inspectionRecordDetailForm.fixTime = null this.inspectionRecordDetailForm.fixUid = null this.inspectionRecordDetailForm.info = null - this.inspectionRecordDetailForm.img = [] + this.inspectionRecordDetailForm.imgInfoList = [] + this.inspectionRecordDetailForm.noticeDepId = null + this.inspectionRecordDetailForm.fixDepId = null } this.$refs["inspectionRecordDetailForm"].validate((valid) =>{ if(valid){ + this.inspectionRecordDetailForm.imgInfoList = this.inspectionRecordDetailForm.imgInfoList.map(item =>{ return { url:item.url}}) submitUnitOne(this.inspectionRecordDetailForm).then( res =>{ if(res.data.code === '200'){ - this.$message({ type:'success', message:'上报成功', @@ -329,7 +343,6 @@ type:'warning' }) } - this.inspectionRecordDetailFormVisible = false }) }else{ this.$message({ @@ -339,12 +352,30 @@ } }) }, + changeDepartment(type){ + if(type === 'notice'){ + if(this.inspectionRecordDetailForm.noticeDepId === ''){ + this.noticeUserList = [] + }else{ + let department = this.departmentList.find(item => item.id === this.inspectionRecordDetailForm.noticeDepId).department + this.noticeUserList = this.userList.filter ( item => item.department === department) + } + }else{ + if(this.inspectionRecordDetailForm.fixDepId === ''){ + this.fixUserList = [] + }else{ + let department = this.departmentList.find(item => item.id === this.inspectionRecordDetailForm.fixDepId).department + this.fixUserList = this.userList.filter ( item => item.department === department) + } + } + }, handleChangeFile(){ this.header.Authorization = Cookies.get('token') }, onFileSuccess(response){ if(response.code === '200'){ - this.inspectionRecordDetailForm.img.push({url:process.env.IMG_API + response.result.path}) + this.inspectionRecordDetailForm.imgInfoList.push({url:response.result.path,name:response.result.name,}) + this.fileList.push({url:process.env.IMG_API + response.result.path,name:response.result.name,}) this.$notify({ type:'success', duration:2000, @@ -363,12 +394,14 @@ this.dialogVisible = true; }, handleRemove(file){ + debugger return this.$confirm(`确定移除 ${ file.name }?`,'提示',{ confirmButtonText:'确定', cancelButtonText:'取消', type:'warning', }).then(()=> { - + this.inspectionRecordDetailForm.imgInfoList.splice(this.inspectionRecordDetailForm.imgInfoList.findIndex(item =>item.name === file.name),1) + this.fileList.splice(this.inspectionRecordDetailForm.imgInfoList.findIndex(item =>item.name === file.name),1) }) }, } diff --git a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue index 9a16baa..e40c8bd 100644 --- a/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue +++ b/src/views/doublePreventAction/hiddenDanger/inspectionRecord/index.vue @@ -140,32 +140,6 @@ /> <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> </div> </template> @@ -239,7 +213,6 @@ title:'', company:'', code:'', - inspectionRecordVisible:false, inspectionRecordForm:{ }, @@ -306,7 +279,7 @@ this.$refs.detail.showInspectionRecordForm(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){ -- Gitblit v1.9.2