<template>
  <div class="alarm-history-table">
    <a-table :dataSource="mockData" :columns="Warncolumns" :scroll="{ y: 300 }"> </a-table>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

const Warncolumns = ref([
  {
    title: '序号',
    align: 'center',
    key: 'index',
    width: 80,
    customRender: ({ index }) => {
      return index + 1;
    },
  },
  {
    title: '设备名称',
    align: 'center',
    width: 200,
    customRender: () => '羊马河主通风机',
  },
  {
    title: '故障描述',
    align: 'center',
    customRender: ({ record }) => {
      const activeFaults = record.title;
      return activeFaults;
    },
  },
  {
    title: '故障原因',
    align: 'center',
    key: 'faultStatus',
    customRender: ({ record }) => {
      const activeFaults = record.faultStatus;
      return activeFaults;
    },
  },
  {
    title: '解决方案',
    align: 'center',
    key: 'netStatus',
    customRender: ({ record }) => {
      const activeFaults = record.netStatus;
      return activeFaults;
    },
  },
  {
    title: '时间',
    align: 'center',
    key: 'readTime',
    customRender: () => {
      const now = new Date();
      return now.toLocaleString(); // 格式化为本地时间字符串
    },
  },
]);

const mockData = [
  {
    key: 0,
    title: '水平或垂直振动>6mm',
    faultStatus: '通风阻力增大；静压值低于正常运行值100pa',
    netStatus: '检查相关参数传感器、增大风机运行频率',
  },
  {
    key: 1,
    title: '前轴/后轴温度>70℃',
    faultStatus: '缺乏润滑脂或轴承损坏',
    netStatus: '检查轴承润滑脂状态、检查轴承是否损坏、检查相关参数传感器',
  },
  {
    key: 2,
    title: '前轴/后轴温度>105℃',
    faultStatus: '轴承损坏',
    netStatus: '检查轴承是否损坏',
  },
  {
    key: 3,
    title: '水平或垂直振动>8mm,且变化范围较大',
    faultStatus: '电机轴承发生损坏；风机扇叶发生损坏',
    netStatus: '检查振动传感器、检查电机轴承、检查风机扇叶',
  },
  {
    key: 4,
    title: '额定电压超过额定值的10%时',
    faultStatus: '电网电压出现出现异常或者通风阻力增大',
    netStatus: '检查相关参数传感器、检查电网电压',
  },
];
</script>