|
@@ -14,12 +14,12 @@
|
|
|
<button class="custom-button" @click="startSelectedPlan">确定并启动预案</button>
|
|
|
</span>
|
|
|
</template>
|
|
|
- <StartPlan v-model="startPlanVisible" :title="startPlanTitle" />
|
|
|
+ <StartPlan v-if="startPlanVisible" :title="startPlanTitle" :event-id="eventId" />
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { listPlan } from '@/api/duty/eventing';
|
|
|
+import { listPlan, launchPlan } from '@/api/duty/eventing';
|
|
|
import StartPlan from '@/views/emergencyCommandMap/RightSection/StartPlan.vue';
|
|
|
|
|
|
// 用于存储预案信息的数组
|
|
@@ -32,17 +32,11 @@ const selectedPlanId = ref<number | null>(null);
|
|
|
const props = withDefaults(
|
|
|
defineProps<{
|
|
|
modelValue: boolean;
|
|
|
- event_id: string;
|
|
|
- plan_id: string;
|
|
|
- plan_name: string;
|
|
|
- response_level: string;
|
|
|
+ tempEventId: string;
|
|
|
}>(),
|
|
|
{
|
|
|
modelValue: false,
|
|
|
- event_id: '',
|
|
|
- plan_id: '',
|
|
|
- plan_name: '',
|
|
|
- response_level: ''
|
|
|
+ tempEventId: ''
|
|
|
}
|
|
|
);
|
|
|
|
|
@@ -68,19 +62,53 @@ watch(
|
|
|
|
|
|
// 控制对话框的显示
|
|
|
const startPlanVisible = ref(false);
|
|
|
-const startPlanTitle = ref('');
|
|
|
-
|
|
|
+const startPlanTitle = ref('启动预案');
|
|
|
+const eventId = ref(props.tempEventId);
|
|
|
// 关闭对话框
|
|
|
const handleCloseDialog = () => {
|
|
|
emits('update:modelValue', false);
|
|
|
};
|
|
|
|
|
|
// 启动预案
|
|
|
-const startSelectedPlan = () => {
|
|
|
- startPlanTitle.value = '启动预案';
|
|
|
- startPlanVisible.value = true;
|
|
|
-};
|
|
|
+const startSelectedPlan = async () => {
|
|
|
+ if (selectedPlanId.value === null) {
|
|
|
+ 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 fetchPlanList = async () => {
|
|
|
try {
|
|
@@ -90,9 +118,11 @@ const fetchPlanList = async () => {
|
|
|
console.log('Fetched plans:', response.data); // 调试信息
|
|
|
} else {
|
|
|
console.error('Invalid data format in the response:', response);
|
|
|
+ alert('无法获取预案列表,请稍后重试!');
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('Error fetching plan list:', error);
|
|
|
+ alert('无法获取预案列表,请稍后重试!');
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -107,10 +137,6 @@ onMounted(() => {
|
|
|
fetchPlanList();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
-// 调试信息
|
|
|
-console.log('Initial isDialogVisible:', isDialogVisible.value);
|
|
|
-console.log('Initial selectedPlanId:', selectedPlanId.value);
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|