|
@@ -2,58 +2,75 @@
|
|
|
<div class="page">
|
|
|
<el-card shadow="nover">
|
|
|
<el-form :model="tableData.param" ref="queryRef" inline label-width="68px">
|
|
|
- <el-form-item label="创建时间" prop="dateRange">
|
|
|
- <el-date-picker v-model="tableData.param.dateRange" style="width: 240px" value-format="YYYY-MM-DD" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
|
|
+ <!-- 创建时间 -->
|
|
|
+ <el-form-item :label="$t('message.formI18nLabel.createdTime')" prop="dateRange" :label-width="labelWidth">
|
|
|
+ <el-date-picker v-model="tableData.param.dateRange" style="width: 240px" value-format="YYYY-MM-DD" type="daterange" range-separator="-" :start-placeholder="$t('message.formI18nPlaceholder.startDate')" :end-placeholder="$t('message.formI18nPlaceholder.endDate')"></el-date-picker>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="告警状态" prop="status" style="width: 200px;">
|
|
|
- <el-select v-model="tableData.param.status" placeholder="告警状态" clearable style="width: 240px">
|
|
|
- <el-option label="未处理" :value="0" />
|
|
|
- <el-option label="已处理" :value="1" />
|
|
|
- <el-option label="已忽略" :value="2" />
|
|
|
+ <!-- 告警状态 -->
|
|
|
+ <el-form-item :label="$t('message.formI18nLabel.alarmStatus')" prop="status" :label-width="labelWidth">
|
|
|
+ <el-select v-model="tableData.param.status" :placeholder="$t('message.formI18nPlaceholder.alarmStatus')" clearable style="width: 180px">
|
|
|
+ <el-option :label="$t('message.formI18nOption.unprocessed')" :value="0" />
|
|
|
+ <el-option :label="$t('message.formI18nOption.ignored')" :value="2" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
+ <!-- 查询 -->
|
|
|
<el-button type="primary" class="ml10" @click="typeList">
|
|
|
<el-icon>
|
|
|
<ele-Search />
|
|
|
</el-icon>
|
|
|
- 查询
|
|
|
+ {{ $t('message.formI18nButton.query') }}
|
|
|
</el-button>
|
|
|
+ <!-- 重置 -->
|
|
|
<el-button @click="resetQuery(queryRef)">
|
|
|
<el-icon>
|
|
|
<ele-Refresh />
|
|
|
</el-icon>
|
|
|
- 重置
|
|
|
+ {{ $t('message.formI18nButton.reset') }}
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading" max-height="calc(100vh - 255px)">
|
|
|
<el-table-column label="ID" align="center" prop="id" width="100" v-col="'ID'" />
|
|
|
- <el-table-column label="告警类型" prop="type" width="120" show-overflow-tooltip v-col="'type'">
|
|
|
+ <!-- 告警类型 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.alarmType')" prop="type" width="120" show-overflow-tooltip v-col="'type'">
|
|
|
<template #default="scope">
|
|
|
- <span v-if="scope.row.type == 1">规则告警</span>
|
|
|
- <span v-else-if="scope.row.type == 2">设备自主告警</span>
|
|
|
- <span v-else-if="scope.row.type == 3">规侧告警升级</span>
|
|
|
- <span v-else>设备自主告警</span>
|
|
|
+ <!-- 规则告警 -->
|
|
|
+ <span v-if="scope.row.type == 1">{{ $t('message.tableI18nAlarmType.ruleAlarm') }}</span>
|
|
|
+ <!-- 设备自主告警 -->
|
|
|
+ <span v-else-if="scope.row.type == 2">{{ $t('message.tableI18nAlarmType.deviceSelfAlarm') }}</span>
|
|
|
+ <!-- 规则侧告警升级 -->
|
|
|
+ <span v-else-if="scope.row.type == 3">{{ $t('message.tableI18nAlarmType.ruleAlarmUpgrade') }}</span>
|
|
|
+ <!-- 规则告警 -->
|
|
|
+ <span v-else>{{ $t('message.tableI18nAlarmType.deviceSelfAlarm') }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="规则级别" prop="alarmLevel.name" width="100" align="center" show-overflow-tooltip v-col="'alarmLevel'"></el-table-column>
|
|
|
- <el-table-column label="规则名称" prop="ruleName" show-overflow-tooltip v-col="'ruleName'" />
|
|
|
- <el-table-column label="产品标识" prop="productKey" show-overflow-tooltip v-col="'productKey'" />
|
|
|
- <el-table-column label="设备标识" prop="deviceKey" show-overflow-tooltip v-col="'deviceKey'" />
|
|
|
+ <!-- 规则级别 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.alarmLevel')" prop="alarmLevel.name" width="100" align="center" show-overflow-tooltip v-col="'alarmLevel'"></el-table-column>
|
|
|
+ <!-- 规则名称 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.ruleName')" prop="ruleName" show-overflow-tooltip v-col="'ruleName'" />
|
|
|
+ <!-- 产品标识 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.productKey')" prop="productKey" show-overflow-tooltip v-col="'productKey'" />
|
|
|
+ <!-- 设备标识 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.deviceKey')" prop="deviceKey" show-overflow-tooltip v-col="'deviceKey'" />
|
|
|
|
|
|
- <el-table-column prop="status" label="告警状态" width="100" align="center" v-col="'status'">
|
|
|
+ <!-- 告警状态 -->
|
|
|
+ <el-table-column prop="status" :label="$t('message.tableI18nColumn.alarmStatus')" width="120" align="center" v-col="'status'">
|
|
|
<template #default="scope">
|
|
|
- <el-tag type="danger" size="small" v-if="scope.row.status == 0">未处理</el-tag>
|
|
|
- <el-tag type="success" size="small" v-if="scope.row.status == 1">已处理</el-tag>
|
|
|
- <el-tag type="info" size="small" v-if="scope.row.status == 2">已忽略</el-tag>
|
|
|
+ <el-tag type="danger" size="small" v-if="scope.row.status == 0">{{ $t('message.tableI18nStatus.unprocessed') }}</el-tag>
|
|
|
+ <el-tag type="success" size="small" v-if="scope.row.status == 1">{{ $t('message.tableI18nStatus.processed') }}</el-tag>
|
|
|
+ <el-tag type="info" size="small" v-if="scope.row.status == 2">{{ $t('message.tableI18nStatus.ignored') }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="createdAt" label="告警时间" align="center" width="160" v-col="'createdAt'"></el-table-column>
|
|
|
- <el-table-column label="操作" width="140" align="center" fixed="right" v-col="'handle'">
|
|
|
+ <!-- 告警时间 -->
|
|
|
+ <el-table-column prop="createdAt" :label="$t('message.tableI18nColumn.alarmTime')" align="center" width="160" v-col="'createdAt'"></el-table-column>
|
|
|
+ <!-- 操作 -->
|
|
|
+ <el-table-column :label="$t('message.tableI18nColumn.operation')" width="140" align="center" fixed="right" v-col="'handle'">
|
|
|
<template #default="scope">
|
|
|
- <el-button size="small" text type="primary" @click="onOpenDetailDic(scope.row)" v-auth="'detail'">详情</el-button>
|
|
|
- <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)" v-if="scope.row.status == 0" v-auth="'edit'">处理</el-button>
|
|
|
+ <!-- 详情 -->
|
|
|
+ <el-button size="small" text type="primary" @click="onOpenDetailDic(scope.row)" v-auth="'detail'">{{ $t('message.tableI18nAction.detail') }}</el-button>
|
|
|
+ <!-- 处理 -->
|
|
|
+ <el-button size="small" text type="warning" @click="onOpenEditDic(scope.row)" v-if="scope.row.status == 0" v-auth="'edit'">{{ $t('message.tableI18nAction.handle') }}</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -65,12 +82,16 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
-<script lang="ts">
|
|
|
-import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
|
|
|
+<script lang="ts" setup>
|
|
|
+import { onMounted, ref, computed } from 'vue';
|
|
|
import { FormInstance } from 'element-plus';
|
|
|
import api from '/@/api/alarm';
|
|
|
import EditDic from './component/edit.vue';
|
|
|
import DetailDic from './component/detail.vue';
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
+
|
|
|
+// 国际化
|
|
|
+const { locale } = useI18n();
|
|
|
|
|
|
// 定义接口来定义对象的类型
|
|
|
interface TableDataRow {
|
|
@@ -81,99 +102,60 @@ interface TableDataRow {
|
|
|
desc: string;
|
|
|
createBy: string;
|
|
|
}
|
|
|
-interface TableDataState {
|
|
|
- ids: number[];
|
|
|
- tableData: {
|
|
|
- data: Array<TableDataRow>;
|
|
|
- total: number;
|
|
|
- loading: boolean;
|
|
|
- param: {
|
|
|
- pageNum: number;
|
|
|
- pageSize: number;
|
|
|
|
|
|
- dateRange: string[];
|
|
|
- status: string;
|
|
|
- };
|
|
|
- };
|
|
|
-}
|
|
|
+const addDicRef = ref();
|
|
|
+const editDicRef = ref();
|
|
|
+const detailRef = ref();
|
|
|
+const queryRef = ref();
|
|
|
+const ids = ref<number[]>([])
|
|
|
+const tableData = ref({
|
|
|
+ data: [],
|
|
|
+ total: 0,
|
|
|
+ loading: false,
|
|
|
+ param: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ status: '',
|
|
|
+ dateRange: [],
|
|
|
+ },
|
|
|
+})
|
|
|
|
|
|
-export default defineComponent({
|
|
|
- name: 'log',
|
|
|
- components: { EditDic, DetailDic },
|
|
|
|
|
|
- setup() {
|
|
|
- const addDicRef = ref();
|
|
|
- const editDicRef = ref();
|
|
|
- const detailRef = ref();
|
|
|
- const queryRef = ref();
|
|
|
- const state = reactive<TableDataState>({
|
|
|
- ids: [],
|
|
|
- tableData: {
|
|
|
- data: [],
|
|
|
- total: 0,
|
|
|
- loading: false,
|
|
|
- param: {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 20,
|
|
|
- status: '',
|
|
|
- dateRange: [],
|
|
|
- },
|
|
|
- },
|
|
|
- });
|
|
|
- // 初始化表格数据
|
|
|
- const initTableData = () => {
|
|
|
- typeList();
|
|
|
- };
|
|
|
- const typeList = () => {
|
|
|
- state.tableData.loading = true;
|
|
|
- api.log
|
|
|
- .getList(state.tableData.param)
|
|
|
- .then((res: any) => {
|
|
|
- state.tableData.data = res.list;
|
|
|
- state.tableData.total = res.Total;
|
|
|
- })
|
|
|
- .finally(() => (state.tableData.loading = false));
|
|
|
- };
|
|
|
+// 动态设置 createdTime 标签宽度
|
|
|
+const labelWidth = computed(() => {
|
|
|
+ return locale.value === 'en' ? '100px' : '68px';
|
|
|
+});
|
|
|
+// 初始化表格数据
|
|
|
+const initTableData = () => {
|
|
|
+ typeList();
|
|
|
+};
|
|
|
+const typeList = () => {
|
|
|
+ tableData.value.loading = true;
|
|
|
+ api.log
|
|
|
+ .getList(tableData.value.param)
|
|
|
+ .then((res: any) => {
|
|
|
+ tableData.value.data = res.list;
|
|
|
+ tableData.value.total = res.Total;
|
|
|
+ })
|
|
|
+ .finally(() => (tableData.value.loading = false));
|
|
|
+};
|
|
|
|
|
|
- //打开详情页
|
|
|
- const onOpenDetailDic = (row: TableDataRow) => {
|
|
|
- detailRef.value.openDialog(row);
|
|
|
- };
|
|
|
- // 打开新增产品弹窗
|
|
|
- const onOpenAddDic = () => {
|
|
|
- editDicRef.value.openDialog();
|
|
|
- };
|
|
|
- // 打开修改产品弹窗
|
|
|
- const onOpenEditDic = (row: TableDataRow) => {
|
|
|
- editDicRef.value.openDialog(row);
|
|
|
- };
|
|
|
- // 页面加载时
|
|
|
- onMounted(() => {
|
|
|
- initTableData();
|
|
|
- });
|
|
|
- /** 重置按钮操作 */
|
|
|
- const resetQuery = (formEl: FormInstance | undefined) => {
|
|
|
- if (!formEl) return;
|
|
|
- formEl.resetFields();
|
|
|
- typeList();
|
|
|
- };
|
|
|
- // 多选框选中数据
|
|
|
- const handleSelectionChange = (selection: TableDataRow[]) => {
|
|
|
- state.ids = selection.map((item) => item.id);
|
|
|
- };
|
|
|
- return {
|
|
|
- addDicRef,
|
|
|
- editDicRef,
|
|
|
- queryRef,
|
|
|
- detailRef,
|
|
|
- onOpenDetailDic,
|
|
|
- onOpenAddDic,
|
|
|
- onOpenEditDic,
|
|
|
- typeList,
|
|
|
- resetQuery,
|
|
|
- handleSelectionChange,
|
|
|
- ...toRefs(state),
|
|
|
- };
|
|
|
- },
|
|
|
+//打开详情页
|
|
|
+const onOpenDetailDic = (row: TableDataRow) => {
|
|
|
+ detailRef.value.openDialog(row);
|
|
|
+};
|
|
|
+// 打开修改产品弹窗
|
|
|
+const onOpenEditDic = (row: TableDataRow) => {
|
|
|
+ editDicRef.value.openDialog(row);
|
|
|
+};
|
|
|
+// 页面加载时
|
|
|
+onMounted(() => {
|
|
|
+ initTableData();
|
|
|
});
|
|
|
+/** 重置按钮操作 */
|
|
|
+const resetQuery = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ formEl.resetFields();
|
|
|
+ typeList();
|
|
|
+};
|
|
|
</script>
|