Browse Source

Merge remote-tracking branch 'origin/dev' into dev

Hwf 8 months ago
parent
commit
594d1d7f88

+ 22 - 0
src/api/emergencyCommandMap/JointDuty.ts

@@ -37,3 +37,25 @@ export function getCheckinList(eventId: string) {
     }
   });
 }
+
+// 更新事发地点 (用于将表单数据发送到服务器以更新某个事件的位置信息)
+export function updateEventLocation(evevtId: string, address: string, longitude: string, latitude: string) {
+  return request({
+    url: '/api/event_management/event/save_address',
+    method: 'post',
+    params: {
+      eventId: eventId,
+      address: address,
+      longitude: longitude,
+      latitude: latitude
+    }
+  });
+}
+
+export function addEvent(data) {
+  return request({
+    url: '/api/event_management/event/create',
+    method: 'post',
+    data: data
+  });
+}

+ 10 - 1
src/components/Map/company-map.vue

@@ -77,6 +77,7 @@
 <script setup>
 import AMapLoader from '@amap/amap-jsapi-loader';
 import { useRouter } from 'vue-router';
+import { updateEventLocation } from '@/api/emergencyCommandMap/JointDuty';
 
 const props = defineProps({
   visible: {
@@ -108,6 +109,7 @@ let searchList = ref([]);
 let searchPop = ref(false);
 let placeSearch;
 let form = reactive({
+  eventId: '',
   address: '',
   longitude: '',
   latitude: ''
@@ -281,11 +283,18 @@ function submit() {
       console.log('提交数据', form);
       router.push({
         path: '/emergencyCommandMap',
-        query: { event_id: '11111111' }
+        query: { event_id: eventId.value }
       });
     }
   });
 }
+// 获取event_id
+updateEventLocation().then((res) => {
+  form.event_id = res.data.event_id;
+  form.address = res.data.address;
+  form.latitude = res.data.latitude;
+  form.longitude = res.data.longitude;
+});
 </script>
 
 <style lang="scss" scoped>

+ 0 - 7
src/types/components.d.ts

@@ -45,9 +45,6 @@ declare module 'vue' {
     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']
-    ElRadio: typeof import('element-plus/es')['ElRadio']
-    ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSelect: typeof import('element-plus/es')['ElSelect']
@@ -64,8 +61,6 @@ declare module 'vue' {
     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']
-    ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
     ElUpload: typeof import('element-plus/es')['ElUpload']
     FileUpload: typeof import('./../components/FileUpload/index.vue')['default']
     FooterSection: typeof import('./../components/FooterSection/index.vue')['default']
@@ -76,7 +71,6 @@ declare module 'vue' {
     HikvisionPlayer: typeof import('./../components/HKVideo/hikvision-player.vue')['default']
     HKVideo: typeof import('./../components/HKVideo/index.vue')['default']
     IconSelect: typeof import('./../components/IconSelect/index.vue')['default']
-    IEpUploadFilled: typeof import('~icons/ep/upload-filled')['default']
     IFrame: typeof import('./../components/iFrame/index.vue')['default']
     ImagePreview: typeof import('./../components/ImagePreview/index.vue')['default']
     ImageUpload: typeof import('./../components/ImageUpload/index.vue')['default']
@@ -105,7 +99,6 @@ declare module 'vue' {
     UserSelect: typeof import('./../components/UserSelect/index.vue')['default']
     VideoContainer: typeof import('./../components/HKVideo/video-container.vue')['default']
     YMap: typeof import('./../components/Map/YMap.vue')['default']
-    YMapold: typeof import('./../components/Map/YMapold.vue')['default']
     YztMap: typeof import('./../components/Map/YztMap/index.vue')['default']
   }
   export interface ComponentCustomProperties {

+ 63 - 34
src/views/emergencyCommandMap/LeftSection/CloseCommand.vue

@@ -26,8 +26,8 @@
 
 <script lang="ts" setup>
 import { ref, reactive, toRefs } from 'vue';
-import { editEvent, registeredEvent } from '@/api/duty/eventing';
-import { useRouter } from 'vue-router';
+import { editEvent, registeredEvent, closeEvent } from '@/api/duty/eventing';
+import { useRouter, useRoute } from 'vue-router';
 const proxy = getCurrentInstance()?.proxy;
 const { mm_event_title, region } = toRefs<any>(proxy?.useDict('mm_event_title', 'region'));
 const router = useRouter();
@@ -35,13 +35,21 @@ const buttonLoading = ref(false);
 const eventFormRef = ref();
 const visible = ref(false);
 const events = ref([]);
+const route = useRoute();
+// 从 URL 查询字符串中解析参数
+const urlParams = new URLSearchParams(route.query);
+const address = urlParams.get('address') || '';
+const latitude = urlParams.get('latitude') || '';
+const longitude = urlParams.get('longitude') || '';
 interface Props {
   modelValue: boolean;
   eventId: string;
   title: string;
 }
 const props = withDefaults(defineProps<Props>(), {
-  modelValue: false
+  modelValue: false,
+  eventId: '',
+  title: ''
 });
 
 const emits = defineEmits(['update:modelValue']);
@@ -68,17 +76,17 @@ const initFormData = {
   event_id: '',
   event_type: '', // 事件类型
   event_level: '', // 事件等级
-  event_status: '0' // 事件状态
+  event_status: '0', // 事件状态
+  address: address, // 地址
+  latitude: latitude, // 纬度
+  longitude: longitude // 经度
 };
 
 // 表单数据
 const data = reactive({
   form: { ...initFormData },
   rules: {
-    event_title: [{ required: true, message: '事件标题不能为空', trigger: 'blur' }],
-    event_type: [{ required: true, message: '事件类型不能为空', trigger: 'blur' }],
-    event_level: [{ required: true, message: '事件等级不能为空', trigger: 'blur' }],
-    event_status: [{ required: true, message: '事件状态不能为空', trigger: 'blur' }]
+    event_title: [{ required: true, message: '事件标题不能为空', trigger: 'blur' }]
   }
 });
 
@@ -86,24 +94,39 @@ const { form, rules } = toRefs(data);
 
 // 提交表单
 const submitForm = async () => {
-  eventFormRef.value?.validate(async (valid) => {
-    if (valid) {
-      buttonLoading.value = true;
-      try {
-        // 提交关闭事件请求
-        await closeEvent({
-          event_id: form.value.event_id,
-        });
-        proxy?.$modal.msgSuccess('已成功关闭');
-        closeDialog();
-      } catch (error) {
-        console.error('Failed to close event:', error);
-      } finally {
-        buttonLoading.value = false;
+  return new Promise((resolve, reject) => {
+    eventFormRef.value?.validate(async (valid) => {
+      if (valid) {
+        buttonLoading.value = true;
+        try {
+          // 构造请求参数
+          const params = {
+            eventId: form.value.event_id,
+            address: form.value.address,
+            latitude: form.value.latitude,
+            longitude: form.value.longitude
+          };
+          console.log('Sending request with params:', params); // 添加调试信息
+          // 提交关闭事件请求
+          await closeEvent(params);
+          proxy?.$modal.msgSuccess('已成功关闭');
+          resolve(); // 解析Promise表示成功
+          closeDialog();
+        } catch (error) {
+          console.error('Failed to close event:', error);
+          reject(error); // 拒绝Promise表示失败
+          proxy?.$message.error('关闭事件失败,请检查您的输入');
+        } finally {
+          buttonLoading.value = false;
+        }
+      } else {
+        reject(new Error('Validation failed')); // 验证失败也拒绝Promise
+        proxy?.$message.error('表单验证失败,请检查您的输入');
       }
-    }
+    });
   });
 };
+
 // 获取注册的事件列表
 const fetchEvents = async () => {
   try {
@@ -123,21 +146,30 @@ const closeDialog = () => {
   if (eventFormRef.value) {
     eventFormRef.value.resetFields();
   }
-  form.value.event_id = null;
+  form.value.event_id = '';
   form.value.event_title = '';
 };
 const endProcess = () => {
-  // 确保在点击结束指挥时重新显示对话框
-  ensureDialogVisible();
-
-  // 判断是否需要提交表单
+  // 如果没有 eventId,则提交表单
   if (props.eventId === '') {
-    // 如果没有 eventId,则提交表单
-    submitForm();
+    // 使用 async/await 来等待表单提交的结果
+    submitForm()
+      .then(() => {
+        // 提交成功后的处理
+        console.log('Form submitted successfully.');
+        closeDialog();
+        // 关闭对话框后返回上一级页面
+        router.go(-1);
+      })
+      .catch((error) => {
+        // 提交失败后的处理
+        console.error('Failed to submit the form:', error);
+        proxy?.$message.error('提交表单失败,请检查您的输入');
+      });
   } else {
     // 如果有 eventId,则直接关闭对话框并返回上一页
     closeDialog();
-    router.go(-1);
+    router.go(-1); // 立即返回上一级页面
   }
 };
 // 确保在点击结束指挥时重新显示对话框
@@ -159,8 +191,5 @@ const selectEvent = (item) => {
   // 更新表单中的 event_id 和 event_title
   form.value.event_id = item.event_id;
   form.value.event_title = item.event_title;
-
-  // 可以在这里进行其他逻辑处理
-  console.log('Selected event:', item);
 };
 </script>

+ 18 - 4
src/views/emergencyCommandMap/LeftSection/index.vue

@@ -187,9 +187,20 @@ const eventData = ref({
 });
 const fetchEventDetail = () => {
   console.log('fetchEventDetail');
-  getEventDetail({ event_id: eventId.value }).then((res) => {
-    eventData.value = res.data;
-  });
+  if (eventId.value) {
+    // 如果有eventId,则正常获取事件详情
+    getEventDetail({ event_id: eventId.value }).then((res) => {
+      eventData.value = res.data;
+      // 初始化响应时间
+      updateTime();
+    });
+  } else {
+    // 如果没有eventId,则从URL中获取address,并设置到eventData.address
+    eventData.value.address = route.query.address as string;
+    // 设置一个默认的事件时间,即当前时间
+    eventData.value.event_time = new Date().toISOString();
+    updateTime();
+  }
 };
 
 // 综合值守
@@ -291,6 +302,9 @@ const updateTime = () => {
     } else {
       console.error('Invalid date format:', eventData.value.event_time);
     }
+  } else {
+    // 如果没有event_time,则重置响应时间为0
+    elapsedTime.value = 0;
   }
 };
 
@@ -431,7 +445,7 @@ onUnmounted(() => {
           display: flex;
           justify-content: center;
           align-items: center;
-          width: 600px;
+          width: 650px;
           height: 82px;
           margin-top: 10px;
         }

+ 21 - 0
src/views/emergencyCommandMap/MiddleSection.vue

@@ -1,11 +1,20 @@
 <template>
   <div class="middle-section">
+    <div class="search-button">
+      <el-button type="primary" @click="handleQuery1">备战防御</el-button>
+      <el-button type="primary" :disabled="true" @click="handleQuery2">指挥调度</el-button>
+    </div>
     <GlobalMap is-component width="3321" height="2140" />
   </div>
 </template>
 
 <script lang="ts" setup>
 import GlobalMap from '@/views/globalMap/index.vue';
+import { useRouter } from 'vue-router';
+const router = useRouter();
+const handleQuery1 = () => {
+  router.push({ path: '/' });
+};
 </script>
 
 <style lang="scss" scoped>
@@ -15,6 +24,18 @@ import GlobalMap from '@/views/globalMap/index.vue';
   height: 2140px;
   animation: slideAndFade 1.5s;
 }
+.search-button {
+  position: absolute;
+  top: 240px;
+  left: 3700px;
+  z-index: 10;
+}
+.el-button {
+  width: 360px;
+  height: 100px;
+  padding: 20px 40px;
+  font-size: 48px;
+}
 
 @keyframes slideAndFade {
   0% {

+ 8 - 5
src/views/routineCommandMap/MiddleSection.vue

@@ -1,10 +1,10 @@
 <template>
   <div class="middle-section">
     <div class="search-button">
-      <el-button type="primary" @click="handleQuery1">备战防御</el-button>
+      <el-button type="primary" @click="handleQuery1" :disabled="true">备战防御</el-button>
       <el-button type="primary" @click="handleQuery2">指挥调度</el-button>
     </div>
-    <company-map v-model:visible="mapDialogVisible" />
+    <company-map v-model:visible="mapDialogVisible" @change="handleMapChange" />
     <GlobalMap is-component width="3894" height="2140" />
   </div>
 </template>
@@ -16,11 +16,13 @@ import { ref } from 'vue';
 import CompanyMap from './company-map.vue';
 
 const form = ref({
+  eventId: '',
   address: '',
   lon: '',
   lat: ''
 });
 const mapDialogVisible = ref(false);
+
 const handleQuery1 = () => {
   console.log('备战防御被点击');
 };
@@ -28,11 +30,12 @@ const handleQuery1 = () => {
 const handleQuery2 = () => {
   mapDialogVisible.value = true;
 };
+
 const handleMapChange = (data) => {
-  form.value.drillAddress = data.address;
+  form.value.address = data.address;
   form.value.lon = data.lnglat[0];
-  form.value.lat = data.lnglat[1];
-  mapDialogVisible.value = false;
+  form.value.lat = data.lat[1];
+  mapDialogVisible.value = true;
 };
 </script>
 

+ 9 - 30
src/views/routineCommandMap/company-map.vue

@@ -77,6 +77,7 @@
 <script setup>
 import AMapLoader from '@amap/amap-jsapi-loader';
 import { useRouter } from 'vue-router';
+import { updateEventLocation, addEvent } from '@/api/emergencyCommandMap/JointDuty';
 
 const props = defineProps({
   visible: {
@@ -137,7 +138,6 @@ onUnmounted(() => {
   }
   window.removeEventListener('resize', handleResize);
 });
-
 function handleInput(flag) {
   if (!location.value) return;
 
@@ -178,13 +178,11 @@ function handleInput(flag) {
     }
   });
 }
-
 function handleChangePage(newNum) {
   if (!searchPop.value) return;
   pageNum.value = newNum;
   this.handleInput(1);
 }
-
 function closeSearchList() {
   searchPop.value = false;
   location.value = '';
@@ -192,18 +190,17 @@ function closeSearchList() {
   total.value = 0;
   pageNum.value = 1;
 }
-
 // 地图中心的平移至指定点位置
 function handlePanTo(index) {
   let lnglat = searchList.value[index].lnglat;
-  form.longitude = searchList.value[index].name + '(' + searchList.value[index] + ')';
-  form.latitude = lnglat[0];
+  form.address = searchList.value[index].name + '(' + searchList.value[index].address + ')';
+  form.longitude = lnglat[0];
   form.latitude = lnglat[1];
+
   map.panTo(lnglat);
   setMarks(lnglat);
   closeSearchList();
 }
-
 const initMap = async () => {
   let position = [110.93154257997, 21.669064031332];
   const AMap = await AMapLoader.load({
@@ -226,7 +223,6 @@ const initMap = async () => {
   map.on('rightclick', handleRightclick);
   handleResize();
 };
-
 function ContextMenu() {
   contextMenu = new AMap.ContextMenu();
   contextMenu.addItem(
@@ -246,14 +242,12 @@ function ContextMenu() {
     1
   );
 }
-
 // 右键事件
 function handleRightclick(e) {
   let lnglat = [e.lnglat.getLng(), e.lnglat.getLat()];
   contextMenu.open(map, e.lnglat);
   lnglatPosition.value = lnglat;
 }
-
 function setMarks(lnglat) {
   //添加标记
   if (marker) map.remove(marker);
@@ -269,14 +263,11 @@ function setMarks(lnglat) {
   });
   marker.setMap(map);
 }
-
 function handleClose() {
   emits('update:visible', false);
 }
-
 let queryFormRef = ref();
 let containerRef = ref();
-
 function handleResize() {
   const containerWidth = containerRef.value.clientWidth * (document.body.clientWidth / 8960);
   const containerHeight = containerRef.value.clientHeight * (document.body.clientHeight / 2520);
@@ -286,14 +277,17 @@ function handleResize() {
     map.resize();
   });
 }
-
 function submit() {
   queryFormRef.value.validate((valid) => {
     if (valid) {
       console.log('提交数据', form);
       router.push({
         path: '/emergencyCommandMap',
-        query: { id: '11111111' }
+        query: {
+          address: form.address,
+          longitude: form.longitude,
+          latitude: form.latitude
+        }
       });
     }
   });
@@ -306,12 +300,10 @@ function submit() {
   background: rgba(0, 0, 0, 0.3);
   margin-bottom: 20px;
 }
-
 .map {
   width: 100%;
   height: 100%;
 }
-
 .search {
   width: 50%;
   position: absolute;
@@ -322,7 +314,6 @@ function submit() {
   border-radius: 3px;
   display: flex;
 }
-
 .btn {
   margin-left: 10px;
 }
@@ -337,7 +328,6 @@ function submit() {
   top: 70px;
   padding: 15px;
   border-radius: 3px;
-
   .close {
     position: absolute;
     right: 2%;
@@ -346,7 +336,6 @@ function submit() {
     font-size: 20px;
   }
 }
-
 .scroll {
   width: 100%;
   max-height: 250px;
@@ -388,7 +377,6 @@ function submit() {
     }
   }
 }
-
 ::v-deep {
   .el-scrollbar__wrap {
     overflow-x: hidden !important;
@@ -398,11 +386,9 @@ function submit() {
     display: none;
   }
 }
-
 .empty {
   margin: 20px 0;
 }
-
 .dialog-wrap {
   position: fixed;
   top: 50%;
@@ -413,7 +399,6 @@ function submit() {
   align-items: center;
   justify-content: center;
   font-size: 16px;
-
   .dialog {
     width: 4000px;
     height: 2000px;
@@ -422,29 +407,23 @@ function submit() {
     border-radius: 10px;
   }
 }
-
 .dialog {
   padding: 0 20px;
-
   .dialog-header {
     width: 100%;
     height: 70px;
     display: flex;
     justify-content: space-between;
     align-items: center;
-
     .dialog-title {
       font-size: 36px;
     }
-
     .icon-close {
       cursor: pointer;
     }
   }
-
   .dialog-content {
     padding: 10px 0;
-
     .map_box {
       width: calc(4000px - 50px) !important;
       height: calc(2000px - 200px) !important;