<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_goods_name.required ? 'has-error' : '']">
               <label for:f_goods_name class="font_normal_body">商品名称</label>
               <input type="text" v-model="model.f_goods_name" v-validate:f_goods_name='{required: true }'
                      class="input_search" style="width:60%" placeholder="商品名称" >
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_goods_unit.required ? 'has-error' : '']">
               <label class="font_normal_body">商品单位</label>
               <input type="text" v-model="model.f_goods_unit" v-validate:f_goods_unit='{required: true }'
                      class="input_search" style="width:60%" placeholder="商品单位" >
             </div>
             <div class="col-sm-6 form-group">
               <label class="font_normal_body">商品规格</label>
               <input type="text" v-model="model.f_goods_specifications"
                      class="input_search" style="width:60%" placeholder="商品规格">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_goods_code.minlength || $v.f_goods_code.maxlength ? 'has-error' : '']">
               <label class="font_normal_body">商品编码</label>
               <input type="text" maxlength="19" v-model="model.f_goods_code" v-validate:f_goods_code='{minlength: 19, maxlength: 19 }'
                      class="input_search" style="width:60%" placeholder="商品编码">
             </div>
             <div class="col-sm-6 form-group" :class="[$v.f_tax_rate.required ? 'has-error' : '']">
               <label class="font_normal_body">税&ensp;&ensp;&ensp;&ensp;率</label>
               <input type="text"  v-model="model.f_tax_rate" v-validate:f_tax_rate='{required: true }'
                      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>

  export default {
    props: ['row'],
    name: 'InvoiceGoodsInput',
    data () {
      return {
        model: {}
      }
    },
    created () {
    },
    ready () {
      this.model = Object.assign({}, this.row)
    },
    methods: {
      close () {
        this.model = {}
        this.model.id = this.row.id
      },
      confirm () {
        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.$resetpost('rs/logic/saveGoodsInfo', this.model, {
          resolveMsg: '保存成功',
          rejectMsg: '保存失败'
        }).then((res) => {
          this.$dispatch('invoice-goods-input-close')
        })
      },
    }
  }
</script>

<style lang="less">

</style>
