<template>
  <div>
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria'>
        <div partial>
          <p class="text-center" style="padding: 7px;"><b>安检计划项明细</b></p>
        </div>
      </criteria>
      <data-grid :model="model" partial='list'>

        <template partial='head'>
          <tr>
            <th><nobr>用户编号</nobr></th>
            <th><nobr>用户名称</nobr></th>
            <th><nobr>小区名称</nobr></th>
            <th><nobr>地址</nobr></th>
            <th><nobr>安检状态</nobr></th>
            <th><nobr>是否安检</nobr></th>
          </tr>
        </template>
        <template partial='body'>
          <td><nobr>{{row.f_userinfo_code}}</nobr></td>
          <td><nobr>{{row.f_user_name}}</nobr></td>
          <td><nobr>{{row.f_residential_area}}</nobr></td>
          <td><nobr>{{row.f_address}}</nobr></td>
          <td><nobr>{{row.f_last_check_state}}</nobr></td>
          <td><nobr>{{row.f_state}}</nobr></td>
        </template>
      <data-grid>
    </criteria-paged>
  </div>
</template>

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

export default {
  title: '安检计划项列表',
  data () {
    return {
      model: new PagedList('rs/sql/planItem', 20)
    }
  },
  props: [ 'check' ],
  watch: {
    'check' (val) {
      let condition
      console.log('123'+this.check.f_checker)
      if(this.check.f_checker != null){
        condition = "f_checker='" + this.check.f_checker + "' and f_plan_year='" + this.check.f_plan_year + "'and f_plan_month='" + this.check.f_plan_month + "'"
      }else{
        condition = "f_checker is null and f_plan_year='" + this.check.f_plan_year + "'and f_plan_month='" + this.check.f_plan_month + "'"
      }

      this.model.search(condition, {})
    }
  },
  ready () {
    if (this.check) {
      let condition
      console.log('123'+this.check.f_checker)
      if(this.check.f_checker != null){
        condition = "f_checker='" + this.check.f_checker + "'and f_plan_year='" + this.check.f_plan_year + "'and f_plan_month='" + this.check.f_plan_month + "'"
      }else{
        condition = "f_checker is null and f_plan_year='" + this.check.f_plan_year + "'and f_plan_month='" + this.check.f_plan_month + "'"
      }
      this.model.search(condition, {})
    }
  }
}
</script>
