listLoanModal.vue 6.38 KB
<template>
  <a-modal title="登记放款" :width="600" :centered="true" :maskClosable="false" :visible="visible" :confirmLoading="confirmLoading" @ok="handleSubmit" @cancel="handleCancel" cancelText="关闭" style="top:20px;" class="scope-link-man">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="借款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-input v-decorator="[ 'remitFee', {'initialValue':model.applyMoney,rules:[{required: true, message: '请输入借款金额(元)'}]}]" :read-only="true" />
        </a-form-item>
        <a-form-item label="是否拒绝放款" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-radio-group v-decorator="['remitStatus',{'initialValue':'',rules:[{required: true, message: '请选择是否拒绝放款'}]}]" @change="handleRefuseRemark">
            <a-radio :value="0">是</a-radio>
            <a-radio :value="1">否</a-radio>
          </a-radio-group>
        </a-form-item>
        <a-form-item label="放款方式" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select v-decorator="['paymentWay', {'initialValue':'',rules:[{required: !refuseDis, message: '请选择放款方式'}]}]" placeholder="请选择" @change="handlePayment" :disabled="refuseDis">
            <a-select-option v-for="(item, index) in dbPaymentWay" :key="index" :value="item.name">{{item.title}}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item label="请选择放款账户" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-select v-decorator="['remitAccountType', {'initialValue':'',rules:[{required: !refuseDis && !paymentDis, message: '请选择放款账户'}]}]" placeholder="请选择" :disabled="refuseDis||paymentDis">
            <a-select-option v-for="(item, index) in dbRemitAccountType" :key="index" :value="item.name">{{item.title}}</a-select-option>
          </a-select>
        </a-form-item>
        <a-form-item v-show="!paymentDis" label="放款日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-date-picker style="width: 100%" :disabledDate="disabledDate" v-decorator="['birthday',{'initialValue':null,rules:[{required: !refuseDis && !paymentDis, message: '请选择放款日期'}]}]" @change="onChangeDate" :disabled="refuseDis||paymentDis" />
        </a-form-item>
        <a-form-item v-show="paymentDis" label="放款日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-date-picker style="width: 100%" :defaultValue="moment(new Date(), 'YYYY-MM-DD')" :disabled="refuseDis||paymentDis" />
        </a-form-item>
        <a-form-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol">
          <a-textarea rows="4" placeholder="备注" v-decorator="['remark', {'initialValue':'',rules:[{required: refuseDis, message: '拒绝放款请输入理由'}]}]" maxlength="60" />
        </a-form-item>
        <div style="color:red;text-align:center;">注:系统会根据输入的放款日期去设置起息日和生成还款计划,请正确登记放款日期。</div>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import { submitLoanApply } from '@/api/makeLoan'
import pick from 'lodash.pick'
import moment from 'moment'

export default {
  name: 'personLinkManModal',
  data () {
    return {
      visible: false,
      confirmLoading: false,
      refuseDis: false, // 拒绝放款
      paymentDis: false, // 线上线下 
      dbPaymentWay: JSON.parse(sessionStorage.getItem('DB_PAYMENT_WAY')), // 放款方式
      dbRemitAccountType: JSON.parse(sessionStorage.getItem('DB_REMIT_ACCOUNT_TYPE')), // 放款账户类型
      title: '',
      model: {},
      orderNo: '',
      form: this.$form.createForm(this),
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      loanDate: undefined,
      dateFormat: 'YYYY-MM-DD 00:00:00',
      disableMixinCreated: true
    }
  },
  methods: {
    moment,
    edit (data) {
      this.orderNo = data.orderNo
      this.model = Object.assign({}, data)
      this.form.resetFields()
      this.visible = true
      this.$nextTick(() => { })
    },

    close () {
      this.$emit('close')
      this.visible = false
      this.disableSubmit = false
      this.selectedRole = []
    },
    handleSubmit () {
      // 触发表单验证
      this.form.validateFields((err, values) => {
        if (!err) {
          this.confirmLoading = true
          let formData = Object.assign({ 'orderNo': this.orderNo, 'loanDate': this.loanDate }, values)
          delete formData.birthday
          delete formData.remitFee
          this.confirmLoading = false
          submitLoanApply(formData)
            .then(res => {
              if (res.status.statusCode == 0) {
                this.$message.success(res.status.statusReason)
                this.$emit('ok')
              } else {
                this.$message.warning(res.status.statusReason)
              }
            })
            .finally(() => {
              this.confirmLoading = false
              this.close()
              this.$emit('ok')
            })
        }
      })
    },
    disabledDate (current) {
      return current && current >= moment().endOf('day');
    },
    handleRefuseRemark (e) {
      let val = e.target.value
      if (val == 0) {
        this.refuseDis = true
        this.form.setFieldsValue({
          paymentWay: null,
          bankCardName: null,
          remitAccountType: null,
          birthday: null,
        });
        this.loanDate = ''
      } else {
        this.refuseDis = false
      }
    },
    handleCancel () {
      this.close()
    },
    // 线上线下判断 0:线上 1:线下
    handlePayment (key) {
      if (key == 0) {
        let Year = new Date().getFullYear(),
          Month = new Date().getMonth() + 1 <= 10 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1,
          Day = new Date().getDate() <= 10 ? '0' + new Date().getDate() : new Date().getDate();
        this.loanDate = Year + '-' + Month + '-' + Day
        this.paymentDis = true
        this.form.setFieldsValue({
          bankCardName: null,
          remitAccountType: null,
          birthday: null
        });
      } else {
        this.paymentDis = false
      }
    },
    // 时间处理
    onChangeDate (value, dateString) {
      this.loanDate = dateString
    },
  }
}
</script>
<style>
</style>