<template>
  <div class="auto">
    <criteria-paged :model="model"  v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div partial>
          <form>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户编号：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font"
                       v-model=model.f_userinfo_code condition="f_userinfo_code = '{}'" placeholder="请输入用户编号" />
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">表 &nbsp;&nbsp; &nbsp;&nbsp; 号：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font"
                       v-model=model.f_meternumber condition="f_meternumber = '{}'" placeholder="请输入表号" />
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户名称：</label>
              </div>
              <div class="col-xs-8" >
                <input class="search_input input-font" v-model="model.f_username" placeholder="请输入用户名称（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户类型.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户类型：</label>
              </div>
              <div class="col-xs-8" >
                <v-select :value.sync="$parent.$parent.model.f_user_type" class="input-font"
                          :options='$parent.$parent.user_types' placeholder='请选择用户类型' :value-single="true"
                          v-model="$parent.$parent.model.f_user_type" close-on-select clear-button></v-select>
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">小区名称：</label>
              </div>
              <div class="col-xs-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_districtname" placeholder="请输入用户小区（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_building" placeholder="请输入用户楼号（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元：</label>
              </div>
              <div class="col-xs-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_unit" placeholder="请输入用户单元（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">用户地址：</label>
              </div>
              <div class="col-xs-8" >
                <input style="width: 100%" class="search_input input-font" v-model="model.f_address" placeholder="请输入用户地址（可模糊查询）">
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/安检状态.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">档案状态：</label>
              </div>
              <div class="col-xs-8" >
                <v-select class="input-font"
                          placeholder='请选择档案状态'
                          :value.sync="$parent.$parent.model.f_user_state"
                          :options='$parent.$parent.f_user_states'
                          close-on-select clear-button></v-select>
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/安检状态.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label class="font text-left">安检类型：</label>
              </div>
              <div class="col-xs-8" >
                <v-select class="input-font"
                          placeholder='请选择安检类型'
                          :value.sync="$parent.$parent.model.f_check_type"
                          :options='$parent.$parent.f_check_types'
                          close-on-select clear-button></v-select>
              </div>
            </div>

            <div class="row text-center" style="margin-top: 20px;">
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 45%;" @click="search">查询</button>
            </div>
            <div style="height:30px;"></div>
          </form>
        </div>
      </criteria>

      <list :model="model" partial='list'>
        <div partial>
          <div @click="$parent.$parent.$parent.inspect(row)" class="auto app-text" style="margin-top: 5px;">
            <div class="panel" style="padding: 10px 10px 5px 10px;">
              <div class="panel-body panel-self">
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">用户编号</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_userinfo_code }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">用户名称</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_user_name }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">用户类型</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_user_type }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">用户电话</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone }}</p>
                </div>

                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">小区名称</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_residential_area }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">用户地址</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_address }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">最后安检日期</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_last_check_date }}</p>
                </div>
                <div class="row">
                  <p class="panel-title col-xs-4 text-left font">最后安检状态</p>
                  <p class="panel-title col-xs-8 text-left input-font">{{ row.f_last_check_state }}</p>
                </div>
              </div>
            </div>

          </div>
        </div>
      </list>
    </criteria-paged>
    <back-page :need-back='true'   @flag="$back()"></back-page>
  </div>
</template>

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

  export default {
    title: '安检员B',
    data () {
      let model = new PagedList(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/提取用户档案`, 20, { groupitem: '""', orderitem: '"f_residential_area"',f_check_type:'this.f_check_type[0]',
        f_user_name:'this.model.f_username',myCycle: 'this.myCycle',fyCycle: 'this.fyCycle', f_user_type:'this.f_user_type',f_sign: 'this.f_sign[0]', f_residential_area:'this.model.f_districtname', f_address:'this.model.f_address',f_user_state: 'this.f_user_state[0]',f_orgids:'this.f_orgids',f_unit:'this.model.f_unit',f_building:'this.model.f_building',f_filialeid:'this.f_filialeid'})
      model.f_sign = ['']
      model.f_user_type = ''
      model.f_user_state =['']
      model.f_check_type =['']
      model.myCycle = 0
      model.fyCycle = 0
      model.f_filialeid = Vue.user.orgid
      return {
        model: model,
        showModal:false,
        signs: [
          {label:'请选择录入状态', value:''},
          {label:'录入', value:'1'},
          {label:'非录入', value:'0'},
        ],
        user_types: [
          {label: '请选择用户类型', value: ''},
          {label: '民用', value: '民用'},
          {label: '非民用', value: '非民用'},
        ],
        f_user_states: [
          {label:'请选择档案状态', value:''},
          {label:'正常', value:'正常'},
          {label:'点火', value:'点火'},
        ],
        f_check_types: [
          {label:'请选择安检类型', value:''},
          {label:'应检', value:'应检'},
          {label:'超期', value:'超期'},
        ],
      }
    },
    ready () {
      this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/getSafeCheckCycle`,{},{resolveMsg: null, rejectMsg: null}).then((res) => {
        console.log(JSON.stringify(res))
      if(res.data.code == 200){
        this.model.myCycle = res.data.civil.value
        this.model.fyCycle = res.data.civilian.value
      }else{
        self.$showMessage(res.data.msg)
      }
    })
    },
    computed: {
      reload(){
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
      },
      selected () {
        return this.$refs.paged.$refs.grid.selected
      }
    },
    methods:{
      inspect (info){
        info.id = ''
        info.f_state = '未检'
        info.f_no_checkplan = '无计划安检'
        console.log(info)
        this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/查询计划项表信息`,{data:{f_userid:info.f_userinfo_id}}).then((response)=>{
          console.log(JSON.stringify(response))
          info['f_plan_meters'] = response.data
          var pardate = {
            _this:this,
            tittle:'安检详情',
            safe:true
          }
           this.$dispatch('gotoson',pardate)
          this.$goto('safecheck-order-v', {item: info, role: 'inspect'}, 'self', this.reload)

        })
      }
    }
  }
</script>
<style>
  .app-row {
    background-color: white;
    padding: 10px 10px 0 10px;
    border-bottom: 1px solid rgba(235, 235, 235, 0.5);
  }
  .search_input {
    border: 0;
    outline: none;
  }
  .font{
    font: 15px PingFang-SC-Medium;
    color: #666666;
  }
  .input-font{
    font: 15px PingFang-SC-Medium;
    color: #333333;
  }
  .btn-font{
    font:600 16px PingFang-SC-Bold;
    color: #499EDF;
  }
  .btn-color{
    background-color: #FFFFFF;
    border-radius: 10px ;
    border: 1px solid #499EDF;
  }
  .app-text {
    font-size: 12px;
  }
  .panel-self{
    border-radius: 10px;
    border:1px solid #499EDF;
    background-color: #F8F8F8;
  }
  .yybtn-color{
    border-radius: 4px ;
    border: 1px solid #499EDF;
  }
  .qxbtn-color{
    background-color: #FFFFFF;
    border-radius: 4px ;
    border: 1px solid #499EDF;
  }
</style>
