Commit 20bcdf7bd0390c8f4cdc9739fda98d552f3b1705

Authored by xp.Huang
2 parents ee4eedb5 e57d95a3

Merge branch 'sqy_dev' into 'main'

'fix:[DEFECT-337]:修复告警输出选择的问题'

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