Browse Source

修改地址

Hwf 5 months ago
parent
commit
bd36d952ca

+ 3 - 3
src/api/duty/eventing.ts

@@ -50,11 +50,11 @@ export function getEventDetail(params) {
 }
 
 // 编辑事件
-export function editEvent(params) {
+export function editEvent(data) {
   return request({
     url: '/api/event_management/event/edit',
-    method: 'get',
-    params: params
+    method: 'post',
+    data: data
   });
 }
 

BIN
src/assets/images/edit.png


+ 14 - 2
src/types/components.d.ts

@@ -27,9 +27,12 @@ declare module 'vue' {
     ElAutocomplete: typeof import('element-plus/es')['ElAutocomplete']
     ElBadge: typeof import('element-plus/es')['ElBadge']
     ElButton: typeof import('element-plus/es')['ElButton']
+    ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
+    ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
     ElCol: typeof import('element-plus/es')['ElCol']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
+    ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDialog: typeof import('element-plus/es')['ElDialog']
     ElDivider: typeof import('element-plus/es')['ElDivider']
     ElDrawer: typeof import('element-plus/es')['ElDrawer']
@@ -40,19 +43,28 @@ declare module 'vue' {
     ElForm: typeof import('element-plus/es')['ElForm']
     ElFormItem: typeof import('element-plus/es')['ElFormItem']
     ElIcon: typeof import('element-plus/es')['ElIcon']
+    ElImage: typeof import('element-plus/es')['ElImage']
     ElInput: typeof import('element-plus/es')['ElInput']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
+    ElOption: typeof import('element-plus/es')['ElOption']
     ElPagination: typeof import('element-plus/es')['ElPagination']
     ElPopover: typeof import('element-plus/es')['ElPopover']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
+    ElSelect: typeof import('element-plus/es')['ElSelect']
+    ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
+    ElSkeletonItem: typeof import('element-plus/es')['ElSkeletonItem']
+    ElSlider: typeof import('element-plus/es')['ElSlider']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
     ElSwitch: typeof import('element-plus/es')['ElSwitch']
-    ElTable: typeof import('element-plus/es')['ElTable']
-    ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
+    ElTag: typeof import('element-plus/es')['ElTag']
     ElText: typeof import('element-plus/es')['ElText']
+    ElTimeline: typeof import('element-plus/es')['ElTimeline']
+    ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem']
     ElTooltip: typeof import('element-plus/es')['ElTooltip']
+    ElTree: typeof import('element-plus/es')['ElTree']
+    ElUpload: typeof import('element-plus/es')['ElUpload']
     ExcelEditor: typeof import('./../components/ExcelEditor/index.vue')['default']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FlvVideo: typeof import('./../components/FlvVideo/index.vue')['default']

+ 17 - 17
src/views/emergencyCommandMap/LeftSection/index.vue

@@ -31,7 +31,7 @@
       </div>
     </div>
     <div class="event-card">
-      <div class="common-title gradient-text">灾害信息</div>
+      <div class="common-title gradient-text">灾害信息<i class="icon-edit" @click="showPositionMap = true" /></div>
       <div class="card-content">
         <div class="event-box">
           <div class="event-item">
@@ -101,6 +101,7 @@
       :event-id="eventId"
       @update:event-title="updateEventTitle"
     />
+    <PositionMap v-if="showPositionMap" v-model:visible="showPositionMap" :id="eventId" @confirm="fetchEventDetail" />
   </div>
 </template>
 <script lang="ts" setup name="LeftSection">
@@ -110,12 +111,11 @@ import { ref, onMounted, onUnmounted, computed } from 'vue';
 import Communication from './Communication.vue';
 import CloseCommand from './CloseCommand.vue';
 import AssociatedEvent from './AssociatedEvent.vue';
+import PositionMap from '@/views/routineCommandMap/PositionMap.vue';
+
 const proxy = getCurrentInstance()?.proxy;
-const { mm_event_level } = toRefs<any>(
-  proxy?.useDict( 'mm_event_level')
-);
+const { mm_event_level } = toRefs<any>(proxy?.useDict('mm_event_level'));
 const route = useRoute();
-const router = useRouter();
 
 const eventId = ref('');
 
@@ -141,6 +141,7 @@ const eventData = ref({
   longitude: '',
   latitude: ''
 });
+let showPositionMap = ref(false);
 
 // 灾害信息卡片中的持续时间
 const duration = computed(() => {
@@ -219,15 +220,12 @@ function getWindDirection(angle) {
 
 const fetchEventDetail = () => {
   const id = eventId.value;
-  console.log('fetchEventDetail');
-  if (id && id !== eventData.value.event_id) {
+  if (id) {
     // 如果有 id,则正常获取事件详情
     getEventDetail({ event_id: id }).then((res) => {
       eventData.value = res.data;
-      console.log('Received del_flag:', eventData.value.del_flag);
       // 根据 del_flag 设置 flag
       closeCommandState.flag = eventData.value.del_flag === '0';
-      console.log('closeCommandState.flag:', closeCommandState.flag);
       // 初始化响应时间
       updateTime();
     });
@@ -279,7 +277,7 @@ onMounted(() => {
   // 从 URL 参数中获取 event_id
   eventId.value = route.query.event_id as string;
   // 获取事件数据并检查 del_flag
-  fetchEventDetail(eventId.value);
+  fetchEventDetail();
   fetchWeatherData();
   intervalId = setInterval(updateTime, 1000);
 });
@@ -289,13 +287,6 @@ onUnmounted(() => {
     clearInterval(intervalId);
   }
 });
-// 监听事件标题的变化
-watchEffect(() => {
-  if (eventData.value.event_title) {
-    // 每次事件标题变化时,重新获取事件详情
-    fetchEventDetail();
-  }
-});
 
 // 发射自定义事件
 defineExpose({
@@ -387,6 +378,15 @@ defineExpose({
     position: relative;
     animation-name: slideLeft;
     animation-duration: 1s;
+    .icon-edit {
+      display: inline-block;
+      width: 20px;
+      height: 20px;
+      background: url('@/assets/images/edit.png') no-repeat;
+      background-size: 100% 100%;
+      cursor: pointer;
+      margin-left: 6px;
+    }
     .card-content {
       width: 100%;
       //display: flex;

+ 72 - 36
src/views/routineCommandMap/PositionMap.vue

@@ -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>