Showing
4 changed files
with
85 additions
and
21 deletions
@@ -98,6 +98,7 @@ | @@ -98,6 +98,7 @@ | ||
98 | :arr="arr" | 98 | :arr="arr" |
99 | @deleteAction="deleteAction" | 99 | @deleteAction="deleteAction" |
100 | @getActionFormArr="getActionFormArr" | 100 | @getActionFormArr="getActionFormArr" |
101 | + @dynamicChangeAlarmConfig="handleDynamicChangeAlarmConfig" | ||
101 | /> | 102 | /> |
102 | </template> | 103 | </template> |
103 | <!-- 按钮 --> | 104 | <!-- 按钮 --> |
@@ -550,8 +551,14 @@ | @@ -550,8 +551,14 @@ | ||
550 | const getMasterDeviceList = ref([]); | 551 | const getMasterDeviceList = ref([]); |
551 | const orgId = ref(''); | 552 | const orgId = ref(''); |
552 | const alarmConfigList = ref([]); | 553 | const alarmConfigList = ref([]); |
554 | + //FT add 2022-10-27 | ||
555 | + const addOrgId = ref(''); | ||
556 | + //FT add 2022-10-27 | ||
553 | watch(organizationId, async (newValue: string) => { | 557 | watch(organizationId, async (newValue: string) => { |
554 | if (!newValue) return; | 558 | if (!newValue) return; |
559 | + //FT add 2022-10-27 | ||
560 | + addOrgId.value = newValue; | ||
561 | + //FT add 2022-10-27 | ||
555 | const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | 562 | const { items = [] } = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); |
556 | //TODO fengtao | 563 | //TODO fengtao |
557 | getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); | 564 | getMasterDeviceList.value = await byOganizationIdGetMasterDevice(newValue); |
@@ -567,13 +574,33 @@ | @@ -567,13 +574,33 @@ | ||
567 | alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); | 574 | alarmConfigList.value = data.map((item) => ({ label: item.name, value: item.id })); |
568 | setAlarmConfig(skipUnwrap.actionItemRefs, true); | 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 | function setFields(linkAge, isOrganizationChange = false) { | 594 | function setFields(linkAge, isOrganizationChange = false) { |
573 | unref(linkAge).map((item) => { | 595 | unref(linkAge).map((item) => { |
574 | isOrganizationChange && item.resetFieldsValueFunc(); | 596 | isOrganizationChange && item.resetFieldsValueFunc(); |
575 | //TODO fengtao | 597 | //TODO fengtao |
576 | item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); | 598 | item.updateFieldDeviceId(deviceList, orgId, isUpdate, getMasterDeviceList); |
599 | + if (isUpdate.value) { | ||
600 | + item.updateEditFieldAlarmConfig(editAlarmConfigData); | ||
601 | + } else { | ||
602 | + item.updateFieldAlarmConfig(alarmConfigList); | ||
603 | + } | ||
577 | //TODO fengtao | 604 | //TODO fengtao |
578 | }); | 605 | }); |
579 | } | 606 | } |
@@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; | @@ -3,7 +3,7 @@ import { BasicColumn, FormSchema } from '/@/components/Table'; | ||
3 | import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; | 3 | import { screenLinkOrganizationGetApi } from '/@/api/ruleengine/ruleengineApi'; |
4 | import { scheduleOptions } from './formatData'; | 4 | import { scheduleOptions } from './formatData'; |
5 | import { copyTransFun } from '/@/utils/fnUtils'; | 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,10 +334,11 @@ export const actionSchema: FormSchema[] = [ | ||
334 | { | 334 | { |
335 | field: 'alarm_config', | 335 | field: 'alarm_config', |
336 | label: '', | 336 | label: '', |
337 | - component: 'Select', | 337 | + component: 'Input', |
338 | componentProps: { | 338 | componentProps: { |
339 | placeholder: '请选择告警配置', | 339 | placeholder: '请选择告警配置', |
340 | }, | 340 | }, |
341 | + slot: 'alarmConfigSlot', | ||
341 | ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', | 342 | ifShow: ({ values }) => values.outTarget === 'MSG_NOTIFY', |
342 | colProps: { span: 6 }, | 343 | colProps: { span: 6 }, |
343 | }, | 344 | }, |
@@ -292,6 +292,17 @@ | @@ -292,6 +292,17 @@ | ||
292 | currentIndex.value = index; | 292 | currentIndex.value = index; |
293 | }; | 293 | }; |
294 | const scheduleData = ref(null); | 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 | defineExpose({ | 306 | defineExpose({ |
296 | getFieldsValueFunc, | 307 | getFieldsValueFunc, |
297 | updateFieldDeviceId, | 308 | updateFieldDeviceId, |
@@ -307,13 +318,15 @@ | @@ -307,13 +318,15 @@ | ||
307 | isUpdate, | 318 | isUpdate, |
308 | alarmScheduleRef, | 319 | alarmScheduleRef, |
309 | updateFieldAttributeFunc, | 320 | updateFieldAttributeFunc, |
321 | + updateFieldAlarmConfig, | ||
322 | + updateEditFieldAlarmConfig, | ||
310 | }); | 323 | }); |
311 | </script> | 324 | </script> |
312 | 325 | ||
313 | <style lang="less" scoped> | 326 | <style lang="less" scoped> |
314 | ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 | 327 | ///移除选择框默认样式(24px)否则超出默认宽度会造成页面样式错乱 |
315 | :deep(.ant-select-selector) { | 328 | :deep(.ant-select-selector) { |
316 | - padding-right: 0px !important; | 329 | + padding-right: 0 !important; |
317 | } | 330 | } |
318 | </style> | 331 | </style> |
319 | 332 |
@@ -19,6 +19,24 @@ | @@ -19,6 +19,24 @@ | ||
19 | placeholder="请选择执行动作" | 19 | placeholder="请选择执行动作" |
20 | allowClear | 20 | allowClear |
21 | /></template> | 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 | <template #doContext> | 40 | <template #doContext> |
23 | <div class="flex"> | 41 | <div class="flex"> |
24 | <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> | 42 | <div ref="jsoneditorRef" style="height: 100%; width: 100%"></div> |
@@ -56,19 +74,23 @@ | @@ -56,19 +74,23 @@ | ||
56 | >新增清除告警</a-button | 74 | >新增清除告警</a-button |
57 | > | 75 | > |
58 | </CollapseContainer> | 76 | </CollapseContainer> |
77 | + <AlarmConfigDrawer @register="registerAlarmContactDrawer" @success="handleSuccess" /> | ||
59 | </template> | 78 | </template> |
79 | + | ||
60 | <script lang="ts" setup> | 80 | <script lang="ts" setup> |
61 | import { ref, onMounted, nextTick, unref, computed, provide } from 'vue'; | 81 | import { ref, onMounted, nextTick, unref, computed, provide } from 'vue'; |
62 | import { CollapseContainer } from '/@/components/Container/index'; | 82 | import { CollapseContainer } from '/@/components/Container/index'; |
63 | import { BasicForm, useForm } from '/@/components/Form/index'; | 83 | import { BasicForm, useForm } from '/@/components/Form/index'; |
64 | import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; | 84 | import { Tooltip, Select, Checkbox, Card } from 'ant-design-vue'; |
65 | import { Icon } from '/@/components/Icon'; | 85 | import { Icon } from '/@/components/Icon'; |
66 | - import { actionSchema } from '../config/config.data.ts'; | 86 | + import { actionSchema } from '../config/config.data'; |
67 | import jsoneditor from 'jsoneditor'; | 87 | import jsoneditor from 'jsoneditor'; |
68 | import 'jsoneditor/dist/jsoneditor.min.css'; | 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 | import ClearAlarm from './ClearAlarm.vue'; | 90 | import ClearAlarm from './ClearAlarm.vue'; |
71 | import { useMessage } from '/@/hooks/web/useMessage'; | 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 | const props = defineProps({ | 95 | const props = defineProps({ |
74 | actionIndex: { | 96 | actionIndex: { |
@@ -96,13 +118,24 @@ | @@ -96,13 +118,24 @@ | ||
96 | default: '', | 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 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); | 132 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); |
100 | const refItem = { | 133 | const refItem = { |
101 | clearRuleRefs: ref([]), | 134 | clearRuleRefs: ref([]), |
102 | }; | 135 | }; |
103 | const { createMessage } = useMessage(); | 136 | const { createMessage } = useMessage(); |
104 | 137 | ||
105 | - const emit = defineEmits(['deleteAction', 'getActionFormArr']); | 138 | + const emit = defineEmits(['deleteAction', 'getActionFormArr', 'dynamicChangeAlarmConfig']); |
106 | const options = computed(() => { | 139 | const options = computed(() => { |
107 | return [ | 140 | return [ |
108 | { label: '设备输出', value: 'DEVICE_OUT' }, | 141 | { label: '设备输出', value: 'DEVICE_OUT' }, |
@@ -228,23 +261,14 @@ | @@ -228,23 +261,14 @@ | ||
228 | }, | 261 | }, |
229 | }); | 262 | }); |
230 | }; | 263 | }; |
231 | - //TODO-fengtao | 264 | + //FT add 2022-10-27 |
232 | const updateEditFieldAlarmConfig = (alarmConfigList) => { | 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 | const updateFieldAlarmConfig = (alarmConfigList) => { | 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 | const checked = ref(false); | 273 | const checked = ref(false); |
250 | const validateForm = () => { | 274 | const validateForm = () => { |
@@ -346,7 +370,6 @@ | @@ -346,7 +370,6 @@ | ||
346 | clearRuleList, | 370 | clearRuleList, |
347 | }); | 371 | }); |
348 | </script> | 372 | </script> |
349 | - | ||
350 | <style> | 373 | <style> |
351 | .jsoneditor { | 374 | .jsoneditor { |
352 | border: none; | 375 | border: none; |