<template>
  <div id="unit" class="flex-row" v-if="listpage" >
    <div :class="{'basic-main':((!isdetail) && (!usershow)),'binary-left':isdetail||usershow}" >
      <meter-book-list :showclass="((!isdetail) && (!usershow))?'col-sm-2  form-group':'col-sm-3  form-group'" v-ref:list :row="row" :config="config" :f_filialeid.sync="f_filialeid" @select-changed="selected" ></meter-book-list>
    </div>
    <div class="binary-right" style="overflow-y: scroll" v-if="isdetail&&!usershow">
      <meter-book-add v-show="!changeView" :data="row" :config="config" :f_filialeid.sync="f_filialeid" @close="refresh" v-ref:gas ></meter-book-add>

    </div>
    <div class="binary-right" v-if="usershow">
      <meterbook-user  :f_meterbook_num="f_meterbook_num" ></meterbook-user>
    </div>

  </div>
  <div v-if="!listpage">
    <user-info-detail-manage :f_userinfo_id="f_userinfo_id" @cancel-main="cancel"></user-info-detail-manage>
  </div>

</template>
<script>
/**
*阶梯气价管理组件
*/

let readGen = async function (self) {
  // 获取里面表册的配置
  let getConfig = await self.$getConfig(self, 'GetMeterBook')
  if (getConfig) {
    Object.assign(self.config, self.config, getConfig.data)
  }
  console.log('获取表册配置', self.config)
}

export default {
  title: '抄表册管理',
  data () {
    return {
      f_userinfo_id: '',
      f_filialeid: this.$login.f.orgid,
      config: {
        isLimit: true, // 限购
        audit: false,  // 启用审核
        heatingSeason: true, // 采暖季
        deductionWay: 'cycle'  // 'cycle: 周期扣费； day: 日运算扣费； singleHS: 采暖季独立扣费； dayHS: 采暖季日扣费；' 此值不配置默认周期扣费
      },
      listpage: true,
      row: null,
      parentData: '',
      isdetail: false,
      priceid: '',
      pricename: '',
      gasPriceShow: false,
      usershow: false,
      f_meterbook_num: '',
      // 控制气价信息界面和变更操作记录界面的展示
      changeView: false
    }
  },
  ready () {
    readGen(this)
  },
  methods: {
    cancel (obj) {
      this.listpage = true
    },
    dealMsg (val) {
      this.listpage = false
      this.f_userinfo_id = val.f_userinfo_id
    },
    selected (obj) {
      this.row = obj.val
      this.parentData = this.row.id
      this.isdetail = true
      this.usershow = false
      this.listpage = true
    },
    selected2 (obj) {
      this.row = Object.assign({}, this.row, obj.val)
      this.gasPriceShow = true
      this.listpage = true
      this.usershow = false
    },
    refresh () {
      this.row = null
      this.gasPriceShow = false
      this.isdetail = false
      this.usershow = false
      this.listpage = true
      this.$refs.list.search()
    }
  },
  events: {
    'success' (name, row, res) {
      this.row = row
      this.gasPriceShow = false
      this.isdetail = false
      this.usershow = false
      this.listpage = true
      this.$refs.list.search()
    },
    'error' (name, row, res) {
      this.row = row
      this.gasPriceShow = false
      this.isdetail = false
      this.usershow = false
      this.listpage = true
      this.$refs.list.search()
    },
    'close' (res) {
      this.row = null
      this.gasPriceShow = false
      this.isdetail = false
      this.usershow = false
      this.listpage = true
    },
    'search' () {
      this.row = null
      this.gasPriceShow = false
      this.isdetail = false
      this.usershow = false
      this.listpage = true
      // this.$refs.list.search()
    },

    'add' () {
      this.isdetail = true
      this.usershow = false
      this.listpage = true
      if (this.gasPriceShow) {
        this.$refs.gas.initModel()
      }
      this.gasPriceShow = true
      this.$refs.list.$refs.paged.$refs.grid.selectStore.selected = null
      this.row = null
    }
  },
  watch: {
    'f_meterbook_num' (val) {
    }
  }
}
</script>
<style>

</style>
