|
@@ -21,6 +21,22 @@
|
|
|
/>
|
|
/>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template #isEmergency>
|
|
|
|
|
+ <el-radio-group v-model="ruleFormData.isEmergency">
|
|
|
|
|
+ <el-radio :value="IS_EMERGENCY.EMERGENCY">是</el-radio>
|
|
|
|
|
+ <el-radio :value="IS_EMERGENCY.NOT_EMERGENCY">否</el-radio>
|
|
|
|
|
+ </el-radio-group>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template #eventType>
|
|
|
|
|
+ <el-select v-model="ruleFormData.eventType" placeholder="请选择应急事件类型" filterable>
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in emergencyEventDice"
|
|
|
|
|
+ :key="item.itemCode"
|
|
|
|
|
+ :label="item.itemValue"
|
|
|
|
|
+ :value="item.itemValue"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </template>
|
|
|
<template #isPush>
|
|
<template #isPush>
|
|
|
<el-radio-group v-model="ruleFormData.isPush">
|
|
<el-radio-group v-model="ruleFormData.isPush">
|
|
|
<el-radio :value="IS_PUSH.PUSH">是</el-radio>
|
|
<el-radio :value="IS_PUSH.PUSH">是</el-radio>
|
|
@@ -29,8 +45,8 @@
|
|
|
<SelectGroup
|
|
<SelectGroup
|
|
|
v-if="ruleFormData.isPush"
|
|
v-if="ruleFormData.isPush"
|
|
|
ref="selectGroupRef"
|
|
ref="selectGroupRef"
|
|
|
- :userGroupList="ruleFormData.userGroupList || []"
|
|
|
|
|
- @userGroupListChange="handleUserGroupListChange"
|
|
|
|
|
|
|
+ :user-group-list="ruleFormData.userGroupList || []"
|
|
|
|
|
+ @user-group-list-change="handleUserGroupListChange"
|
|
|
/>
|
|
/>
|
|
|
</template>
|
|
</template>
|
|
|
</BasicForm>
|
|
</BasicForm>
|
|
@@ -38,27 +54,79 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
- import { onMounted, ref } from 'vue';
|
|
|
|
|
|
|
+ import { onMounted, ref, watch } from 'vue';
|
|
|
import BasicForm from '@/components/BasicForm.vue';
|
|
import BasicForm from '@/components/BasicForm.vue';
|
|
|
import SelectGroup from '@/components/PersonGroup/SelectGroup.vue';
|
|
import SelectGroup from '@/components/PersonGroup/SelectGroup.vue';
|
|
|
import { useFormConfigHook } from '@/hooks/useFormConfigHook';
|
|
import { useFormConfigHook } from '@/hooks/useFormConfigHook';
|
|
|
import { useUserInfoHook } from '@/views/disaster/hooks';
|
|
import { useUserInfoHook } from '@/views/disaster/hooks';
|
|
|
import { useDisasterWarningHook } from '../hook';
|
|
import { useDisasterWarningHook } from '../hook';
|
|
|
|
|
+ import { useEmergencyProcedureHook } from '@/views/emergency/emergency-procedure/hooks';
|
|
|
import type { WarningInfoRuleForm } from '../type';
|
|
import type { WarningInfoRuleForm } from '../type';
|
|
|
import { WARNING_INFO_FROM_CONFIG, WARNING_INFO_FROM_DATA, WARNING_INFO_FROM_RULES } from '../config';
|
|
import { WARNING_INFO_FROM_CONFIG, WARNING_INFO_FROM_DATA, WARNING_INFO_FROM_RULES } from '../config';
|
|
|
- import { IS_PUSH } from '@/views/disaster/constant';
|
|
|
|
|
|
|
+ import { IS_PUSH, IS_EMERGENCY } from '@/views/disaster/constant';
|
|
|
|
|
|
|
|
const { realname } = useUserInfoHook();
|
|
const { realname } = useUserInfoHook();
|
|
|
const basicFormRef = ref<InstanceType<typeof BasicForm>>();
|
|
const basicFormRef = ref<InstanceType<typeof BasicForm>>();
|
|
|
const selectGroupRef = ref<InstanceType<typeof SelectGroup>>();
|
|
const selectGroupRef = ref<InstanceType<typeof SelectGroup>>();
|
|
|
|
|
|
|
|
const { warningTypeDice, disasterLevelDice, getWarningInfoDict, getDisasterLevelDict } = useDisasterWarningHook();
|
|
const { warningTypeDice, disasterLevelDice, getWarningInfoDict, getDisasterLevelDict } = useDisasterWarningHook();
|
|
|
|
|
+ const { emergencyEventDice, getEmergencyEventDict } = useEmergencyProcedureHook();
|
|
|
|
|
|
|
|
const { ruleFormConfig, ruleFormData, formRules, cloneRuleFormData, beforeRouteLeave } =
|
|
const { ruleFormConfig, ruleFormData, formRules, cloneRuleFormData, beforeRouteLeave } =
|
|
|
useFormConfigHook<WarningInfoRuleForm>(WARNING_INFO_FROM_CONFIG, WARNING_INFO_FROM_DATA, WARNING_INFO_FROM_RULES);
|
|
useFormConfigHook<WarningInfoRuleForm>(WARNING_INFO_FROM_CONFIG, WARNING_INFO_FROM_DATA, WARNING_INFO_FROM_RULES);
|
|
|
|
|
|
|
|
|
|
+ // 应急事件类型配置
|
|
|
|
|
+ const EVENT_TYPE_PROP = 'eventType';
|
|
|
|
|
+ const initialFormConfig = [...ruleFormConfig.value];
|
|
|
|
|
+ const eventTypeIndex = initialFormConfig.findIndex((item) => item.prop === EVENT_TYPE_PROP);
|
|
|
|
|
+ const eventTypeConfig = eventTypeIndex > -1 ? initialFormConfig[eventTypeIndex] : null;
|
|
|
|
|
+ const eventTypeRules = formRules[EVENT_TYPE_PROP];
|
|
|
|
|
+
|
|
|
|
|
+ // 如果应急事件未启动,则默认启动应急事件
|
|
|
|
|
+ if (ruleFormData.isEmergency === undefined || ruleFormData.isEmergency === null) {
|
|
|
|
|
+ ruleFormData.isEmergency = IS_EMERGENCY.EMERGENCY;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ watch(
|
|
|
|
|
+ () => ruleFormData.isEmergency,
|
|
|
|
|
+ (value) => {
|
|
|
|
|
+ const isEmergencyOpen = value === IS_EMERGENCY.EMERGENCY;
|
|
|
|
|
+
|
|
|
|
|
+ // 如果应急事件未启动,则清空应急事件类型
|
|
|
|
|
+ if (!isEmergencyOpen) {
|
|
|
|
|
+ if (ruleFormData.eventType) {
|
|
|
|
|
+ ruleFormData.eventType = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果应急事件类型配置存在,则删除应急事件类型配置
|
|
|
|
|
+ if (eventTypeConfig && ruleFormConfig.value.some((item) => item.prop === EVENT_TYPE_PROP)) {
|
|
|
|
|
+ const withoutEventType = ruleFormConfig.value.filter((item) => item.prop !== EVENT_TYPE_PROP);
|
|
|
|
|
+ ruleFormConfig.value = withoutEventType;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 如果应急事件类型规则存在,则删除应急事件类型规则
|
|
|
|
|
+ if (formRules[EVENT_TYPE_PROP]) {
|
|
|
|
|
+ delete formRules[EVENT_TYPE_PROP];
|
|
|
|
|
+ }
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果应急事件已启动,则添加应急事件类型配置
|
|
|
|
|
+ if (eventTypeConfig && !ruleFormConfig.value.some((item) => item.prop === EVENT_TYPE_PROP)) {
|
|
|
|
|
+ const newConfig = [...ruleFormConfig.value];
|
|
|
|
|
+ const insertIndex =
|
|
|
|
|
+ eventTypeIndex > -1 && eventTypeIndex <= newConfig.length ? eventTypeIndex : newConfig.length;
|
|
|
|
|
+ newConfig.splice(insertIndex, 0, eventTypeConfig);
|
|
|
|
|
+ ruleFormConfig.value = newConfig;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (eventTypeRules) {
|
|
|
|
|
+ formRules[EVENT_TYPE_PROP] = eventTypeRules;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ { immediate: true },
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
const handleUserGroupListChange = (userGroupList: number[]) => {
|
|
const handleUserGroupListChange = (userGroupList: number[]) => {
|
|
|
- ruleFormData.userGroupList = userGroupList;
|
|
|
|
|
|
|
+ ruleFormData.userGroupList = userGroupList ?? [];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const handleValidate = async () => {
|
|
const handleValidate = async () => {
|
|
@@ -74,6 +142,9 @@
|
|
|
if (!ruleFormData.isPush) {
|
|
if (!ruleFormData.isPush) {
|
|
|
ruleFormData.userGroupList = [];
|
|
ruleFormData.userGroupList = [];
|
|
|
}
|
|
}
|
|
|
|
|
+ if (ruleFormData.isEmergency !== IS_EMERGENCY.EMERGENCY) {
|
|
|
|
|
+ ruleFormData.eventType = '';
|
|
|
|
|
+ }
|
|
|
cloneRuleFormData();
|
|
cloneRuleFormData();
|
|
|
return ruleFormData;
|
|
return ruleFormData;
|
|
|
};
|
|
};
|
|
@@ -85,6 +156,7 @@
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getWarningInfoDict();
|
|
getWarningInfoDict();
|
|
|
getDisasterLevelDict();
|
|
getDisasterLevelDict();
|
|
|
|
|
+ getEmergencyEventDict();
|
|
|
ruleFormData.realname = realname;
|
|
ruleFormData.realname = realname;
|
|
|
cloneRuleFormData();
|
|
cloneRuleFormData();
|
|
|
beforeRouteLeave();
|
|
beforeRouteLeave();
|