import type { TableColumnType, TableColumnsType } from "ant-design-vue";

const INDEX_COLUMN: TableColumnType = {
  key: "index",
  title: "序号",
  width: 60,
  fixed: true,
  align: "center",
} as const;

// 定义操作列配置
const ACTION_COLUMN: TableColumnType = {
  key: "action",
  title: "操作",
  width: 120,
  ellipsis: true,
  fixed: "right",
  align: "center",
} as const;

// 使用 Record 类型确保键值对的安全性
export const fields: Record<string, string> = {
  alarmId: "报警ID",
  alarmCode: "报警代码",
  alarmMsg: "报警信息",
  alarmDatetime: "报警时间",
  updateTime: "更新时间",
  updateBy: "更新人",
  createTime: "创建时间",
  createBy: "创建人",
} as const;

// 导出完整的列配置
export const columns: TableColumnsType = [
  INDEX_COLUMN,
  ...Object.entries(fields).map(([key, title]) => ({
    key,
    title,
    ellipsis: true,
  })),
  ACTION_COLUMN,
];
