Commit 20bcdf7bd0390c8f4cdc9739fda98d552f3b1705
Merge branch 'sqy_dev' into 'main'
'fix:[DEFECT-337]:修复告警输出选择的问题' See merge request huang/yun-teng-iot-front!196
Showing
3 changed files
with
32 additions
and
37 deletions
| @@ -41,7 +41,7 @@ export const useUserStore = defineStore({ | @@ -41,7 +41,7 @@ export const useUserStore = defineStore({ | ||
| 41 | //平台信息 | 41 | //平台信息 |
| 42 | platInfo: storage.get('platformInfo') || null, | 42 | platInfo: storage.get('platformInfo') || null, |
| 43 | enterPriseInfo: storage.get('enterPriseInfo') || null, | 43 | enterPriseInfo: storage.get('enterPriseInfo') || null, |
| 44 | - outTarget: 'DEVICE_OUT', | 44 | + |
| 45 | // user info | 45 | // user info |
| 46 | userInfo: null, | 46 | userInfo: null, |
| 47 | userUpdateInfo: null, | 47 | userUpdateInfo: null, |
| @@ -64,9 +64,7 @@ export const useUserStore = defineStore({ | @@ -64,9 +64,7 @@ export const useUserStore = defineStore({ | ||
| 64 | getUserInfo(): UserInfo { | 64 | getUserInfo(): UserInfo { |
| 65 | return this.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {}; | 65 | return this.userInfo || getAuthCache<UserInfo>(USER_INFO_KEY) || {}; |
| 66 | }, | 66 | }, |
| 67 | - getOutTarget(): any { | ||
| 68 | - return this.outTarget; | ||
| 69 | - }, | 67 | + |
| 70 | getUserUpdateInfo(): UserUpdateInfo { | 68 | getUserUpdateInfo(): UserUpdateInfo { |
| 71 | return this.userUpdateInfo || {}; | 69 | return this.userUpdateInfo || {}; |
| 72 | }, | 70 | }, |
| @@ -93,9 +91,7 @@ export const useUserStore = defineStore({ | @@ -93,9 +91,7 @@ export const useUserStore = defineStore({ | ||
| 93 | setEnterPriseInfo(enterPriseInfo: any) { | 91 | setEnterPriseInfo(enterPriseInfo: any) { |
| 94 | this.enterPriseInfo = enterPriseInfo; | 92 | this.enterPriseInfo = enterPriseInfo; |
| 95 | }, | 93 | }, |
| 96 | - setOutTarget(outTarget) { | ||
| 97 | - this.outTarget = outTarget; | ||
| 98 | - }, | 94 | + |
| 99 | storeToken(jwtToken: string, refreshToken: string) { | 95 | storeToken(jwtToken: string, refreshToken: string) { |
| 100 | this.jwtToken = jwtToken; | 96 | this.jwtToken = jwtToken; |
| 101 | this.refreshToken = refreshToken; | 97 | this.refreshToken = refreshToken; |
| @@ -66,7 +66,9 @@ | @@ -66,7 +66,9 @@ | ||
| 66 | :triggerData="triggerData" | 66 | :triggerData="triggerData" |
| 67 | :ref="skipUnwrap.actionItemRefs" | 67 | :ref="skipUnwrap.actionItemRefs" |
| 68 | :deviceList="deviceList" | 68 | :deviceList="deviceList" |
| 69 | + :arr="arr" | ||
| 69 | @deleteAction="deleteAction" | 70 | @deleteAction="deleteAction" |
| 71 | + @getActionFormArr="getActionFormArr" | ||
| 70 | /> | 72 | /> |
| 71 | </template> | 73 | </template> |
| 72 | <!-- 按钮 --> | 74 | <!-- 按钮 --> |
| @@ -97,7 +99,6 @@ | @@ -97,7 +99,6 @@ | ||
| 97 | } from '/@/api/ruleengine/ruleengineApi'; | 99 | } from '/@/api/ruleengine/ruleengineApi'; |
| 98 | import TriggerOrCondition from './cpns/Trigger-Condition.vue'; | 100 | import TriggerOrCondition from './cpns/Trigger-Condition.vue'; |
| 99 | import Action from './cpns/Action.vue'; | 101 | import Action from './cpns/Action.vue'; |
| 100 | - import { useUserStore } from '/@/store/modules/user'; | ||
| 101 | import { findOperation } from './config/formatData.ts'; | 102 | import { findOperation } from './config/formatData.ts'; |
| 102 | import { formatToDateTime } from '/@/utils/dateUtil'; | 103 | import { formatToDateTime } from '/@/utils/dateUtil'; |
| 103 | 104 | ||
| @@ -344,8 +345,6 @@ | @@ -344,8 +345,6 @@ | ||
| 344 | // 如果是设备输出设置脚本值 | 345 | // 如果是设备输出设置脚本值 |
| 345 | if (action.outTarget === 'DEVICE_OUT') { | 346 | if (action.outTarget === 'DEVICE_OUT') { |
| 346 | unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); | 347 | unref(skipUnwrap.actionItemRefs)[index].setJsonValue(action.doContext.params); |
| 347 | - } else { | ||
| 348 | - userStore.setOutTarget(action.outTarget); | ||
| 349 | } | 348 | } |
| 350 | // 清除告警有值?{数组} | 349 | // 清除告警有值?{数组} |
| 351 | if (action?.doContext?.clearRule?.length) { | 350 | if (action?.doContext?.clearRule?.length) { |
| @@ -565,7 +564,6 @@ | @@ -565,7 +564,6 @@ | ||
| 565 | setDrawerProps({ confirmLoading: false }); | 564 | setDrawerProps({ confirmLoading: false }); |
| 566 | } | 565 | } |
| 567 | }; | 566 | }; |
| 568 | - const userStore = useUserStore(); | ||
| 569 | // 删除 | 567 | // 删除 |
| 570 | const deleteTriggerOrCondition = ({ index, title }) => { | 568 | const deleteTriggerOrCondition = ({ index, title }) => { |
| 571 | if (title === '触发器') { | 569 | if (title === '触发器') { |
| @@ -574,11 +572,13 @@ | @@ -574,11 +572,13 @@ | ||
| 574 | unref(conditionData).splice(index, 1); | 572 | unref(conditionData).splice(index, 1); |
| 575 | } | 573 | } |
| 576 | }; | 574 | }; |
| 577 | - const deleteAction = ({ actionIndex, outTarget }) => { | 575 | + const deleteAction = (actionIndex) => { |
| 578 | unref(actionData).splice(actionIndex, 1); | 576 | unref(actionData).splice(actionIndex, 1); |
| 579 | - if (unref(outTarget) === 'MSG_NOTIFY') { | ||
| 580 | - userStore.setOutTarget('DEVICE_OUT'); | ||
| 581 | - } | 577 | + unref(arr).splice(actionIndex, 1); |
| 578 | + }; | ||
| 579 | + const arr = ref([]); | ||
| 580 | + const getActionFormArr = () => { | ||
| 581 | + arr.value = unref(skipUnwrap.actionItemRefs).map((item) => item.getFieldsValue()); | ||
| 582 | }; | 582 | }; |
| 583 | const handleClose = () => { | 583 | const handleClose = () => { |
| 584 | id.value = undefined; | 584 | id.value = undefined; |
| @@ -600,6 +600,5 @@ | @@ -600,6 +600,5 @@ | ||
| 600 | unref(skipUnwrap.actionItemRefs).map((item) => { | 600 | unref(skipUnwrap.actionItemRefs).map((item) => { |
| 601 | item.resetFieldsValueFunc(); | 601 | item.resetFieldsValueFunc(); |
| 602 | }); | 602 | }); |
| 603 | - userStore.setOutTarget('DEVICE_OUT'); | ||
| 604 | }; | 603 | }; |
| 605 | </script> | 604 | </script> |
| @@ -67,7 +67,6 @@ | @@ -67,7 +67,6 @@ | ||
| 67 | import jsoneditor from 'jsoneditor'; | 67 | import jsoneditor from 'jsoneditor'; |
| 68 | import 'jsoneditor/dist/jsoneditor.min.css'; | 68 | import 'jsoneditor/dist/jsoneditor.min.css'; |
| 69 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; | 69 | import { QuestionCircleOutlined } from '@ant-design/icons-vue'; |
| 70 | - import { useUserStore } from '/@/store/modules/user'; | ||
| 71 | import ClearAlarm from './ClearAlarm.vue'; | 70 | import ClearAlarm from './ClearAlarm.vue'; |
| 72 | 71 | ||
| 73 | const props = defineProps({ | 72 | const props = defineProps({ |
| @@ -87,29 +86,30 @@ | @@ -87,29 +86,30 @@ | ||
| 87 | type: Array, | 86 | type: Array, |
| 88 | required: true, | 87 | required: true, |
| 89 | }, | 88 | }, |
| 89 | + arr: { | ||
| 90 | + type: Array, | ||
| 91 | + default: () => [], | ||
| 92 | + }, | ||
| 90 | }); | 93 | }); |
| 91 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); | 94 | const isAddClearRule = computed(() => clearRuleList.value.length < props.triggerData.length); |
| 92 | const refItem = { | 95 | const refItem = { |
| 93 | clearRuleRefs: ref([]), | 96 | clearRuleRefs: ref([]), |
| 94 | }; | 97 | }; |
| 95 | - const emit = defineEmits(['deleteAction']); | ||
| 96 | - const userStore = useUserStore(); | ||
| 97 | - const options = computed(() => [ | ||
| 98 | - { label: '设备输出', value: 'DEVICE_OUT' }, | ||
| 99 | - { | ||
| 100 | - label: '告警输出', | ||
| 101 | - value: 'MSG_NOTIFY', | ||
| 102 | - disabled: userStore.getOutTarget === 'MSG_NOTIFY' || !props.triggerData.length, | ||
| 103 | - }, | ||
| 104 | - ]); | ||
| 105 | - const outTarget = ref(''); | ||
| 106 | - | ||
| 107 | - // TODO:此处有个小Bug,日后在调试。 | ||
| 108 | - const changeOutTarget = (value: 'DEVICE_OUT' | 'MSG_NOTIFY') => { | ||
| 109 | - outTarget.value = value; | ||
| 110 | - if (userStore.getOutTarget === 'DEVICE_OUT') { | ||
| 111 | - userStore.setOutTarget(value); | ||
| 112 | - } | 98 | + const emit = defineEmits(['deleteAction', 'getActionFormArr']); |
| 99 | + const options = computed(() => { | ||
| 100 | + return [ | ||
| 101 | + { label: '设备输出', value: 'DEVICE_OUT' }, | ||
| 102 | + { | ||
| 103 | + label: '告警输出', | ||
| 104 | + value: 'MSG_NOTIFY', | ||
| 105 | + disabled: | ||
| 106 | + props.arr.filter((item) => item.outTarget === 'MSG_NOTIFY').length || | ||
| 107 | + !props.triggerData.length, | ||
| 108 | + }, | ||
| 109 | + ]; | ||
| 110 | + }); | ||
| 111 | + const changeOutTarget = () => { | ||
| 112 | + emit('getActionFormArr'); | ||
| 113 | }; | 113 | }; |
| 114 | const [registerAction, { getFieldsValue, resetFields, updateSchema, setFieldsValue, validate }] = | 114 | const [registerAction, { getFieldsValue, resetFields, updateSchema, setFieldsValue, validate }] = |
| 115 | useForm({ | 115 | useForm({ |
| @@ -163,7 +163,6 @@ | @@ -163,7 +163,6 @@ | ||
| 163 | options: alarmConfigList, | 163 | options: alarmConfigList, |
| 164 | }, | 164 | }, |
| 165 | }); | 165 | }); |
| 166 | - userStore.setOutTarget('DEVICE_OUT'); | ||
| 167 | }; | 166 | }; |
| 168 | 167 | ||
| 169 | const checked = ref(false); | 168 | const checked = ref(false); |
| @@ -172,7 +171,7 @@ | @@ -172,7 +171,7 @@ | ||
| 172 | }; | 171 | }; |
| 173 | 172 | ||
| 174 | const handleDelete = (actionIndex) => { | 173 | const handleDelete = (actionIndex) => { |
| 175 | - emit('deleteAction', { actionIndex, outTarget }); | 174 | + emit('deleteAction', actionIndex); |
| 176 | }; | 175 | }; |
| 177 | 176 | ||
| 178 | const clearRuleList = ref([]); | 177 | const clearRuleList = ref([]); |
| @@ -243,6 +242,7 @@ | @@ -243,6 +242,7 @@ | ||
| 243 | }; | 242 | }; |
| 244 | 243 | ||
| 245 | defineExpose({ | 244 | defineExpose({ |
| 245 | + getFieldsValue, | ||
| 246 | getFieldsValueFunc, | 246 | getFieldsValueFunc, |
| 247 | setFieldsFormValueFun, | 247 | setFieldsFormValueFun, |
| 248 | resetFieldsValueFunc, | 248 | resetFieldsValueFunc, |