fix: 告警中心组件替换及自测

This commit is contained in:
leiqiaochu 2023-03-14 13:39:49 +08:00
parent 351e4f35ab
commit a8fd7232eb
12 changed files with 172 additions and 170 deletions

View File

@ -1,27 +1,27 @@
<template>
<div>
<a-form layout="vertical" :rules="rule" :model="form" ref="formRef">
<a-row :gutter="24">
<a-col :span="12">
<a-form-item label="名称" name="name">
<a-input
<j-form layout="vertical" :rules="rule" :model="form" ref="formRef">
<j-row :gutter="24">
<j-col :span="12">
<j-form-item label="名称" name="name">
<j-input
placeholder="请输入名称"
v-model:value="form.name"
></a-input> </a-form-item
></a-col>
<a-col :span="12">
<a-form-item label="类型" name="targetType">
<a-select
></j-input> </j-form-item
></j-col>
<j-col :span="12">
<j-form-item label="类型" name="targetType">
<j-select
:options="options"
v-model:value="form.targetType"
:disabled="selectDisable"
></a-select>
</a-form-item>
</a-col>
</a-row>
<a-form-item label="级别" name="level">
<a-radio-group v-model:value="form.level">
<a-radio-button
></j-select>
</j-form-item>
</j-col>
</j-row>
<j-form-item label="级别" name="level">
<j-radio-group v-model:value="form.level">
<j-radio-button
v-for="(item, index) in levelOption"
:key="index"
:value="item.value"
@ -40,14 +40,14 @@
alt=""
/>{{ item.label }}
</div>
</a-radio-button>
</a-radio-group>
</a-form-item>
<a-form-item label="说明" name="description">
<a-textarea v-model:value="form.description"></a-textarea>
</a-form-item>
</j-radio-button>
</j-radio-group>
</j-form-item>
<j-form-item label="说明" name="description">
<j-textarea v-model:value="form.description"></j-textarea>
</j-form-item>
<PermissionButton type="primary" @click="handleSave" :hasPermission="['rule-engine/Alarm/Configuration:add','rule-engine/Alarm/Configuration:update']">保存</PermissionButton>
</a-form>
</j-form>
</div>
</template>
@ -178,7 +178,7 @@ const handleSave = async () => {
const res = await save(form);
loading.value = false;
if (res.status === 200) {
message.success('操作成功');
message.success('操作成功,请配置关联的场景联动');
menuStory.jumpPage(
'rule-engine/Alarm/Configuration/Save',
{},

View File

@ -1,5 +1,5 @@
<template>
<a-modal
<j-modal
visible
title="新增"
okText="确定"
@ -8,7 +8,7 @@
@cancel="closeModal"
@ok="saveCorrelation"
>
<Search :columns="columns" @search="handleSearch"></Search>
<pro-search :columns="columns" @search="handleSearch"/>
<div style="height: 500px; overflow-y: auto">
<JProTable
model="CARD"
@ -78,7 +78,7 @@
</template>
</JProTable>
</div>
</a-modal>
</j-modal>
</template>
<script lang="ts" setup>
@ -213,7 +213,7 @@ const saveCorrelation = async () => {
const list = _selectedRowKeys.value.map((item: any) => {
return {
alarmId: props.id,
releId: item,
ruleId: item,
};
});
const res = await bindScene([...list]);

View File

@ -10,12 +10,12 @@
ref="actionRef"
>
<template #headerTitle>
<a-space>
<j-space>
<PermissionButton type="primary" @click="showModal" hasPermission="rule-engine/Alarm/Configuration:add">
<template #icon><AIcon type="PlusOutlined" /></template>
新增
</PermissionButton>
</a-space>
</j-space>
</template>
<template #card="slotProps">
<SceneCard

View File

@ -9,7 +9,7 @@
<Scene></Scene>
</j-tab-pane>
<j-tab-pane key="3" tab="告警记录">
<Log/>
<Log v-if="activeKey === '3'" />
</j-tab-pane>
</j-tabs>
</j-card>
@ -29,7 +29,7 @@ const changeTabs = (e:any) =>{
} else {
message.error('请先保存基础配置');
}
}
};
const activeKey = ref('1');
</script>
<style lang="less" scoped>

View File

@ -56,8 +56,8 @@
{{ slotProps.name }}
</span>
</Ellipsis>
<a-row>
<a-col :span="12">
<j-row>
<j-col :span="12">
<div class="content-des-title">
关联场景联动
</div>
@ -66,8 +66,8 @@
{{ (slotProps?.scene || []).map((item: any) => item?.name).join(',') || '' }}
</div></Ellipsis
>
</a-col>
<a-col :span="12">
</j-col>
<j-col :span="12">
<div class="content-des-title">
告警级别
</div>
@ -75,8 +75,8 @@
{{ (Store.get('default-level') || []).find((item: any) => item?.level === slotProps.level)?.title ||
slotProps.level }}
</div>
</a-col>
</a-row>
</j-col>
</j-row>
</template>
<template #actions="item">
<PermissionButton
@ -109,7 +109,7 @@
<span>{{ map[slotProps.targetType] }}</span>
</template>
<template #level="slotProps">
<a-tooltip
<j-tooltip
placement="topLeft"
:title="(Store.get('default-level') || []).find((item: any) => item?.level === slotProps.level)?.title ||
slotProps.level"
@ -118,7 +118,7 @@
{{ (Store.get('default-level') || []).find((item: any) => item?.level === slotProps.level)?.title ||
slotProps.level }}
</div>
</a-tooltip>
</j-tooltip>
</template>
<template #sceneId="slotProps">
<span
@ -126,7 +126,7 @@
>
</template>
<template #state="slotProps">
<a-badge
<j-badge
:text="
slotProps.state?.value === 'enabled'
? '正常'
@ -140,7 +140,7 @@
/>
</template>
<template #action="slotProps">
<a-space :size="16">
<j-space :size="16">
<template
v-for="i in getActions(slotProps, 'table')"
:key="i.key"
@ -168,7 +168,7 @@
/></template>
</PermissionButton>
</template>
</a-space>
</j-space>
</template>
</JProTable>
</div>

View File

@ -1,10 +1,10 @@
<template>
<page-container>
<Search
<pro-search
:columns="columns"
target="alarm-log-detail"
@search="handleSearch"
></Search>
/>
<JProTable
:columns="columns"
model="TABLE"
@ -19,7 +19,7 @@
moment(slotProps.alarmTime).format('YYYY-MM-DD HH:mm:ss')
}}</template>
<template #action="slotProps">
<a-space
<j-space
><template
v-for="i in getActions(slotProps, 'table')"
:key="i.key"
@ -37,7 +37,7 @@
<template #icon><AIcon :type="i.icon"/></template>
</PermissionButton>
</template>
</a-space>
</j-space>
</template>
</JProTable>
<Info v-if="visiable" :data="current" @close="close"/>

