<template>
    <basic-container class="examinListBox">
        <!--搜索栏-->
    <el-form
      size="small"
      label-position="right"
      :inline="true"
      style="padding-left: 10px;padding-right: 10px;"
    >
      <el-row :span="24">
        <el-form-item >
          <el-radio-group v-model="search.status" size="small" @change="changeCategory">
            <el-radio-button
              v-for="(item,key,index) in examineListStatus"
              :key="index"
              :label="item.value"
            >{{item.label}}</el-radio-button>
          </el-radio-group>
        </el-form-item><br/>
        <el-form-item label="用工单位:">
          <el-input v-model="search.companyName" placeholder="用工单位" clearable></el-input>
        </el-form-item>
        <el-form-item label="注册电话:" v-if="search.status === 3 || search.status === 4 || search.status === 5">
          <el-input v-model="search.phone" placeholder="注册电话" clearable></el-input>
        </el-form-item>
        <el-form-item label="所属市场:">
          <el-select
            v-model="search.stationId"
            placeholder="所属市场"
            style="width: 100%"
            filterable
          >
            <el-option
              v-for="(item, key, index) in workstationList"
              :key="index"
              :label="item.stationName"
              :value="item.stationId"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="商保状态:" v-if="search.status === 0 || search.status === 1 || search.status === 9">
          <el-select
            v-model="search.insuranceOn"
            placeholder="商保状态"
            style="width: 100%"
            filterable
          >
            <el-option
              v-for="(item, key, index) in insuranceOnList"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="电子合同:" v-if="search.status === 0 || search.status === 1 || search.status === 9">
          <el-select
            v-model="search.contractOn"
            placeholder="电子合同"
            style="width: 100%"
            filterable
          >
            <el-option
              v-for="(item, key, index) in contractOnList"
              :key="index"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <div class="searchBtn">
          <el-button type="primary" size="small" icon="el-icon-search" @click="handleSearch">搜 索</el-button>
          <el-button size="small" icon="el-icon-delete" @click="handleClear">清 空</el-button>
        </div>
      </el-row>
    </el-form>
    <!--/搜索栏-->
    <!-- table -->
    <wait-table ref="wait" v-if="search.status === 3" @refresh="handleClear"></wait-table>
    <ing-table ref="ing" v-if="search.status === 4" @refresh="handleClear"></ing-table>
    <success-table ref="success" v-if="search.status === 0" @refresh="handleClear"></success-table>
    <fail-table ref="fail" v-if="search.status === 1" @refresh="handleClear"></fail-table>
    <pause-table ref="pause" v-if="search.status === 5" @refresh="handleClear"></pause-table>
    <stop-table ref="stop" v-if="search.status === 9" @refresh="handleClear"></stop-table>
    </basic-container>
</template>
<script>
import WaitTable from './examineTable/waitTable'//待完善
import IngTable from './examineTable/ingTable'//待审核
import SuccessTable from './examineTable/successTable'//审核通过
import FailTable from './examineTable/failTable'//审核不通过
import PauseTable from './examineTable/pauseTable'//暂不处理
import StopTable from './examineTable/stopTable'//暂不处理
import { examineListState } from '@/common/dic'
import { getStation } from "@/api/manage/station";
export default {
    name: "manage_compan_examineList",
    components: {
        WaitTable,
        IngTable,
        SuccessTable,
        FailTable,
        PauseTable,
        StopTable
    },
    data () {
    return {
        workstationList:{},
        examineListStatus:examineListState,
        insuranceOnList:[{
          value: '0',
          label: '停用'
        }, {
          value: '1',
          label: '启用'
        }],
        contractOnList:[{
          value: '0',
          label: '关闭'
        }, {
          value: '1',
          label: '开启'
        }],
        search: {
            status: 3//认证状态 0：审核通过；1：审核不通过； 2：已驳回 3:待完善；4.待审核；5，暂不处理；9：终止合作
        },
        page: {
            pageSize: 10,
            currentPage: 1,
            total: 0
      },
    }
    },
    created(){
        getStation().then((res) => {
          this.workstationList = res.data.data;
        })
    },
    methods:{
        changeCategory(){
            this.search = {
                status: this.search.status,
            }
        },
        //搜索按钮
        handleSearch () {
            if (this.search.status === 3) {
                this.$refs.wait.onLoad(this.page, this.search);
            } else if (this.search.status === 4) {
                this.$refs.ing.onLoad(this.page, this.search);
            } else if (this.search.status === 0) {
                this.$refs.success.onLoad(this.page, this.search);
            } else if (this.search.status === 1) {
                this.$refs.fail.onLoad(this.page, this.search);
            } else if (this.search.status === 5) {
                this.$refs.pause.onLoad(this.page, this.search);
            }else if (this.search.status === 9) {
                this.$refs.stop.onLoad(this.page, this.search);
            }
        },
        //清空按钮
        handleClear(){
            this.search.companyName = "";
            this.search.phone = "";
            this.search.stationId = "";
            this.search.insuranceOn = "";
            this.search.contractOn = "";
            this.handleSearch ();
        } 
    }
}
</script>
<style >
.searchBtn {
  display: inline-block;
  margin-bottom: 0;
}
.examinListBox .el-form--inline .el-form-item{
    margin-bottom: 28px !important;
  }
</style>
