<template>
  <el-dialog class="contact-dialog"
             title="驳回" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">

    <div class="input">
      <el-form :model="contact" ref="contactForm" :label-width="'100px'">


        <el-form-item label="借款编号:" prop="loanNo">
          {{loanNo}} {{raiseNo}}
        </el-form-item>

        <el-form-item label="客户名称:" prop="clientNo">
          {{client.clientName}}
        </el-form-item>

        <el-form-item label="驳回原因:" prop="content">
          <el-input type="textarea" row="3" v-model="memo"></el-input>
        </el-form-item>
      </el-form>
    </div>

    <div slot="footer">
      <el-button @click="handleClose">取 消</el-button>
      <el-button type="primary" @click="submitClick">驳 回</el-button>
    </div>
  </el-dialog>
</template>

<script type="text/ecmascript-6">


  export default {
    name: 'CancelLoanDialog',
    props: {
      dialogVisible: {
        type: Boolean
      },
      loanNo: {
        type: String,
        required: true
      },
      raiseNo: {
        type: String,
      },
      bizNo: {
        type: String
      },
      client: {
        type: Object,
        required: true
      },
      type: {
        type: String,
        required: true
      }
    },
    data() {
      return {
        contact: {},
        memo: '',
        visible: this.$props.dialogVisible,
      }
    },
    methods: {
      submitClick() {
        var url = '';
        var param = {};
        if (this.type == 'raiseReject') {
          url = '/loanRaise/refuse'
          param = {raiseNo: this.raiseNo, memo: this.memo}
        } else if (this.type == "remindReject") {
          url = '/loanBacked/remindRefuse'
          param = {backedNo: this.bizNo, memo: this.memo}
        } else if (this.type == "collectReject") {
          url = '/loanBacked/collectRefuse'
          param = {backedNo: this.bizNo, memo: this.memo}
        }

        this.$$post(url, param).then(res => {
          if (res.data.code < 1) {
            this.$message.error(res.data.msg);
            return
          }
          this.$message({message: '操作成功', type: 'success'});
          this.handleClose();
        })

      },
      /** 关闭处理 */
      handleClose() {
        this.visible = false;
        setTimeout(() => {
          this.$emit('update:dialogVisible', false)
        }, 100);
        this.$emit('refreshList');
      }
    }
  }
</script>
<style lang="stylus" rel="stylesheet/stylus">

  .client-contact-dialog {
    .input {
      width 60%
      margin auto
    }
  }

</style>
