<template>
  <div>
    <div class="leakage-top">
      <div style="color: #666666"></div>

      <div class="operate-btn">
        <el-button
          :type="multipleSelection.length ? 'primary' : 'info'"
          :disabled="!multipleSelection.length"
          @click="delData"
          >删除</el-button
        >
        <el-button type="primary" @click="refresh">刷新</el-button>
        <el-button type="primary" @click="query">查询</el-button>
        <el-button type="primary" @click="exportData">导出</el-button>
      </div>
    </div>
    <el-table
      ref="multipleTable"
      class="statistics-table"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      :row-class-name="tableRowClassName"
      :row-style="{ height: '50px' }"
      :header-cell-style="{
        background: '#eaf1fe',
        color: '#000',
        fontWeight: 700,
        height: '50px',
      }"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      
      <el-table-column
        prop="parentId"
        label="所在铁路线"
        align="center"
      />
      
      <el-table-column
        prop="hundredMetersLoss"
        label="漏缆百米损耗"
        show-overflow-tooltip
        align="center"
      /> 
      <el-table-column
        prop="leakyCableCode"
        label="漏缆编号"
        show-overflow-tooltip
        align="center"
      />  <el-table-column
        prop="leakyCableDescribe"
        label="描述"
        show-overflow-tooltip
        align="center"
      />  <el-table-column
        prop="leakyCableLength"
        label="漏缆长度"
        show-overflow-tooltip
        align="center"
      />  <el-table-column
        prop="leakyCableMode"
        label="漏缆型号"
        show-overflow-tooltip
        align="center"
      />  <el-table-column
        prop="reductRatio"
        label="漏缆速度衰减系数："
        show-overflow-tooltip
        align="center"
      />  <el-table-column
        prop="sendPower"
        label="发射功率"
        show-overflow-tooltip
        align="center"
      />  
       <el-table-column
        prop="jumperLength"
        label="跳线长度"
        show-overflow-tooltip
        align="center"
      />  
      <el-table-column
        prop="inserterLength"
        label="插入器长度"
        show-overflow-tooltip
        align="center"
      />
      <el-table-column prop="antennaFeederLength" label="天馈线长度：" align="center" />
      <el-table-column
        prop="action"
        label="详细信息"
        show-overflow-tooltip
        align="center"
      >
        <template slot-scope="{ row }">
          <el-link type="primary" :underline="false" @click="handleView(row)"
            >查看</el-link
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :limit="params.pageSize"
      :page="params.pageNum"
      :total="total"
      class="pagination"
      @pagination="handlePageChange"
    />
  </div>
</template>
<script>
import Pagination from "@/components/Pagination";
import { leakyCablelist, leakyCablebatchDelete, leakyCabledetail } from "../../api";
export default {
  props: [],
  components: { Pagination },
  data() {
    return {
      tableData: [],
      params: {
        pageNum: 1,
        pageSize: 10,
      },
      total: 10,
      multipleSelection: [],
      ids: [],
    };
  },
  computed: {},
  methods: {
    tableRowClassName({ row, rowIndex }) {
      return rowIndex % 2 === 0 ? "" : "single-row";
    },
    changeType(item) {
      this.activeName = item.key;
    },
    delData() {
      let ids = this.ids;
      leakyCablebatchDelete({ ids }).then((res) => {});
      this.getTableData();
    },
    refresh() {},
    query() {},
    exportData() {},
    handleSelectionChange(val) {
      this.multipleSelection = val;

      this.ids = this.multipleSelection.map((i) => i.id);
    
    },

    handleView(row) {
    
      let id = row.id;
      leakyCabledetail({ id }).then((res) => {
        
      });
    },
    handlePageChange(pageData) {
      this.params.pageSize = pageData.size;
      this.params.pageNum = pageData.page;
      this.getTableData();
    },
    getTableData() {
      // this.tableData2 = this.tableData.slice(( this.params.pageNum - 1) * this.params.pageSize,
      //    this.params.pageNum * this.params.pageSize
      // );
      // this.total = this.tableData.length
      let params = {
        current: this.params.pageNum,
        size: this.params.pageSize,
      };
      leakyCablelist(params).then((res) => {
        let list = res.records || [];
        this.tableData = list;
        this.total = res.total;
      });
    },
  },
  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 .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>
<style lang="scss">
.statistics-table {
  .single-row {
    background: #f1f6ff;
  }
  td {
    padding: 5px !important;
  }
}
</style>