View File

@ -1,16 +1,16 @@
<template>
<a-modal visible title="详情" okText="确定" cancelText="取消" :width="1000" @ok="closeModal" @cancel="closeModal">
<a-descriptions bordered :column="2">
<a-descriptions-item v-if="props.data.targetType==='device'" label="告警设备" :span="1">{{props.data?.targetName || ''}}</a-descriptions-item>
<a-descriptions-item v-if="props.data.targetType==='device'" label="设备ID" :span="1">{{props.data?.targetId || ''}}</a-descriptions-item>
<a-descriptions-item label="告警名称" :span="1">{{
<j-modal visible title="详情" okText="确定" cancelText="取消" :width="1000" @ok="closeModal" @cancel="closeModal">
<j-descriptions bordered :column="2">
<j-descriptions-item v-if="props.data.targetType==='device'" label="告警设备" :span="1">{{props.data?.targetName || ''}}</j-descriptions-item>
<j-descriptions-item v-if="props.data.targetType==='device'" label="设备ID" :span="1">{{props.data?.targetId || ''}}</j-descriptions-item>
<j-descriptions-item label="告警名称" :span="1">{{
props.data?.alarmConfigName
}}</a-descriptions-item>
<a-descriptions-item label="告警时间" :span="1">{{
}}</j-descriptions-item>
<j-descriptions-item label="告警时间" :span="1">{{
moment(data?.alarmTime).format('YYYY-MM-DD HH:mm:ss')
}}</a-descriptions-item>
<a-descriptions-item label="告警级别" :span="1">
<a-tooltip
}}</j-descriptions-item>
<j-descriptions-item label="告警级别" :span="1">
<j-tooltip
placement="topLeft"
:title="(Store.get('default-level') || []).find((item: any) => item?.level === data?.level)
?.title || props.data?.level"
@ -21,10 +21,10 @@
?.title || props.data?.level}}
</span>
</Ellipsis>
</a-tooltip>
</a-descriptions-item>
<a-descriptions-item label="告警说明" :span="1"
><a-tooltip
</j-tooltip>
</j-descriptions-item>
<j-descriptions-item label="告警说明" :span="1"
><j-tooltip
placement="topLeft"
:title="data?.description || ''"
>
@ -33,14 +33,14 @@
{{ data?.description || '' }}
</span> </Ellipsis
>
</a-tooltip></a-descriptions-item
</j-tooltip></j-descriptions-item
>
<a-descriptions-item
<j-descriptions-item
label="告警流水"
:span="2"
><div style="max-height: 500px; overflow-y: auto;"><JsonViewer :value="JSON.parse(data?.alarmInfo || '{}')" :expand-depth="5"></JsonViewer></div></a-descriptions-item>
</a-descriptions>
</a-modal>
><div style="max-height: 500px; overflow-y: auto;"><JsonViewer :value="JSON.parse(data?.alarmInfo || '{}')" :expand-depth="5"></JsonViewer></div></j-descriptions-item>
</j-descriptions>
</j-modal>
</template>
<script lang="ts" setup>

