<template>
  <div id="unit" class="flex-row">
    <user-list @select-changed="selected"  style="width:auto;" v-ref:list></user-list>
    <div class="flex" style="margin-left: 10px; width: 40%;" v-if="isChange">
      <add-user :data="row"></add-user>
    </div>
  </div>
</template>

<script>

  import UserList from './UserList'
  import AddUser from './AddUser'

  export default {
    title: '人员管理',
    components: {
      UserList, AddUser
    },
    props: ['data'],
    data () {
      return {
        row: null,
        isChange: false
      }
    },
    methods: {
      selected (obj) {
        this.row = obj.val
        this.isChange = true
      }
    },
    events: {
      'adduser' () {
        this.isChange = true
      },
      'search' () {
        this.isChange = false
      },
      'refresh' () {
        this.row = null
        this.isChange = false
        this.$refs.list.$refs.paged.$refs.cri.search()
      }
    }
  }

</script>
