<template>
   <div id='InformationInput'>
     <div class="auto select-overspread">
       <validator name='v'>
         <ul class="nav nav-tabs">
           <p class="bg-info text-center" style="padding: 8px;">发票信息</p>
         </ul>
         <div class="form-horizontal select-overspread container-fluid auto" style="margin-top:20px;flex: 1;">
           <div class="row">
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_usercode.required ? 'has-error' : '']">
               <label class="font_normal_body">客户编号</label>
               <input type="text" v-model="model.f_invoice_usercode"  v-validate:f_invoice_usercode='{required: true }'
                      class="input_search" style="width:60%" placeholder="客户编号">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_name.required ? 'has-error' : '']">
               <label class="font_normal_body">客户名称</label>
               <input type="text" v-model="model.f_invoice_name"  v-validate:f_invoice_name='{required: true }'
                      class="input_search" style="width:60%" placeholder="客户名称">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_num.required ? 'has-error' : '']">
               <label class="font_normal_body">发票号码</label>
               <input type="text" v-model="model.f_invoice_num"  v-validate:f_invoice_num='{required: true }'
                      class="input_search" style="width:60%" placeholder="发票号码">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_money.required ? 'has-error' : '']">
               <label class="font_normal_body">发票金额</label>
               <input type="number" v-model="model.f_invoice_money"  v-validate:f_invoice_money='{required: true }'
                      class="input_search" style="width:60%" placeholder="发票金额">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_date.required ? 'has-error' : '']">
               <label class="font_normal_body">开票时间</label>
               <datepicker style="width:60%" placeholder="开票时间"
                           v-model="model.f_invoice_date"
                           :value.sync="model.f_invoice_date"
                           class="datepicker"
                           :format="'yyyy-MM-dd'"
                           :show-reset-button="true">
               </datepicker>
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_operator.required ? 'has-error' : '']">
               <label class="font_normal_body">开&ensp;票&ensp;人</label>
               <input type="text" v-model="model.f_operator" v-validate:f_operator='{required: true }' disabled
                      class="input_search" style="width:60%" placeholder="开票人">
             </div>
             <div class="col-sm-6 form-group">
               <label class="font_normal_body">备&emsp;&emsp;注</label>
               <input type="text" v-model="model.f_comments"
                      class="input_search" style="width:60%" placeholder="备注">
             </div>
           </div>
         </div>
         <div class="row">
           <div style="float:right;">
             <button @click="confirm()" class="btn button_search" style="width: 70px" :disabled='!$v.valid'>
               <span class="glyphicon glyphicon-floppy-disk"></span>保存
             </button>
             <button @click='close()' class="btn button_clear" style="width: 70px">
               <span class="glyphicon glyphicon-log-out"></span>清空
             </button>
           </div>
         </div>
       </validator>
     </div>
   </div>
</template>

<script>
  import * as Util from '../../../Util'

  export default {
    name: 'InvoiceInformationInput',
    data () {
      return {
        invoiceType: [{label: '增值税专用发票', value: '增值税专用发票'}, {label: '增值税普通发票', value: '增值税普通发票'}],
        model: {
          f_operator: this.$login.f.name
        }
      }
    },
    created () {
    },
    ready () {
    },
    methods: {
      close () {
        this.$dispatch('information-input-refresh')
      },
      confirm () {
        this.model.f_operatorid = this.$login.f.id
        this.model.f_orgid = this.$login.f.orgid
        this.model.f_orgname = this.$login.f.orgs
        this.model.f_depid = this.$login.f.depids
        this.model.f_depname = this.$login.f.deps
        this.model.f_state = '有效'
        this.model.f_invoice_date = Util.toStandardDateString()
        this.$resetpost('rs/entity/t_invoiceuse', this.model, {
          resolveMsg: null,
          rejectMsg: '未通过，抄表数据返回未抄表保存出错!!!'
        }).then((res) => {
          this.$dispatch('information-input-refresh')
        })
      }

    }
  }
</script>

<style lang="less">

</style>