View File

@ -1,5 +1,5 @@
<template>
<a-modal
<j-modal
title="告警处理"
okText="确定"
cancelText="取消"
@ -9,18 +9,18 @@
destroyOnClose
:confirmLoading="loading"
>
<a-form :rules="rules" layout="vertical" ref="formRef" :model="form">
<a-form-item label="处理结果" name="describe">
<a-textarea
<j-form :rules="rules" layout="vertical" ref="formRef" :model="form">
<j-form-item label="处理结果" name="describe">
<j-textarea
:rows="8"
:maxlength="200"
showCount
placeholder="请输入处理结果"
v-model:value="form.describe"
></a-textarea>
</a-form-item>
</a-form>
</a-modal>
></j-textarea>
</j-form-item>
</j-form>
</j-modal>
</template>
<script lang="ts" setup>
@ -64,6 +64,7 @@ const handleSave = () => {
});
if (res.status === 200) {
onlyMessage('操作成功!');
emit('closeSolve');
} else {
onlyMessage('操作失败!', 'error');
}

View File

@ -1,5 +1,5 @@
<template>
<a-modal
<j-modal
visible
title="处理记录"
:width="1200"
@ -8,11 +8,11 @@
@ok="clsoeModal"
@cancel="clsoeModal"
>
<Search
<pro-search
:columns="columns"
target="bind-channel"
@search="handleSearch"
></Search>
/>
<JProTable
model="TABLE"
:columns="columns"
@ -48,7 +48,7 @@
</span>
</template>
</JProTable>
</a-modal>
</j-modal>
</template>
<script lang="ts" setup>

View File

