<template>
  <div class="auto">
    <strong :style="{color: model.isOk ? 'blue' : 'red'}">{{model.msg}}</strong>
  </div>
</template>

<script>

  import {HttpResetClass} from  'vue-client'

  let getCurrentBill = async function (self) {
    let http = new HttpResetClass()
    let param = {
      f_bill_user: self.$login.f.name, // 票据使用人
      f_bill_type: self.data.f_bill_type[0], // 票据类型
      f_filialeids: self.$login.f.f_orgids, //所属分公司
      f_use_type: self.data.f_use_type // 票据使用类型（燃气费、其他费用等）可不传
    }
    let res = await http.load('POST', 'rs/logic/sale_validateBill', param, {resolveMsg: null, rejectMsg: '获取发票号出错！！'})
    console.log('验证发票。。', res)
    self.model.msg = res.data.msg
    self.model.isOk = res.data.isOk
    self.$dispatch('validate-bill', res.data)
  }

  export default {
    title: '验证票号',
    data () {
      return {
        model: {
          msg: '',
          isOk: false
        }
      }
    },
    props: ['data'],
    ready () {
      if (this.data.f_bill_type) {
        getCurrentBill(this)
      }
    }
  }

</script>
