<template>
  <div class="main-content market m20">
    <!-- <CommonTitle label="严重违法失信企业" /> -->
    <searchHeader title="查询" />
    <div class="search-box">
      <el-row class="mb10">
        <el-col :span="12">
          <div class="search-field">
            <p>企业名称</p>
            <el-input v-model="searchForm.name" size="mini" placeholder="请输入企业名称" @keyup.native.enter="search" />
          </div>
        </el-col>
        <el-col :span="12">
          <div class="search-field">
            <p>注册码/统一社会信用代码</p>
            <el-input v-model="searchForm.uscc" size="mini" placeholder="请输入注册码/统一社会信用代码" @keyup.native.enter="search" />
          </div>
        </el-col>
      </el-row>
      <el-row v-if="showMore" class="mb10">
        <el-col :span="12">
          <div class="search-field">
            <p>法定代表人/负责人</p>
            <el-input v-model="searchForm.leRepName" size="mini" placeholder="请输入法定代表人/负责人" @keyup.native.enter="search" />
          </div>
        </el-col>
        <el-col :span="12">
          <div class="search-field">
            <p>登记机关</p>
            <el-select v-model="searchForm.regOrg" size="mini" placeholder="请选择登记机关" clearable>
              <el-option v-for="each in regOrgOptions" :key="each.id" :label="each.name" :value="each.code" />
            </el-select>
          </div>
        </el-col>
      </el-row>
      <el-row style="margin-top:10px;">
        <el-col v-if="showMore" :span="12">
          <div class="search-field">
            <p>列入原因</p>
            <el-select v-model="searchForm.serillrea" placeholder="列入原因" size="mini" clearable>
              <el-option v-for="each in serillreaOptions" :key="each.basecodeid" :label="each.name" :value="each.code" />
            </el-select>
          </div>
        </el-col>
        <el-col :span="6" :offset="2">
          <div class="btn-box" style="text-align:center">
            <span v-if="!showMore" style="margin-right:20px;color:#409EFF;cursor:pointer" @click="showMoreCriteria">
              展开<i class="el-icon-d-arrow-right" />
            </span>
            <span v-if="showMore" style="margin-right:20px;color:#409EFF;cursor:pointer" @click="showMoreCriteria">
              <i class="el-icon-d-arrow-left" />隐藏
            </span>
            <el-button size="mini" type="primary" icon="el-icon-search" @click="search">查询</el-button>
            <el-button size="mini" type="info" icon="el-icon-refresh-left" @click="resetForm">重置</el-button>
          </div>
        </el-col>
      </el-row>
    </div>
    <div class="func-box" />
    <div class="main-body ">
      <div class="header">
        <el-row>
          <el-col :span="12" />
          <el-col :span="12">
            <!-- <div class="btn-box">
              <el-button type="primary" icon="el-icon-plus" size="mini">新建</el-button>
            </div> -->
          </el-col>
        </el-row>
      </div>
      <div class="content">
        <el-table
          v-loading="loading"
          :data="tableData"
          class="table-style"
          :row-class-name="tableRowClassName"
          :header-cell-style="{background:'#8cc3fb',color:'#fff'}"
        >
          <el-table-column
            prop="index"
            label="序号"
            width="50"
          />
          <el-table-column
            prop="uniscid"
            label="统一社会信用代码企业名称"
            width="180"
          />
          <el-table-column
            prop="entName"
            label="企业名称"
            show-overflow-tooltip
          />
          <el-table-column
            prop="leRepName"
            label="法定代表人/负责人"
          />
          <el-table-column
            prop="address"
            label="经营地址"
            show-overflow-tooltip
            min-width="180"
          />
          <el-table-column
            prop="bustypeName"
            label="业务类型"
            show-overflow-tooltip
          />
          <el-table-column
            label="操作"
          >
            <template slot-scope="scope">
              <el-link type="primary" @click="gotoHandle(scope.row)">查看详情</el-link>
            </template>
          </el-table-column>
        </el-table>
        <div class="page-box">
          <el-row>
            <el-col :span="24" style="text-align:right">
              <el-pagination
                :disabled="loading"
                :page-size="pageParam.pageSize"
                :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"
              >
                <!-- <batchFunction :options="options" style="float:left" /> -->
                <span>
                  第 {{ pageParam.curPage }} 页 /
                  共 {{ (pageParam.total !== 0 ? parseInt((pageParam.total + pageParam.pageSize - 1)/pageParam.pageSize) : 1) }} 页
                </span>
              </el-pagination>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import searchHeader from '@/components/searchHeader'
