<template>
  <div id="unit" class="flex-row" style="width: 100%">
    <div class="flex binary-left" style="flex: 1; width:100%">
      <platform-list @select-changed="selected" v-ref:list></platform-list>
    </div>
    <div class="flex binary-left" style="width:30%">
      <platform-add-edit :listinfo="listinfo" :title.sync="title"></platform-add-edit>
    </div>
  </div>
</template>

<script>
  export default {
    title: '平台管理',
    data () {
      return {
        listinfo: null,
        title: ''
      }
    },
    ready () {
      this.init()
    },
    methods: {
      selected (obj) {
        this.title = '编&emsp;&emsp;辑'
        var row = Object.assign({}, obj.val)
        this.listinfo = row
      },
      // 初始化
      init () {
        this.listinfo = {
          f_state: '有效',
          f_weight: 0
        }
        this.title = '新&emsp;&emsp;增'
      }
    },
    events: {
      'add' () {
        this.init()
      },
      'refresh' () {
        this.$refs.list.$refs.paged.$refs.cri.search()
        this.init()
      }
    }
  }
</script>
<style>
</style>
