<template>
  <div class="main-content m20">
    <!--头部-查询-->
    <div class="content-header">
      <div class="body search-body">
        <el-row>
          <el-col :span="12">
            <el-row class="mb10">
              <label class="label-name_1">统一社会信用代码/注册号：</label>
              <div class="search-input-box_1">
                <el-input v-model="searchForm.uscc" clearable size="mini" type="text" class="search-input" placeholder="请输入统一社会信用代码/注册号" @keyup.enter.native="loadPage" />
              </div>
            </el-row>
          </el-col>
          <el-col :span="12" class="mb10">
            <label class="label-name">主体名称：</label>
            <div class="search-input-box">
              <el-input v-model="searchForm.entName" clearable size="mini" type="text" class="search-input" placeholder="请输入主体名称（模糊）" @keyup.enter.native="loadPage" />
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="11" :offset="1">
            <div class="btn-box">
              <el-button size="mini" type="primary" @click="loadPage">查询</el-button>
              <el-button size="mini" @click="reset">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <!--body-查询结果-->
    <div class="content-body">
      <div class="body">
        <el-table
          ref="multipleTable"
          v-loading="loading"
          size="mini"
          :data="tableData"
          tooltip-effect="dark"
          style="width: 95%;margin:0 auto"
          :fit="true"
          :row-class-name="tableRowClassName"
          :header-cell-style="{background:'#8cc3fb',color:'#fff'}"
        >
          <el-table-column prop="index" label="序号" min-width="10%" align="center" />
          <el-table-column prop="uscc" label="统一社会信用代码/注册号" min-width="25%" align="left" />
          <el-table-column prop="entName" label="主体名称" min-width="25%" align="left" />
          <el-table-column prop="lerepName" label="法定代表人（负责人、经营者）" min-width="20%" align="left" />
          <el-table-column prop="removeDate" label="除名日期" min-width="15%" align="left" />
          <el-table-column prop="auditOpinion" :show-overflow-tooltip="true" label="除名原因" align="left" min-width="30%" />
          <el-table-column prop="removeOrgName" label="除名机关" align="left" min-width="20%" />
          <el-table-column label="操作" min-width="10%" align="center" fixed="right">
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="check(scope.row)">办理</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div class="page-box">
          <el-row class="bl0">
            <el-col :span="24">
              <el-pagination
                :disabled="loading"
                :page-size="pageParam.size"
                :total="pageParam.total"
                :page-sizes="[10, 20, 30, 40,50,100,200]"
                layout="slot,total, sizes, prev, pager, next, jumper"
                @size-change="pageSizeChange"
                @current-change="pageIndexChange"
              >
                <span>
                  第 {{ pageParam.current }} 页 /
                  共 {{ (pageParam.total !== 0 ? parseInt((pageParam.total + pageParam.size - 1)/pageParam.size) : 1) }} 页
                </span>
              </el-pagination>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { expelledAnnouncementList, expelledRevokeStartBiz } from '@/api/除名公告'
export default {
  data() {
    return {
      loading: false,
      searchForm: {
        uscc: '',
        entName: ''
      },
      tableData: [],
      pageParam: {
        current: 1,
        total: 0,
        size: 10
      }
    }
  },
  mounted() {
    this.loadPage()
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      }
    },
    // 当前分页改变
    pageIndexChange(current) {
      this.pageParam.current = current
      this.loadPage()
    },
    // 分页大小改变
    pageSizeChange(size) {
      this.pageParam.size = size
      this.loadPage()
    },
    // 加载分页
    loadPage() {
      if (this.loading) return
      this.loading = true
      expelledAnnouncementList({
        current: this.pageParam.current,
        size: this.pageParam.size,
        entity: {
          bizType: '2',
          state: '10',
          ...this.searchForm
        }
      }).then(res => {
        this.loading = false
        const list = []
        let i = 1
        const pageStart = (this.pageParam.current - 1) * this.pageParam.size
        res.data.records.forEach(each => {
          each.index = pageStart + i++
          list.push(each)
        })
        this.tableData = list
        this.pageParam.total = res.data.total
      })
    },
    reset() {
      this.searchForm.uscc = ''
      this.searchForm.entName = ''
      this.loadPage()
    },
    check(row) {
      this.$confirm('是否确认启动待办', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        return expelledRevokeStartBiz(row).then(({ code, data }) => {
          if (code === 0) {
            this.$message.success('除名撤销业务启动成功')
            this.$router.push({ path: '/entManage/expelled/removeRevokeAccept', query: { bizId: data.bizId }})
          } else {
            this.$message.error('除名撤销业务启动失败')
          }
        })
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        })
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.main-content{
  background: #fff;
  padding: 20px;
  .content-header{
    background: white;
    .search-body{
      /deep/ .el-date-editor *{
        font-size: 16px!important;
      }
      /deep/ .el-date-editor .el-range-separator{
        width: 8%!important;
      }
    }
    .label-name_1{
      text-align: right;
      display: inline-block;//转成行内快，才可定义宽度
      width: 220px;
      font-size: $table-content-font-size;
    }
    .search-input-box_1{
      display: inline-block;
      width: calc(100% - 220px);
    }
    .label-name_2{
      text-align: right;
      display: inline-block;//转成行内快，才可定义宽度
      width: 220px;
      font-size: $table-content-font-size;
    }
    .search-input-box_2{
      display: inline-block;
      width: calc(100% - 220px);
    }
    .label-name {
      text-align: right;
      display: inline-block;//转成行内快，才可定义宽度
      width: 220px;
      font-size: $table-content-font-size;
    }

    .search-input-box{
      display: inline-block;
      width: calc(100% - 220px);
      // width: 300px;
    }
    .custom{
      width: 60%
    }
    .search-input{
      cursor: pointer;
    }
    .body{
      padding: 20px 0 ;
      border-top:none;
      margin-bottom: 20PX;
    }
  }
  .content-body{
    background:white;
    margin-bottom: 100px;
  }
  .header{
    height:50PX;
    padding:15PX 10PX;
    .title{
      font-weight: 600;
      font-size: 1.2rem;
    }
  }
  .page-box{
    margin:10PX;
    .el-pagination{
      text-align: right;
    }
  }
  .mb10{
    margin-bottom: 10px;
  }
}
.fixed-bottom {
  position: fixed;
  width: 100%;
  bottom: -10px;
  right: 0;
  z-index: 99;
  padding: 10px;
  /* background: #8bbef6; */
  border-radius: 5px 5px 0 0;
  background: linear-gradient(to bottom, #fff 0%,#8bbef6 100%);
  box-shadow:  1px -4px 4px rgba(0, 21, 41, 0.08);
}
.content-body{
  background: #fff;
  /deep/.el-table .warning-row {
    background: #eaf4fe!important;
  }
}

</style>
<style lang="scss">
// .content-body .el-table-column--selection .cell{
  // padding-right: 0px;
// }
.fixed-bottom {
  .el-pagination {
    text-align: right!important;
  }
}
</style>
