<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div novalidate class="form-inline auto" partial>
          <div class="form-group">
            <input type="text" class="form-control" v-modeljian="model.f_user_name"
                   placeholder="用户名称"
                   condition="f_user_name like '%{}%'">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_user_phone"
                   placeholder="用户电话"
                   condition="f_user_phone like '%{}%'">
          </div>
          <div class="form-group">
            <input type="text" class="form-control" v-model="model.f_userinfoid"
                   placeholder="用户编号"
                   condition="f_userinfoid like '%{}%'">
          </div>
          <div class="form-group">
            <v-select id="f_entry"
                      placeholder='安检状态'
                      v-model='$parent.$parent.model.f_entry'
                      :value.sync="model.f_entry"
                      :options='$parent.$parent.f_entry_status'
                      condition="f_entry = '{}'"
                      close-on-select clear-button> </v-select>
          </div>
         <div class="form-group">
            <v-select id="f_device_type"
                      placeholder='安检项'
                      v-model='$parent.$parent.f_device_type'
                      :value.sync="model.f_device_type"
                      :options='$parent.$parent.f_devices'
                      condition="f_devices.f_device_type = '{}'"
                      close-on-select clear-button> </v-select>
          </div>
        <div class="form-group">
        <input type="text" v-show="false" class="form-control" v-model="model.f_filialeids"
               placeholder="组织id"
               condition="f_filialeids like '%{}%'">
            </div>
          <div class="form-group">
            <button class="btn btn-success width-80" @click="search()">查询</button>
          </div>
        </div>
      </criteria>

      <data-grid :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>安检状态</th>
            <th>审核状态</th>
            <th>用户名称</th>
            <th>用户编号</th>
            <th>入户时间</th>
            <th>离开时间</th>
            <th>安检人</th>
            <th>用户类型</th>
            <th>详细地址</th>
          </tr>
        </template>
        <template partial='body'>
          <td>{{row.f_entry_status}}</td>
          <td>{{row.f_approved}}</td>
          <td>{{row.f_user_name}}</td>
          <td>{{row.f_userinfoid}}</td>
          <td>{{row.f_onsite_time}}</td>
          <td>{{row.f_offsite_time}}</td>
          <td>{{row.f_checker_name}}</td>
          <td>{{row.f_user_type}}</td>
          <td>{{row.f_address}}</td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  import Vue from 'vue'
  import co from 'co'

  export default {
    title: '安检项查询',
    data() {
      let model = new PagedList('rs/path/getUserinfomation', 20)
      model.f_approved = ['']
      model.f_no_checkplan = ['']
      return {
        show: true,
        fun: this.$login.f,
        model: model,
        f_device_type: '',
        showModal: false,
        f_approval_states: this.approval_states,
        f_entry_status: this.entry_status,
        f_devices: this.devices,
        f_checkplans: this.checkplans
      }
    },
    methods: {
      approval_states() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('34状态')]
      },
      entry_status() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('安检状态')]
      },
      devices() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('安检项')]
      },
      checkplans() {
        return [{label: '全部', value: ''}, ...this.$appdata.getParam('有无计划')]
      }
    },
    watch: {
      'model.model.f_device_type'(val) {
        this.f_device_type = val[0]
      }
    },
    ready() {
      this.$refs.paged.$refs.cri.model.f_filialeids = this.$login.f.f_orgids
    }
  };
</script>
