<template>
  <div id="unit" class="flex-row" >
    <div :class="{'basic-main':show == 0,'binary-left':show != 0}">
      <host-meter-list @child-dblclick="selected"
                       v-ref:hostmeterlist :style="style"
                       :f_filialeids.sync="f_filialeids">
      </host-meter-list>
    </div>
    <div v-if="show == 1" class="binary-right">
      <div class="flex">
        <div style="height: 40%">
          <host-meter-add v-ref:hostmeteradd
                          :f_filialeids.sync="f_filialeids"
                          :row.sync="row">
          </host-meter-add>
        </div>
        <div style="height: 60%">
          <host-meter-user-list :data="meterinfo"
                                :f_filialeids.sync="f_filialeids"
                                v-if="meterinfo">
          </host-meter-user-list>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  title: '总表管理',
  components: {},
  data () {
    return {
      // 分公司id串
      f_filialeids: this.$login.f.orgid,
      show: 0,
      meterinfo: null,
      style: 'col-sm-2 form-group',
      row: null
    }
  },
  ready () {
  },
  methods: {
    selected (obj) {
      console.log('看看双击传进来的参数', obj)
      this.$refs.hostmeterlist.showrightchange = false
      this.style = 'col-sm-3 form-group'
      if (obj && obj.f_host_meter_id) {
        if (obj.f_orgid != this.f_filialeids) {
          this.refresh()
          return
        }
        this.show = 1
        this.row = obj
        this.meterinfo = obj
      }
    },
    refresh () {
      this.show = 0
      this.$refs.hostmeterlist.$refs.paged.$refs.cri.search()
    }
  },
  watch: {
    'show' (value) {
      if (value === 0) {
        this.meterinfo = null
        this.type = null
      }
    }
  },
  events: {
    'showUser' (row) {
      console.log('row===========>', row)
      this.style = 'col-sm-3 form-group'
      this.show = 2
      this.meterinfo = row
    },
    'confirm' () {
      this.style = 'col-sm-2 form-group'
      this.$refs.hostmeterlist.$refs.paged.$refs.cri.search()
      this.show = 0
    },
    'cancel' () {
      this.style = 'col-sm-2 form-group'
      this.$refs.hostmeterlist.showrightchange = true
      this.$refs.hostmeterlist.$refs.paged.$refs.cri.search()
      this.meterinfo = null
      this.show = 0
    },
    'add' (row) {
      this.style = 'col-sm-3 form-group'
      this.row = row
      this.show = 1
    }
  }
}
</script>
<style>
</style>
