<template>
  <div id="unit" class="flex-row">
    <basic-living-list class="binary-left" v-ref:list :row="row"   :style="style"   @select-changed="selected" style="width:auto;"></basic-living-list>
    <div style="margin-left: 10px;" class="binary-right" v-if="isdetail">
      <!-- <p class="bg-info text-center" style="padding: 8px;" v-if="row.pricecount">气价变更情况汇总</p> -->


      <basic-living style="height: 40%; margin-bottom: 100px;"  :data="row"  @close="refresh" @success="refresh" v-ref:gas ></basic-living>
      <div  v-if="row">
        <ul class="nav nav-tabs" >
          <li class="active"><a href="#">低保户使用记录</a></li>
        </ul>
        <update-basic-living v-ref:update :data="row" :parent-data="parentData" @select-changed="selected2"></update-basic-living>
      </div>
      </div>

  </div>
</template>
<script>

  export default {
    title: '低保管理',
    data () {
      return {
        style:'col-sm-2',
        row: null,
        parentData: '',
        isdetail: false,
        gasPriceShow: false
      }
    },
    methods: {
      selected (obj) {
        this.style='col-sm-3'
        this.row = obj.val
        this.parentData = this.row.id
        this.isdetail = true
        if (this.row.pricecount <= 1) {
          this.row.pricecount = null
        }
        this.gasPriceShow = !this.row.pricecount
      },
      selected2 (obj) {
        this.gasPriceShow = true
        this.row = Object.assign({}, this.row, obj.val)
      },
      refresh () {
        this.row = null
        this.gasPriceShow = false
        this.isdetail = false
        this.$refs.list.search()
      }
    },
    events: {
      'success' (name, row, res) {
        //this.style='col-sm-2'
        this.row = row
        this.gasPriceShow = false
        this.isdetail = false
        this.$refs.list.search()
        if (row.pricecount) {
          this.$refs.update.getUpdate()
        }
      },
      'error' (name, row, res) {
        this.row = row
        this.gasPriceShow = false
        this.isdetail = false
        this.$refs.list.search()
        if (row.pricecount) {
          row.pricecount === 1
          this.$refs.update.getUpdate()
        }
      },
      'close' (res) {
        this.style='col-sm-2'
        this.row = null
        this.gasPriceShow = false
        this.isdetail = false
      },
      'search' () {
        this.style='col-sm-2'
        this.row = null
        this.gasPriceShow = false
        this.isdetail = false
        // this.$refs.list.search()
      },
      'add' () {
        this.style='col-sm-3'
        this.isdetail = true
        if(this.gasPriceShow){
          this.$refs.gas.initModel()
        }
        this.gasPriceShow = true
        this.$refs.list.$refs.paged.$refs.grid.selectStore.selected = null
        this.row = null
      }
    }
  }
</script>
<style>
  .datapanel {
    color: #333;
    background-color: white;
    box-shadow: darkgrey 0.5px 0.5px 0.5px 0.5px ;
    padding: 10px 10px 5px 10px;
    border-radius:10px;
  }
</style>
