<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-4" >
              <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-4 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>
            <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_userinfo_code}}</td>
            <td style="text-align:center">{{row.f_user_name}}</td>
            <td style="text-align:center">{{row.f_user_type}}</td>
            <td style="text-align:center;white-space: nowrap;">{{row.f_address}}</td>
            <td style="text-align:center">{{row.f_state}}</td>
            <td style="text-align:center">{{row.f_entry_status}}</td>
            <td style="text-align:center">{{row.f_offsite_time}}</td>
            <td style="text-align:center">{{row.f_defect_content}}</td>
            <td style="text-align:center">{{row.f_check_number}}</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/getCheckPlanUserList', 50, {}),
        condition: '',
        getfield: {},
        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) {
        // 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
        //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
        //tag
        this.$parent.f_userinfo_id=val.f_userinfo_id
        this.$parent.listpage=false
      }
    },
    watch: {
      'checkrow' () {
        this.search()
      }
    }
  }
</script>
