<template>
  <div>
    <criteria-paged class="search_area" :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search'>
        <div novalidate class="form-inline auto" partial>
          <div class="form-group">
          用户名:
          <input type="text" class="form-control" v-model="model.f_user_oldname" v-on:keyup.enter="search"
          condition="f_user_oldname like '%{}%'">
          用户编号:
          <input type="text" class="form-control" v-model="model.f_user_oldid" v-on:keyup.enter="search"
          condition="f_user_oldid like '%{}%'">
          </div>
          <div class="form-group">
            <label for="f_subcompany">分公司：</label>
            <v-select id="f_subcompany"
            placeholder='请选择'
            :value.sync="$parent.$parent.model.f_subcompany"
            :options='$parent.$parent.f_divisions'
            close-on-select clear-button></v-select>

            审核状态：
            <v-select id="f_approved"
            placeholder='请选择审核状态'
            v-model='model.f_approved'
            :value.sync="$parent.$parent.model.f_approved"
            :options='$parent.$parent.f_approval_states'
            condition="f_subcompany='{}'"
            close-on-select clear-button></v-select>
          </div>
          <button class="btn btn-default" @click="search()">查询</button>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>用户ID</th>
            <th>分公司</th>
            <th>用户姓名</th>
            <th>审核状态</th>
            <th>审核</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_user_oldid}}</td>
          <td>{{row.f_old_subcompany}}</td>
          <td>{{row.f_user_oldname}}</td>
          <td>{{row.f_approved}}</td>
          <td><button class="btn btn-default" @click="$parent.$parent.$parent.change(row)">审核</button></td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
import { PagedList } from 'vue-client'
import Vue from 'vue'
import AppData from '../../stores/AppData'

export default {
  title: '档案审核',
  data () {
    let model = new PagedList('api/af-safecheck/sql/用户档案审核查询', 20, {items: '"*"', tablename: '"t_tmp_userfiles"', groupitem: '""', orderitem: '"f_user_oldid"',
     f_subcompany: 'this.f_subcompany[0]', f_approved: 'this.f_approved[0]'})
    model.f_subcompany = [Vue.f_subcompany]
    model.f_archive_date = ''
    model.f_approved = ['']
    return {
      model: model,
      f_divisions: Vue.f_subcompany != '' ? [{label: Vue.f_subcompany, value: Vue.f_subcompany}]: this.$appdata.getParam('安检系统用子公司'),
      f_approval_states: this.$appdata.getParam('用户档案审核状态')
    }
  },
  methods: {
    change (row) {
      this.$goto('userfile-changeaudit', {model: row})
    }
  }
}
</script>
