<template>
  <a-modal
    :visible="visible"
    :title="null"
    @cancel="close"
    :footer="null"
    :width="330"
  >
    <div style="text-align: center">
      <a-space>
        <span>￥</span>
        <a-input-number style="width: 120px" v-model="price" />
        <a-button type="primary" @click="send">发送订单</a-button>
      </a-space>
    </div>
  </a-modal>
</template>
<script>
import { sendPrice } from '@/api/order'

export default {
  name: 'SendPriceModal',
  props: ['onSuccess', 'orderId'],
  data() {
    return {
      visible: false,
      price: 0
    }
  },
  methods: {
    show() {
      this.visible = true
    },
    send() {
      const reqData = {
        id: this.orderId,
        price: this.price
      }
      sendPrice(reqData).then(({ code }) => {
        if (code == 200) {
          this.$message.success('发送成功')
          this.onSuccess()
          this.close()
        }
      })
    },
    close() {
      this.visible = false
      this.price = 0
    }
  }
}
</script>
