<template>
  <div id="unit" class="flex-row">
    <fun-display @select-changed='selected' @modify-res="modifyRes"
                 @add-res="addRes"
                 class="basic-main" style="width:auto;" v-ref:funlist>
    </fun-display>
    <div class="binary-right" style="width: 40%;overflow-x: hidden; overflow-y: scroll;" v-if="row">
      <display  :look='look' :data="row" :title="title"
               :parent="row.parent_name" @cancel="cancel">
      </display>
    </div>
  </div>
</template>

<script>

export default {
  title: '功能展示',
  data() {
    return {
      row: null,
      look: true,
      title: '功能信息'
    }
  },
  methods: {
    //选中数据
    selected(obj) {
      this.title = '功能信息'
      this.look = true
      this.row = obj.val.data
    },
    //修改数据
    modifyRes(obj) {
      this.title = '修改信息'
      this.row = obj.data
      this.look = false
    },
    //添加数据
    addRes(obj) {
      this.title = '添加功能'
      this.row = Object.assign({}, {parent_id: obj.data.menu_id, parent_name: obj.data.menu_name})
      this.look = false
    },
    //返回
    cancel() {
      // 把选择的节点清空  不然点击同样的节点点不出来
      this.$refs.funlist.$refs.list.selectStore.selected = null
      this.row = null
    },

  },
}

</script>
