<template>
  <div class="trademark">
    <div class="trademarkLoading" v-if="loading" v-loading="true"></div>
    <h3>
      <p class="el-icon-arrow-left" @click="showTable">返回</p>
      <b></b>
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item>商标注册证</el-breadcrumb-item>
      </el-breadcrumb>
    </h3>
    <table>
      <thead class="trademark-table-header">
        <tr>
          <td>序号</td>
          <td>商标图样</td>
          <td>商标名</td>
          <td>注册号</td>
          <td>类别</td>
          <td>状态</td>
          <td>申请时间</td>
          <td>详情</td>
        </tr>
      </thead>
      <tbody class="trademark-table-body" v-if="itemList.length != 0">
        <tr v-for="(item, index) in itemList" :key="index">
          <td>{{ getIndex(index) }}</td>
          <td><img :src="item.logo" alt="" /></td>
          <td>{{ item.sbmc ? item.sbmc : "---" }}</td>
          <td>{{ item.sbzch ? item.sbzch : "---" }}</td>
          <td>{{ item.gjfl ? item.gjfl : "---" }}类</td>
          <td>{{ item.sbzt ? item.sbzt : "---" }}</td>
          <td>{{ item.sqrq ? item.sqrq : "---" }}</td>
          <td class="gotoDetail" @click="gotoDetail(item.sbzch, item.gjfl)">
            详情
          </td>
        </tr>
      </tbody>
      <tbody v-else class="trademark-table-body">
        <tr class="notList">
          <td colspan="8">暂无数据</td>
        </tr>
      </tbody>
    </table>
    <el-pagination
      background
      layout="prev, pager, next"
      :page-size="pageSize"
      :total="listcount"
      @current-change="handleCurrentChange"
    >
    </el-pagination>
  </div>
</template>

<script>
import { findTrademarkzcr } from "@/api/tmQuery.js";
export default {
  props: ["name"],
  data() {
    return {
      pageSize: 5,
      currentPage: 1,
      trademarkList: [],
      itemList: [],
      listcount: 0,
      loading: false
    };
  },
  mounted() {
    this.loading = true;
    findTrademarkzcr(this.name, this.pageSize, this.currentPage).then(res => {
      console.log(res, "获取商标注册证");
      this.loading = false;
      if (res.status == 0) {
        let newArr = res.data.rows;
        this.itemList = newArr;
        this.listcount = res.data.count;
        this.$emit("getCount", res.data.count);
      }
    });
  },
  methods: {
    //跳转详情页
    gotoDetail(sbzch, gjfl) {
      this.$router.push({ path: "/jdbycdetailtm", query: { sbzch, gjfl } });
    },
    handleCurrentChange(val) {
      // this.itemList = this.trademarkList.slice(
      //   (val - 1) * this.pageSize,
      //   val * this.pageSize
      // );
      this.currentPage = val;
      this.loading = true;
      findTrademarkzcr(this.name, this.pageSize, this.currentPage).then(res => {
        console.log(res, "获取商标注册证");
        this.loading = false;
        if (res.status == 0) {
          let newArr = res.data.rows;
          this.itemList = newArr;
          this.listcount = res.data.count;
        }
      });
    },
    //获取序号
    getIndex(index) {
      return index + 1 + this.currentPage * this.pageSize - this.pageSize;
    },
    indexMethod(index) {
      return index * 2;
    },
    //翻转
    showTable() {
      this.$emit("unshowOne");
    },
  }
};
</script>

<style lang="scss">
.trademark {
  width: 100%;
  position: relative;
  .trademarkLoading{
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
  .gotoDetail {
    color: #1478f0;
    cursor: pointer;
  }
  h3 {
    display: flex;
    align-items: center;
    margin-bottom: 17px;
    p {
      margin-right: 8px;
      font-size: 15px;
      cursor: pointer;
    }
    b {
      width: 2.5px;
      height: 14px;
      background: #1478f0;
      display: block;
      margin-right: 5px;
    }
    .el-breadcrumb {
      .el-breadcrumb__item:nth-child(1) {
        .el-breadcrumb__inner {
          font-size: 16px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: rgba(51, 51, 51, 1);
          line-height: 22px;
        }
      }
      .el-breadcrumb__item:nth-child(2) {
        .el-breadcrumb__inner {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(20, 120, 240, 1);
          line-height: 22px;
        }
      }
    }
  }
  table {
    width: 100%;
    text-align: center;
    .trademark-table-header {
      width: 100%;
      tr {
        width: 100%;
        td {
          width: 12.5%;
          padding: 15px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          border: 1px solid #e4eef6;
          background: #f2f9fc;
        }
      }
    }
    .trademark-table-body {
      width: 100%;
      tr {
        width: 100%;
        .notList {
          text-align: center;
        }
        td {
          width: 12.5%;
          padding: 15px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          border: 1px solid #e4eef6;
          img {
            width: 60px;
            height: 34px;
            border: 2px solid #ccc;
            display: inline-block;
          }
        }
      }
    }
  }
  .el-pagination {
    display: flex;
    justify-content: center;
    margin: 19px 0;
  }
}
</style>
