<template>
  <div  class="flex " @keyup.enter="search">
    <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="row">
            <div class="span" style="float:right;">
              <button class="button_search button_spacing" @click="search()">查询</button>
<!--              <button class="button_new button_spacing" v-if="$parent.$parent.hasbtn('新建部门')" @click="$parent.$parent.add()">新建部门</button>-->
              <div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>
            </div>
          </div>
          <div class="row" v-show="$parent.$parent.criteriaShow">


          </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;">序号</th>
            <th style="text-align: center;">登录人员</th>
            <th style="text-align: center;">登入/登出</th>
            <th style="text-align: center;">操作时间</th>

          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td style="text-align: center;">{{$index+1}}</td>
            <td style="text-align: center;">{{row.username}}</td>
            <td style="text-align: center;">{{row.type}}</td>
            <td style="text-align: center;">{{row.logindate}}</td>

          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>
  import { PagedList } from 'vue-client'
  import Util from '../Util'
  export default {
    title:"登录日志",
    data () {
      return {
        model: new PagedList('rs/sql/loginrecord',20, {}),
        row: null,
        //控制修改按钮
        editshow:false,
        rowparent: null,
        orgoptions:[],
        depoptiones:[],
        personoptions:[{label:"正式",value:"正式"},{label:"退休",value:"退休"},{label:"试用",value:"试用"}],
        linkoptions:[{label:"是",value:"是"},{label:"否",value:"否"}],

        criteriaShow: false,
      }
    },
    ready(){
      this.search()
    },
    methods: {
      show() {
        this.criteriaShow = true
      },
      hidden() {
        this.criteriaShow = !this.criteriaShow
      },
      //修改资源
      modifyRes (obj) {
        delete obj.num
        this.row = obj
        this.row.f_data_type = this.searchtype;
        this.editshow=true
      },

      cancel  () {
        this.row = null
        this.rowparent = null
        this.editshow=false
      },
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      async selfSearch (args) {
      //  let getHasPermissionDepts = await this.$LdapService.getHasNodeByType('department')
       // args.condition += `${getHasPermissionDepts.condition}`
       // this.orgoptions =getHasPermissionDepts.orgoptions
       // this.depoptiones = getHasPermissionDepts.depoptions
        if(!this.$login.r.includes('其他登录日志查看')){
          args.condition = `${args.condition} and userid =${this.$login.f.id}`
        }
        this.model.search(args.condition, args.model)
        this.$dispatch('search')
      },
      hasbtn (val) {
        if(Util.f.ldapReslist&&Util.f.ldapReslist.includes(val)){
          return true
        }else {
          return false
        }
      },
      //添加部门
      add(){
        this.$refs.paged.$refs.grid.selectStore.selected = null
        this.editshow=true
        //this.$dispatch('add')
      },
    },
    events: {
      //提交
      'success' () {
        this.row = null
        this.rowparent = null
        this.editshow=false
        this.$showAlert('操作成功', 'success', 2000)
        this.search()
      },
      //返回
      'cancel' () {
        this.row = null
        this.rowparent = null
        this.editshow=false
        this.$dispatch('cancel')
      },
    },
  }
</script>
<style>
  .datapanel {
    color: #333;
    background-color: white;
    box-shadow: darkgrey 0.5px 0.5px 0.5px 0.5px;
    padding: 10px 10px 10px 10px;
    border-radius: 15px;
  }
</style>
