<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 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>
            </div>

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

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

export default {
  title: '安检员B',
  data () {
    let model = new PagedList(`${this.$androidUtil.getProxyUrl()}/rs/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
    //model.f_filialeid = 287
    return {
      model: model,
      cbc:[],
      showModal:false,
      signs: [
        {label:'请选择录入状态', value:''},
        {label:'录入', value:'1'},
        {label:'非录入', value:'0'},
      ],
      ischecks: [
      ],
      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()}/rs/logic/getSafeCheckCycle`,{},{resolveMsg: null, rejectMsg: null}).then((res) => {
      //tag)
      if(res.data.code == 200){
        this.model.myCycle = res.data.civil.value
        this.model.fyCycle = res.data.civilian.value
      }else{
        //this.$showMessage(res.data.msg)
      }

    })
    this.getCheckTime()
    this.Mreadibook()*/
  },
  computed: {
    reload(){
      this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
    },
    selected () {
      return this.$refs.paged.$refs.grid.selected
    }
  },
  methods:{
    getCheckTime(){
      //tag
      new HttpResetClass().load('post',`${this.$androidUtil.getProxyUrl()}/rs/sql/tel_singleTable_OrderBy`,{data: {
          items: 'f_circle,f_start_time',
          tablename: 't_safe_circle',
          condition: `f_filialeid  = '${Vue.user.orgid}'`,
          orderitem: 'id'
        }}).then(res=>{
        //tag)
        let  nocheck=''
        let  ischeck=''
        if (res.data[0]){
          if (res.data[0].f_circle=='1'){
            nocheck=`(ua.f_last_check_date<'${res.data[0].f_start_time}' or ua.f_last_check_date is null)`
            ischeck=`ua.f_last_check_date>'${res.data[0].f_start_time}'`

          }else{
            let addtime= (Util.toStandardTimeString().substring(0,4)-res.data[0].f_start_time.substring(0,4))%res.data[0].f_circle
            //tag
            let time =(Util.toStandardTimeString().substring(0,4)-addtime)+'-01-01 00:00:00'
            //tag
            nocheck=`(ua.f_last_check_date<'${time}' or ua.f_last_check_date is null)`
            ischeck=`ua.f_last_check_date>'${time}'`
          }
          //tag
          this.ischecks=[
            {label: '全部', value: ''},
            {label: '已检', value: ischeck },
            {label: '未检', value: nocheck},
          ]
          //tag
        }else{
          this.$showMessage("未配置安检周期")
        }

      })
      //tag
    },
    inspect (info){
        info.id = ''
        info.f_state = '未检'
        info.f_no_checkplan = '无计划安检'
        //tag
          var pardate = {
            _this:this,
            tittle:'巡检详情',
            safe:true
          }
          this.$dispatch('gotoson',pardate)
          this.$goto('inspectionOrderV', {item: info, role: 'inspect'}, 'self', this.reload)
    },
    Mreadibook(){
      this.cbc=[]
      let http = new HttpResetClass()
      http.load('POST',`${this.$androidUtil.getProxyUrl()}/rs/logic/getMeterBooksData`,
        {data: {f_orgid: "('"+Vue.user.orgid+"')"}},
        {resolveMsg: null, rejectMsg: '获取失败！！！'}).then((getMeterReadingBooks)=>{
        this.cbc = [{label: '全部', value: ''}]
        //tag
        //tag)
        //tag
        getMeterReadingBooks.data.meterbooks.forEach((res) => {
          this.cbc.push({label: res.f_book_name, value: res.id})
          /*if(res.f_book_slice_area){
            if(this.sliceArea.indexOf(res.f_book_slice_area)<0){
              this.sliceArea.push(res.f_book_slice_area)
            }
          }*/
        })
      })


    }
  }
}
</script>
<style scoped>
.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>
