<!-- 驳回原因用户姓名输入 -->
<template>
  <a-form ref="form" v-bind="formItemLayout" :form="form">
    <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-checkbox-group v-decorator="['business_order_item_ids']" style="width: 100%;">
        <a-row>
          <a-col v-for="it in item.banks" :key="it.business_order_item_id" :span="24">
            <a-checkbox :value="it.business_order_item_id">{{ it.institution.title }}</a-checkbox>
          </a-col>
        </a-row>
      </a-checkbox-group>
    </a-form-item>
    <a-form-item label="补差价原因">
      <a-textarea
        :rows="4"
        v-decorator="[
          'remark',
          {
            rules: [
              { required: true, message: '请输入详细的添加补差价原因!', type: 'string' },
            ]
          }
        ]"
        placeholder="请输入详细的添加补差价原因" />
    </a-form-item>
    <div class="remark">勾选机构是给机构补差价，不勾选则是给服务包补差价。</div>
  </a-form>
</template>

<script>
import { diffPrice } from '@/api/order'
export default {
  name: 'PayDifference',
  props: {
    item: {
      type: Object,
      default: () => {
        return {
          banks: [] // 机构列表
        }
      }
    }
  },
  data: () => ({
    formItemLayout: {
      labelCol: { span: 6 },
      wrapperCol: { span: 14 }
    },
    loading: false,
    expressList: []
  }),
  beforeCreate () {
    this.form = this.$form.createForm(this)
  },
  created () {
    // getExpressCommonList(this.order.order_no).then(res => {
    //   this.expressList = res
    // })
  },
  methods: {
    onOk () {
      return new Promise(resolve => {
        this.form.validateFields((errors, values) => {
          if (!errors) {
            diffPrice(this.item.id, values).then(() => {
              this.$notification.success({
                message: '成功',
                description: '补差价成功'
              })
              resolve(true)
            }).catch((err) => {
              this.$notification.error({
                message: '失败',
                description: err.message
              })
            })
          }
        })
      })
    }
  }
}
</script>

<style scoped lang="less">
.remark{
  text-align: center;
  color: #999;
  font-size: 12px;
}
</style>
