<template>
  <el-dialog title="核销" width="30%" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit('dataForm')" label-width="80px">
      <el-form-item label="核销码" prop="verificationCode">
        <div class="flex">
          <el-input v-model="dataForm.verificationCode" placeholder="请输入核销码"></el-input>
          <!-- <el-button class="ml10">查询</el-button> -->
        </div>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit('dataForm')">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
// import orderService from '@/api/orderService.js'
import { pickUpVerification } from '@/api/order.js'
export default {
  data () {
    return {
      visible: false,
      dataForm: {
        verificationCode: ''
      },
      dataRule: {
        verificationCode: [{
          required: true,
          message: '核销码不能为空',
          trigger: 'blur'
        }]
      }
    }
  },

  methods: {
    init () {
      this.visible = true
    },
    dataFormSubmit (e) {
      this.$refs[e].validate((valid) => {
        if (valid) {
          pickUpVerification(this.dataForm).then(res => {
            if (res.data && res.data.code == 200) {
              this.$message.success('核销成功！')
              this.$emit('result', res.data.data)
            }
          })
        } else {
          console.log('error submit!!')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss">
.flex {
  display: flex;
}

.ml10 {
  margin-left: 10px;
}
</style>
