|
@@ -18,7 +18,7 @@
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="item in AlarmTypes"
|
|
v-for="item in AlarmTypes"
|
|
|
:key="item.id"
|
|
:key="item.id"
|
|
|
- :label="item.label"
|
|
|
|
|
|
|
+ :label="item.name"
|
|
|
:value="item.id"
|
|
:value="item.id"
|
|
|
/></el-select>
|
|
/></el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -29,19 +29,19 @@
|
|
|
placeholder="请选择报警等级"
|
|
placeholder="请选择报警等级"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="item in AlarmLevels"
|
|
|
|
|
- :key="item.id"
|
|
|
|
|
- :label="item.label"
|
|
|
|
|
- :value="item.id"
|
|
|
|
|
|
|
+ v-for="item in Object.keys(ALARMLEVEL_MAP)"
|
|
|
|
|
+ :key="item"
|
|
|
|
|
+ :label="ALARMLEVEL_MAP[item]"
|
|
|
|
|
+ :value="+item"
|
|
|
/></el-select>
|
|
/></el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="推送渠道:" prop="pushChannel">
|
|
<el-form-item label="推送渠道:" prop="pushChannel">
|
|
|
- <el-checkbox-group v-model="alarmConfigForm.pushChannel">
|
|
|
|
|
|
|
+ <el-checkbox-group v-model="(alarmConfigForm.pushChannel as number[])">
|
|
|
<el-checkbox
|
|
<el-checkbox
|
|
|
- v-for="channel in PushChannels"
|
|
|
|
|
- :key="channel.id"
|
|
|
|
|
- :label="channel.label"
|
|
|
|
|
- :value="channel.id"
|
|
|
|
|
|
|
+ v-for="channel in Object.keys(ALARMCHANNEL_MAP)"
|
|
|
|
|
+ :key="channel"
|
|
|
|
|
+ :label="ALARMCHANNEL_MAP[channel]"
|
|
|
|
|
+ :value="+channel"
|
|
|
>
|
|
>
|
|
|
</el-checkbox>
|
|
</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
@@ -51,16 +51,23 @@
|
|
|
class="alarm-config-checkbox-group"
|
|
class="alarm-config-checkbox-group"
|
|
|
v-model="alarmConfigForm.pushOccasions"
|
|
v-model="alarmConfigForm.pushOccasions"
|
|
|
>
|
|
>
|
|
|
- <div v-for="occasion in PushOccasions">
|
|
|
|
|
- <el-checkbox :key="occasion.id" :label="occasion.label" :value="occasion.id">
|
|
|
|
|
|
|
+ <div v-for="phase in Object.keys(ALARMPHASE_MAP)">
|
|
|
|
|
+ <el-checkbox :key="phase" :label="ALARMPHASE_MAP[phase]" :value="+phase">
|
|
|
</el-checkbox>
|
|
</el-checkbox>
|
|
|
- <div
|
|
|
|
|
- v-if="alarmConfigForm.pushPhaseVOList.some((it) => it.pushPhase === occasion.id)"
|
|
|
|
|
- >
|
|
|
|
|
- <PushOccasionsCard
|
|
|
|
|
|
|
+ <div v-if="alarmConfigForm.pushPhaseVOList.some((it) => it.pushPhase === +phase)">
|
|
|
|
|
+ <div class="push-occasions-card">
|
|
|
|
|
+ <PushObject />
|
|
|
|
|
+ <div>{{
|
|
|
|
|
+ '【' +
|
|
|
|
|
+ (AlarmTypes.find((it) => it.id === alarmConfigForm.violationType)?.name! ||
|
|
|
|
|
+ '') +
|
|
|
|
|
+ '】'
|
|
|
|
|
+ }}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- <PushOccasionsCard
|
|
|
:form="alarmConfigForm.pushPhaseVOList.find((it) => it.pushPhase === occasion.id)!"
|
|
:form="alarmConfigForm.pushPhaseVOList.find((it) => it.pushPhase === occasion.id)!"
|
|
|
:type="AlarmTypes.find((it) => it.id === alarmConfigForm.violationType)?.label!"
|
|
:type="AlarmTypes.find((it) => it.id === alarmConfigForm.violationType)?.label!"
|
|
|
- />
|
|
|
|
|
|
|
+ /> -->
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
@@ -82,7 +89,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
- import PushOccasionsCard from './components/PushOccasionsCard.vue';
|
|
|
|
|
|
|
+ import PushObject from '../components/PushObject.vue';
|
|
|
import AlarmExample from './components/AlarmExample.vue';
|
|
import AlarmExample from './components/AlarmExample.vue';
|
|
|
import {
|
|
import {
|
|
|
ElForm,
|
|
ElForm,
|
|
@@ -93,26 +100,72 @@
|
|
|
FormInstance,
|
|
FormInstance,
|
|
|
FormRules,
|
|
FormRules,
|
|
|
} from 'element-plus';
|
|
} from 'element-plus';
|
|
|
- import { AlarmConfigForm } from './types';
|
|
|
|
|
import { ref, watch } from 'vue';
|
|
import { ref, watch } from 'vue';
|
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
|
- import { useRouter } from 'vue-router';
|
|
|
|
|
|
|
+ import { useRouter, useRoute } from 'vue-router';
|
|
|
|
|
+ import {
|
|
|
|
|
+ getAlarmConfigDetail,
|
|
|
|
|
+ getExistingAlarmType,
|
|
|
|
|
+ // addAlarmConfig,
|
|
|
|
|
+ // editAlarmConfig,
|
|
|
|
|
+ type AlarmConfigForm,
|
|
|
|
|
+ // type PushPhaseVOList,
|
|
|
|
|
+ // type UserGroupVOItem,
|
|
|
|
|
+ // type CustomUserItem,
|
|
|
|
|
+ type AvailableAlarmType,
|
|
|
|
|
+ } from '@/api/message/message';
|
|
|
|
|
+ import {
|
|
|
|
|
+ // AlarmLevel,
|
|
|
|
|
+ ALARMLEVEL_MAP,
|
|
|
|
|
+ // AlarmChannel,
|
|
|
|
|
+ ALARMCHANNEL_MAP,
|
|
|
|
|
+ // AlarmPhase,
|
|
|
|
|
+ ALARMPHASE_MAP,
|
|
|
|
|
+ } from './types';
|
|
|
|
|
|
|
|
const useUser = useUserStore();
|
|
const useUser = useUserStore();
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
- // const route = useRoute();
|
|
|
|
|
|
|
+ const route = useRoute();
|
|
|
|
|
+
|
|
|
|
|
+ const AlarmTypes = ref<AvailableAlarmType[]>([]);
|
|
|
|
|
+
|
|
|
const alarmConfigForm = ref<AlarmConfigForm>({
|
|
const alarmConfigForm = ref<AlarmConfigForm>({
|
|
|
violationType: undefined,
|
|
violationType: undefined,
|
|
|
- violationLevel: undefined,
|
|
|
|
|
|
|
+ violationLevel: '',
|
|
|
pushChannel: [],
|
|
pushChannel: [],
|
|
|
pushOccasions: [],
|
|
pushOccasions: [],
|
|
|
pushPhaseVOList: [],
|
|
pushPhaseVOList: [],
|
|
|
creator: useUser.info.nickname,
|
|
creator: useUser.info.nickname,
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ // 判断是否为编辑和查看
|
|
|
|
|
+ if (route.query.alarmConfigId) {
|
|
|
|
|
+ // TODO 获取报警配置详情
|
|
|
|
|
+ getAlarmConfigDetail(route.query.alarmConfigId).then((res) => {
|
|
|
|
|
+ alarmConfigForm.value.violationType = res.violationType;
|
|
|
|
|
+ alarmConfigForm.value.violationLevel = res.violationLevel;
|
|
|
|
|
+ alarmConfigForm.value.pushChannel = JSON.parse(res.pushChannel as string);
|
|
|
|
|
+ alarmConfigForm.value.pushPhaseVOList = res.pushPhaseVOList;
|
|
|
|
|
+ alarmConfigForm.value.pushOccasions = res.pushPhaseVOList.map((it) => it.pushPhase);
|
|
|
|
|
+
|
|
|
|
|
+ AlarmTypes.value.push({
|
|
|
|
|
+ id: res.violationType,
|
|
|
|
|
+ name: res.violationName,
|
|
|
|
|
+ } as AvailableAlarmType);
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ getExistingAlarmType().then((res) => {
|
|
|
|
|
+ AlarmTypes.value = res;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (route.query.alarmMessageId) {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
watch(
|
|
watch(
|
|
|
() => alarmConfigForm.value.pushOccasions,
|
|
() => alarmConfigForm.value.pushOccasions,
|
|
|
() => {
|
|
() => {
|
|
|
|
|
+ if (!alarmConfigForm.value.pushOccasions) return;
|
|
|
alarmConfigForm.value.pushOccasions.forEach((occasion) => {
|
|
alarmConfigForm.value.pushOccasions.forEach((occasion) => {
|
|
|
if (!alarmConfigForm.value.pushPhaseVOList.some((it) => it.pushPhase === occasion)) {
|
|
if (!alarmConfigForm.value.pushPhaseVOList.some((it) => it.pushPhase === occasion)) {
|
|
|
alarmConfigForm.value.pushPhaseVOList.push({
|
|
alarmConfigForm.value.pushPhaseVOList.push({
|
|
@@ -123,7 +176,7 @@
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
alarmConfigForm.value.pushPhaseVOList.forEach((vo) => {
|
|
alarmConfigForm.value.pushPhaseVOList.forEach((vo) => {
|
|
|
- if (!alarmConfigForm.value.pushOccasions.some((occ) => occ === vo.pushPhase)) {
|
|
|
|
|
|
|
+ if (!alarmConfigForm.value.pushOccasions?.some((occ) => occ === vo.pushPhase)) {
|
|
|
alarmConfigForm.value.pushPhaseVOList.splice(
|
|
alarmConfigForm.value.pushPhaseVOList.splice(
|
|
|
alarmConfigForm.value.pushPhaseVOList.findIndex((it) => it.pushPhase === vo.pushPhase),
|
|
alarmConfigForm.value.pushPhaseVOList.findIndex((it) => it.pushPhase === vo.pushPhase),
|
|
|
1,
|
|
1,
|
|
@@ -142,30 +195,6 @@
|
|
|
pushOccasions: [{ required: true, message: '请选择推送阶段', trigger: 'change' }],
|
|
pushOccasions: [{ required: true, message: '请选择推送阶段', trigger: 'change' }],
|
|
|
pushPhaseVOList: [{ required: true, message: '请选择推送人员', trigger: 'change' }],
|
|
pushPhaseVOList: [{ required: true, message: '请选择推送人员', trigger: 'change' }],
|
|
|
});
|
|
});
|
|
|
- // 违规类型
|
|
|
|
|
- const AlarmTypes = [
|
|
|
|
|
- { id: 1, label: '违规类型1' },
|
|
|
|
|
- { id: 2, label: '违规类型2' },
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- // 报警等级
|
|
|
|
|
- const AlarmLevels = [
|
|
|
|
|
- { id: 1, label: '报警等级1' },
|
|
|
|
|
- { id: 2, label: '报警等级2' },
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- // 推送渠道
|
|
|
|
|
- const PushChannels = [
|
|
|
|
|
- { id: 1, label: '平台' },
|
|
|
|
|
- { id: 2, label: '蓝信' },
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- // 推送阶段
|
|
|
|
|
- const PushOccasions = [
|
|
|
|
|
- { id: 1, label: '问题发生时推送', value: {} },
|
|
|
|
|
- { id: 2, label: '问题生效后推送', value: {} },
|
|
|
|
|
- { id: 3, label: '审核通过后推送', value: {} },
|
|
|
|
|
- ];
|
|
|
|
|
|
|
|
|
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return;
|
|
if (!formEl) return;
|
|
@@ -214,6 +243,13 @@
|
|
|
.alarm-config-checkbox-group {
|
|
.alarm-config-checkbox-group {
|
|
|
max-height: 556px;
|
|
max-height: 556px;
|
|
|
overflow: auto;
|
|
overflow: auto;
|
|
|
|
|
+
|
|
|
|
|
+ .push-occasions-card {
|
|
|
|
|
+ width: 541px;
|
|
|
|
|
+ height: 248px;
|
|
|
|
|
+ background-color: #fafafa;
|
|
|
|
|
+ font-size: 16px;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
.alarm-config-example {
|
|
.alarm-config-example {
|