Commit 1da0e999fee7a049323d2fc2e8e299a86849d96a

Authored by fengtao
1 parent 23279808

pref:优化场景联动 告警配置选择框 弹窗告警配置

... ... @@ -98,6 +98,7 @@
98 98 :arr="arr"
99 99 @deleteAction="deleteAction"
100 100 @getActionFormArr="getActionFormArr"
  101 + @dynamicChangeAlarmConfig="handleDynamicChangeAlarmConfig"
101 102 />
102 103 </template>
103 104 <!-- 按钮 -->
... ... @@ -550,8 +551,14 @@
550 551 const getMasterDeviceList = ref([]);
551 552 const orgId = ref('');
552 553 const alarmConfigList = ref([]);
  554 + //FT add 2022-10-27
  555 + const addOrgId = ref('');
  556 + //FT add 2022-10-27
553 557 watch(organizationId, async (newValue: string) => {
554 558 if (!newValue) return;
  559 + //FT add 2022-10-27
  560 + addOrgId.value = newValue;
  561 + //FT add 2022-10-27
555 562 const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue });
556 563 //TODO fengtao
557 564 getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue);
... ... @@ -567,13 +574,33 @@
567 574 alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id }));
568 575 setAlarmConfig(skipUnwrap.actionItemRefs, true);
569 576 });
570   -
  577 + //FT add 2022-10-27
  578 + const handleDynamicChangeAlarmConfig = async () => {
  579 + const data = await getOrganizationAlarmConfig({
  580 + organizationId: isUpdate.value ? provideOrgid.value : addOrgId.value,
  581 + });
  582 + const res = data.map((item) => ({ label: item.name, value: item.id }));
  583 + isUpdate.value ? (editAlarmConfigData.value = res) : (alarmConfigList.value = res);
  584 + unref(skipUnwrap.actionItemRefs)?.map((item: any) => {
  585 + if (isUpdate.value) {
  586 + item.updateEditFieldAlarmConfig(editAlarmConfigData);
  587 + } else {
  588 + item.updateFieldAlarmConfig(alarmConfigList);
  589 + }
  590 + });
  591 + };
  592 + //FT add 2022-10-27
571 593 // 根据上面组织变化动态改变触发器,执行条件,执行动作的设备值
572 594 function setFields(linkAge, isOrganizationChange = false) {
573 595 unref(linkAge).map((item) => {
574 596 isOrganizationChange && item.resetFieldsValueFunc();
575 597 //TODO fengtao
576 598 item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList);
  599 + if (isUpdate.value) {
  600 + item.updateEditFieldAlarmConfig(editAlarmConfigData);
  601 + } else {
  602 + item.updateFieldAlarmConfig(alarmConfigList);
  603 + }
577 604 //TODO fengtao
578 605 });
579 606 }
... ...
... ... @@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table';
3 3 import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi';
4 4 import { scheduleOptions } from './formatData';
5 5 import { copyTransFun } from '/@/utils/fnUtils';
6   -import { numberAndNonegativeRule,numberAndEngLishRule } from '/@/utils/rules';
  6 +import { numberAndNonegativeRule, numberAndEngLishRule } from '/@/utils/rules';
