<template>
  <div class="channelList">
    <div class="channelTop">
      <div class="channelTopLeft">
        <el-input
          placeholder="搜索通道名称或注册码"
          v-model="filterText"
          class="channelTopLeftInput"
        >
          <template #suffix>
            <i class="el-icon-search el-input__icon"></i>
          </template>
        </el-input>
        <el-button
          class="search-button"
          icon="el-icon-plus"
          type="success"
          @click="Insert()"
        >
          添加通道
        </el-button>
      </div>
    </div>

    <div class="channelContent">
      <el-table
        :data="
          tableData.filter(
            (data) =>
              !filterText ||
              data.channelName
                .toLowerCase()
                .includes(filterText.toLowerCase()) ||
              data.regCode.toLowerCase().includes(filterText.toLowerCase())
          )
        "
        border
        stripe
        :header-cell-style="headClass"
        :height="Height"
      >
        <el-table-column
          prop="stationStatus"
          align="center"
          label="状态"
          width="50"
        >
          <template #default="scope">
            <el-avatar
              class="status"
              :style="
                scope.row.stationStatus == 0
                  ? 'background-color:red'
                  : 'background-color:#04F21C'
              "
            ></el-avatar>
          </template>
        </el-table-column>

        <el-table-column
          prop="channelName"
          label="通信名称"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="netNumber"
          label="网络卡号"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="netDeadline"
          label="网络截止时间"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="accessMode"
          label="接入方式"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="channelIP"
          label="通道IP:端口号"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="regCode"
          label="注册码"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column
          prop="reportingAdd"
          label="上报地址:端口"
          align="center"
          width=""
        ></el-table-column>
        <el-table-column label="操作" align="center" width="150">
          <template #default="scope">
            <el-button
              type="text"
              size="small"
              style="color: #409eff"
              @click.prevent="Details(scope.row)"
            >
              详情
            </el-button>
            <el-button
              @click="Delete(scope.$index, scope.row)"
              type="text"
              size="small"
              style="color: red"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="listPagination">
        <el-pagination
          v-model:currentPage="currentPage"
          :page-sizes="[15, 20, 25, 30]"
          :page-size="15"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.length"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
        ></el-pagination>
      </div>
    </div>
    <div></div>
  </div>
</template>
<script>
import { defineComponent, ref } from 'vue'

export default defineComponent({
  name: 'powerEquip',
  components: {},
  props: {
    Height: String,
  },
  data() {
    return {
      deviceNumData: [],

      tableData: [
        {
          stationStatus: 0,
          channelName: '上海美争企业发展有限公司',
          netNumber: '89860426102070967305',
          netDeadline: '',
          accessMode: '拨号',
          channelIP: '',
          regCode: 'DA00023997',
          reportingAdd: '139.196.33.250:2404',
        },
        {
          stationStatus: 1,
          channelName: '上海美争企业发展有限公司',
          netNumber: '89860426102070967305',
          netDeadline: '',
          accessMode: '拨号',
          channelIP: '',
          regCode: 'DA00023997',
          reportingAdd: '139.196.33.250:2404',
        },
      ],
      activeName: 'powerEquip',
      filterText: '',
      currentPage: ref(15),
    }
  },
  methods: {
    //新增
    Insert() {
      console.log('')
    },
    // 表头样式设置
    headClass() {
      return 'background:#FAFAFA !important;color: black;'
    },
    //详情
    Details(row) {
      console.log(row)
    },
    //删除
    Delete(ind, row) {
      console.log(ind, row)
    },
    handleSizeChange(val) {
      console.log(`${val} items per page`)
    },
    handleCurrentChange(val) {
      console.log(`current page: ${val}`)
    },
  },
})
</script>

<style lang="scss" scoped>
.channelList {
  margin: 15px;
  //顶部左侧样式
  .channelTop {
    display: flex;
    height: 32px;
    line-height: 32px;
    .channelTopLeft {
      width: 70%;
      .goBack {
        margin-right: 15px;
      }
      .channelTopLeftTitle {
        font-size: 14px;
        margin-right: 10px;
      }
      .channelTopLeftInput {
        width: 15rem;
      }
      .el-input__icon {
        color: #409eff;
      }
      .el-input__inner:hover {
        border-color: #409eff;
      }
      .el-input__inner:focus {
        border-color: #409eff;
      }
      .search-button {
        margin-left: 1rem;
      }
    }
  }
  .channelContent {
    margin-top: 15px;
  }
}

.listPagination {
  margin-top: 15px;
  float: right;
}
</style>