<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="18">
|
<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">
|
<el-col :span="6">
|
<el-form-item prop="investigationDate" label="现场勘验时间">
|
<el-date-picker
|
style="width: 100%"
|
v-model="state.formData.investigationPlanDate"
|
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="investigationDate" 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">
|
<el-radio :label="true" size="large">是</el-radio>
|
<el-radio :label="false" size="large">否</el-radio>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row :gutter="30">
|
<el-col :span="6">
|
<el-form-item label="附件上传">
|
<el-upload accept="image/*" :action="state.uploadUrl" :headers="state.header" method="post" :on-success="handleAvatarSuccess" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='state.imgLimit' v-model:file-list="state.fileList" list-type="picture-card" :before-upload="picSize" :on-remove="handleRemove" :before-remove="beforeRemove">
|
<el-icon><Plus /></el-icon>
|
<template #tip>
|
<div class="el-upload__tip">上传jpg/png图片尺寸小于5M,最多可上传1张</div>
|
</template>
|
</el-upload>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<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-form-item label="企业陪同照片">
|
|
</el-form-item>
|
</el-form>
|
<map-location ref="mapLocationRef" @giveLatLng="achieveLatLng"></map-location>
|
</div>
|
</template>
|
<script setup>
|
|
import {defineEmits, onMounted, reactive, ref} from "vue"
|
import {ElMessage} from "element-plus"
|
import {Search} from '@element-plus/icons-vue'
|
import {addRisk, editRisk, getRiskDetail} from "@/api/projectManage/riskAnalysis"
|
import {delPic} from "@/api/login"
|
import { getToken } from "@/utils/auth";
|
import Cookies from "js-cookie"
|
const emit = defineEmits(["getNextStatus"])
|
import MapLocation from "./mapLocation.vue"
|
|
const state = reactive({
|
formData: {
|
id: null,
|
projectId: null,
|
investigationDate: '',
|
location: '',
|
isSafetyCheck: null,
|
recordData: ''
|
},
|
planPersons: [],
|
rules: {
|
recordData: [{required: true, message: '请填写现场勘验记录', trigger: 'blur'}]
|
},
|
imgLimit: 1,
|
uploadUrl: import.meta.env.VITE_APP_BASE_API + '/system/common/uploadFile',
|
header: {
|
Authorization: 'Bearer ' + getToken()
|
}
|
})
|
|
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;
|
}
|
});
|
|
const riskOpen = async (type,val) => {
|
console.log("type",type,val)
|
if(type === 'detail' || type === 'edit' ){
|
const res = await getRiskDetail({projectId: val});
|
if(res.code == 200){
|
state.formData = res.data;
|
state.formData.project.business = parseInt(res.data.project.business);
|
state.formData.project.area = [res.data.project.province,res.data.project.city];
|
}else {
|
ElMessage.warning(res.message)
|
}
|
}
|
if(type === 'add' || type === 'clickEdit') {
|
const valid = await formRef.value.validate();
|
if(valid){
|
if (isAmin.value) {
|
ElMessage.warning("当前用户暂无权限");
|
return;
|
}
|
if(type === 'add'){
|
const {projectId, ...data} = JSON.parse(JSON.stringify(state.formData))
|
const res = await addRisk(data);
|
if (res.code == 200) {
|
ElMessage.success('保存成功')
|
formRef.value.clearValidate();
|
emit('getNextStatus', res.data);
|
|
} else {
|
ElMessage.warning(res.message)
|
}
|
}else if(type === 'clickEdit'){
|
const { ...data} = JSON.parse(JSON.stringify(state.formData))
|
const res = await editRisk(data);
|
if (res.code == 200) {
|
ElMessage.success('变更成功')
|
formRef.value.clearValidate();
|
// emit('getNextStatus', data.project.id);
|
} 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) => {
|
state.dialogImageUrl = uploadFile.url
|
state.dialogImg = true
|
};
|
|
|
const handleAvatarSuccess = (res, uploadFile) => {
|
if(res.code == 200){
|
// state.registerForm.agency.reportPath = res.data.path
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: '文件上传失败'
|
})
|
}
|
}
|
|
const handleRemove = async (file, uploadFiles) => {
|
const res = await delPic({path: state.registerForm.agency.reportPath})
|
if(res.code == 200){
|
ElMessage({
|
type: 'success',
|
message: '文件已删除'
|
})
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.message
|
})
|
}
|
}
|
|
defineExpose({
|
riskOpen
|
});
|
|
|
</script>
|
<style scoped lang="scss">
|
.riskBox{
|
:deep(.el-form .el-form-item__label) {
|
font-size: 15px;
|
}
|
}
|
|
</style>
|