<!-- 驳回原因用户姓名输入 -->
<template>
  <a-form
    ref="form"
    v-bind="formItemLayout"
    :form="form"
  >
    <a-form-item label="驳回原因">
      <a-textarea
        :rows="6"
        v-decorator="[
          'reason',
          {
            rules: [
              { required: true, message: '请输入驳回原因!', type: 'string' },
            ]
          }
        ]"
        placeholder="请输入驳回原因" />
    </a-form-item>
  </a-form>
</template>

<script>
import { checkInfo } from '@/api/order'
// import { getExpressCommonList } from '@/api/express'

export default {
  name: 'Reason',
  props: {
    item: {
      type: Object,
      default: () => {
          return {}
        }
    }
  },
  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) {
            const params = {
              item_id: this.item.id.item_id,
              type: this.item.actionType === 'user' ? 1 : 2,
              params: {
                key: this.item.key,
                value: this.item.value,
                reason: values.reason
              }
            }
            checkInfo(this.item.id.order_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>

</style>
