<template>
  <div id='AddTobook'>
    <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" style="text-align: center">
            <p class="text-center" style="padding: 8px;">共{{usernum?usernum:0}}位用户</p>
            <div class="col-sm-12 form-group" :class="[$v.f_meter_book_num.required ? 'has-error' : '']">
              <label class="font_normal_body" style="width: 26%;">目标抄表册</label>
              <input type="text" v-model="model.f_meter_book_num" v-show="false"
                     v-validate:f_meter_book_num='{required: true }'>
              <v-select :value.sync="model.f_meter_book_num" v-model="model.f_meter_book_num"
                        :options='meterbook' placeholder='抄表册'
                        :value-single="true" :search="true"
                        style="width:60%"
                        close-on-select></v-select>
            </div>
            <!--
             <div class="col-sm-6 form-group" :class="[$v.f_invoice_type.required ? 'has-error' : '']">
              <label class="font_normal_body">发票类型</label>
              <input type="text" v-model="model.f_invoice_type" v-show="false" v-validate:f_invoice_type='{required: true }'>
              <v-select :value.sync="model.f_invoice_type" :options='invoiceType' :value-single="true" :search="false"
                        placeholder='发票类型' close-on-select v-model='model.f_invoice_type'>
              </v-select>
            </div>
            -->
          </div>
        </div>
        <div class="row">
          <div style="float:right;margin-top: 250px;margin-right: 20px;">
            <button @click="confirm()" class="btn button_search" style="width: 70px" :disabled='!$v.valid'>
              <span class="glyphicon glyphicon-floppy-disk"></span>保存
            </button>
          </div>
        </div>
      </validator>
    </div>
  </div>
</template>

<script>
  import * as Util from '../../../Util'
  export default {
    name: 'AddTobook',
    props: ['usernum'],
    data () {
      return {
        model: {
          f_meter_book_num: '',
          f_userinfo_code: '',
          f_user_state: '',
          f_operator: this.$login.f.name,
          f_operatorid: this.$login.f.id,
          f_orgid: this.$login.f.orgid,
          f_orgname: this.$login.f.orgs,
          f_depid: this.$login.f.depids,
          f_depname: this.$login.f.deps,
          f_state: '有效'
        },
        meterbook: [],
        f_orgid: ''
      }
    },
    created () {
    },
    async ready () {
      // await this.$LoadParams.loadMeterBook(this.f_filialeid)
      this.$refs.paged.$refs.cri.model.performDate = this.$login.toStandardDateString()
      this.close()
    },
    methods: {
       selectbook(val){
          console.log("val",val)
         this.meterbook=val
         this.meterbook.push({label: '移出表册', value: '0'})
         console.log(" this.meterbook.push(val)", this.meterbook)
      },
      close () {
        this.model.f_meter_book_num = ''
        this.$dispatch('add-tobook-refresh')
      },
      confirm () {
        this.$dispatch('add-tobook-confirm', this.model)
      }
    },
    computed: {
      // meterbooks () {
      //   return [{label: '移出表册', value: 'null'}, ...this.$GetSaleParam.getMeterBooks()]
      // }
    }
  }
</script>

<style lang="less">

</style>
