From 137910cf4fc73a3a2787a3a02718f1e1f637c368 Mon Sep 17 00:00:00 2001 From: zhouwx <1175765986@qq.com> Date: 星期五, 14 六月 2024 16:01:17 +0800 Subject: [PATCH] bug修改 --- src/views/safetyReview/projectManage/components/siteCheckRcd.vue | 471 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 319 insertions(+), 152 deletions(-) diff --git a/src/views/safetyReview/projectManage/components/siteCheckRcd.vue b/src/views/safetyReview/projectManage/components/siteCheckRcd.vue index 4dbb3c4..f5d5883 100644 --- a/src/views/safetyReview/projectManage/components/siteCheckRcd.vue +++ b/src/views/safetyReview/projectManage/components/siteCheckRcd.vue @@ -2,13 +2,26 @@ <div class="riskBox"> <el-form ref="formRef" :model="state.formData" :rules="state.rules" class="register-form" label-position="top"> <el-row :gutter="30" style="margin-bottom: 20px"> - <el-col :span="18"> + <el-col :span="28"> <el-alert title="说明:现场勘验记录由项目组成员通过APP端进行信息填报,组长完成现场勘验并在APP端提交后,电脑可对资料信息完善并进行下一步操作。" type="warning" /> </el-col> <!-- <el-col :span="6" style="display:flex;justify-content: right">--> <!-- <el-button type="primary">全部查看</el-button>--> <!-- <el-button type="primary">全部下载</el-button>--> <!-- </el-col>--> + </el-row> + <el-row :gutter="30" style="margin-bottom: 30px" v-if="state.data.length>0"> + <el-col :span="28"> + <div style="display: flex;align-items: center"> + <span style="font-size: 22px;font-weight: 600;margin-top: 10px;">记录编号:{{ chooseItem.index }}(提交时间:{{chooseItem.createTime}})</span> + <div style="display: flex;align-items: center;flex-wrap: wrap"> + <div v-for="(item,index) in state.data"> + <el-check-tag style="margin-left: 20px;margin-top:10px;cursor: pointer;padding: 15px 25px" :checked="chooseItem.id === item.id" size="large" @click="chooseRecord(item,index)">记录编号{{ index+1 }}</el-check-tag> + </div> + </div> + </div> + + </el-col> </el-row> <el-row :gutter="30"> <el-col :span="6"> @@ -29,7 +42,9 @@ v-model="state.formData.location" size="large" placeholder="请填写现场勘验位置" + @focus="openLocation" > + <template #append> <el-button :icon="Search" @click="openLocation"/> </template> @@ -38,7 +53,7 @@ </el-col> <el-col :span="6"> <el-form-item prop="isSafetyCheck" label="编制现场安全检查表"> - <el-radio-group v-model="state.formData.isSafetyCheck" size="large"> + <el-radio-group v-model="state.formData.isSafetyCheck" size="large" @change="changeRadio" :disabled="projectType==='view' || isEnd"> <el-radio :label="1" size="large">是</el-radio> <el-radio :label="0" size="large">否</el-radio> </el-radio-group> @@ -48,7 +63,7 @@ <el-row :gutter="30"> <el-col :span="24" v-if="state.formData.isSafetyCheck == 1"> <el-form-item label="安全检查表上传" prop="assAccessoryFiles"> - <el-upload accept="image/*,.pdf,.doc,.docx,.xlsx,.xls" :action="state.uploadUrl" :data="{moduleType: 5,projectId: props.projectId}" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,5)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='1' v-model:file-list="state.safetyList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,5)"> + <el-upload :disabled="projectType==='view' || isEnd" accept="image/*,.pdf,.doc,.docx,.xlsx,.xls" :action="state.uploadUrl" :data="{moduleType: 5,projectId: props.projectId}" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,5)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='1' v-model:file-list="state.safetyList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,5)"> <el-button type="primary">附件上传</el-button> <template #tip> <div class="el-upload__tip">上传文件尺寸小于5M,最多可上传1份</div> @@ -71,7 +86,7 @@ <el-row style="border: 1px dashed #999;border-radius: 4px;padding: 10px;margin-top: 20px"> <el-col :span="24"> <el-form-item label="主要装置前合影照片" prop="deviceImages"> - <el-upload accept="image/*" :action="state.uploadUrl" :data="{moduleType: 1,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,1)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.beforeDeviceList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,1)" > + <el-upload accept="image/*" :disabled="projectType === 'view' || isEnd" :action="state.uploadUrl" :data="{moduleType: 1,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,1)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.beforeDeviceList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,1)" > <el-icon><Plus /></el-icon> <template #tip> <div class="el-upload__tip">上传照片尺寸小于5M,最多可上传10张</div> @@ -83,7 +98,7 @@ <el-row style="border: 1px dashed #999;border-radius: 4px;padding: 10px;margin-top: 20px"> <el-col :span="24"> <el-form-item label="现场勘验照片" prop="investingationImages"> - <el-upload accept="image/*" :action="state.uploadUrl" :data="{moduleType: 2,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,2)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.siteCheckList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,2)" > + <el-upload accept="image/*" :disabled="projectType === 'view' || isEnd" :action="state.uploadUrl" :data="{moduleType: 2,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,2)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.siteCheckList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,2)" > <el-icon><Plus /></el-icon> <template #tip> <div class="el-upload__tip">上传照片尺寸小于5M,最多可上传10张</div> @@ -94,8 +109,8 @@ </el-row> <el-row style="border: 1px dashed #999;border-radius: 4px;padding: 10px;margin-top: 20px;margin-bottom: 20px"> <el-col :span="24"> - <el-form-item label="企业陪同人员照片" prop="ccompanyImages"> - <el-upload accept="image/*" :action="state.uploadUrl" :data="{moduleType: 3,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,3)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.companyList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,3)" > + <el-form-item label="企业陪同人员照片" prop="companyImages"> + <el-upload :disabled="projectType === 'view' || isEnd" accept="image/*" :action="state.uploadUrl" :data="{moduleType: 3,projectId: props.projectId}" list-type="picture-card" :headers="state.header" method="post" :on-success="(res, uploadFile)=>handleAvatarSuccess(res, uploadFile,3)" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='10' v-model:file-list="state.companyList" :before-upload="picSize" :on-remove="(file, uploadFiles)=>handleRemove(file, uploadFiles,3)" > <el-icon><Plus /></el-icon> <template #tip> <div class="el-upload__tip">上传照片尺寸小于5M,最多可上传10张</div> @@ -116,13 +131,24 @@ import {defineEmits, onMounted, reactive, ref} from "vue" import {ElMessage, ElMessageBox} from "element-plus" import {Search} from '@element-plus/icons-vue' -import {addSiteCheck,editSiteCheck,getSiteCheckDetail, delFile, getFiles} from "@/api/projectManage/siteCheckRcd"; +import { + addSiteCheck, + editSiteCheck, + getSiteCheckDetail, + delFile, + getFiles, + getDetailById, doSiteCheck +} from "@/api/projectManage/siteCheckRcd"; import { getToken } from "@/utils/auth"; import Cookies from "js-cookie" +import { useRoute } from 'vue-router' +const route = useRoute() const props = defineProps(['projectId']) const emit = defineEmits(["getNextStatus"]) import MapLocation from "./mapLocation.vue" - +const direction = ref('rtl'); +const size = ref('400px') +const showDrawer = ref(false); let checkSafetyFiles = (rule, value, callback)=>{ if(state.safetyList.length === 0){ callback(new Error('请上传现场安全检查表')) @@ -150,6 +176,7 @@ const state = reactive({ + data: [], formData: { id: null, projectId: null, @@ -160,14 +187,14 @@ assAccessoryFiles: [], deviceImages: [], investingationImages: [], - ccompanyImages:[] + companyImages:[] }, projectId: null, planPersons: [], rules: { investigationDate: [{required: true, message: '请选择现场勘验时间', trigger: 'blur'}], - location: [{required: true, message: '请选择现场勘验位置', trigger: 'blur'}], - isSafetyCheck: [{required: true, message: '请选择现场勘验位置', trigger: 'blur'}], + location: [{required: true, message: '请选择现场勘验位置', trigger: 'change'}], + isSafetyCheck: [{required: true, message: '请选择是否编制现场安全检查表', trigger: 'blur'}], recordData: [{required: true, message: '请填写现场勘验记录', trigger: 'blur'}], assAccessoryFiles: [{required: true, validator: checkSafetyFiles, trigger: 'blur'}], // investingationImages: [{required: true, validator: checkInvestFiles, trigger: 'blur'}], @@ -197,58 +224,116 @@ if(props.projectId){ getDetail(props.projectId) } + isEnd.value = Cookies.get('end') + projectType.value = route.query.type; }); +const chooseRecord = async (item, index) => { + state.formData = item; + state.data.forEach((i,index) => { + if(i.id === item.id){ + chooseItem.value = i; + chooseItem.value.index = index+1; + + } + }) + await getPicDetail(item.id); + showDrawer.value = false; +} + +const chooseItem = ref(); const getDetail = async (val) => { const res = await getSiteCheckDetail({projectId: val}); if(res.code == 200){ - state.formData = res.data; - state.beforeDeviceList = res.data.deviceImages.map(i=>{ - return { - name: i.fileName, - url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, - id: i.id, - projectId: i.projectId, - moduleType: i.moduleType - } - }) - state.siteCheckList = res.data.investingationImages.map(i=>{ - return { - name: i.fileName, - url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, - id: i.id, - projectId: i.projectId, - moduleType: i.moduleType - } - }) - state.companyList = res.data.ccompanyImages.map(i=>{ - return { - name: i.fileName, - url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, - id: i.id, - projectId: i.projectId, - moduleType: i.moduleType - } - }) - state.safetyList = res.data.assAccessoryFiles.map(i=>{ - return { - name: i.fileName, - url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, - id: i.id, - projectId: i.projectId, - moduleType: i.moduleType - } - }) + if(res.data && res.data.length > 0){ + Cookies.set('btn','变更') + state.data = res.data; + state.formData = res.data[0]; + chooseItem.value = state.formData; + chooseItem.value.index = 1; + + await getPicDetail(state.formData.id) + }else { + Cookies.set('btn','保存') + } + + }else { + ElMessage.warning(res.message) + } +} +const getPicDetail = async (val) => { + const res = await getDetailById(val); + if(res.code == 200){ + if(res.data){ + state.formData = res.data; + doPic(res.data) + } }else { ElMessage.warning(res.message) } } +const doPic = (val) => { + state.beforeDeviceList = val.deviceImages?.map(i=>{ + return { + name: i.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, + id: i.id, + projectId: i.projectId, + moduleType: i.moduleType + } + }) + state.siteCheckList = val.investingationImages?.map(i=>{ + return { + name: i.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, + id: i.id, + projectId: i.projectId, + moduleType: i.moduleType + } + }) + state.companyList = val.companyImages?.map(i=>{ + return { + name: i.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, + id: i.id, + projectId: i.projectId, + moduleType: i.moduleType + } + }) + state.safetyList = val.assAccessoryFiles?.map(i=>{ + return { + name: i.originName, + url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, + id: i.id, + projectId: i.projectId, + moduleType: i.moduleType + } + }) +} +const changeRadio = () => { + if(state.formData.isSafetyCheck == 1){ + getSafetyFiles() + } +} + +const projectType = ref(''); +const isEnd = ref('') const riskOpen = async (type,val) => { state.formData.projectId = val + isEnd.value = Cookies.get('end') state.projectId = val + projectType.value = route.query.type; + if(type === 'sixEnd') { + const res = await doSiteCheck({projectId: val}); + if(res.code == 200) { + emit('getNextStatus', val); + }else { + ElMessage.warning(res.message) + } + } if(type === 'detail' || type === 'edit' ){ // await getDetail(val) } @@ -260,61 +345,87 @@ return; } if(type === 'add'){ - if(state.formData.isSafetyCheck == 1){ - state.formData.recordData = '' - } - const {id, ...data} = JSON.parse(JSON.stringify(state.formData)) - const res = await addSiteCheck(data); - if (res.code == 200) { - ElMessage.success('保存成功') - if(state.formData.isSafetyCheck == 0){ - const res = await delFile(state.safetyList[0].id) - if(res.code == 200){ - console.log('删除原有附件') - await getSafetyFiles() - }else{ - ElMessage({ - type: 'warning', - message: res.message - }) - } - } - formRef.value.clearValidate(); - emit('getNextStatus', state.projectId); - } else { - ElMessage.warning(res.message) + if(!state.data.length >0){ + await saveData(val); + }else { + await editData(); } }else if(type === 'clickEdit'){ - if(state.formData.isSafetyCheck == 1){ - state.formData.recordData = '' - } - const { ...data} = JSON.parse(JSON.stringify(state.formData)) - const res = await editSiteCheck(data); - if (res.code == 200) { - ElMessage.success('变更成功') - if(state.formData.isSafetyCheck == 0){ - const res = await delFile(state.safetyList[0].id) - if(res.code == 200){ - await getSafetyFiles() - }else{ - ElMessage({ - type: 'warning', - message: res.message - }) - } - } - formRef.value.clearValidate(); - // emit('getNextStatus', data.project.id); - } else { - ElMessage.warning(res.message) - } + await editData(); } } } } +const saveData = async (val) => { + + if(state.formData.isSafetyCheck == 1){ + state.formData.recordData = '' + } + const {id, ...data} = JSON.parse(JSON.stringify(state.formData)) + const res = await addSiteCheck(data); + if (res.code == 200) { + ElMessage.success('保存成功') + // const res = await doSiteCheck({projectId: val}); + // if(res.code == 200) { + if(state.formData.isSafetyCheck == 0){ + if(state.safetyList && state.safetyList.length >0){ + console.log('删除原有附件',state.safetyList[0]) + let id = state.safetyList[0].response.data.id + const res = await delFile(id) + if(res.code == 200){ + console.log('删除原有附件') + await getSafetyFiles() + }else{ + ElMessage({ + type: 'warning', + message: res.message + }) + } + } + } + await getDetail(val) + formRef.value.clearValidate(); + // emit('getNextStatus', val); + // }else { + // ElMessage.warning(res.message) + // } + + } else { + ElMessage.warning(res.message) + } +} +const editData = async () => { + + if(state.formData.isSafetyCheck == 1){ + state.formData.recordData = '' + } + const { ...data} = JSON.parse(JSON.stringify(state.formData)) + const res = await editSiteCheck(data); + if (res.code == 200) { + ElMessage.success('变更成功') + if(state.formData.isSafetyCheck == 0 && state.safetyList.length>0){ + const res = await delFile(state.safetyList[0].id) + if(res.code == 200){ + await getSafetyFiles() + }else{ + ElMessage({ + type: 'warning', + message: res.message + }) + } + } + await getPicDetail(chooseItem.value.id) + formRef.value.clearValidate(); + // emit('getNextStatus', data.project.id); + } else { + ElMessage.warning(res.message) + } +} + + const getBeforeFiles = async (id)=>{ - const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 1}) + const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 1,processId:chooseItem.value.id }) if(res.code == 200){ if(res.data && res.data.length>0){ state.beforeDeviceList = res.data.map(i=>{ @@ -322,10 +433,12 @@ name: i.fileName, url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, id: i.id, + processId: state.formData.id, projectId: i.projectId, moduleType: i.moduleType } }) + state.formData.deviceImages = state.beforeDeviceList; }else{ state.beforeDeviceList=[] } @@ -335,7 +448,7 @@ } const getSiteCheckFiles = async (id)=>{ - const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 2}) + const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 2,processId:chooseItem.value.id}) if(res.code == 200){ if(res.data && res.data.length>0){ state.siteCheckList = res.data.map(i=>{ @@ -343,10 +456,12 @@ name: i.fileName, url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, id: i.id, + processId: state.formData.id, projectId: i.projectId, moduleType: i.moduleType } }) + state.formData.investingationImages = state.siteCheckList; }else{ state.siteCheckList = [] } @@ -356,7 +471,7 @@ } const getCompanyFiles = async (id)=>{ - const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 3}) + const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 3,processId:chooseItem.value.id}) if(res.code == 200){ if(res.data && res.data.length>0){ state.companyList = res.data.map(i=>{ @@ -364,10 +479,12 @@ name: i.fileName, url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, id: i.id, + processId: state.formData.id, projectId: i.projectId, moduleType: i.moduleType } }) + state.formData.companyImages = state.companyList; }else{ state.companyList=[] } @@ -377,18 +494,20 @@ } const getSafetyFiles = async (id)=>{ - const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 5}) + const res = await getFiles({projectId: id ? id : props.projectId,moduleType: 5,processId: chooseItem.value? chooseItem.value.id:''}) if(res.code == 200){ if(res.data && res.data.length>0){ state.safetyList = res.data.map(i=>{ return { - name: i.fileName, + name: i.originName, url: import.meta.env.VITE_APP_BASE_API + '/' + i.path, id: i.id, + processId: state.formData.id, projectId: i.projectId, moduleType: i.moduleType } }) + state.formData.assAccessoryFiles = state.safetyList }else{ state.safetyList = [] } @@ -433,75 +552,119 @@ const handleAvatarSuccess = (res, uploadFile, type) => { if(res.code == 200){ if(type == 1){ - getBeforeFiles() + let obj = { + name: res.data.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + res.data.path, + id: res.data.id, + processId: state.formData.id, + projectId: res.data.projectId, + moduleType: res.data.moduleType + } + state.formData.deviceImages.push(obj); + // getBeforeFiles() } if(type == 2){ - getSiteCheckFiles() + let obj = { + name: res.data.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + res.data.path, + id: res.data.id, + processId: state.formData.id, + projectId: res.data.projectId, + moduleType: res.data.moduleType + } + state.formData.investingationImages.push(obj); + // getSiteCheckFiles() } if(type == 3){ - getCompanyFiles() + let obj = { + name: res.data.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + res.data.path, + id: res.data.id, + processId: state.formData.id, + projectId: res.data.projectId, + moduleType: res.data.moduleType + } + state.formData.companyImages.push(obj); + // getCompanyFiles() } if(type == 5){ + let obj = { + name: res.data.fileName, + url: import.meta.env.VITE_APP_BASE_API + '/' + res.data.path, + id: res.data.id, + processId: state.formData.id, + projectId: res.data.projectId, + moduleType: res.data.moduleType + } + state.formData.assAccessoryFiles.push(obj); console.log(res,'res') - getSafetyFiles() + // getSafetyFiles() } }else{ ElMessage({ type: 'warning', - message: '文件上传失败' + message: res.message }) } } const handleRemove = async (file, uploadFiles,type) => { - ElMessageBox.confirm( - '确定删除该附件?', - '提示', - { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - }) - .then( async() => { - const res = await delFile(file.id) - if(res.code == 200){ - ElMessage({ - type: 'success', - message: '文件已删除' - }) - if(type == 1){ - await getBeforeFiles() + + ElMessageBox.confirm( + '确定删除该附件?', + '提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + }) + .then( async() => { + const res = await delFile(file.id) + if(res.code == 200){ + ElMessage({ + type: 'success', + message: '文件已删除' + }) + if(type == 1){ + const index = state.formData.deviceImages.findIndex(v => v.id === file.id) + state.formData.deviceImages.splice(index,1); + + } + if(type == 2){ + const index = state.formData.investingationImages.findIndex(v => v.id === file.id) + state.formData.investingationImages.splice(index,1); + + } + if(type == 3){ + const index = state.formData.companyImages.findIndex(v => v.id === file.id) + state.formData.companyImages.splice(index,1); + } + if(type == 5){ + const index = state.formData.assAccessoryFiles.findIndex(v => v.id === file.id) + state.formData.assAccessoryFiles.splice(index,1); + } + }else{ + ElMessage({ + type: 'warning', + message: res.message + }) } - if(type == 2){ - await getSiteCheckFiles() - } - if(type == 3){ - await getCompanyFiles() - } - if(type == 5){ - await getSafetyFiles() - } - }else{ - ElMessage({ - type: 'warning', - message: res.message - }) - } - }) - .catch(()=>{ - if(type == 1){ - getBeforeFiles() - } - if(type == 2){ - getSiteCheckFiles() - } - if(type == 3){ - getCompanyFiles() - } - if(type == 5){ - getSafetyFiles() - } - }) + }) + .catch(()=>{ + // if(type == 1){ + // getBeforeFiles() + // } + // if(type == 2){ + // getSiteCheckFiles() + // } + // if(type == 3){ + // getCompanyFiles() + // } + // if(type == 5){ + // getSafetyFiles() + // } + }) + } defineExpose({ @@ -516,5 +679,9 @@ font-size: 15px; } } +.textColor{ + color: #3b82f6; +} + </style> -- Gitblit v1.9.2