@ -1,29 +1,29 @@
<template>
<div class="alarm-log-card">
<Search
<pro-search
:columns="columns"
target="alarm-log"
v-if="['all', 'detail'].includes(props.type)"
@search="search"
></Search>
<Search
/>
<pro-search
:columns="produtCol"
target="alarm-log"
v-if="['product', 'other'].includes(props.type)"
@search="search"
></Search>
<Search
/>
<pro-search
:columns="deviceCol"
target="alarm-log"
v-if="props.type === 'device'"
@search="search"
></Search>
<Search
/>
<pro-search
:columns="orgCol"
target="alarm-log"
v-if="props.type === 'org'"
@search="search"
></Search>
/>
<JProTable
:columns="columns"
:request="handleSearch"
@ -31,6 +31,7 @@
:gridColumns="[1, 1, 2]"
:gridColumn="2"
model="CARD"
ref="tableRef"
>
<template #card="slotProps">
<CardBox
@ -52,8 +53,8 @@
{{ slotProps.alarmName }}
</span>
</Ellipsis>
<a-row :gutter="24">
<a-col :span="8">
<j-row :gutter="24">
<j-col :span="8">
<div class="content-des-title">
{{ titleMap.get(slotProps.targetType) }}
</div>
@ -62,8 +63,8 @@
{{ slotProps?.targetName }}
</div></Ellipsis
>
</a-col>
<a-col :span="8">
</j-col>
<j-col :span="8">
<div class="content-des-title">
最近告警时间
</div>
@ -76,17 +77,17 @@
}}
</div></Ellipsis
>
</a-col>
<a-col :span="8">
</j-col>
<j-col :span="8">
<div class="content-des-title">状态</div>
<a-badge
<j-badge
:status="
slotProps.state.value === 'warning'
? 'error'
: 'default'
"
>
</a-badge
</j-badge
><span
:style="
slotProps.state.value === 'warning'
@ -96,8 +97,8 @@
>
{{ slotProps.state.text }}
</span>
</a-col>
</a-row>
</j-col>
</j-row>
</template>
<template #actions="item">
<PermissionButton
@ -105,7 +106,6 @@
item.key === 'solve' &&
slotProps.state.value === 'normal'
"
:popConfirm="item.popConfirm"
:tooltip="{
...item.tooltip,
}"
@ -152,11 +152,11 @@ import { Store } from 'jetlinks-store';
import moment from 'moment';
import type { ActionsType } from '@/components/Table';
import SolveComponent from '../SolveComponent/index.vue';
import SolveLog from '../SolveLog/index.vue'
import SolveLog from '../SolveLog/index.vue';
import { useMenuStore } from '@/store/menu';
import { usePermissionStore } from '@/store/permission';
const menuStory = useMenuStore();
const tableRef = ref();
const alarmStore = useAlarmStore();
const { data } = storeToRefs(alarmStore);
const getDefaulitLevel = () => {
@ -347,24 +347,20 @@ watchEffect(() => {
const search = (data: any) => {
params.value.terms = [...data?.terms];
if (props.type !== 'all' && !props.id) {
params.value.terms.push(
{
params.value.terms.push({
termType: 'eq',
column: 'targetType',
value: props.type,
type: 'and',
},
);
});
}
if (props.id) {
params.value.terms.push (
{
params.value.terms.push({
termType: 'eq',
column: 'alarmConfigId',
value: props.id,
type: 'and',
},
);
});
}
};
@ -385,13 +381,15 @@ const getActions = (
data.value.current = currentData;
data.value.solveVisible = true;
},
popConfirm:{
title: !usePermissionStore().hasPermission('rule-engine/Alarm/Log:action')
? '暂无权限,请联系管理员'
: data.state?.value === 'normal'
? '无告警'
: ''
}
// popConfirm: {
// title: !usePermissionStore().hasPermission(
// 'rule-engine/Alarm/Log:action',
// )
// ? ''
// : data.state?.value === 'normal'
// ? ''
// : '',
// },
},
{
key: 'log',
@ -401,8 +399,10 @@ const getActions = (
},
icon: 'FileOutlined',
onClick: () => {
menuStory.jumpPage(`rule-engine/Alarm/Log/Detail`,{id:currentData.id});
}
menuStory.jumpPage(`rule-engine/Alarm/Log/Detail`, {
id: currentData.id,
});
},
},
{
key: 'detail',
@ -414,7 +414,7 @@ const getActions = (
onClick: () => {
data.value.current = currentData;
data.value.logVisible = true;
}
},
},
];
return actions;
@ -424,13 +424,14 @@ const getActions = (
*/
const closeSolve = () => {
data.value.solveVisible = false;
}
tableRef.value.reload(params.value);
};
/**
* 关闭处理记录
*/
const closeLog = () => {
data.value.logVisible = false;
}
};
</script>
<style lang="less" scoped>
</style>

View File

@ -1,5 +1,5 @@
<template>
<a-modal
<j-modal
:maskClosable="false"
width="650px"
destroyOnClose
@ -12,30 +12,30 @@
:confirmLoading="loading"
>
<div style="margin-top: 10px">
<a-form
<j-form
:layout="'vertical'"
ref="formRef"
:rules="rules"
:model="modelRef"
>
<a-form-item label="名称" name="name">
<a-input
<j-form-item label="名称" name="name">
<j-input
v-model:value="modelRef.name"
placeholder="请输入名称"
/>
</a-form-item>
<a-form-item label="说明" name="describe">
<a-textarea
</j-form-item>
<j-form-item label="说明" name="describe">
<j-textarea
v-model:value="modelRef.description"
placeholder="请输入说明"
showCount
:maxlength="200"
:rows="4"
/>
</a-form-item>
</a-form>
</j-form-item>
</j-form>
</div>
</a-modal>
</j-modal>
</template>
<script lang="ts" setup>

View File

@ -1,11 +1,11 @@
<template>
<page-container>
<div>
<Search
<pro-search
:columns="query.columns"
target="device-instance"
@search="handleSearch"
></Search>
/>
<JProTable
:columns="columns"
:request="queryList"
@ -53,15 +53,15 @@
{{ slotProps.name }}
</span>
</Ellipsis>
<a-row>
<a-col :span="12">
<j-row>
<j-col :span="12">
<Ellipsis>
<div>
{{ slotProps.description }}
</div>
</Ellipsis>
</a-col>
</a-row>
</j-col>
</j-row>
</template>
<template #actions="item">
<PermissionButton
@ -88,7 +88,7 @@
</CardBox>
</template>
<template #state="slotProps">
<a-badge
<j-badge
:text="
slotProps.state?.value === 'started'
? '正常'
@ -102,7 +102,7 @@
/>
</template>
<template #action="slotProps">
<a-space :size="16">
<j-space :size="16">
<template
v-for="i in getActions(slotProps, 'table')"
:key="i.key"
@ -123,7 +123,7 @@
/></template>
</PermissionButton>
</template>
</a-space>
</j-space>
</template>
</JProTable>
<!-- 新增编辑 -->