<template>
  <div class="noticepage">
    <!-- 头部导航面包屑 -->
    <div class="nav">
      <span>商标公告查询</span>
    </div>
    <!-- 查询选择表单 -->
    <div class="choice-form">
      <el-form :inline="true" :model="choiceForm" :rules="rule">
        <el-row class="first-row">
          <el-form-item label="公告类型：" class="left-span">
            <el-select
              v-model="choiceForm.type"
              placeholder="商标初步审定公告"
              class="info-box"
              @change="changeOption"
            >
              <el-option label="商标初步审定公告" value="TMZCSQ"></el-option>
              <el-option label="商标注册公告（一）" value="TMZCZC"></el-option>
              <el-option label="商标注册公告（二）" value="TMQTZC"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="公告期号：" class="left-span" prop="num">
            <el-input
              v-model="choiceForm.num"
              placeholder="请输入公告期号"
              class="info-box"
            ></el-input>
          </el-form-item>
          <el-button type="primary" @click="onSubmit" class="btn-size left-span"
            >查询</el-button
          >
        </el-row>
      </el-form>
    </div>

    <!-- 初审公告 -->
    <div class="record">
      <span>最新12期初审公告</span>
    </div>

    <!-- 公告表格 -->
    <div class="brand-form-wrap">
      <el-table :data="brandData" class="brand-form" v-loading="loading">
        <el-table-column prop="notice_issue" label="公告期" align="center">
        </el-table-column>
        <el-table-column
          prop="date"
          label="初审公告日期"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="enddate"
          label="异议申请截止日期"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="lastday"
          label="异议申请剩余时间"
          align="center"
        ></el-table-column>

        <el-table-column prop="operation" label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="passNoticeNumber(scope.$index, scope.row)"
              >公告详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { noticequeryTMZCSQ } from "@/api/tmQuery.js";
export default {
  data() {
    return {
      // 查询选择表单数据
      choiceForm: {
        type: "TMZCSQ", // 公告类型
        num: null // 公告期号
      },
      rule: {},

      // 商标表格数据
      brandData: [],

      // 动画
      loading: false
    };
  },
  methods: {
    onSubmit() {
      console.log(this.choiceForm.num);
      if (this.choiceForm.num == null) {
        console.log("konhkongkong");
        this.$message({
          message: "请输入目标",
          type: "warning"
        });
      } else if (/\D/.test(this.choiceForm.num)) {
        this.$message({
          message: "工期号只能是数字",
          type: "warning"
        });
      } else {
        this.$router.push({
          path: "/bycnoticeindex",
          query: {
            type: this.choiceForm.type,
            noticenum: this.choiceForm.num
          }
        });
      }
    },
    changeOption(value) {
      //   console.log(value);
      this.choiceForm.type = value;
      console.log("change change", this.choiceForm.type);
    },
    passNoticeNumber(index, row) {
      this.choiceForm.num = row.notice_issue;
      // 提交请求
      this.$router.push({
        path: "/bycnoticeindex",
        query: {
          type: this.choiceForm.type,
          noticenum: this.choiceForm.num
        }
      });
    }
  },
  created() {
    // 刷新页面取消查询的query参数
    this.$router.push("/bycnoticetm");
    this.loading = true;
    noticequeryTMZCSQ().then(res => {
      this.brandData = res.data.rows;
      this.loading = false;
    });
  },
  mounted() {}
};
</script>

<style lang="scss">
.noticepage {
  // 企链 70px的footer ; 启服通的footer是377px
  min-height: calc(100% - 70px);

  .choice-form {
    .el-input__inner {
      border-radius: 0px;
    }
  }
  .has-gutter tr th {
    background: #d6daeb;
  }
  /* 头部导航面包屑 */
  .nav {
    width: 1200px;
    margin: 0 auto;
    padding-top: 21px;
    padding-bottom: 18px;
    span {
      font-weight: 500;
      line-height: 20px;
      font-size: 16px;
      color: #03004c;
    }
  }

  /* 查询选择表单 */
  .choice-form {
    background: #f7f8fc;
    border: 1px solid #eff1f9;
    width: 1198px;
    height: 76px;
    margin: 0 auto;
    .first-row {
      margin-top: 18px;
      button.el-button {
        background: #0989c5;
        width: 80px;
        height: 34px;
        padding: 0;
        box-sizing: border-box;
        border-radius: 0;
        line-height: 0;
      }
    }

    .left-span {
      margin-left: 20px;
      height: 34px;
    }

    .info-box {
      width: 300px;
      border-radius: 0px;
    }

    .btn-size {
      width: 60px;
      height: 34px;
      font-family: PingFangSC-Regular;
      font-size: 14px;
    }
  }

  /* 最新12期初审公告 */
  .record {
    width: 1200px;
    margin: 0 auto;
    height: 40px;
    span {
      padding-left: 17px;
      font-size: 14px;
      color: rgb(130, 130, 130);
      line-height: 40px;
    }
  }

  /* 商标表格 */
  .brand-form-wrap {
    width: 1198px;
    margin: 0 auto;
    border: 1px solid #d6daeb;
    margin-bottom: 100px;
    .brand-form {
      font-family: PingFangSC-Regular;
      font-size: 14px;
      color: #333333;
      // 样式，，，
    }
    .el-table__row {
      td:nth-child(4) {
        .cell {
          color: #de2828;
        }
      }
    }
  }
}
</style>
