import type { FormSchemaGetter } from '#/adapter/form'; import type { VxeGridProps } from '#/adapter/vxe-table'; import { h } from 'vue'; import { getPopupContainer } from '@vben/utils'; import { getDictOptions } from '#/utils/dict'; import { DictEnum } from '@vben/constants'; export const querySchema: FormSchemaGetter = () => [ { component: 'Input', fieldName: 'deviceName', label: '设备名称', }, { component: 'DatePicker', fieldName: 'reportTime', label: '预警时间', componentProps: { format: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD HH:mm:ss', }, }, { component: 'Input', fieldName: 'alarmType', label: '预警类型', }, { component: 'Select', componentProps: { getPopupContainer, options: getDictOptions(DictEnum.alarm_level, true), }, fieldName: 'level', label: '预警级别', }, ]; export const columns: VxeGridProps['columns'] = [ { type: 'checkbox', width: 60 }, { title: '预警编号', field: 'id', }, { title: '预警时间', field: 'reportTime', }, { title: '设备IP', field: 'deviceIp', }, { title: '设备名称', field: 'deviceName', }, { title: '预警级别', field: 'level', slots: { default: ({ row }: any) => { const levelColors: Record = { 1: 'blue', 2: 'orange', 3: 'red', }; return h( 'span', { style: { color: levelColors[row.level] || '#666', fontWeight: 'bold', }, }, row.levelName, ); }, }, }, { title: '预警类型', field: 'alarmTypeName', slots: { default: ({ row }: any) => { return h('span', row.bigTypeName + '-' + row.smallTypeName); }, }, }, { title: '处理状态', field: 'stateName', }, { title: '创建时间', field: 'createTime', }, { field: 'action', fixed: 'right', slots: { default: 'action' }, title: '操作', width: 380, }, ]; export const modalSchema: FormSchemaGetter = () => [ { label: '主键', fieldName: 'id', component: 'Input', dependencies: { show: () => false, triggerFields: [''], }, }, { label: '预警编号', fieldName: 'id', component: 'Input', rules: 'required', disabled: true, }, { label: '预警时间', fieldName: 'reportTime', component: 'DatePicker', componentProps: { format: 'YYYY.MM.DD HH:mm', valueFormat: 'YYYY.MM.DD HH:mm', showTime: true, }, disabled: true, rules: 'required', }, { label: '预警类型', fieldName: 'alarmType', component: 'Input', rules: 'required', disabled: true, }, { label: '设备IP', fieldName: 'deviceIp', component: 'Input', disabled: true, rules: 'required', }, { label: '设备名称', fieldName: 'deviceName', disabled: true, component: 'Input', rules: 'required', }, { label: '预警级别', fieldName: 'level', component: 'Select', disabled: true, componentProps: { getPopupContainer, options: getDictOptions(DictEnum.alarm_level, true), }, rules: 'selectRequired', }, { label: '创建时间', fieldName: 'createTime', component: 'DatePicker', disabled: true, componentProps: { format: 'YYYY.MM.DD HH:mm', valueFormat: 'YYYY.MM.DD HH:mm', showTime: true, }, }, { label: '处理状态', component: 'Select', disabled: true, componentProps: { getPopupContainer, options: getDictOptions(DictEnum.alarm_state, true), }, fieldName: 'state', rules: 'selectRequired', }, { label: '预警描述', disabled: true, fieldName: 'description', component: 'Textarea', formItemClass: 'col-span-2', componentProps: { rows: 3, }, }, // 插入分割线 { component: 'Divider', fieldName: '_divider', formItemClass: 'col-span-2', hideLabel: true, renderComponentContent: () => { return { default: () => h('div', '处理'), }; }, }, { label: '处理人', fieldName: 'solveId', component: 'Select', }, { label: '联系电话', fieldName: 'phonenumber', component: 'Input', }, { label: '邮箱', fieldName: 'email', component: 'Input', }, { label: '所在部门', fieldName: 'deptName', component: 'Input', disabled: true, }, { label: '备注', fieldName: 'remark', component: 'Textarea', formItemClass: 'col-span-2', componentProps: { rows: 3, }, }, ];