<template>
  <div style="flex: 1" class="flex">
    <!--<div class="span">-->
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria'>
        <div partial>
<!--          <label class="font_normal_blue-1">安检计划下发项明细</label>-->
          <ul class="nav nav-tabs">
            <li role="presentation" class="active"><a style="	color: #5ac0d9 !important;">安检计划下发项明细</a></li>
            <export-excel   :data="$parent.$parent.searchData"
                            :field="$parent.$parent.excelHeaders"
                              sqlurl="api/af-safecheck/logic/exportfile" sql-name="planItem" template-name='安检计划明细'></export-excel>
          </ul>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' class="list_area table_sy" style="overflow: hidden" 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>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center">
            <nobr>{{row.f_userinfo_code}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_user_name}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_user_type}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_residential_area}}</nobr>
          </td>
          <td style="text-align: center">
            <nobr>{{row.f_address}}</nobr>
          </td>
        </template>
      </data-grid>
    </criteria-paged>
    <!--</div>-->
    <!--<span>共{{ model.rows.length}}项</span>-->
  </div>
</template>

<script>
    import co from 'co'
    import {PagedList} from 'vue-client'
    import * as Util from '../Util'

    // let fetchItems = function * (self) {
    //   let f_plan_id = "f_plan_id='" + self.item.id + "'"
    //   let plan = yield self.$resetpost('api/af-safecheck/sql/预约计划下发详情',
    //     { data: {items: '*', tablename: 't_check_plan_item', condition: f_plan_id, groupitem: '', orderitem: 'f_userinfoid'} },
    //     { resolveMsg: null, rejectMsg: null })
    //   self.model.rows = plan.data
    // }

    export default {
        title: '项目编写',
        data() {
            return {
                model: new PagedList('api/af-safecheck/sql/planItem', 20),
                // model: {
                //   rows: []
                // },
                f_issued: '',
                selects: [
                    {label: '是', value: '是'},
                    {label: '否', value: '否'}
                ],
              searchData:{
                condition: `c.f_filialeid = ${this.$login.f.orgid} and i.f_plan_id= '${this.item.id}'`
              },
              excelHeaders: {
                'f_userinfo_code': '用户编号',
                'f_user_name': '用户姓名',
                'f_user_phone': '用户电话',
                'f_residential_area': '小区名称',
                'f_address': '用户地址',
                'f_user_type': '用户类型',
                'f_checker': '安检员',
                'f_last_check_state': '上次安检入户状态',
                'f_last_check_result': '上次安检检查结果'
              }
            }
        },
        props: ['item'],
        methods: {
            confirm() {
                let gen = saveGen(this)
                co(gen)
            },
            search() {
                let ge = fetchItems(this)
                co(ge)
            }
        },
        watch: {
            'item'(val) {
                if (this.item) {
                    // let ge = fetchItems(this)
                    // co(ge)
                    this.searchData.condition  =  `c.f_filialeid = ${this.$login.f.orgid} and i.f_plan_id= '${this.item.id}' and  i.f_state != '作废' `
                    let condition = "i.f_plan_id='" + this.item.id + "' and i.f_state != '作废'"
                    this.model.search(condition, {})
                }
            }
        },
        ready() {
            // let ge = fetchItems(this)
            // co(ge)
            let condition = "i.f_plan_id='" + this.item.id + "' and i.f_state != '作废'"
            this.model.search(condition, {})
        }
    }
</script>
<style scoped>
  .table th {
    background-color: #f2f6fa;
    color: black;
  }
</style>
