<template>
  <div class="flex-row">
    <div :class="{'basic-main':!isChange,'binary-left':isChange}">
    <phone-list :row="row" @select-changed="selected"  style="width:auto;" v-ref:list ></phone-list>
    </div>
    <div class="binary-right" style="margin-left: 10px; width: 50%;" v-if="isChange">
      <phone-add :data="row" v-ref:addbox></phone-add>
    </div>
  </div>
</template>
<script>

  import PhoneList from './PhoneList'
  import PhoneAdd from './PhoneAdd'

  export default {
    title: 'PC终端管理',
    components: {
      PhoneList, PhoneAdd
    },
    data () {
      return {
        isChange: false,
        row: null
      }
    },
    methods: {
      selected (obj) {
        this.isChange = true
        this.row = obj.val
      }
    },
    events: {
      'search' () {
        this.isChange = false
        this.row = null
        this.$refs.list.$refs.paged.$refs.cri.search()
      },
      'refresh' () {
        this.isChange = false
        this.row = null
        this.$refs.list.search()
      },
      'error' (name, row, res) {
        this.isChange = false
        this.row = null
      },
      'close' () {
        this.isChange = false
        this.row = null
        this.$refs.list.search()
      },
      'add' () {
        this.row = null
        this.isChange = true
        this.$refs.list.$refs.paged.$refs.grid.selectStore.selected = null
      }
    }
  }
</script>