7 7
8 8 /**
9 9 * 所使用的枚举值
... ... @@ -334,10 +334,11 @@ export const actionSchema: FormSchema[] = [
334 334 {
335 335 field: 'alarm_config',
336 336 label: '',
337   - component: 'Select',
  337 + component: 'Input',
338 338 componentProps: {
339 339 placeholder: '请选择告警配置',
340 340 },
  341 + slot: 'alarmConfigSlot',
341 342 ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY',
342 343 colProps: { span: 6 },
343 344 },
... ...
... ... @@ -292,6 +292,17 @@
292 292 currentIndex.value = index;
293 293 };
294 294 const scheduleData = ref(null);
  295 + //FT add 2022-10-27
  296 + const updateFieldAlarmConfig = (alarmConfigList) => {
  297 + //什么也不做
  298 + console.log(alarmConfigList);
  299 + };
  300 + //FT add 2022-10-27
  301 + const updateEditFieldAlarmConfig = (alarmConfigList) => {
  302 + //什么也不做
  303 + console.log(alarmConfigList);
  304 + };
  305 +
295 306 defineExpose({
296 307 getFieldsValueFunc,
297 308 updateFieldDeviceId,
... ... @@ -307,13 +318,15 @@
307 318 isUpdate,
308 319 alarmScheduleRef,
309 320 updateFieldAttributeFunc,
  321 + updateFieldAlarmConfig,
  322 + updateEditFieldAlarmConfig,
310 323 });
311 324 </script>
312 325
313 326 <style lang="less" scoped>
314 327 ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱
315 328 :deep(.ant-select-selector) {
316   - padding-right: 0px !important;
  329 + padding-right: 0 !important;
317 330 }
318 331 </style>
319 332
... ...
... ... @@ -19,6 +19,24 @@
19 19 placeholder="请选择执行动作"
20 20 allowClear
21 21 /></template>
  22 + <template #alarmConfigSlot="{ model, field }">
  23 + <a-select
  24 + allowClear
  25 + placeholder="请选择告警配置"
  26 + v-model:value="model[field]"
  27 + style="width: 205px; margin-left: 10px"
  28 + :options="alarmConfigOptions.map((item) => ({ value: item.value, label: item.label }))"
  29 + >
  30 + <template #dropdownRender="{ menuNode: menu }">
  31 + <v-nodes :vnodes="menu" />
  32 + <a-divider style="margin: 4px 0" />
  33 + <div @click="handleOpenAlarmConfig" style="padding: 4px 0; cursor: pointer">
  34 + <plus-outlined />
  35 + 新增告警配置
  36 + </div>
  37 + </template>
  38 + </a-select>
  39 + </template>
22 40 <template #doContext>
23 41 <div class="flex">
24 42 <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div>
... ... @@ -56,19 +74,23 @@
56 74 >新增清除告警</a-button
57 75 >
58 76 </CollapseContainer>
  77 + <AlarmConfigDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" />
59 78 </template>
  79 +
60 80 <script lang="ts" setup>
61 81 import { ref, onMounted, nextTick, unref, computed, provide } from 'vue';
62 82 import { CollapseContainer } from '/@/components/Container/index';
63 83 import { BasicForm, useForm } from '/@/components/Form/index';
64 84 import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue';
65 85 import { Icon } from '/@/components/Icon';
66   - import { actionSchema } from '../config/config.data.ts';
  86 + import { actionSchema } from '../config/config.data';
67 87 import jsoneditor from 'jsoneditor';
68 88 import 'jsoneditor/dist/jsoneditor.min.css';
69   - import { QuestionCircleOutlined } from '@ant-design/icons-vue';
  89 + import { QuestionCircleOutlined, PlusOutlined } from '@ant-design/icons-vue';
70 90 import ClearAlarm from './ClearAlarm.vue';
71 91 import { useMessage } from '/@/hooks/web/useMessage';
  92 + import { useDrawer } from '/@/components/Drawer';
  93 + import AlarmConfigDrawer from '/@/views/alarm/config/ContactDrawer.vue';
72 94
73 95 const props = defineProps({
74 96 actionIndex: {
... ... @@ -96,13 +118,24 @@
96 118 default: '',
97 119 },
98 120 });
  121 + const alarmConfigOptions: any = ref([]);
  122 + const [registerAlarmContactDrawer, { openDrawer }] = useDrawer();
  123 + async function handleSuccess() {
  124 + emit('dynamicChangeAlarmConfig');
  125 + }
  126 + // 新增或编辑
  127 + const handleOpenAlarmConfig = () => {
  128 + openDrawer(true, {
  129 + isUpdate: false,
  130 + });
  131 + };
99 132 const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length);
100 133 const refItem = {
101 134 clearRuleRefs: ref([]),
102 135 };
103 136 const { createMessage } = useMessage();
104 137
105   - const emit = defineEmits(['deleteAction', 'getActionFormArr']);
  138 + const emit = defineEmits(['deleteAction', 'getActionFormArr', 'dynamicChangeAlarmConfig']);
106 139 const options = computed(() => {
107 140 return [
108 141 { label: '设备输出', value: 'DEVICE_OUT' },
... ... @@ -228,23 +261,14 @@
228 261 },
229 262 });
230 263 };
231   - //TODO-fengtao
  264 + //FT add 2022-10-27
232 265 const updateEditFieldAlarmConfig = (alarmConfigList) => {
233   - updateSchema({
234   - field: 'alarm_config',
235   - componentProps: {
236   - options: alarmConfigList,
237   - },
238   - });
  266 + alarmConfigOptions.value = alarmConfigList.value;
239 267 };
240 268 const updateFieldAlarmConfig = (alarmConfigList) => {
241   - updateSchema({
242   - field: 'alarm_config',
243   - componentProps: {
244   - options: alarmConfigList,
245   - },
246   - });
  269 + alarmConfigOptions.value = alarmConfigList.value;
247 270 };
  271 + //FT add 2022-10-27
248 272
249 273 const checked = ref(false);
250 274 const validateForm = () => {
... ... @@ -346,7 +370,6 @@
346 370 clearRuleList,
347 371 });
348 372 </script>
349   -
350 373 <style>
351 374 .jsoneditor {
352 375 border: none;
... ...