import { getUniIllegalTaskListPage } from '@/api/illegal'
import { getDataType, getBaseCodeList } from '@/api/constant'
export default {
  components: {
    searchHeader
  },
  data() {
    return {
      tableData: [],
      loading: false,
      showMore: false,
      pageParam: {
        curPage: 1,
        pageSize: 10,
        total: 0,
        paramMap: {

        }
      },
      searchForm: {
        name: '',
        uscc: '',
        leRepName: '',
        regOrg: '',
        serillrea: ''
      },
      regOrgOptions: [],
      serillreaOptions: []
    }
  },
  mounted() {
    // 加载登记机关
    getDataType('registration').then(res => {
      if (res.code === 0) {
        this.regOrgOptions = res.data
      }
    })
    // 加载列入原因
    getBaseCodeList('CD73').then(res => {
      if (res.code === 0) {
        this.serillreaOptions = res.data
      }
    })

    this.loadPage()
  },
  methods: {
    showMoreCriteria() {
      this.showMore = !this.showMore
    },
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex % 2 === 1) {
        return 'warning-row'
      }
    },
    search() {
      if (this.loading) return
      this.pageParam.curPage = 1
      this.pageParam.paramMap = {
        ...this.searchForm
      }
      this.loadPage()
    },
    resetForm() {
      this.searchForm = {
        name: '',
        uscc: '',
        leRepName: '',
        regOrg: '',
        serillrea: ''
      }
    },
    // 当前分页改变
    pageIndexChange(curPage) {
      this.pageParam.curPage = curPage
      this.loadPage()
    },
    // 分页大小改变
    pageSizeChange(pageSize) {
      this.pageParam.pageSize = pageSize
      this.loadPage()
    },
    // 加载分页
    loadPage() {
      if (this.loading) return
      this.loading = true
      getUniIllegalTaskListPage(this.pageParam).then(res => {
        this.loading = false
        if (res.code === 0) {
          const data = res.data
          const list = []
          let index = (this.pageParam.curPage - 1) * this.pageParam.pageSize
          data.records.forEach(each => {
            each.index = ++index
            each.bustypeName = this.$util.getTaskBusinessTypeName(each.bustype)
            list.push(each)
          })
          this.tableData = list
          this.pageParam.total = data.total
        }
      })
    },
    gotoHandle(row) {
      const query = {
        tasklistid: row.tasklistid,
        bizseq: row.bizseq,
        workflowId: row.workflowId
      }
      switch (row.bustype) {
        // 企业经营异常企业列入
        case '5': this.$router.push({ path: '/abnormal/company/inclusion/' + (row.currNodeId === 'exptlistEnter' ? 'accept' : row.currNodeId === 'handleExptlist' ? 'review' : 'examine'), query: query })
          break
        // 企业经营异常企业异议
        case '6': this.$router.push({ path: '/abnormal/company/dissent/' + (row.currNodeId === 'acceptDissentEnter' ? 'ApplyAccept' : row.currNodeId === 'handleDissentAccept' ? 'ApplyExamine' : row.currNodeId === 'approveDissent' ? 'ApprovalAccept' : 'ApprovalExamine'), query: query })
          break
        // 企业经营异常企业移出
        case '7': this.$router.push({ path: '/abnormal/company/remove/' + (row.currNodeId === 'exptlistEnter' ? 'RemoveAccept' : row.currNodeId === 'handleExptlist' ? 'RemoveReview' : 'RemoveExamine'), query: query })
          break
        // 个体工商户标记
        case '11': this.$router.push({ path: '/abnormal/individual/mark/' + (row.currNodeId === 'exptlistEnter' ? 'accept' : row.currNodeId === 'handleExptlist' ? 'review' : 'examine'), query: query })
          break
        // 个体工商户恢复
        case '12': this.$router.push({ path: '/abnormal/individual/recover/' + (row.currNodeId === 'exptlistEnter' ? 'accept' : row.currNodeId === 'handleExptlist' ? 'review' : 'examine'), query: query })
          break
        // 农民专业合作社列入
        case '13': this.$router.push({ path: '/abnormal/agriculture/inclusion/' + (row.currNodeId === 'exptlistEnter' ? 'accept' : row.currNodeId === 'handleExptlist' ? 'review' : 'examine'), query: query })
          break
        // 农民专业合作社移出
        case '14': this.$router.push({ path: '/abnormal/agriculture/remove/' + (row.currNodeId === 'exptlistEnter' ? 'accept' : row.currNodeId === 'handleExptlist' ? 'review' : 'examine'), query: query })
          break
        // 严重违法名录列入
        case '15':
          this.$router.push({ path: '/illegal/inclusion/' + (row.currNodeId === 'serIllegalEnter' ? 'accept' : row.currNodeId === 'handleSerIllegal' ? 'review' : 'examine'), query: query })
          break
        // 严重违法名录异议
        case '16':
          const page = row.currNodeId === 'acceptDissentEnter' ? 'applyAccept' : row.currNodeId === 'handleDissentAccept' ? 'applyExamine' : 'approvalExamine'
          this.$router.push({ path: `/illegal/dissent/${page}`, query: query })
          break
        // 严重违法名录移出
        case '17':
          this.$router.push({ path: '/illegal/remove/' + (row.currNodeId === 'serIllegalEnter' ? 'accept' : row.currNodeId === 'handleSerIllegal' ? 'review' : 'examine'), query: query })
          break
      }
    }
  }

}
</script>

<style lang="scss" scoped>
.main-content{
  background:#fff;
    >div:not(:first-child){
        margin-top:16px;
    }

    .btn-box{
        text-align:right;
    }
    .main-body{
        // padding:16px 0;
        // border-top: 1px dashed #70AEFF;
        .header{
            .header-label{
                font-size: 20PX;
                font-family: Microsoft YaHei, Microsoft YaHei-Bold;
                font-weight: bold;
                color: #243668;
                line-height: 32px;
            }
        }
    }
}
.search-box{
  margin-bottom: 40px;
  .search-field{
      display: flex;
      width:100%;
      >p{
          display:inline-block;
          margin:0 0 10px 0;
          padding: 0 10px;
          width: 220px;
          text-align: right;
          font-family: Microsoft YaHei, Microsoft YaHei-Bold;
          color: #5e5e7a;
          font-size:16PX;
      }
  }
  .el-input,.el-select{
    width: 70%;
  }
}
</style>
