<!--
  @description: 保证金退换审批-输入驳回原因
  @Modifier: sunxinman/haofengxian
  @routerPath:
  @date: 2020/04/03-16:50
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="visibleDialog"
    :close-on-click-modal="false"
    title="提示"
    append-to-body
    width="700px"
  >
    <section class="p8">
      <!-- 表单 -->
      <el-form ref="form" :model="formData" :rules="rules" label-width="100px">
        <el-form-item label="驳回原因" prop="auditReason">
          <el-input
            v-model="formData.auditReason"
            :autosize="{ minRows: 6, maxRows: 6 }"
            type="textarea"
            maxlength="4000"
            show-word-limit
          />
        </el-form-item>
      </el-form>
    </section>
    <!--底部操作按钮-->
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="ensure('form')">提 交</el-button>
      <el-button @click="visibleDialog = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { rejectDepositRefundDetail } from '@api/fee/bailfee'
export default {
  name: 'RejectReasonDialog',
  data() {
    return {
      visibleDialog: false, //  是否打开弹框
      formData: {
        refundDetailId: '', // 退款明细主键
        auditReason: '' // 审核意见
      },
      rules: {
        auditReason: [{ required: true, message: '不能为空', trigger: 'blur' }]
      }
    }
  },
  methods: {
    // 父组件触发此方法 打开弹框
    openDialog(refundDetailId) {
      this.formData.refundDetailId = refundDetailId // 明细id
      this.visibleDialog = true // 打开弹框
    },
    // 提交
    ensure(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          rejectDepositRefundDetail(this.formData).then(res => {
            this.$message({
              type: 'success',
              message: '操作成功'
            })
            this.visibleDialog = false
            this.$emit('loadData')
          }).catch(() => {

          })
        } else {
          return false
        }
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>
