<template>
  <div id="unit" class="flex-row">
    <basic-living-list :class="{'basic-main': !isdetail,'binary-left': isdetail}" v-ref:list :row="row"
                       @select-changed="selected" style="width: auto;"></basic-living-list>
    <div class="binary-right" style="overflow-y: auto;" v-if="isdetail" :style="{width: isdetail?'50%':'auto'}">
      <basic-living  :data="row"  @close="refresh" @success="refresh" v-ref:gas ></basic-living>
      <div  v-if="row" class="auto">
        <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  class="auto">
      <upload :blodid="blodid" cols="col-sm-12" isremark="true" fusetype="低保户"></upload>
      </div>
    </div>

  </div>
</template>
<script>
  export default {
    title: '低保管理',
    data () {
      return {
        row: null,
        blodid: '',
        parentData: '',
        isdetail: false,
        gasPriceShow: false
      }
    },
    methods: {
      selected (obj) {
        if (obj.val.f_state == '有效') {
          this.row = obj.val
          this.blodid = this.row.f_userinfo_id
          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.blodid = ''
        this.gasPriceShow = false
        this.isdetail = false
        this.$refs.list.search()
      }
    },
    events: {
      'success' (name, row, res) {
        // this.style='col-sm-2'
        this.row = row
        this.blodid = this.row.f_userinfo_id
        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.blodid = this.row.f_userinfo_id
        this.gasPriceShow = false
        this.isdetail = false
        this.$refs.list.search()
        if (row.pricecount) {
          row.pricecount === 1
          this.$refs.update.getUpdate()
        }
      },
      'close' (res) {
        this.row = null
        this.gasPriceShow = false
        this.isdetail = false
        this.blodid = ''
      },
      'search' () {
        this.row = null
        this.gasPriceShow = false
        this.isdetail = false
        this.blodid = ''
        // this.$refs.list.search()
      },
      'add' () {
        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
        this.blodid = ''
      }
    }
  }
</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>
