From e40af1855b745d1c09650fff9701954125d4b1f6 Mon Sep 17 00:00:00 2001 From: qiaochuLei <124648559+qiaochuLei@users.noreply.github.com> Date: Wed, 27 Mar 2024 09:56:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E9=85=8D=E7=BD=AE=E7=BB=91=E5=AE=9A=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E8=81=94=E5=8A=A8=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/rule-engine/configuration.ts | 4 +- .../Configuration/Save/Scene/Save/index.vue | 161 +++++++++++------- .../Alarm/Configuration/Save/Scene/index.vue | 7 +- 3 files changed, 106 insertions(+), 66 deletions(-) diff --git a/src/api/rule-engine/configuration.ts b/src/api/rule-engine/configuration.ts index cba16632..5570a740 100644 --- a/src/api/rule-engine/configuration.ts +++ b/src/api/rule-engine/configuration.ts @@ -42,7 +42,9 @@ export const detail = (id:string) => server.get(`/alarm/config/${id}`); /** * 解除场景联动绑定 */ -export const unbindScene = (id:string,data:any, branchId: string) => server.post(`/alarm/rule/bind/${id}/_delete?branchIndex=${branchId}`,data); +// export const unbindScene = (id:string,data:any, branchId: string) => server.post(`/alarm/rule/bind/${id}/_delete?branchIndex=${branchId}`,data); // 新解绑接口 + +export const unbindScene = (id:string,data:any) => server.post(`/alarm/rule/bind/${id}/_delete`,data); /** * 保存关联场景 diff --git a/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue b/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue index 69d6e477..249891be 100644 --- a/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue +++ b/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue @@ -9,13 +9,13 @@ @ok="saveCorrelation" :maskClosable="false" > -
+ +
- - @@ -231,21 +231,40 @@ const props = defineProps({ type: String, }, }); +// 告警改造后的逻辑,后端没有接口暂时屏蔽 +// const current = ref(0) +// const branchGroup = ref([]) +// const branchActiveKey = ref([]) +// const branchCheckKeys = ref([]) -const current = ref(0) -const branchGroup = ref([]) -const branchActiveKey = ref([]) -const branchCheckKeys = ref([]) - -const terms = [ - { - terms: [ +// const terms = [ +// { +// terms: [ // { // column: 'id', // termType: 'alarm-bind-rule$not', // value: props.id, // type: 'and', // }, +// { +// column: 'triggerType', +// termType: 'eq', +// value: props.type === 'other' ? undefined : 'device', +// }, +// ], +// type: 'and', +// }, +// ]; + +const terms = [ + { + terms: [ + { + column: 'id', + termType: 'alarm-bind-rule$not', + value: props.id, + type: 'and', + }, { column: 'triggerType', termType: 'eq', @@ -292,68 +311,86 @@ const onSelectChange = (arr: any[]) => { _selectedRowKeys.value = arr }; -const branchClick = (id: string) => { - const keys = new Set(branchActiveKey.value) +// const branchClick = (id: string) => { +// const keys = new Set(branchActiveKey.value) -} +// } const handleSearch = (e: any) => { params.value = e; }; const emit = defineEmits(['closeSave', 'saveScene']); -const next = () => { - if (_selectedRowKeys.value.length) { - query({ - pageSize: 99, - terms: [{column: 'id', termType: 'in', value: _selectedRowKeys.value.join(',')}] - }).then(res => { - if (res.success) { - branchGroup.value = handleSceneBranches(res.result.data) || [] +// const next = () => { +// if (_selectedRowKeys.value.length) { +// query({ +// pageSize: 99, +// terms: [{column: 'id', termType: 'in', value: _selectedRowKeys.value.join(',')}] +// }).then(res => { +// if (res.success) { +// branchGroup.value = handleSceneBranches(res.result.data) || [] - console.log(branchGroup.value) - } - }) - current.value += 1 +// console.log(branchGroup.value) +// } +// }) +// current.value += 1 - } else { - onlyMessage('请选择场景', 'warning') - } -} +// } else { +// onlyMessage('请选择场景', 'warning') +// } +// } -const branchCheck = (checkedKeys: string[], { checkedNodes }) => { - branchCheckKeys.value = checkedNodes.filter(item => item.branchId).map(item => ({ - branchIndex: item.branchId, - ruleId: item.sceneId, - alarmId: props.id, - })) -} +// const branchCheck = (checkedKeys: string[], { checkedNodes }) => { +// branchCheckKeys.value = checkedNodes.filter(item => item.branchId).map(item => ({ +// branchIndex: item.branchId, +// ruleId: item.sceneId, +// alarmId: props.id, +// })) +// } -const prev = () => { - current.value -= 1 -} +// const prev = () => { +// current.value -= 1 +// } /** * 保存选中关联场景 */ +// const saveCorrelation = async () => { +// if (_selectedRowKeys.value.length === 0 && branchCheckKeys.value.length === 0) { +// onlyMessage('请选择至少一条数据', 'error') +// return +// } + +// const list = props.type === 'other' ? _selectedRowKeys.value.map((item: any) => { +// return { +// alarmId: props.id, +// ruleId: item, +// }; +// }) : branchCheckKeys.value + +// const res = await bindScene([...list]); +// if (res.status === 200) { +// onlyMessage('操作成功'); +// emit('saveScene'); +// } +// }; + const saveCorrelation = async () => { - if (_selectedRowKeys.value.length === 0 && branchCheckKeys.value.length === 0) { - onlyMessage('请选择至少一条数据', 'error') - return - } - - const list = props.type === 'other' ? _selectedRowKeys.value.map((item: any) => { - return { - alarmId: props.id, - ruleId: item, - }; - }) : branchCheckKeys.value - - const res = await bindScene([...list]); - if (res.status === 200) { - onlyMessage('操作成功'); - emit('saveScene'); - } + if (_selectedRowKeys.value.length > 0) { + const list = _selectedRowKeys.value.map((item: any) => { + return { + alarmId: props.id, + ruleId: item, + }; + }); + const res = await bindScene([...list]); + if (res.status === 200) { + onlyMessage('操作成功'); + emit('saveScene'); + } + } else { + onlyMessage('请选择至少一条数据', 'error'); + } }; const closeModal = () => { emit('closeSave'); diff --git a/src/views/rule-engine/Alarm/Configuration/Save/Scene/index.vue b/src/views/rule-engine/Alarm/Configuration/Save/Scene/index.vue index 3561dbab..e9b4a600 100644 --- a/src/views/rule-engine/Alarm/Configuration/Save/Scene/index.vue +++ b/src/views/rule-engine/Alarm/Configuration/Save/Scene/index.vue @@ -100,7 +100,7 @@