
<!--
  @description: 专家审核容器
  @Modifier: wxy
  @routerPath:
  @date:  2020-09-07 16:41:26
-->
<template>
  <div class="main p0-16">
    <section v-if="this.$route.params.status=== '01'" class="title title_border">
      <i class="iconfont icon-fanhui pointer" @click="back" />
      专家入库审核
    </section>
    <section v-if="this.$route.params.status=== '02'" class="title title_border">
      <i class="iconfont icon-fanhui pointer" @click="back" />
      信息变更审核
    </section>
    <expertQuitAudit />
    <div class="clearfix" style="margin:20px 0;">
      <p class="page-title fl">
        专家分类
      </p>
      <div style="width:200px;margin-left:15px;" class="fl">
        <el-select v-model="formData.extractLevel " placeholder="请选择" style="width: 100%">
          <el-option
            v-for="item in extractLevelList"
            :key="item.typecode"
            :label="item.typename"
            :value="item.typecode"
          />
        </el-select>
      </div>
    </div>
    <p class="page-title">
      审核意见
    </p>
    <table class="tableData">
      <tr class="singleRow">
        <td>审核意见</td>
        <td>
          <el-input
            v-model="formData.reason"
            :autosize="{ minRows: 4, maxRows: 4 }"
            type="textarea"
            maxlength="1000"
            show-word-limit
            style="width: 100%"
          />
        </td>
      </tr>
    </table>
    <div class="but_footer">
      <div class="but_footer-h">
        <div class="but_footer-but">
          <el-button type="primary" @click="auditResult('01')">
            审核通过
          </el-button>
          <el-button @click="auditResult('02')">
            审核不通过
          </el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
/* 接口*/
import { auditExpertApply, auditExpertInfoChange } from '@/api/expert/expertscloud.js'
import expertQuitAudit from './expertQuitAudit-detail.vue'
/* 方法*/
import { filterDictText } from '@/assets/js/utils'
export default {
  components: {
    expertQuitAudit
  },
  data() {
    return {
      formData: {
        reason: '', // 审核意见
        auditStatus: '', // 审核状态
        extractLevel: '', // 抽取等级
        expertId: this.$route.params.expertId // 专家id
      },
      searchData: {
        applyId: '', // 申请id
        reason: '', // 审核意见
        auditStatus: '', // 审核状态
        expertId: this.$route.params.expertId // 专家id
      },
      // 抽取等级
      extractLevelList: []
    }
  },
  created() {
    // 字典信息
    this.initGroup()
  },
  methods: {
    filterDictText, // 字典值替换文本通用方法
    // 获取字典方法
    initGroup() {
      const data = [
        'extractLevel' // 抽取等级
      ]
      this.$store.dispatch('getGroupType', data).then(res => {
        Object.keys(res.bidTypeData).forEach((key) => {
          this[key] = res.bidTypeData[key]
        })
      })
    },
    // 返回
    back() {
      if (this.$route.params.status === '01') {
        this.$router.push({
          name: 'expertQuitEnterAudit-lists'
        })
      } else {
        this.$router.push({
          name: 'expertQuitEditAudit-list'
        })
      }
    },
    // 审核
    auditResult(status) {
      if (status === '01' && (this.formData.extractLevel === '' || this.formData.extractLevel === undefined)) {
        this.$message({
          type: 'warning',
          message: '请选择专家分类'
        })
        return false
      }
      if (status === '02' && this.formData.reason === '') {
        this.$message({
          type: 'warning',
          message: '请填写审核意见'
        })
        return false
      }

      const text = status === '01' ? '确定审核通过？' : '确定不通过审核？'
      this.$confirm(text, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn'
      })
        .then(() => {
          if (this.$route.params.status === '01') {
            this.formData.auditStatus = status
            auditExpertApply(this.formData).then(res => {
              this.$router.push('/expert/expertQuitEnterAudit-list')
            }).catch(() => {})
          } else {
            auditExpertInfoChange(this.formData).then(res => {
              this.$router.push('/expert/expertQuitEnterAudit-list')
            }).catch(() => {})
          }
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang='less' scoped>

</style>
