|
@@ -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 () => {
|