<template>
|
<div class="riskBox">
|
<el-form ref="formRef" :model="state.formData" :rules="state.rules" class="register-form" label-position="top">
|
<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="(response, file, fileList) => handleAvatarSuccess(response, file, fileList, 1)"-->
|
<!-- :on-preview="handlePictureCardPreview"-->
|
<!-- v-model:file-list="state.socialList"-->
|
<!-- list-type="picture-card"-->
|
<!-- :before-upload="picSize"-->
|
<!-- :on-remove="(file, file_list)=>{handleRemove(file, file_list, 1)}"-->
|
<!-- >-->
|
<!-- <el-icon><Plus /></el-icon>-->
|
<!-- <template #tip>-->
|
<!-- <div class="el-upload__tip">上传jpg/png图片尺寸小于5M</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 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'}]
|
}
|
})
|
|
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
|
}
|
|
defineExpose({
|
riskOpen
|
});
|
|
|
</script>
|
<style scoped lang="scss">
|
.riskBox{
|
:deep(.el-form .el-form-item__label) {
|
font-size: 15px;
|
}
|
}
|
|
</style>
|