fix: bug#10823

This commit is contained in:
XieYongHong 2023-07-15 11:42:26 +08:00
parent 4e46571076
commit 1baa346733
1 changed files with 47 additions and 7 deletions

View File

@ -137,9 +137,13 @@ import SaveModal from './Save/save.vue';
import type { SceneItem } from './typings'; import type { SceneItem } from './typings';
import { useMenuStore } from 'store/menu'; import { useMenuStore } from 'store/menu';
import { query, _delete, _action, _execute } from '@/api/rule-engine/scene'; import { query, _delete, _action, _execute } from '@/api/rule-engine/scene';
import {
queryList,
} from '@/api/rule-engine/configuration';
import type { ActionsType } from '@/components/Table'; import type { ActionsType } from '@/components/Table';
import { getImage, onlyMessage } from '@/utils/comm'; import { getImage, onlyMessage } from '@/utils/comm';
import BadgeStatus from '@/components/BadgeStatus/index.vue'; import BadgeStatus from '@/components/BadgeStatus/index.vue';
import { Modal } from 'jetlinks-ui-components'
const menuStory = useMenuStore(); const menuStory = useMenuStore();
const visible = ref<boolean>(false); const visible = ref<boolean>(false);
@ -227,6 +231,27 @@ const columns = [
}, },
]; ];
const deleteScene = async (id: string) => {
const resp = await _delete(id);
if (resp.status === 200) {
onlyMessage('操作成功!');
sceneRef.value?.reload();
} else {
onlyMessage('操作失败!', 'error');
}
}
const deleteModal = (id: string) => {
Modal.confirm({
title: '改场景已绑定告警,确定删除?',
onOk: async () => {
await deleteScene(id)
}
})
}
const getActions = ( const getActions = (
data: Partial<Record<string, any>>, data: Partial<Record<string, any>>,
type: 'card' | 'table', type: 'card' | 'table',
@ -293,13 +318,28 @@ const getActions = (
popConfirm: { popConfirm: {
title: '确认删除?', title: '确认删除?',
onConfirm: async () => { onConfirm: async () => {
const resp = await _delete(data.id); //
if (resp.status === 200) { const resp = await queryList({
onlyMessage('操作成功!'); pageSize: 10,
sceneRef.value?.reload(); pageIndex: 0,
} else { terms: [
onlyMessage('操作失败!', 'error'); {
} terms: [
{
column: 'id',
termType: 'rule-bind-alarm',
value: data.id,
},
]
}
],
})
console.log(resp)
if (resp.success && resp.result?.total) {
await deleteModal(data.id)
} else {
await deleteScene(data.id)
}
}, },
}, },
icon: 'DeleteOutlined', icon: 'DeleteOutlined',