<style>
  .bg {
    background-color: blue;
    height: 1px;
    border: 0;
  }
  .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{
    background-color:#499edf;
    border-radius: 4px ;
    border: 1px solid #499EDF;
    color: #FFFFFF;
    font: 14px PingFang-SC-Bold;
  }
  .qxbtn-color{
    background-color: #FFFFFF;
    border-radius: 4px ;
    color: #499edf;
    font: 14px PingFang-SC-Bold;
    border: 1px solid #499EDF;
  }
</style>

<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 = '{}'" />
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4">
                <img src="../../assets/用户姓名.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_user_name" class="font text-left">用户名称：</label>
              </div>
              <div class="col-xs-8" >
                <input id="f_keyword" class="search_input input-font"
                       v-model=model.f_user_name condition="f_user_name like '%{}%'" />
              </div>
            </div>

            <div class="row app-row">
              <div class="col-xs-4" style="margin-top: 8px">
                <img src="../../assets/shijian.png" style="width: 20px;margin-bottom: 5px" alt="">
                <span class="text-left font">起始日期：</span>
              </div>
              <div class="col-xs-8">
                <datepicker
                  :value.sync="model.startDate"
                  :format="'yyyy-MM-dd'"
                  v-model="model.startDate"
                  :show-reset-button="reset" placeholder="请输入起始日期"  style="margin-bottom: 8px">
                </datepicker>
                <!-- <input type="text" class="search_input" v-model="model.startDate" placeholder="请输入起下发时间"/> -->
              </div>
            </div>
            <div class="row app-row">
              <div class="col-xs-4" style="margin-top: 8px">
                <img src="../../assets/shijian.png" style="width: 20px;margin-bottom: 5px" alt="">
                <span class="text-left font">结束日期：</span>
              </div>
              <div class="col-xs-8">
                <datepicker
                  :value.sync="model.endDate"
                  :format="'yyyy-MM-dd'"
                  v-model="model.endDate"
                  :show-reset-button="reset" placeholder="请输入结束日期"  style="margin-bottom: 8px">
                </datepicker>
                <!-- <input type="text" class="search_input" v-model="model.endDate" 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="$parent.$parent.selfSearch">查询</button>
            </div>
            <!--<div class="row app-btn">-->
            <!--<button class="btn btn-primary col-xs-6" type="button"  @click="search"><span class="glyphicon  glyphicon-search" style="margin-right: 20px;">查询</span></button>-->
            <!--</div>-->
            <div style="height:30px;"></div>
          </form>
        </div>
      </criteria>
      <list :model="model" partial='list'>
        <div partial>
          <div 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_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_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.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_order_man }}</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.defname }}</p>
                </div>



              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>
    <modal :show.sync="showModal">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          选择预约时间
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <input type="datetime-local" v-model="f_preset_dt">
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button type="button" class="btn btn-default" @click="genuineReserve">确认</button>
      </div>
    </modal>
    <back-page :need-back='true'  @flag="$back()"></back-page>
  </div>
</template>

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

  export default {
    title: '无计划安检查询',
    data() {
      return {
        model: new PagedList(`${this.$androidUtil.getProxyUrl()}/rs/sql/QueryRepairStatus`, 5,{condition:'this.condition'}),
        showModal: false,
        param: null,
        f_preset_dt : Util.to3339TimeString(),
        check_states: [
          {label: '请选择安检状态', value: null},
          {label: '未检', value: '未检'},
          {label: '已检', value: '已检'},
        ],
        last_check_states: [
          {label: '请选择上次安检状态', value: null},
          {label: '入户', value: '入户'},
          {label: '拒检', value: '拒检'},
          {label: '到访不遇', value: '到访不遇'},
          {label: '未使用天然气', value: '未使用天然气'}
        ],
        upload_states: [
          {label: '请选择上传状态', value: null},
          {label: '未传', value: '未传'},
          {label: '已传', value: '已传'}
        ],
        user_types: [
          {label: '请选择用户类型', value: null},
          {label: '民用', value: '民用'},
          {label: '非民用', value: '非民用'},
        ],
        verify_state: [
          {label: '请选择审核状态', value: null},
          {label: '已审核', value: '已审核'},
          {label: '未审核', value: '未审核'},
          {label: '打回', value: '打回'},
          {label: '重检', value: '重检'},
        ]
      }
    },
    ready(){
      //   this.selfSearch()
    },
    methods: {
      reload(){
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
      },
      makeAPhoneCall(phoneNumber) {
        this.$androidUtil.makeAPhoneCall(phoneNumber)
      },
      reserve (idx) {
        this.param = idx
        this.showModal = true
      },
      search(args) {
        this.model.rows = []
        this.model.search(args.condition, args.model)
      },
      selfSearch () {
        let condition = "1 = 1 "
        if(this.$refs.paged.$refs.cri.model.f_user_name)
          condition += " and f_user_name like '%"+this.$refs.paged.$refs.cri.model.f_user_name+"%'"
        if(this.$refs.paged.$refs.cri.model.f_userinfo_code)
          condition += " and f_userinfo_code = '%"+this.$refs.paged.$refs.cri.model.f_userinfo_code+"%'"
        if(this.$refs.paged.$refs.cri.model.startDate)
          condition += " and f_offsite_time >= '"+this.$refs.paged.$refs.cri.model.startDate+"'"
        if(this.$refs.paged.$refs.cri.model.endDate)
          condition += " and f_offsite_time <= '"+this.$refs.paged.$refs.cri.model.endDate+"'"
          //查询本店安检单信息
         let value =  this.$androidUtil.path({alias: 'getUserinfomation', data:{condition: condition}})
         console.log("value",value.data)
        let serviceids = "''"
          for (let i = 0; i < value.data.length; i++) {
            serviceids += ","+ value.data[i].f_repairorder_id+" "
          }
       console.log(serviceids)
        this.model.ids = serviceids
        this.model.search("ts.id  in" +'('+serviceids+')')
      },
    }
  }
</script>
