<!-- 驳回原因客户姓名输入 -->
<template>
  <a-form
    ref="form"
    v-bind="formItemLayout"
    :form="form"
  >
    <a-form-item label="记录类型">
      <a-select
        v-decorator="[
          'type',
          {
            rules: [
              { required: true, message: '请选择添加记录类型!', type: 'string' },
            ]
          }
        ]"
        placeholder="请选择添加记录类型"
      >
        <a-select-option value="system" v-if="order.itemId != ''"><a-icon type="apartment" :style="{ fontSize: '14px', color: '#1890ff',padding:'6px 16px 6px 0' }" />添加记录(系统展示)</a-select-option>
        <a-select-option value="user"><a-icon type="user" :style="{ fontSize: '14px', color: '#1890ff',padding:'6px 16px 6px 0' }" />添加记录(客户展示)</a-select-option>
      </a-select>
    </a-form-item>
    <a-form-item label="添加时间">
      <a-date-picker
        show-time
        placeholder="请选择添加时间"
        v-decorator="[
          'do_at',
          {
            rules: [
              { required: true, message: '请选择添加时间' },
            ]
          }
        ]"
      />
    </a-form-item>
    <a-form-item label="记录内容">
      <a-textarea
        :rows="4"
        v-decorator="[
          'description',
          {
            rules: [
              { required: true, message: '请输入记录内容!', type: 'string' },
            ]
          }
        ]"
        placeholder="请输入记录内容!" />
    </a-form-item>
  </a-form>
</template>

<script>
import { doLogs } 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)
  },
  created () {
    // getExpressCommonList(this.order.order_no).then(res => {
    //   this.expressList = res
    // })
  },
  methods: {
    moment,
    onChange (date, dateString) {
    },
    onOk () {
      return new Promise(resolve => {
        this.form.validateFields((errors, values) => {
          if (!errors) {
            const params = {
              order: this.order.orderId,
              item_id: this.order.itemId,
              description: values.description,
              do_at: values.do_at.format('YYYY-MM-DD HH:mm:ss'),
              type: values.type
            }
            doLogs(this.order.orderId, 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>
