<template>
  <div class="auto">
    <validator name='v'>
      <form novalidate class="form-horizontal">
        <p class="bg-info text-center" style="padding: 8px;font-size: 20px">已选择{{rowsdata.length}}块表</p>
        <div class="auto select-overspread form-horizontal">
          <div class="col-sm-6 form-group form-input-group">
            <label class="control-label">领用信息</label>
            <input type="text"  v-model="model.f_operat_info" class="form-control" placeholder="领用信息"/>
          </div >
        </div>
      </form>
      <div style="text-align:right;margin-top:6px;margin-right:50px;" class="col-sm-12">
        <button class="btn btn-success" @click="confirm()"  :disabled='!$v.valid'>领 用</button>
      </div>
    </validator>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  export default {
    name: 'MeterReceive',
    data () {
      return {
        model: {
          f_warehouse_id: null,
          f_operat_type: '领用',
          f_operat_info: '',
          f_state: '有效',
          f_operator: this.$login.f.name,
          f_filiale: this.$login.f.f_fengongsi,
          f_outlets: this.$login.f.f_parentname,
          f_orgstr:this.$login.f.orgpathstr,
          f_filialeids:this.$login.f.f_orgids
        },
        // 仓库列表
        warehouse: []
      }
    },
    props: {
      rowsdata: Array,
      f_warehouse_id: Number
    },
    created () {
    },
    ready () {
      // this.getwarehouse()
    },
    methods: {
      // 获取仓库列表
      async getwarehouse(){
        let data = await this.$resetpost('rs/sql/saleSingleTable', {data: {tablename: 't_warehouse',condition: `f_filialeids = '${this.$login.f.f_orgids}'`}}, {resolveMsg: null, rejectMsg: null})
        let house = []
        for (let row of data.data){
          house.push({label: row.f_warehouse_name,value: row.id})
        }
        this.warehouse = house
      },
      async confirm(){
        if (!this.rowsdata.length){
          this.$showAlert("您还未选择表,请在选择表后在进行这个操作","warning", 1500)
          return
        }
        if (!this.f_warehouse_id){
          this.$showAlert("数据出错,请重进系统在试","warning", 1500)
          return
        }
        // 传入仓库id
        this.model.f_warehouse_id = this.f_warehouse_id
        await this.$resetpost('rs/logic/sale_meterReceive', {model: this.model,rowsdata: this.rowsdata}, {resolveMsg: '领用成功', rejectMsg: '领用失败'})
        this.init()
        this.$dispatch('refresh')
      },
      init() {
        this.model.f_operat_info = ''
      }
    },
    watch: {
    }
  }
</script>

<style lang="less">
</style>
