|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
- <Dialog type="md" title="请选择事发地点" draggable height="780px" customShow @close="handleClose" @confirm="submit">
|
|
|
+ <Dialog type="md" :title="!!id ? '修改灾害信息' : '请选择事发地点'" draggable height="780px" customShow @close="handleClose" @confirm="submit">
|
|
|
<div class="custom-dialog">
|
|
|
- <el-form ref="queryFormRef" :model="form" :rules="rules">
|
|
|
+ <el-form ref="queryFormRef" :model="form">
|
|
|
<div class="form">
|
|
|
<div class="line">
|
|
|
<div class="form-item" style="margin-right: 20px">
|
|
@@ -92,19 +92,28 @@
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
|
import { useRouter } from 'vue-router';
|
|
|
import { addEvent } from '@/api/emergencyCommandMap/JointDuty';
|
|
|
+import { editEvent, getEventDetail } from '@/api/duty/eventing';
|
|
|
|
|
|
const props = defineProps({
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ required: false
|
|
|
+ },
|
|
|
visible: {
|
|
|
type: Boolean,
|
|
|
default: () => {
|
|
|
return false;
|
|
|
}
|
|
|
+ },
|
|
|
+ flag: {
|
|
|
+ type: Boolean,
|
|
|
+ required: false
|
|
|
}
|
|
|
});
|
|
|
const proxy = getCurrentInstance()?.proxy;
|
|
|
const { mm_event_level } = toRefs(proxy?.useDict('mm_event_level'));
|
|
|
const router = useRouter();
|
|
|
-const emits = defineEmits(['update:visible']);
|
|
|
+const emits = defineEmits(['update:visible', 'confirm']);
|
|
|
// 地图对象
|
|
|
let map = null;
|
|
|
let amap = {};
|
|
@@ -127,7 +136,7 @@ const hours = String(now.getHours()).padStart(2, '0');
|
|
|
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
|
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
|
const currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
|
|
-let form = reactive({
|
|
|
+let form = ref({
|
|
|
address: '',
|
|
|
longitude: '',
|
|
|
latitude: '',
|
|
@@ -153,7 +162,14 @@ watch(
|
|
|
(n) => {
|
|
|
if (n) {
|
|
|
nextTick(() => {
|
|
|
- initMap();
|
|
|
+ if (props.id) {
|
|
|
+ getEventDetail({ event_id: props.id }).then((res) => {
|
|
|
+ form.value = res.data;
|
|
|
+ initMap();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ initMap();
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
},
|
|
@@ -173,7 +189,7 @@ onUnmounted(() => {
|
|
|
window.removeEventListener('resize', handleResize);
|
|
|
});
|
|
|
function handleInput(flag) {
|
|
|
- if (!form.address) return;
|
|
|
+ if (!form.value.address) return;
|
|
|
|
|
|
if (!flag) {
|
|
|
//搜索
|
|
@@ -191,7 +207,7 @@ function handleInput(flag) {
|
|
|
|
|
|
searchPop.value = true;
|
|
|
placeSearch.setPageIndex(pageNum.value);
|
|
|
- placeSearch.search(form.address, (status, result) => {
|
|
|
+ placeSearch.search(form.value.address, (status, result) => {
|
|
|
// console.log(result.poiList.pois, 'result')
|
|
|
if (!!result.poiList && result.poiList.pois && result.poiList.pois.length > 0) {
|
|
|
let arr = [];
|
|
@@ -226,20 +242,20 @@ function closeSearchList() {
|
|
|
// 地图中心的平移至指定点位置
|
|
|
function handlePanTo(index) {
|
|
|
let lnglat = searchList.value[index].lnglat;
|
|
|
- form.address = searchList.value[index].name + '(' + searchList.value[index].address + ')';
|
|
|
- form.longitude = lnglat[0];
|
|
|
- form.latitude = lnglat[1];
|
|
|
+ form.value.address = searchList.value[index].name + '(' + searchList.value[index].address + ')';
|
|
|
+ form.value.longitude = lnglat[0];
|
|
|
+ form.value.latitude = lnglat[1];
|
|
|
|
|
|
map.panTo(lnglat);
|
|
|
setMarks(lnglat);
|
|
|
closeSearchList();
|
|
|
}
|
|
|
const updateForm = (position) => {
|
|
|
- form.longitude = position[0];
|
|
|
- form.latitude = position[1];
|
|
|
+ form.value.longitude = position[0];
|
|
|
+ form.value.latitude = position[1];
|
|
|
geocoder.getAddress(position, (status, result) => {
|
|
|
if (status === 'complete' && result.info === 'OK') {
|
|
|
- form.address = result.regeocode.formattedAddress;
|
|
|
+ form.value.address = result.regeocode.formattedAddress;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -279,10 +295,10 @@ function ContextMenu() {
|
|
|
contextMenu.addItem(
|
|
|
'选择标点',
|
|
|
() => {
|
|
|
- form.longitude = lnglatPosition.value[0];
|
|
|
- form.latitude = lnglatPosition.value[1];
|
|
|
+ form.value.longitude = lnglatPosition.value[0];
|
|
|
+ form.value.latitude = lnglatPosition.value[1];
|
|
|
contextMenu.close();
|
|
|
- const lnglat = [form.longitude, form.latitude];
|
|
|
+ const lnglat = [form.value.longitude, form.value.latitude];
|
|
|
updateForm(lnglat);
|
|
|
setMarks(lnglat);
|
|
|
},
|
|
@@ -320,7 +336,6 @@ function handleClose() {
|
|
|
let queryFormRef = ref();
|
|
|
let containerRef = ref();
|
|
|
function handleResize() {
|
|
|
- debugger
|
|
|
const containerWidth = containerRef.value.clientWidth * (document.body.clientWidth / 1920);
|
|
|
const containerHeight = containerRef.value.clientHeight * (document.body.clientHeight / 1080);
|
|
|
width.value = containerWidth + 'px';
|
|
@@ -328,26 +343,47 @@ function handleResize() {
|
|
|
map.resize();
|
|
|
}
|
|
|
function submit() {
|
|
|
- if (!form.address) {
|
|
|
- proxy('详细地址不能为空');
|
|
|
- } else if (!form.longitude) {
|
|
|
- showErrorMsg('经度不能为空');
|
|
|
- } else if (!form.latitude) {
|
|
|
- showErrorMsg('纬度不能为空');
|
|
|
+ if (!form.value.address) {
|
|
|
+ proxy.$modal.msgError('详细地址不能为空');
|
|
|
+ } else if (!form.value.longitude) {
|
|
|
+ proxy.$modal.msgError('经度不能为空');
|
|
|
+ } else if (!form.value.latitude) {
|
|
|
+ proxy.$modal.msgError('纬度不能为空');
|
|
|
} else {
|
|
|
- addEvent(form).then((res) => {
|
|
|
- router.push({
|
|
|
- path: '/emergencyCommandMap',
|
|
|
- query: {
|
|
|
- event_id: res.data
|
|
|
- }
|
|
|
+ if (!!props.id) {
|
|
|
+ let temp = {};
|
|
|
+ temp.address = form.value.address;
|
|
|
+ temp.casualties = form.value.casualties;
|
|
|
+ temp.contact = form.value.contact;
|
|
|
+ temp.create_time = form.value.create_time;
|
|
|
+ temp.deaths = form.value.deaths;
|
|
|
+ temp.del_flag = form.value.del_flag;
|
|
|
+ temp.eventId = form.value.event_id;
|
|
|
+ temp.event_code = temp.eventId;
|
|
|
+ temp.description = form.value.description;
|
|
|
+ temp.event_level = form.value.event_level;
|
|
|
+ temp.event_source = form.value.event_source;
|
|
|
+ temp.event_status = form.value.event_status;
|
|
|
+ temp.event_time = form.value.event_time;
|
|
|
+ temp.event_title = form.value.event_title;
|
|
|
+ temp.event_type = form.value.event_type;
|
|
|
+ temp.id = form.value.id;
|
|
|
+ temp.injuries = form.value.injuries;
|
|
|
+ temp.latitude = form.value.latitude;
|
|
|
+ temp.longitude = form.value.longitude;
|
|
|
+ temp.missing = form.value.missing;
|
|
|
+ temp.plan_id = form.value.plan_id;
|
|
|
+ temp.recorded_by = form.value.recorded_by;
|
|
|
+ temp.region_code = form.value.region_code;
|
|
|
+ temp.report_time = form.value.report_time;
|
|
|
+ temp.response_level = form.value.response_level;
|
|
|
+ editEvent(temp).then(() => {
|
|
|
+ proxy.$modal.msgSuccess('修改成功');
|
|
|
+ emits('update:visible', false);
|
|
|
+ emits('confirm');
|
|
|
});
|
|
|
- });
|
|
|
- }
|
|
|
- queryFormRef.value.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- console.log('提交数据', form);
|
|
|
- addEvent(form).then((res) => {
|
|
|
+ } else {
|
|
|
+ addEvent(form.value).then((res) => {
|
|
|
router.push({
|
|
|
path: '/emergencyCommandMap',
|
|
|
query: {
|
|
@@ -356,7 +392,7 @@ function submit() {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|