<template>
  <div id="unit" class="flex-row binary">
    <div class="binary-left">
      <staff-list @select-changed="selected" v-ref:todolist></staff-list>
    </div>
    <div class="binary-right">
      <staff-compile-list :listinfo="listinfo" :title.sync="title"></staff-compile-list>
    </div>
  </div>
</template>

<script>
  export default {
    title: '员工管理',
    data () {
      return {
        listinfo: {
        },
        title: '新增员工'
      }
    },
    methods: {
      selected (obj) {
        this.title = '修改状态'
        var row = Object.assign({}, obj.val)
        row.f_sex = row.f_sex ? [row.f_sex] : ['男']
        row.f_credentials = row.f_credentials ? [row.f_credentials] : ['身份证号']
        row.f_staff_state = row.f_staff_state ? [row.f_staff_state] : ['在职']
        row.img = row.img ? row.img : {content: row.f_photo_path, filename: row.f_photo_name}
        this.listinfo = row
      },
      init () {
        this.listinfo = {f_state: ['未测']}
        this.title = '新增员工'
      }
    },
    events: {
      'add' () {
        this.init()
      },
      'refresh' () {
        this.$refs.todolist.$refs.paged.$refs.cri.search()
        this.init()
      }
    }
  }
</script>
<style>
</style>
