<template>
  <!-- 漏缆实时状态 -->
  <div class="leakage-cable">
    <div class="leakage-top">
      <div>
        共6条数据
      </div>
      <div class="operate-btn">
        <el-button type="primary">刷新</el-button>
        <el-button type="primary">查询</el-button>
        <el-button type="primary">导出</el-button>
      </div>
    </div>
    <el-table :data="tableData" style="width: 100%" :cell-class-name="cellClassFn" :header-cell-style="{background:'#EAF1FE',color:'#666666'}">
      <el-table-column prop="equipment1" label="网元设备" align="center" />
      <el-table-column prop="state1" label="连接状态" align="center" />
      <el-table-column prop="equipment2" label="网元设备" align="center" />
      <el-table-column prop="state2" label="连接状态" align="center" />
      <el-table-column prop="equipment3" label="网元设备" align="center" />
      <el-table-column prop="uploadDate" label="上传时间" align="center" />
    </el-table>
    <pagination
      :limit="searchForm.pageSize"
      :page="searchForm.pageNum"
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>

<script>
import Pagination from '@/components/Pagination'

export default {
  components: { Pagination },
  data() {
    return {
      searchForm: {
        pageNum: 1,
        pageSize: 10
      },
      total: 10,
      tableData: [
        {
          equipment1: '监控中心LSC',
          state1: '连接正常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },
        {
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接正常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接正常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },
        {
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接正常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接正常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },
        {
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接正常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接正常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },
        {
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接正常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接正常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },
        {
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接正常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        },{
          equipment1: '监控中心LSC',
          state1: '连接异常',
          equipment2: '现场管理单元 K65+308',
          state2: '连接异常',
          equipment3: '天馈线A_K4563_535',
          uploadDate: '2022/12/18 11:51:12'
        }
      ],
    };
  },
  methods: {
    // 表格背景图颜色
    cellClassFn({row, column, rowIndex, columnIndex}) {
      if ((row.state1 == '连接正常' && column.property == 'state1')) {
        return 'green'
      }
      if ((row.state1 == '连接异常' && column.property == 'state1')) {
        return 'red'
      }
      if ((row.state2 == '连接正常' && column.property == 'state2')) {
        return 'green'
      } else if ((row.state2 == '连接异常' && column.property == 'state2')) {
        return 'red'
      }
      if (rowIndex%2 == 1) {
        return 'stripe'
      }
    },
    handlePageChange(pageData) {
      this.searchForm.pageSize = pageData.size
      this.searchForm.pageNum = pageData.page
    }
  }
};
</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 .red {
    background-color: #f00;
  }
  & ::v-deep .green {
    background-color: green;
  }
  .page {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    .pageNum {
      margin: 0 20px;
    }
  }
}
</style>
