<!--
  @description: 专家库-专家入库审核
  @Modifier: 徐媛媛
  @routerPath: /expert/expertQuitEnterAudit-list
  @date: 2020/9/3
-->
<template>
  <div>
    <!--标题-->
    <div class="title title_border p0-16">
      <i class="el-icon-s-home" />专家入库审核
    </div>
    <section class="p0-16">
      <!--查询条件-->
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询条件</span>
        <span class="fr pointer" @click="handleToggleSearch">
          <el-link
            :underline="false"
            :class="toggleSearchStatus?'arrow-is-active':''"
            type="primary"
            class="toggleSearchStatus icon el-icon-arrow-down"
          />
          {{ toggleSearchStatus?'收起高级查询' :'展开高级查询' }}
        </span>
      </div>
      <div :class="{'SearchContent_show':toggleSearchStatus}" class="clearfix SearchContent">
        <div class="SearchContent_leftInput fl">
          <el-form
            ref="searchForm"
            :model="searchForm"
            inline
            label-width="100px"
            label-position="left"
          >
            <el-form-item ref="expertName" label="专家姓名" prop="expertName">
              <el-input
                v-model.trim="searchForm.expertName"
                placeholder="专家姓名"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <el-form-item ref="certificateCode" label="身份证号" prop="certificateCode">
              <el-input
                v-model.trim="searchForm.certificateCode"
                placeholder="身份证号"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <el-form-item ref="specialName" label="主评专业" prop="specialName">
              <el-input
                v-model.trim="searchForm.specialName"
                placeholder="主评专业"
                style="width:220px"
                @keyup.enter.native="onSearch"
              />
            </el-form-item>
            <!--创建时间-->
            <el-form-item
              label="创建时间"
              prop="createEndTime"
            >
              <el-date-picker
                v-model="searchForm.createBeginTime"
                :format="elValueFormat"
                :value-format="elValueFormat"
                type="date"
                placeholder="开始日期"
              />
              至
              <el-date-picker
                v-model="searchForm.createBeginTime1"
                :format="elValueFormat"
                :value-format="elValueFormat"
                type="date"
                placeholder="结束日期"
              />
            </el-form-item>
          </el-form>
        </div>
        <div class="fr">
          <el-button type="primary" @click="onSearch">
            搜 索
          </el-button>
          <el-button plain type="info" @click="resetForm('searchForm')">
            重 置
          </el-button>
        </div>
      </div>
      <div class="crud_menu_title clearfix">
        <span class="icon-line fl">查询结果</span>
        <el-upload
          ref="uploads"
          :on-success="handleSuccess"
          :on-error="handleError"
          :show-file-list="false"
          :action="action"
          :limit="1"
          :headers="importHeaders"
          multiple
          style="display: inline-block;margin:0 10px"
        >
          <el-button class="mb10 ml10" type="primary" plain size="small">
            导入名单
          </el-button>
        </el-upload>
        <el-button
          type="primary"
          class="mb10 ml10"
          plain
          @click="downloadTemp"
        >
          下载模板
        </el-button>
      </div>
      <div>
        <el-table
          ref="smallTable"
          v-loading="loading"
          :data="tableData"
          class="tableLimit"
        >
          <el-table-column
            type="index"
            label="序号"
            width="60px"
            align="center"
          />
          <el-table-column
            prop="realName"
            align="center"
            label="专家姓名"
            min-width="170"
          />
          <el-table-column
            align="center"
            prop="certificate"
            label="身份证号"
            min-width="200"
          />
          <el-table-column
            align="center"
            prop="mobile"
            label="联系方式"
            min-width="120"
          />
          <el-table-column
            align="center"
            prop="comName"
            label="工作单位"
            min-width="200"
          />
          <el-table-column
            header-align="center"
            align="left"
            prop="specialtyName"
            label="主评专业"
            min-width="120"
          />
          <el-table-column
            header-align="center"
            align="left"
            prop="area"
            label="所在区域"
            min-width="200"
          />
          <el-table-column
            header-align="center"
            align="left"
            prop="createTime"
            label="申请时间"
            min-width="200"
          >
            <template slot-scope="scope">
              {{ $Moment(scope.row.createTime).format(momentDateTime) }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="操作"
            width="160"
          >
            <template slot-scope="scope">
              <el-link
                type="primary"
                @click.stop="preview(scope.row)"
              >
                [审核]
              </el-link>
            </template>
          </el-table-column>
        </el-table>
        <!--分页组件-->
        <pagination :pagination-data="paginationData" @change="loadData" />
      </div>
    </section>
  </div>
</template>
<script>
/* 接口*/
import { getAuditExpertList, downloadTemplate } from '@/api/expert/expertscloud.js'// 专家入库审核表格接口
/* 公用方法*/
import { filterObj, filterDictText, restoreInitialValue } from '@/assets/js/utils'// 常用方法
import { download } from '@/assets/js/utils/index'
import Cookies from 'js-cookie'
/* 混合开发方法-参数字段*/
import { ListMixin } from '@/mixins/ListMixin'// 分页
import { commonMxin } from '@/mixins/commonMxin'
/* 组件*/
import pagination from '@comp/common/pagination/pagination'// 分页
export default {
  name: 'TenderProjectList',
  components: {
    pagination // 分页

  },
  mixins: [ListMixin, commonMxin],
  data() {
    return {
      loading: true,
      // 搜索
      searchForm: {
        expertName: '', //  专家姓名
        certificateCode: '', // 身份证号
        specialName: '', // 主评专业
        createTime: '' // 创建时间
      },
      tableData: [],
      // 上传文件地址
      action:
        '/bidprocurement/expertscloud-expert/register/ExpertBatchImportController/importBatchExperts',
      // 上传的请求头
      importHeaders: {}
    }
  },
  created() {
    // 获取列表信息
    this.loadData()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取数据
    loadData() {
      this.importHeaders['X-AUTH-TOKEN'] = Cookies.get('X-AUTH-TOKEN')
      const params = this.getQueryParams()// 查询条件
      getAuditExpertList(params).then(response => {
        this.loading = false
        this.tableData = response.data.records
        this.paginationData.total = response.data.total
      }).catch(() => {
        this.loading = false
      })
    },
    // 查询条件
    getQueryParams() {
      const param = Object.assign({}, this.searchForm)
      param.pageNo = this.paginationData.pageNo
      param.pageSize = this.paginationData.pageSize
      return filterObj(param)
    },
    // 搜索
    onSearch() {
      this.paginationData.pageNo = 1
      this.paginationData.pageSize = 10
      // 获取列表信息
      this.loadData()
    },
    // 重置
    resetForm(formName) {
      restoreInitialValue(this.searchForm)
      // 获取列表信息
      this.onSearch()
    },
    // 审核
    preview(row) {
      this.$router.push({
        name: 'expertQuitAuditContent',
        params: {
          status: '01', // 入库审核
          expertId: row.id // 专家id
        }
      })
    },

    // 下载模板
    downloadTemp() {
      //  模板类型
      const data = {
        templateType: 'DT_EXPERTS_BATCH'
      }
      downloadTemplate(data)
        .then(res => {
          download(res, '专家信息导入模板.xlsx')
        })
        .catch(() => {})
    },
    // 导入失败后的回调
    handleError(response, file, fileList) {
      this.$message.error(response.header.msg)
      this.$refs.uploads.clearFiles()
    },
    // 导入成功后的回调
    handleSuccess(response, file, fileList) {
      if (response.header.ret === '0') {
        this.$message.success(response.header.msg)
      } else {
        this.$message.warning(response.header.msg)
      }
      this.$refs.uploads.clearFiles()
      // 获取列表信息
      this.onSearch()
    }
  }
}
</script>
<style lang="less" scoped>
.crud_menu_title{
  .el-button{
    margin-top: 8px;
  }
}

</style>
