<!--
  @description: 京能-机构审核详情
  @Modifier:张慢慢
  @routerPath:/systemManagement/organizationAuditDetail
  @date: 2020/11/13-16:41
-->
<template>
  <div>
    <section class="title p0-16 clearfix">
      <!-- 返回 -->
      <div class="title-back pointer" @click="back()">
        <i class="iconfont icon-fanhui mr10" />机构入库审核
      </div>
    </section>
    <div>
      <!--信息详情-->
      <orgRegisterInfoDetail class="view" :audit-info-param="auditInfoParam" />
      <!--操作按鈕-->
      <div class="but_footer">
        <div class="p0-16">
          <el-form ref="auditInfoParam" :model="auditInfoParam">
            <el-form-item ref="auditOpinion" label="审核意见" prop="auditOpinion">
              <el-input
                v-model="auditInfoParam.auditOpinion"
                :rows="4"
                type="textarea"
                :placeholder="!$route.query.isOnlyShow?'请填写审核意见':''"
                maxlength="200"
                show-word-limit
                :disabled="$route.query.isOnlyShow"
              />
            </el-form-item>
          </el-form>
        </div>
        <div v-if="!$route.query.isOnlyShow" class="but_footer-h">
          <div class="but_footer-but">
            <el-button :loading="confirmLoading" type="primary" @click="verified()">
              审核通过
            </el-button>
            <el-button :loading="confirmLoading" @click="auditFail()">
              审核不通过
            </el-button>
            <el-button @click="back()">
              返回
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
/* 接口*/
import {
  auditAgencyInfo // 审核机构信息
} from '@/api/common/user'// 审核接口
// 详情信息
import orgRegisterInfoDetail from '../orgRegisterInfo/orgRegisterInfo-detail'
export default {
  name: 'OrganizationAuditDetail',
  components: {
    orgRegisterInfoDetail // 详情信息
  },
  data() {
    return {
      confirmLoading: false, // 控制按钮重复点击Loding
      // 审核信息参数
      auditInfoParam: {
        departId: '', // 机构id
        departInfoId: '', // 用户ID
        rolCode: '', // 类型
        roleName: this.$route.params.rolCode, // 注册类型中文
        auditOpinion: '', // 审核意见
        auditFlag: '', // 审核状态01通过02驳回
        ...this.$route.params
      }
    }
  },
  methods: {
    // 操作审核通过不通过调用接口
    handleAuditProject(auditFlag) {
      const params = {
        auditFlag: auditFlag,
        auditOpinion: this.auditInfoParam.auditOpinion,
        ids: this.auditInfoParam.departInfoId
      }
      this.confirmLoading = true// btnLoding
      auditAgencyInfo(params).then(reponse => {
        this.$message({
          type: 'success',
          message: '审核成功'
        })
        this.confirmLoading = false// btnLoding
        this.back()
      }).catch(() => {
        this.confirmLoading = false// btnLoding
      })
    },
    // 审核通过
    verified() {
      this.$confirm('确认提交?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        confirmButtonClass: 'confirmBtn',
        cancelButtonClass: 'cancelBtn',
        type: 'warning'
      }).then(() => {
        this.handleAuditProject('01')
      }).catch(() => {
      })
    },
    // 审核不通过
    auditFail() {
      if (this.auditInfoParam.auditOpinion) {
        this.$confirm('确认提交?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          confirmButtonClass: 'confirmBtn',
          cancelButtonClass: 'cancelBtn',
          type: 'warning'
        }).then(() => {
          this.handleAuditProject('02')
        }).catch(() => {
        })
      } else {
        this.$message({
          type: 'warning',
          message: '请输入审核意见'
        })
      }
    },
    // 返回
    back() {
      this.$router.push({
        path: '/systemManagement/organizationAudit'
      })
    }
  }
}
</script>

<style lang="less" scoped>
  .view{
    margin-top: 0px;
  }
</style>
