<template>
  <div id="unit" class="flex-row">
    <gas-brand-list v-ref:list :row="row" @select-changed="selected" style="width:auto;"></gas-brand-list>
    <div class="flex" v-el:gasbrand style="margin-left: 10px; width: 50%;" v-if="!isEmpty(val) || isChange">
      <span v-show='row'>
        <ul class="nav nav-tabs">
          <li role="presentation" class="active"><a href="#">气表品牌相关信息</a></li>
        </ul>
        <div style="height:150px; overflow: auto;">
          <gas-model-info v-ref:update :data="row"></gas-model-info>
        </div>
        <ul v-if="showParameValue" class="nav nav-tabs">
          <li role="presentation" class="active"><a href="#">气表型号参数</a></li>
        </ul>
        <div v-if="showParameValue" style="height:150px; overflow: auto;">
          <parames :id="row.id" :type="0"></parames>
        </div>
     </span>
      <add-gas-brand v-if="isChange" :data="gasmodel" v-on:toggle="getChange"></add-gas-brand>
    </div>
  </div>
</template>
<script>


  export default {
    title: '气表品牌管理',
    data() {
      return {
        isChange: false,
        row: null,
        gasmodel: null,
        showParameValue: false,
        parame:undefined,
        dataType:0
      }
    },
    methods: {
      selected(obj) {
        this.showParameValue=false
        this.row = obj.val
        this.gasmodel = obj.val
        this.isChange = true
      },
      getChange() {
        this.isChange = true
      },
      isEmpty(value) {
        for (let name in value) {
          return false
        }
        return true
      },
      showParame() {
        this.showParameValue = this.showParameValue ? false : true
      }
    },
    events: {
      'search'() {
        this.isChange = false
        this.row = null
        this.gasmodel = {}
        this.$refs.list.$refs.paged.$refs.cri.search()
      },
      'success'(name, row, res) {
        this.isChange = false
        this.row = null
        this.gasmodel = {}
        this.$refs.list.search()
      },
      'error'(name, row, res) {
        this.isChange = false
        this.row = null
        this.gasmodel = {}
      },
      'close'() {
        this.isChange = false
        this.row = null
        this.gasmodel = {}
        this.$refs.list.search()
      },
      'add'() {
        this.isChange = true
        this.row = null
        this.gasmodel = {}
        this.$refs.list.$refs.paged.$refs.grid.selectStore.selected = null
      }
    }
  }
</script>
