<template>
|
<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="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">记录编号:{{ 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" :checked="chooseItem.id === item.id" type="primary" @click="chooseRecord(item,index)">记录编号{{ index+1 }}</el-check-tag>
|
</div>
|
</div>
|
</div>
|
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="6">
|
<el-form-item prop="investigationDate" label="现场勘验时间">
|
<el-date-picker
|
style="width: 100%"
|
v-model="state.formData.investigationDate"
|
type="date"
|
value-format="YYYY-MM-DD 00:00:00"
|
placeholder="选择日期"
|
size="large"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item prop="location" label="现场勘验位置">
|
<el-input
|
v-model="state.formData.location"
|
size="large"
|
placeholder="请填写现场勘验位置"
|
>
|
<template #append>
|
<el-button :icon="Search" @click="openLocation"/>
|
</template>
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="6">
|
<el-form-item prop="isSafetyCheck" label="编制现场安全检查表">
|
<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>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="24" v-if="state.formData.isSafetyCheck == 1">
|
<el-form-item label="安全检查表上传" prop="assAccessoryFiles">
|
<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>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24" v-if="state.formData.isSafetyCheck == 0">
|
<el-form-item prop="recordData" label="现场勘验记录">
|
<el-input
|
v-model="state.formData.recordData"
|
:autosize="{ minRows: 6 }"
|
maxlength="200"
|
show-word-limit
|
type="textarea">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<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/*" :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>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<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/*" :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>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
</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="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>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<el-dialog v-model="state.imgDialog">
|
<img style="width: 100%" :src="state.imgUrl" alt="Preview Image" />
|
</el-dialog>
|
<map-location ref="mapLocationRef" @giveLatLng="achieveLatLng"></map-location>
|
</div>
|
</template>
|
<script setup>
|
|
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,
|
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('请上传现场安全检查表'))
|
}else{
|
callback()
|
}
|
}
|
|
let checkInvestFiles = (rule, value, callback)=>{
|
if(state.siteCheckList.length === 0){
|
callback(new Error('请上传现场勘验照片'))
|
}else{
|
callback()
|
}
|
}
|
|
let checkCompanyFiles = (rule, value, callback)=>{
|
if(state.companyList.length === 0){
|
callback(new Error('请上传企业陪同人员照片'))
|
}else{
|
callback()
|
}
|
}
|
|
|
|
const state = reactive({
|
data: [],
|
formData: {
|
id: null,
|
projectId: null,
|
investigationDate: '',
|
location: '',
|
isSafetyCheck: null,
|
recordData: '',
|
assAccessoryFiles: [],
|
deviceImages: [],
|
investingationImages: [],
|
companyImages:[]
|
},
|
projectId: null,
|
planPersons: [],
|
rules: {
|
investigationDate: [{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'}],
|
// ccompanyImages: [{required: true, validator: checkCompanyFiles, trigger: 'blur'}]
|
},
|
beforeDeviceList: [],
|
siteCheckList: [],
|
companyList: [],
|
safetyList: [],
|
imgLimit: 1,
|
uploadUrl: import.meta.env.VITE_APP_BASE_API + '/manage/accessory-file/uploadFile',
|
header: {
|
Authorization: getToken()
|
},
|
imgDialog: false,
|
imgUrl: ''
|
})
|
|
const isAmin = ref(false)
|
const formRef = ref()
|
const mapLocationRef = ref()
|
onMounted(() => {
|
const userInfo = JSON.parse(Cookies.get('userInfo'))
|
if(userInfo.identity === 0){
|
isAmin.value = true;
|
}
|
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){
|
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)
|
}
|
if(type === 'add' || type === 'clickEdit') {
|
const valid = await formRef.value.validate();
|
if(valid){
|
if (isAmin.value) {
|
ElMessage.warning("当前用户暂无权限");
|
return;
|
}
|
if(type === 'add'){
|
if(!state.data.length >0){
|
await saveData(val);
|
}else {
|
await editData();
|
}
|
}else if(type === 'clickEdit'){
|
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,processId:chooseItem.value.id })
|
if(res.code == 200){
|
if(res.data && res.data.length>0){
|
state.beforeDeviceList = res.data.map(i=>{
|
return {
|
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=[]
|
}
|
}else {
|
ElMessage.warning(res.message)
|
}
|
}
|
|
const getSiteCheckFiles = async (id)=>{
|
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=>{
|
return {
|
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 = []
|
}
|
}else {
|
ElMessage.warning(res.message)
|
}
|
}
|
|
const getCompanyFiles = async (id)=>{
|
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=>{
|
return {
|
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=[]
|
}
|
}else {
|
ElMessage.warning(res.message)
|
}
|
}
|
|
const getSafetyFiles = async (id)=>{
|
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.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 = []
|
}
|
}else {
|
ElMessage.warning(res.message)
|
}
|
}
|
|
const openLocation = ()=>{
|
mapLocationRef.value.openMapLocation(state.formData.location.split(',')[0],state.formData.location.split(',')[1])
|
}
|
|
const achieveLatLng=(lng,lat)=>{
|
state.formData.location = lng + ',' + lat
|
}
|
|
// 图片上传
|
const showTip =()=>{
|
ElMessage({
|
type: 'warning',
|
message: '超出文件上传数量'
|
});
|
}
|
|
const picSize = async (rawFile) => {
|
if(rawFile.size / 1024 / 1024 > 5){
|
ElMessage({
|
type: 'warning',
|
message: '文件大小不能超过5M'
|
});
|
return false
|
}
|
};
|
|
const handlePictureCardPreview = (uploadFile) => {
|
console.log(uploadFile,'file')
|
state.imgUrl = uploadFile.url
|
state.imgDialog = true
|
};
|
|
|
const handleAvatarSuccess = (res, uploadFile, type) => {
|
if(res.code == 200){
|
if(type == 1){
|
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){
|
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){
|
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()
|
}
|
}else{
|
ElMessage({
|
type: 'warning',
|
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){
|
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
|
})
|
}
|
})
|
.catch(()=>{
|
// if(type == 1){
|
// getBeforeFiles()
|
// }
|
// if(type == 2){
|
// getSiteCheckFiles()
|
// }
|
// if(type == 3){
|
// getCompanyFiles()
|
// }
|
// if(type == 5){
|
// getSafetyFiles()
|
// }
|
})
|
|
}
|
|
defineExpose({
|
riskOpen
|
});
|
|
|
</script>
|
<style scoped lang="scss">
|
.riskBox{
|
:deep(.el-form .el-form-item__label) {
|
font-size: 15px;
|
}
|
}
|
.textColor{
|
color: #3b82f6;
|
}
|
|
|
</style>
|