You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

171 lines
4.2 KiB

import type { BasicColumn, FormSchema } from '@/components/Table'
import {optionListApi, subSystemListApi} from "@/api/alert/model/select";
import {h, ref} from "vue";
import {systemSelectParams} from "@/api/alert/model/model/optionsModel";
import {formatToDateTime, getDate} from "@/utils/dateUtil";
export const currentTime = ref(Date.now())
setInterval(() => {
currentTime.value = Date.now()
}, 1000)
function toTimestamp(time: string): number {
if (!time) return 0
// 兼容:2026-01-04T09:30:15 / 2026-01-04 09:30:15
return new Date(time.replace('T', ' ')).getTime()
}
export const columns: BasicColumn[] = [
{
title: '编号',
dataIndex: 'warnId',
width: 80,
fixed: 'left',
},
{
title: '机组',
dataIndex: 'unitName',
width: 80,
fixed: 'left',
},
{
title: '报警名称',
dataIndex: 'alarmName',
width: 200,
fixed: 'left',
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', record.pointName),
h('div', { style: 'color: #999; font-size: 12px' }, record.pointId)
]);
},
},
{
title: '单位',
dataIndex: 'unit',
width: 50,
fixed: 'left',
},
{
title: '测点值',
dataIndex: 'unit',
width: 150,
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', { style: 'color: #006400;font-weight:bold' },'实时值:'+Number(record.pointValue).toFixed(3)),
h('div', { style: 'color: #0960BD;font-weight:bold' },'重构值:'+Number(record.outputPointValue).toFixed(3)),
]);
},
},
{
title: '偏差值',
dataIndex: 'biasValue', // 可以写,也可以不写
width: 65,
customRender: ({ record }) => {
const real = Number(record.pointValue)
const target = Number(record.outputPointValue)
if (isNaN(real) || isNaN(target)) return '-'
return (real - target).toFixed(2)
},
},
{
title: '安全区间',
dataIndex: 'limit',
width: 100,
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', (Number(record.outputPointValue)+Number(record.lowlimit)).toFixed(2)),
h('div', (Number(record.outputPointValue)+Number(record.uplimit)).toFixed(2)),
]);
},
},
{
title: '模型实例名称',
dataIndex: 'mpName',
width: 150,
ellipsis: false, // ⭐ 关键
},
{
title: '预警时间',
dataIndex: 'insertTime',
width: 200,
// 将 JSX 改为 h 函数调用
customRender: ({ record }) => {
return h('div', [
h('div', record.insertTime),
// h('div', '--'),
h('div', formatToDateTime(currentTime.value))
]);
},
},
{
title: '持续时长',
dataIndex: 'timeDiffStr',
width: 100,
customRender: ({ record }) => {
if (!record.insertTime) return '-'
const diffMs = currentTime.value - toTimestamp(record.insertTime)
return getDate(diffMs)
},
},
{
title: '告警级别',
dataIndex: 'alarmModelRuleName',
width: 80,
ellipsis: false, // ⭐ 关键
},
{
title: '专业',
dataIndex: 'systemName',
width: 100,
}
]
// export const formTrend: FormSchema[] = [
// {
// label: '时间',
// field: 'time',
// show: true,
// component: 'RangePicker',
// componentProps: {
// placeholder: ['开始时间', '结束时间'],
// defaultValue: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')],
// valueFormat: 'YYYY-MM-DD HH:mm:ss',
// showTime: {
// defaultValue: [moment().subtract(1, 'day').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')],
// },
// onChange: (e: any) => {
// console.log(e)
// },
// colProps: {
// span: 8,
// },
// },
// },
// {
// label: '时间间隔',
// field: 'interval',
// component: 'Select',
// defaultValue: 60,
// labelWidth:100,
// componentProps: {
// options: [{ value: 60, label: '60秒' }, { value: 100, label: '100秒' }, { value: 300, label: '300秒' }],
// },
// required: true,
// colProps: {
// span: 5,
// },
// },
// ]