<!--
  @description: 退款打回
  @Modifier: sunxinman/haofengxian
  @routerPath:
  @date: 2020/04/02-15:50
-->
<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="visibleDialog"
    :close-on-click-modal="false"
    title="提示"
    width="600px"
  >
    <section class="p8">
      <!-- 表单 -->
      <el-form ref="operateReasonForm" :model="formData" :rules="rules" label-width="100px">
        <el-form-item ref="operateReason" label="驳回原因" prop="operateReason">
          <el-input
            v-model="formData.operateReason"
            :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('operateReasonForm')">提 交</el-button>
      <el-button @click="visibleDialog = false">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
/* 接口*/
import { repulseDepositRefundDetail } from '@api/fee/bailfee'
export default {
  name: 'RejectReasonDialog',
  data() {
    return {
      visibleDialog: false, // 是否打开弹框
      formData: {
        refundDetailId: '', // 退款明细主键
        operateReason: '' // 打回意见
      },
      rules: {
        operateReason: [{ 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) {
          repulseDepositRefundDetail(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>
