<template>
  <div class="leakage-cable">
    <!-- 设备连接维修历史 -->
    <div class="leakage-top">
      <div style="color: #666666"></div>
      <div class="operate-btn">
        <el-button
          :type="multipleSelection.length ? 'primary' : 'info'"
          :disabled="!multipleSelection.length"
          >删除</el-button
        >
        <el-button type="primary">刷新</el-button>
        <el-button type="primary">查询</el-button>
        <el-button type="primary">导出</el-button>
        <el-button type="primary">清空数据</el-button>
      </div>
    </div>
    <el-table
      :data="tableData2"
      style="width: 100%"
      :cell-class-name="cellClassFn"
      :header-cell-style="{ background: '#EAF1FE', color: '#666666' }"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />

      <el-table-column prop="netDevice" label="网元设备" align="center" />
      <el-table-column
        prop="linkStatus"
        label="连接状态"
        width="150"
        align="center"
      >
      </el-table-column>
      <el-table-column prop="netDevice2" label="网元设备" align="center">
      </el-table-column>
      <el-table-column prop="repairPerson" label="维修人员信息" align="center">
      </el-table-column>
      <el-table-column
        prop="linkRepairDate"
        label="连接告警维修时间"
  
        align="center"
      />
    </el-table>
    <Pagination
      :limit="searchForm.pageSize"
      :page="searchForm.pageNum"
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    >
    </Pagination>
  </div>
</template>
<script>
import Pagination from "@/components/Pagination";
export default {
  props: [],
  components: { Pagination },
  data() {
    return {
      multipleSelection: [],
      searchForm: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 14,
tableData2:[],
      tableData: [
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          repairPerson: "张三",
          linkRepairDate: "2022/12/18 11:59:42",
        },
        {
          netDevice: "现场管理单元 K65+308",
          linkStatus: "连接正常",
          netDevice2: "故障定位单元 K64+287",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "现场管理单元 K65+308",
          linkStatus: "连接正常",
          netDevice2: "故障定位单元 K64+287",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "现场管理单元 K65+308",
          linkStatus: "连接正常",
          netDevice2: "故障定位单元 K64+287",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "现场管理单元 K65+308",
          linkStatus: "连接正常",
          netDevice2: "故障定位单元 K64+287",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
        {
          netDevice: "监控中心LSC",
          linkStatus: "连接异常",
          netDevice2: "现场管理单元 K65+308",
          linkRepairDate: "2022/12/18 11:59:42",
          repairPerson: "张三",
        },
      ],
    };
  },
  computed: {},
  methods: {
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    handlePageChange(pageData) {
      this.searchForm.pageSize = pageData.size;
      this.searchForm.pageNum = pageData.page;
        this.getTableData()
    },
      getTableData() {
      this.tableData2 = this.tableData.slice(( this.searchForm.pageNum - 1) * this.searchForm.pageSize,
         this.searchForm.pageNum * this.searchForm.pageSize
      );
      this.total = this.tableData.length
  
    },
    cellClassFn({ row, column, rowIndex, columnIndex }) {
      if (row.linkStatus == "连接异常" && column.label == "连接状态") {
        return "emergency";
      } else if (row.linkStatus == "连接正常" && column.label == "连接状态") {
        return "normal";
      }
      if (rowIndex % 2 == 1) {
        return "stripe";
      }
    },
  },
  mounted() {
     this.getTableData()
  },
};
</script>
<style lang="scss" scoped>
.leakage-cable {
  .leakage-top {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
  }
  & ::v-deep .cell {
    color: #333333;
  }

  & ::v-deep .stripe {
    background-color: #eaf1fe;
  }
  & ::v-deep .emergency {
    background-color: #f00;
  }
  & ::v-deep .important {
    background-color: #f89850;
  }
  & ::v-deep .normal {
    background-color: green;
  }

  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    .pageNum {
      margin: 0 20px;
    }
  }
}
</style>