<!-- 驳回原因客户姓名输入 -->
<template>
  <a-form
    ref="form"
    v-bind="formItemLayout"
    :form="form"
  >
    <a-form-item label="当前机构/欠款" v-if="order">
      <span>{{ order.item.institution }} / <span>￥{{ order.item.price }}</span></span>
    </a-form-item>
    <a-form-item label="修改欠款金额">
      <a-input
        prefix="￥"
        suffix="RMB"
        v-decorator="[
          'price',
          {
            rules: [
              { required: true, message: '请输入欠款金额!', type: 'string' },
            ]
          }
        ]"
        placeholder="请输入欠款金额" />
    </a-form-item>
    <a-form-item label="修改原因">
      <a-textarea
        :rows="4"
        v-decorator="[
          'reason',
          {
            rules: [
              { required: true, message: '请输入记录内容!', type: 'string' },
            ]
          }
        ]"
        placeholder="请输入记录内容!" />
    </a-form-item>
  </a-form>
</template>

<script>
import { changeBankCount } from '@/api/order'
import moment from 'moment'
export default {
  name: 'OperationAdd',
  props: {
    order: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data: () => ({
    formItemLayout: {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 }
    },
    loading: false,
    expressList: []
  }),
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  methods: {
    moment,
    onOk () {
      return new Promise(resolve => {
        this.form.validateFields((errors, values) => {
          if (!errors) {
            const params = {
              reason: values.reason,
              price: values.price
            }
            changeBankCount(this.order.orderId, this.order.item.order_item_id, params).then((res) => {
              this.$notification.success({
                message: '成功',
                description: '欠款金额修改成功'
              })
              resolve(true)
            }).catch((err) => {
              this.$notification.error({
                message: '失败',
                description: err.message
              })
              resolve(false)
            })
          }
        })
      })
    }
  }
}
</script>

<style scoped>
.flexrow{
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

</style>
