<template>
  <div class="flex">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:criteria>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="form-group col-sm-3" >
              <label class="font_normal_body">客户编号</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_userinfo_code" placeholder='客户编号'
                     condition="f_userinfo_code = '{}'" @keyup.enter="search()">
            </div>
            <div class="form-group col-sm-3" >
              <label class="font_normal_body">用户类型</label>
              <v-select style="width:60% "
                        class="select select_list"
                        :value.sync="model.f_check_type"
                        v-model="model.f_check_type"
                        :options='$parent.$parent.userType'
                        placeholder='用户类型'
                        condition="f_check_type = '{}'"
                        close-on-select>
              </v-select>
            </div>
            <div class="form-group col-sm-3" >
              <label class="font_normal_body">安检状态</label>
              <v-select style="width:60% "
                        class="select select_list"
                        :value.sync="model.f_state"
                        v-model="model.f_state"
                        :options='$parent.$parent.checkState'
                        placeholder='安检状态'
                        condition="f_entry_status = '{}'"
                        close-on-select>
              </v-select>
            </div>
            <div class="form-group col-sm-2 button-range" >
              <button class="button_search" style="margin-right: 10px"  @click="search()" v-el:cba>查询</button>
              <!--<export-excel-safe-->
                <!--:data="{condition: $parent.$parent.condition}"-->
                <!--:field="$parent.$parent.getfield"-->
                <!--sqlurl="rs/logic/saleExport" sql-name="getGasUser" :template-name="$parent.$parent.pricename+'气价使用人'"-->
                <!--:choose-col="true"></export-excel-safe>-->

            </div>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" class="table_sy"  partial='list' v-ref:grid >
        <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>
            <th><nobr>安检时间</nobr></th>

          </tr>
        </template>
        <template partial='body' >
          <tr >
            <td style="text-align:center;">{{$index+1}}</td>
            <td style="text-align:center"><span @click="$parent.$parent.$parent.dealmsg(row)"><a>{{row.f_userinfo_code}}</a></span></td>
            <td style="text-align:center">{{row.f_user_name}}</td>
            <td style="text-align:center">{{row.f_check_type}}</td>
            <td style="text-align:center">{{row.f_address}}</td>
            <td style="text-align:center">{{row.f_entry_status}}</td>
            <td style="text-align:center">{{row.f_upload_date}}</td>
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  export default {
    title: '安检情况明细',
    data () {
      return {
        model: new PagedList('rs/sql/tel_singleTable_OrderBy', 50, {items: '"*"', tablename: '"t_check_paper"', orderitem: '"f_upload_date desc"'}),
        condition: '',
        getfield: {},
        userType:[{label:'全部',value:''}, ...this.$appdata.getParam('用户类型')],
        checkState:[{label:'全部',value:''},{label:'入户',value:'入户'},{label:'拒检',value:'拒检'},{label:'到访不遇',value:'到访不遇'}],
        config: {
          excelHeaders: {
            'f_price_name': '气价名称', 'f_userinfo_code': '客户编号', 'f_user_name': '客户姓名', 'f_address': '客户地址',
            'f_orgname': '组织机构'
          }
        }
      }
    },
    props: ['checkrow'],
    ready () {

        this.search()
        this.getfield = this.config.excelHeaders
    },
    methods: {
      search () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        if(!this.checkrow){
          return
        }
        // args.condition = `${args.condition} and f_price_id = '${this.priceid}'`
        //tag
        var cc= this.$parent.$refs.list.model.condition
        //tag
        this.condition = args.condition
        args.condition=args.condition+' and '+ cc
        args.condition=args.condition+` and f_checker_name='${this.checkrow.f_checker_name}'`
        //tag
        var self=this
        this.$parent.$refs.list.nameForSql.forEach(function (s) {

          if(s!='f_user_number'&&self.checkrow[s]!='undefined'){
            var rowsname=self.checkrow[s].replace('*&','')
            args.condition=args.condition+" and  s."+s+"=\'"+rowsname+"\'"
          }
        })

        //tag
        this.model.search(args.condition, args.model)
      },
      dealmsg (val) {
        //tag
        this.$parent.f_userinfo_id=val.f_userinfoid
        this.$parent.listpage=false
      }
    },
    watch: {
      'checkrow' () {
        this.search()
      }
    }
  }
</script>
