<template>
  <div class="flex" style="flex:1; ">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>

            <div class="col-sm-3">
              <label  class="font_normal_body">员工姓名</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.name"
                     condition="name like '%{}%'" placeholder='员工姓名'>
            </div>
            <div class="col-sm-3">
              <label  class="font_normal_body">&nbsp;&nbsp;&nbsp;登录名</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.ename"
                     condition="ename like '%{}%'" placeholder='登录名'>
            </div>
            <div class="col-sm-3">
              <label  class="font_normal_body">所在部门</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_department_name"
                     condition="f_department_name like '%{}%'" placeholder='所在部门'>
            </div>
            <div class="col-sm-3">
              <label  class="font_normal_body">所属角色</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_role_name"
                     condition="f_role_name like '%{}%'" placeholder='所属角色'>
            </div>

           <div class="span" style="float:right;">
              <button class="button_search button_spacing" style="width:80px;margin-left:30px;"@click="$parent.$parent.search()" v-el:cx>查询</button>
              <button class="button_new button_spacing" style="width:80px;margin-left:30px;" v-if="$parent.$parent.hasbtn('新建人员')" @click="$parent.$parent.createNew()" v-el:cx>新建人员</button>

          </div>
        </div>
      </criteria>
      <data-grid class="list_area table_sy" :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th style="text-align: center;"><nobr>序号</nobr></th>
            <th style="text-align: center;"><nobr>员工编号</nobr></th>
            <th style="text-align: center;"><nobr>员工名称</nobr></th>
            <th style="text-align: center;"><nobr>登录名</nobr></th>
            <th style="text-align: center;"><nobr>电话</nobr></th>
            <th style="text-align: center;"><nobr>所属部门</nobr></th>
            <th style="text-align: center;"><nobr>所属角色</nobr></th>
            <th style="text-align: center;"><nobr>状态</nobr></th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center;">{{$index+1}}</td>
          <td style="text-align: center;">{{row.userid}}</td>
          <td style="text-align: center;">{{row.name}}</td>
          <td style="text-align: center;">{{row.ename}}</td>
          <td style="text-align: center;">{{row.f_user_telephone}}</td>
          <td style="text-align: center;">{{row.f_department_name}}</td>
          <td style="text-align: center;">{{row.f_role_name}}</td>
          <td style="text-align: center;">{{row.state}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>
  import { PagedList } from 'vue-client'
  import * as Util from '../Util'

  export default {
    title: '用户列表',
    data () {
      return {
        model: new PagedList('rs/sql/ldap_getAllUser', 20)
      }
    },
    ready () {
      this.search()
    },
    methods: {
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      async selfSearch (args) {
        let getHasPermissionUsers = await this.$LdapService.getHasNodeByType('user')
        args.condition += `${getHasPermissionUsers}`
        this.model.search(args.condition, args.model)
        this.$dispatch('search')
      },
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
      },
      hasbtn (val) {
        if(Util.f.ldapReslist&&Util.f.ldapReslist.includes(val)){
          return true
        }else {
          return false
        }
      },
      createNew () {
        this.$dispatch('adduser')
      }
    },
    computed: {
    }
  }
</script>
