瀏覽代碼

迭代四调整

zhangyihao 8 月之前
父節點
當前提交
3c225fa709

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

@@ -101,7 +101,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 {

+ 11 - 33
src/views/emergencyCommandMap/RightSection/SelectPlan.vue

@@ -14,13 +14,10 @@
         <button class="custom-button" @click="startSelectedPlan">确定并启动预案</button>
       </span>
     </template>
-    <StartPlan v-if="startPlanVisible" :title="startPlanTitle" :event-id="eventId" />
   </el-dialog>
 </template>
-
 <script lang="ts" setup>
 import { listPlan, launchPlan } from '@/api/duty/eventing';
-import StartPlan from '@/views/emergencyCommandMap/RightSection/StartPlan.vue';
 
 // 用于存储预案信息的数组
 const plans = ref([]);
@@ -41,7 +38,7 @@ const props = withDefaults(
 );
 
 // 定义组件事件
-const emits = defineEmits(['update:modelValue']);
+const emits = defineEmits(['update:modelValue', 'updatePlan']);
 
 // 控制内部模型值
 const isDialogVisible = ref(props.modelValue);
@@ -61,8 +58,6 @@ watch(
 );
 
 // 控制对话框的显示
-const startPlanVisible = ref(false);
-const startPlanTitle = ref('启动预案');
 const eventId = ref(props.tempEventId);
 // 关闭对话框
 const handleCloseDialog = () => {
@@ -75,39 +70,22 @@ const startSelectedPlan = async () => {
     alert('请先选择预案!');
     return;
   }
-
   const selectedPlan = plans.value.find((plan) => plan.plan_id === selectedPlanId.value);
 
   if (!selectedPlan) {
     alert('未能找到所选预案的信息,请重试!');
     return;
   }
-
-  try {
-    const data = {
-      eventId: props.tempEventId,
-      plan_id: selectedPlan.plan_id.toString(),
-      response_level: selectedPlan.response_level
-    };
-
-    console.log('Sending data to launchPlan:', data); // 打印请求数据
-
-    const response = await launchPlan(data);
-    console.log('Launch Plan Response:', response); // 打印响应数据
-
-    if (response.status === 200 && response.data && response.data.code === 200 && response.data.msg === '启动预案成功') {
-      console.log('Setting startPlanVisible to true:', startPlanVisible.value); // 确认状态更新
-      alert('预案启动成功!');
-      eventId.value = props.tempEventId;
-      startPlanVisible.value = true;
-      console.log('Updated startPlanVisible:', startPlanVisible.value); // 确认状态更新
-    }
-  } catch (error) {
-    console.error('Error launching plan:', error);
-    if (error.response && error.response.data && error.response.data.error) {
-      alert(`启动预案失败:${error.response.data.error.message}`);
-    }
-  }
+  const data = {
+    eventId: props.tempEventId,
+    plan_id: selectedPlan.plan_id.toString(),
+    response_level: selectedPlan.response_level
+  };
+  console.log('Sending data to launchPlan:', data); // 打印请求数据
+  const response = await launchPlan(data);
+  console.log('Launch Plan Response:', response); // 打印响应数据
+  emits('update-plan', { planId: selectedPlan.plan_id, eventId: props.tempEventId }); // 发射 update-plan 事件
+  handleCloseDialog();
 };
 // 获取预案列表
 const fetchPlanList = async () => {

+ 11 - 20
src/views/emergencyCommandMap/RightSection/StartPlan.vue

@@ -75,7 +75,9 @@ import { ref, watch, defineProps, defineEmits, reactive } from 'vue';
 import { ElMessage } from 'element-plus';
 import TaskDelivery from './TaskDelivery.vue';
 import { matchingPlan, launchPlan } from '@/api/duty/eventing';
-
+// 内部状态
+const planTitle = ref(''); // 预案名称
+const selectedLevel = ref(''); // 默认响应等级为空
 // 定义组件接收的属性类型
 interface Props {
   modelValue: boolean;
@@ -83,14 +85,17 @@ interface Props {
   title: string;
   show?: boolean; // 新增 show 属性
 }
-
 // 初始化组件属性
 const props = defineProps<Props>();
-
-// 内部状态
 const show = ref(props.show ?? false); // 对话框是否可见
-const planTitle = ref(''); // 预案名称
-const selectedLevel = ref(''); // 默认响应等级为空
+watch(
+  () => props.modelValue,
+  () => {
+    show.value = props.modelValue;
+  },
+  { immediate: true }
+);
+
 const responseLevels = [
   // 响应等级选项
   { value: '1', name: '特重大(I级)' },
@@ -110,20 +115,6 @@ const planData = reactive({
 // 定义事件发射器
 const emit = defineEmits(['update:modelValue', 'update:show']);
 
-// 监听 modelValue 变化
-watch(
-  () => props.modelValue,
-  (newValue) => {
-    show.value = newValue;
-  }
-);
-// 监听 show 属性变化
-watch(
-  () => props.show,
-  (newValue) => {
-    show.value = newValue;
-  }
-);
 // 对话框关闭时执行的操作
 const onClose = () => {
   emit('update:show', false);

+ 10 - 5
src/views/emergencyCommandMap/RightSection/index.vue

@@ -38,8 +38,8 @@
     <RightTop :event-id="eventId" />
     <JointDuty />
   </div>
-  <StartPlan v-model="startPlanState.show" :title="startPlanState.title" :event-id="eventId" />
-  <SelectPlan v-model="selectPlanState.show" :title="selectPlanState.title" :temp-event-id="tempEventId" />
+  <StartPlan v-model="startPlanState.show" :title="startPlanState.title" :event-id="startPlanState.eventId" />
+  <SelectPlan v-model="selectPlanState.show" :title="selectPlanState.title" :temp-event-id="tempEventId" @update-plan="updatePlan" />
 </template>
 
 <script lang="ts" setup>
@@ -65,6 +65,7 @@ const startPlanState = reactive({
 const selectPlanState = reactive({
   show: false,
   title: '',
+  tempEventId: '',
   plans: [] as { id: number; name: string }[]
 });
 
@@ -85,12 +86,10 @@ const startPlan = () => {
       console.log('DOM updated, showing StartPlan:', startPlanState.show);
     });
   } else if (tempEventId.value) {
-    // 如果没有eventId但有tempEventId,则显示SelectPlan弹窗并传递tempEventId
     selectPlanState.title = '预案任务下发';
+    selectPlanState.tempEventId = tempEventId.value;
     selectPlanState.show = true;
     console.log('Showing SelectPlan with state:', selectPlanState.show, 'and tempEventId:', tempEventId.value);
-    // 传递 tempEventId 给 SelectPlan
-    selectPlanState.tempEventId = tempEventId.value;
     loadPlans();
   }
 };
@@ -128,6 +127,12 @@ watchEffect(() => {
   console.log('Event ID from URL on dependency change:', eventId.value);
   console.log('Temp Event ID from URL on dependency change:', tempEventId.value);
 });
+const updatePlan = (data: { eventId: string }) => {
+  console.log('Received  event ID:', data);
+  startPlanState.title = '启动预案';
+  startPlanState.eventId = data.eventId;
+  startPlanState.show = true;
+};
 </script>
 
 <style lang="scss" scoped>