feat: 暂时屏蔽告警配置绑定场景联动新逻辑

This commit is contained in:
qiaochuLei 2024-03-27 09:56:03 +08:00 committed by GitHub
parent 1c50005161
commit e40af1855b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 106 additions and 66 deletions

View File

@ -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);
/** /**
* *

View File

@ -9,13 +9,13 @@
@ok="saveCorrelation" @ok="saveCorrelation"
:maskClosable="false" :maskClosable="false"
> >
<div v-if="type !== 'other'" style="padding: 0 24px"> <!-- <div v-if="type !== 'other'" style="padding: 0 24px">
<j-steps :current="current" > <j-steps :current="current" >
<j-step title="选择场景"></j-step> <j-step title="选择场景"></j-step>
<j-step title="选择条件"></j-step> <j-step title="选择条件"></j-step>
</j-steps> </j-steps>
</div> </div> -->
<template v-if="current === 0 || type === 'other' "> <!-- <template v-if="current === 0 || type === 'other' "> -->
<pro-search :columns="columns" type="simple" @search="handleSearch"/> <pro-search :columns="columns" type="simple" @search="handleSearch"/>
<div style="height: 500px; overflow-y: auto"> <div style="height: 500px; overflow-y: auto">
<JProTable <JProTable
@ -86,8 +86,8 @@
</template> </template>
</JProTable> </JProTable>
</div> </div>
</template> <!-- </template> -->
<template v-if="current === 1"> <!-- <template v-if="current === 1">
<div class="branch-terms-items"> <div class="branch-terms-items">
<j-tree <j-tree
v-if="branchGroup.length" v-if="branchGroup.length"
@ -97,7 +97,7 @@
@check="branchCheck" @check="branchCheck"
> >
</j-tree> </j-tree> -->
<!-- <CardBox--> <!-- <CardBox-->
<!-- v-for="(item, index) in branchGroup.branches"--> <!-- v-for="(item, index) in branchGroup.branches"-->
<!-- :showStatus="false"--> <!-- :showStatus="false"-->
@ -124,14 +124,14 @@
<!-- </div>--> <!-- </div>-->
<!-- </template>--> <!-- </template>-->
<!-- </CardBox>--> <!-- </CardBox>-->
</div> <!-- </div>
</template> </template>
<template #footer> <template #footer>
<j-button v-if="current === 0" @click="closeModal">取消</j-button> <j-button v-if="current === 0" @click="closeModal">取消</j-button>
<j-button v-if="current === 0" type="primary" @click="next">下一步</j-button> <j-button v-if="current === 0" type="primary" @click="next">下一步</j-button>
<j-button v-if="current === 1" @click="prev">上一步</j-button> <j-button v-if="current === 1" @click="prev">上一步</j-button>
<j-button v-if="current === 1" type="primary" @click="saveCorrelation">完成</j-button> <j-button v-if="current === 1" type="primary" @click="saveCorrelation">完成</j-button>
</template> </template> -->
</j-modal> </j-modal>
</template> </template>
@ -231,21 +231,40 @@ const props = defineProps({
type: String, type: String,
}, },
}); });
//
// const current = ref(0)
// const branchGroup = ref<any[]>([])
// const branchActiveKey = ref([])
// const branchCheckKeys = ref([])
const current = ref(0) // const terms = [
const branchGroup = ref<any[]>([]) // {
const branchActiveKey = ref([]) // terms: [
const branchCheckKeys = ref([])
const terms = [
{
terms: [
// { // {
// column: 'id', // column: 'id',
// termType: 'alarm-bind-rule$not', // termType: 'alarm-bind-rule$not',
// value: props.id, // value: props.id,
// type: 'and', // 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', column: 'triggerType',
termType: 'eq', termType: 'eq',
@ -292,68 +311,86 @@ const onSelectChange = (arr: any[]) => {
_selectedRowKeys.value = arr _selectedRowKeys.value = arr
}; };
const branchClick = (id: string) => { // const branchClick = (id: string) => {
const keys = new Set(branchActiveKey.value) // const keys = new Set(branchActiveKey.value)
} // }
const handleSearch = (e: any) => { const handleSearch = (e: any) => {
params.value = e; params.value = e;
}; };
const emit = defineEmits(['closeSave', 'saveScene']); const emit = defineEmits(['closeSave', 'saveScene']);
const next = () => { // const next = () => {
if (_selectedRowKeys.value.length) { // if (_selectedRowKeys.value.length) {
query({ // query({
pageSize: 99, // pageSize: 99,
terms: [{column: 'id', termType: 'in', value: _selectedRowKeys.value.join(',')}] // terms: [{column: 'id', termType: 'in', value: _selectedRowKeys.value.join(',')}]
}).then(res => { // }).then(res => {
if (res.success) { // if (res.success) {
branchGroup.value = handleSceneBranches(res.result.data) || [] // branchGroup.value = handleSceneBranches(res.result.data) || []
console.log(branchGroup.value) // console.log(branchGroup.value)
} // }
}) // })
current.value += 1 // current.value += 1
} else { // } else {
onlyMessage('请选择场景', 'warning') // onlyMessage('', 'warning')
} // }
} // }
const branchCheck = (checkedKeys: string[], { checkedNodes }) => { // const branchCheck = (checkedKeys: string[], { checkedNodes }) => {
branchCheckKeys.value = checkedNodes.filter(item => item.branchId).map(item => ({ // branchCheckKeys.value = checkedNodes.filter(item => item.branchId).map(item => ({
branchIndex: item.branchId, // branchIndex: item.branchId,
ruleId: item.sceneId, // ruleId: item.sceneId,
alarmId: props.id, // alarmId: props.id,
})) // }))
} // }
const prev = () => { // const prev = () => {
current.value -= 1 // current.value -= 1
} // }
/** /**
* 保存选中关联场景 * 保存选中关联场景
*/ */
const saveCorrelation = async () => { // const saveCorrelation = async () => {
if (_selectedRowKeys.value.length === 0 && branchCheckKeys.value.length === 0) { // if (_selectedRowKeys.value.length === 0 && branchCheckKeys.value.length === 0) {
onlyMessage('请选择至少一条数据', 'error') // onlyMessage('', 'error')
return // return
} // }
const list = props.type === 'other' ? _selectedRowKeys.value.map((item: any) => { // 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) {
const list = _selectedRowKeys.value.map((item: any) => {
return { return {
alarmId: props.id, alarmId: props.id,
ruleId: item, ruleId: item,
}; };
}) : branchCheckKeys.value });
const res = await bindScene([...list]); const res = await bindScene([...list]);
if (res.status === 200) { if (res.status === 200) {
onlyMessage('操作成功'); onlyMessage('操作成功');
emit('saveScene'); emit('saveScene');
} }
} else {
onlyMessage('请选择至少一条数据', 'error');
}
}; };
const closeModal = () => { const closeModal = () => {
emit('closeSave'); emit('closeSave');

View File

@ -100,7 +100,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { queryBranch} from '@/api/rule-engine/scene'; import { queryBranch , query} from '@/api/rule-engine/scene';
import { unbindScene } from '@/api/rule-engine/configuration'; import { unbindScene } from '@/api/rule-engine/configuration';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import type { ActionsType } from '@/components/Table'; import type { ActionsType } from '@/components/Table';
@ -159,7 +159,8 @@ const getActions = (
popConfirm: { popConfirm: {
title: '确定解绑?', title: '确定解绑?',
onConfirm: async () => { onConfirm: async () => {
const res = await unbindScene(id, [data.id], data.branchIndex); // const res = await unbindScene(id, [data.id], data.branchIndex);
const res = await unbindScene(id, [data.id]);
if (res.status === 200) { if (res.status === 200) {
onlyMessage('操作成功'); onlyMessage('操作成功');
actionRef.value.reload(); actionRef.value.reload();
@ -172,7 +173,7 @@ const getActions = (
}; };
const queryTable = (_terms: any) => { const queryTable = (_terms: any) => {
return queryBranch(_terms, id) return query(_terms, id)
} }
const visible = ref(false); const visible = ref(false);