|
@@ -26,7 +26,7 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { ref, reactive, toRefs } from 'vue';
|
|
|
-import { editEvent, registeredEvent } from '@/api/duty/eventing';
|
|
|
+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'));
|
|
@@ -36,14 +36,20 @@ const eventFormRef = ref();
|
|
|
const visible = ref(false);
|
|
|
const events = ref([]);
|
|
|
const route = useRoute();
|
|
|
-const idFromUrl = route.query.id as string;
|
|
|
+// 从 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']);
|
|
@@ -70,7 +76,10 @@ const initFormData = {
|
|
|
event_id: '',
|
|
|
event_type: '', // 事件类型
|
|
|
event_level: '', // 事件等级
|
|
|
- event_status: '0' // 事件状态
|
|
|
+ event_status: '0', // 事件状态
|
|
|
+ address: address, // 地址
|
|
|
+ latitude: latitude, // 纬度
|
|
|
+ longitude: longitude // 经度
|
|
|
};
|
|
|
|
|
|
// 表单数据
|
|
@@ -92,8 +101,10 @@ const submitForm = async () => {
|
|
|
try {
|
|
|
// 构造请求参数
|
|
|
const params = {
|
|
|
- event_id: form.value.event_id,
|
|
|
- command_id: idFromUrl // 从URL中获取的id
|
|
|
+ eventId: form.value.event_id,
|
|
|
+ address: form.value.address,
|
|
|
+ latitude: form.value.latitude,
|
|
|
+ longitude: form.value.longitude
|
|
|
};
|
|
|
console.log('Sending request with params:', params); // 添加调试信息
|
|
|
// 提交关闭事件请求
|
|
@@ -115,22 +126,7 @@ const submitForm = async () => {
|
|
|
});
|
|
|
});
|
|
|
};
|
|
|
-// 提交关闭事件请求
|
|
|
-const closeEvent = async (params) => {
|
|
|
- try {
|
|
|
- console.log('Attempting to close event with params:', params); // 添加调试信息
|
|
|
- await request({
|
|
|
- url: '/api/event_management/event/close',
|
|
|
- method: 'post',
|
|
|
- data: params
|
|
|
- });
|
|
|
- proxy?.$modal.msgSuccess('已成功关闭');
|
|
|
- closeDialog();
|
|
|
- } catch (error) {
|
|
|
- console.error('Failed to close event:', error);
|
|
|
- throw error;
|
|
|
- }
|
|
|
-};
|
|
|
+
|
|
|
// 获取注册的事件列表
|
|
|
const fetchEvents = async () => {
|
|
|
try {
|
|
@@ -150,21 +146,20 @@ 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,则提交表单
|
|
|
+ // 使用 async/await 来等待表单提交的结果
|
|
|
submitForm()
|
|
|
.then(() => {
|
|
|
// 提交成功后的处理
|
|
|
console.log('Form submitted successfully.');
|
|
|
closeDialog();
|
|
|
+ // 关闭对话框后返回上一级页面
|
|
|
+ router.go(-1);
|
|
|
})
|
|
|
.catch((error) => {
|
|
|
// 提交失败后的处理
|
|
@@ -174,7 +169,7 @@ const endProcess = () => {
|
|
|
} else {
|
|
|
// 如果有 eventId,则直接关闭对话框并返回上一页
|
|
|
closeDialog();
|
|
|
- router.go(-1);
|
|
|
+ router.go(-1); // 立即返回上一级页面
|
|
|
}
|
|
|
};
|
|
|
// 确保在点击结束指挥时重新显示对话框
|