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

.button_shrink_top {
  width: 35px;
  height: 35px;
  background-size: 100%;
  background-image: url("../../../../../static/newStyle/stretch_top.png")
}

.button_shrink_bottom {
  width: 35px;
  height: 35px;
  background-size: 100%;
  background-image: url("../../../../../static/newStyle/stretch_bottom.png")
}

.button_shrink_left {
  width: 35px;
  height: 35px;
  background-size: 100%;
  background-image: url("../../../../../static/newStyle/stretch_left.png")
}

.button_shrink_right {
  width: 35px;
  height: 35px;
  background-size: 100%;
  background-image: url("../../../../../static/newStyle/stretch_right.png")
}
</style>

<template>
  <div style="height: auto;width: 100%">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:cri>
        <div partial>
          <form>
            <div class="row app-row">
              <!--小区名称-->
              <v-select :value.sync="model.f_residential_area"
                        class="input-font"
                        :align="'right'"
                        :options='$parent.$parent.residentialAreaOptions'
                        placeholder='小区名称'
                        :width="'32.5%'"
                        v-model="model.f_residential_area"
                        condition="ti.f_residential_area = '{}'"
                        @change="$parent.$parent.getbuilds"
                        close-on-select clear-button>
              </v-select>
              <!--楼栋-->
              <v-select :value.sync="model.f_building"
                        class="input-font"
                        :options='$parent.$parent.buildOptions'
                        placeholder='楼栋'
                        :width="'32.5%'"
                        v-model="model.f_building"
                        condition="ti.f_building = '{}'"
                        @change="$parent.$parent.getUnits"
                        close-on-select clear-button>
              </v-select>
              <!--单元-->
              <v-select :value.sync="model.f_unit"
                        class="input-font"
                        :options='$parent.$parent.unitOptions'
                        placeholder='单元'
                        :width="'32.5%'"
                        v-model="model.f_unit"
                        condition="ti.f_unit = '{}'"
                        close-on-select clear-button>
              </v-select>
            </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_user_name condition="f_user_name like '%{}%'"/>
              </div>
            </div>

            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-4">
                <img src="../../../../assets/安检状态.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_plan_name" class="font text-left">计划名称：</label>
              </div>
              <v-select
                id="f_plan_name"
                :value.sync="model.f_plan_name"
                class="input-font"
                :options='$parent.$parent.planNameOptions'
                placeholder='计划名称'
                :width="'60%'"
                v-model="model.f_plan_name"
                condition="f_plan_name like '%{}%'"
                close-on-select clear-button>
              </v-select>
            </div>

            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-4">
                <img src="../../../../assets/是否已检.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_state" class="font text-left">是否已检：</label>
              </div>
              <v-select id="f_state"
                        :value.sync="model.f_state"
                        class="input-font"
                        :options='$parent.$parent.check_states'
                        placeholder='是否已检'
                        :width="'60%'"
                        v-model="model.f_state"
                        condition="f_state='{}'"
                        close-on-select clear-button>
              </v-select>
            </div>

            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-4">
                <img src="../../../../assets/用户ID.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_userinfo_code" class="font text-left">用户编号：</label>
              </div>
              <div class="col-xs-8">
                <input id="f_userinfo_code" class="search_input input-font"
                       v-model=model.f_userinfo_code condition="f_userinfo_code like '%{}%'"/>
              </div>
            </div>

            <!--<div class="row app-row">-->
            <!--<div class="col-xs-4">-->
            <!--<img src="../../assets/shijian.png" style="width: 20px;margin-bottom: 5px" alt="">-->
            <!--<label for="f_plan_year" class="font text-left">计划年份：</label>-->
            <!--</div>-->
            <!--<div class="col-xs-8" >-->
            <!--<input id="f_plan_year" class="search_input input-font"-->
            <!--v-model="model.f_plan_year" condition="f_plan_year = '{}'" />-->
            <!--</div>-->
            <!--</div>-->
            <!--<div class="row app-row">-->
            <!--<div class="col-xs-4">-->
            <!--<img src="../../assets/shijian.png" style="width: 20px;margin-bottom: 5px" alt="">-->
            <!--<label for="f_plan_month" class="font text-left">计划月份：</label>-->
            <!--</div>-->
            <!--<div class="col-xs-8" >-->
            <!--<input id="f_plan_month" class="search_input input-font"-->
            <!--v-model="model.f_plan_month" condition="f_plan_month = '{}'" />-->
            <!--</div>-->
            <!--</div>-->

            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <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;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8">
                <input class="search_input input-font"
                       v-model=model.f_meter_no condition="f_meter_no like '%{}%'"/>
              </div>
            </div>

            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <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_keyword condition="f_address like '%{}%'"/>
              </div>
            </div>
            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-4">
                <img src="../../../../assets/用户类型.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_user_type" class="font text-left">用户类型：</label>
              </div>
              <v-select id="f_user_type" :value.sync="model.f_user_type" class="input-font"
                        :width="'60%'"
                        :options='$parent.$parent.user_types' placeholder='请选择用户类型'
                        v-model="model.f_user_type" condition="f_user_type='{}'" close-on-select
                        clear-button></v-select>
            </div>
            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-4">
                <img src="../../../../assets/是否已检.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="safechecktype" class="font text-left">安检类型：</label>
              </div>
              <v-select id="safechecktype" :value.sync="model.f_safecheck_type" class="input-font"
                        :width="'60%'"
                        :options='$parent.$parent.safechecktypes' placeholder='请选择安检类型'
                        v-model="model.f_safecheck_type" condition="f_safecheck_type ='{}'" close-on-select
                        clear-button></v-select>
            </div>
            <div class="row app-row" v-if="$parent.$parent.criteriaShow">
              <div class="col-xs-6" style="text-align: center">
                <span class="font text-left">待办{{ $parent.$parent.upcomingCount }}条</span>
              </div>
              <div class="col-xs-6" style="text-align: center">
                <span class="font text-left">已办{{ $parent.$parent.doneCount }}条</span>
              </div>
              <div class="col-xs-6" style="text-align: center">
                <span class="font text-left">临时保存{{ $parent.$parent.tempSaveCount }}条</span>
              </div>
              <div class="col-xs-6" style="text-align: center">
                <span class="font text-left">总共{{ $parent.$parent.allPlanCount }}条</span>
              </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="model.f_flow_direction"-->
            <!--:options='$parent.$parent.flow_direction' placeholder='请选择挂表方式'-->
            <!--v-model="model.f_flow_direction" condition="f_flow_direction='{}'" 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 for="f_last_state" class="font text-left">安检状态：</label>-->
            <!--</div>-->
            <!--<div class="col-xs-8" >-->
            <!--<v-select id="f_last_state" :value.sync="model.f_last_state" class="input-font"-->
            <!--:options='$parent.$parent.last_check_states' placeholder='请选择安检状态'-->
            <!--v-model="model.f_last_state" condition="f_last_check_state='{}'" close-on-select clear-button></v-select>-->
            <!--</div>-->
            <!--</div>-->
            <!--  <div class="row app-row">
                <div class="col-xs-8" >
                  <v-select id="f_approved" :value.sync="model.f_approved" class="input-font"
                            :options='$parent.$parent.verify_state' placeholder='请选择审核状态'
                            v-model="model.f_approved" condition="f_approved='{}'" 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: 25%;"
                      @click="$parent.$parent.selfSearch">查询
              </button>
              <button type="button" class="btn btn-lg btn-font btn-color" style="width: 25%; margin-left: 10px"
                      @click="$parent.$parent.queryplanmany">转发
              </button>
              <div style="float: right;margin-right: 3% " class="button_spacing"
                   :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                   @click="$parent.$parent.hidden()"></div>
              <img style="float: right;margin-right: 3% " @click="$parent.$parent.getNewOrder"
                   src="../../../../assets/shuaxindaiban1.png" style="width: 40px;padding: 5px; float:right">
            </div>

            <div class="row">
              <div style="float: right;margin-right: 30px;margin-top: 5px;display: flex;padding: 8px;border: 1px solid #499EDF;border-radius: 5px;">
                <span class="font text-left">
                  <input type="checkbox" id="multiple-check-id" class="search_input input-font"  @click="$parent.$parent.selcheckAll($event)" />
                </span>
                <label for="multiple-check-id" class="font text-left" style="font: 600 15px PingFang-SC-Bold; color: #499EDF;padding: 0;margin: 0;">
                  [已选{{ $parent.$parent.planparam.length }}]
                </label>
              </div>
            </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="col-xs-12">
                  <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户编号:</b></p>
                  <p class="panel-title col-xs-5 text-left input-font" style="width: 74%">{{ row.f_userinfo_code }}</p>
                  <p class="panel-title col-xs-2 text-left input-font" style="width: 5%;float:right">
                    <input type="checkbox" @click="$parent.$parent.$parent.setPlanParam(row.id, $event)"
                           :checked="$parent.$parent.$parent.planparam.includes(row.id)"/>
                  </p>
                </div>
                <div class="col-xs-12">
                  <p class="panel-title col-xs-5 text-left font" style="width: 21%;float: left"><b>用户名称:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font" style="width: 79%">{{ row.f_user_name }}</p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>用户类型:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_user_type }}
                  </p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>计划名称:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_plan_name }}</p>
                </div>
                <!--                <div class="col-xs-6">-->
                <!--                  <p class="panel-title col-xs-5 text-left font"><b>小区名称:</b></p>-->
                <!--                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_residential_area }}</p>-->
                <!--                </div>-->
                <div class="col-xs-12">
                  <p class="panel-title text-left font" style="width: 23%;float: left"><b>用户电话:</b></p>
                  <p class="panel-title text-left input-font" style="width: 77%">
                    {{ row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone }}
                    <img src="../../../../assets/phone.png" style="width: 6%"
                         v-on:click.stop.prevent='$parent.$parent.$parent.makeAPhoneCall(row.f_user_phone2 ? row.f_user_phone2 : row.f_user_phone)'></img>
                  </p>
                </div>

                <div class="col-xs-12">
                  <p class="panel-title text-left font" style="width: 21%;float: left"><b>用户地址:</b></p>
                  <p class="panel-title text-left input-font" style="width: 79%">{{ 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_plan_year }}</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_plan_month }}</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_prearranged_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 class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>安检状态:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">
                    {{ row.f_state == '已检' ? '临时保存' : row.f_state }}</p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>上传状态:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_upload_state }}</p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>安检类型:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_safecheck_type }}</p>
                </div>
                <div class="col-xs-6">
                  <p class="panel-title col-xs-5 text-left font"><b>投保日期:</b></p>
                  <p class="panel-title col-xs-7 text-left input-font">{{ row.f_insurance_gas_date }}</p>
                </div>
                <!--<div class="col-xs-12">-->
                <!--<p class="panel-title col-xs-5 text-left font"><b>送气期限:</b></p>-->
                <!--<p class="panel-title col-xs-7 text-left input-font">{{timeSet(row.f_issue_time)}}</p>-->
                <!--</div>-->
                <div class="col-xs-12">
                  <button type="button" name="button" class="btn btn-primary"
                          style="background-color:#499edf;float: right" @click="$parent.$parent.$parent.inspect(row)">处理
                  </button>
                  <button type="button" name="button" class="btn btn-primary"
                          style="background-color:#499edf;float: right;margin-right:10px;"
                          @click="$parent.$parent.$parent.queryplan(row.id)">转发
                  </button>
                  <!--<button type="button" class="btn btn-default" @click="$parent.$parent.$parent.ceshi">确认2</button>-->
                </div>
                <!--                <div class="row text-right" v-show="row.f_upload_state != '已传'" >-->
                <!--                  <button type="button" class="btn yybtn-color" v-on:click.stop.prevent='$parent.$parent.$parent.reserve($index)'>预约</button>&nbsp;-->
                <!--                  <button type="button" class="btn qxbtn-color" v-if ='row.f_prearranged_date'-->
                <!--                          v-on:click.stop.prevent='$parent.$parent.$parent.cancelReserve($index, row.id)'>取消预约</button>-->
                <!--                </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>-->
    <modal :show.sync="showModal2" v-ref:modal :backdrop="false">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          选择计划
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <div class="col-xs-12">

          <div class="col-xs-4">
            <v-select :value.sync="check" v-model='check'
                      :value-single="true"
                      class="select_list select"
                      :options='checkers' placeholder='安检员'
                      close-on-select width="100%"></v-select>
          </div>

          <div class="col-xs-1">
            <!--<label  style="font-size:20px;line-height: 35px">人员 </label>-->
          </div>
          <div class="col-xs-4" style="padding-left: 2px">
            <input class="select-style" placeholder="计划名称" type="text" v-model="plan"
                   style="border: 1px solid #93B2D3;height:34px;width: 100%;line-height: 35px"/>
          </div>
          <div class="col-xs-1">
            <!--<label  style="font-size: 20px;line-height: 35px">计划</label>-->
          </div>
          <!--<input placeholder="安检员" type="text"  v-model="check" style="height:30px;width: 100px"/>-->
          <div class="col-xs-2" style="float: right">
            <button type="button" class="btn btn-primary" @click="plansearch"
                    style="background-color:#499edf;float: right;margin-right:10px;border: 1px solid #93B2D3;height:34px;width: 100%;line-height: 1px;padding-left: 12px">
              查询
            </button>
          </div>
        </div>
        <table class="table table_sy">
          <thead>
          <tr>
            <th style="width: 30px"></th>
            <th style="font-family: 'Adobe 黑体 Std R'">计划名称</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="row in planoption">
            <td @click="select(row, $index)">{{ row.selected == true ? '☆' : '&nbsp;&nbsp;&nbsp;&nbsp;' }}</td>
            <td @click="select(row, $index)" style="text-align: center">{{ row.label }}</td>


          </tr>
          </tbody>
        </table>
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button class="btn btn-default" @click="isok()">确认</button>
        <button class="btn btn-default" @click="iscancel()">取消</button>
      </div>
    </modal>
    <modal :show.sync="showModal3" v-ref:modal>
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          选择计划
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <div class="col-xs-12">

          <div class="col-xs-4">
            <v-select :value.sync="check" v-model='check'
                      :value-single="true"
                      class="select_list select"
                      :options='checkers' placeholder='安检员'
                      close-on-select width="100%"></v-select>
          </div>

          <div class="col-xs-1">
            <!--<label  style="font-size:20px;line-height: 35px">人员 </label>-->
          </div>
          <div class="col-xs-4" style="padding-left: 2px">
            <input class="select-style" placeholder="计划名称" type="text" v-model="plan"
                   style="border: 1px solid #93B2D3;height:34px;width: 100%;line-height: 35px"/>
          </div>
          <div class="col-xs-1">
            <!--<label  style="font-size: 20px;line-height: 35px">计划</label>-->
          </div>
          <!--<input placeholder="安检员" type="text"  v-model="check" style="height:30px;width: 100px"/>-->
          <div class="col-xs-2" style="float: right">
            <button type="button" class="btn btn-primary" @click="plansearch"
                    style="background-color:#499edf;float: right;margin-right:10px;border: 1px solid #93B2D3;height:34px;width: 100%;line-height: 1px;padding-left: 12px">
              查询
            </button>
          </div>
        </div>
        <table class="table table_sy">
          <thead>
          <tr>
            <th style="width: 30px"></th>
            <th style="font-family: 'Adobe 黑体 Std R'">计划名称</th>
          </tr>
          </thead>
          <tbody>
          <tr v-for="row in planoption">
            <td @click="select(row, $index)">{{ row.selected == true ? '☆' : '&nbsp;&nbsp;&nbsp;&nbsp;' }}</td>
            <td @click="select(row, $index)" style="text-align: center">{{ row.label }}</td>


          </tr>
          </tbody>
        </table>
      </div>
      <div slot="modal-footer" class="modal-footer">
        <button class="btn btn-default" @click="manyisok()">确认</button>
        <button class="btn btn-default" @click="iscancel()">取消</button>
      </div>
    </modal>
  </div>

</template>

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

let select = function * (self) {
  let http = new HttpResetClass()
  http.load('POST', `${self.$androidUtil.getProxyUrl()}/rs/search`, {
    source: 'this.getParentByType($department$).getAllChildrens().where(row.getAttributes().get($rolestr$).indexOf($安检员$) != -1))',
    userid: Vue.user.id
  }, {resolveMsg: null, rejectMsg: null}).then((res) => {
    console.log('获取安检员', res)
    self.checkers.push({label: '全部', value: ''})
    res.data.forEach((checker) => {
      self.checkers.push({label: checker.name, value: checker.id})
    })
  })
}
export default {
  title: '无计划安检查询',
  data () {
    return {
      f_filialeids: `('${Vue.user.orgid}')`,
      // f_filialeids:'(305)',
      planparam: [],
      check: '',
      plan: '',
      planid: '',
      model: Vue.android ? new LocalPagedList('androidGetuserinfoTS', 20, {condition: 'this.condition'}) : new PagedList('AndroidRest/api/af-safecheck/sql/androidGetuserinfoTS', 20, {condition: 'this.condition'}),
      showModal: false,
      showModal2: false,
      showModal3: false,
      needid: '',
      criteriaShow: false,
      planoption: [],
      condition: '',
      checklistcodes: [],
      checkers: [],
      enableButton: false,
      param: null,
      f_preset_dt: Util.to3339TimeString(),
      flow_direction: [
        {label: '请选择挂表方式', value: ''},
        {label: '左表', value: '左表'},
        {label: '右表', value: '右表'}
      ],
      check_states: [
        {label: '请选择安检状态', value: ''},
        {label: '未检', value: '未检'},
        {label: '临时保存', value: '已检'}
      ],
      last_check_states: [
        {label: '请选择上次安检状态', value: ''},
        {label: '入户', value: '入户'},
        {label: '拒检', value: '拒检'},
        {label: '到访不遇', value: '到访不遇'},
        {label: '未使用天然气', value: '未使用天然气'}
      ],
      upload_states: [
        {label: '请选择上传状态', value: ''},
        {label: '未传', value: '未传'},
        {label: '已传', value: '已传'}
      ],
      user_types: [
        {label: '请选择用户类型', value: ''},
        {label: '民用', value: '民用'},
        {label: '非民用', value: '非民用'}
      ],
      safechecktypes: [
        {label: '请选择安检类型', value: ''},
        {label: '年度普检', value: '年度普检'},
        {label: '专项计划', value: '专项计划'}
      ],
      verify_state: [
        {label: '请选择审核状态', value: ''},
        {label: '未审核', value: '未审核'},
        {label: '打回', value: '打回'}
      ],
      residentialAreaOptions: [],
      buildOptions: [],
      unitOptions: [],
      planNameOptions: [],
      upcomingCount: 0,
      doneCount: 0,
      tempSaveCount: 0,
      allPlanCount: 0
    }
  },
  ready () {
    this.getAllArea()
    this.getAllPlanName()
    this.selfSearch()
    let gen = select(this)
    co(gen)
  },
  methods: {
    getNowDate (f_time) {
      let year = ''
      let month = ''
      let day = ''
      let hour = ''
      let minutes = ''
      let seconds = ''
      let mydate = new Date(f_time)
      let mymonth = mydate.getMonth() + 1
      let myday = mydate.getDate()
      let myyear = mydate.getYear()
      let myhour = mydate.getHours()
      let myminutes = mydate.getMinutes()
      let myseconds = mydate.getSeconds()
      year = (myyear > 200) ? myyear : 1900 + myyear
      month = (mymonth > 9) ? mymonth : '0' + mymonth
      day = (myday > 9) ? myday : '0' + myday
      hour = (myhour > 9) ? myhour : '0' + myhour
      minutes = (myminutes > 9) ? myminutes : '0' + myminutes
      seconds = (myseconds > 9) ? myseconds : '0' + myseconds
      // document.write("<font color=#ffffff>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
      return year + '-' + month + '-' + day + ' ' + hour + ':' + minutes + ':' + seconds
    },
    iscancel () {
      this.showModal2 = false
      this.showModal3 = false
      this.planoption = []
    },
    timeSet (val) {
      return val
    },
    async isok () {
      if (this.planoption.length == 0) {
        this.$showMessage('请选择计划')
        return false
      }
      for (let i = 0; i < this.planoption.length; i++) {
        if (this.planoption[i]['selected'] == true) {
          this.planid = this.planoption[i].value
          break
        }
      }
      if (this.planid == '') {
        this.$showMessage('请选择计划')
        return false
      }
      await this.okput()
    },
    async manyisok () {
      if (this.planoption.length == 0) {
        this.$showMessage('请选择计划')
        return false
      }
      for (let i = 0; i < this.planoption.length; i++) {
        if (this.planoption[i]['selected'] == true) {
          this.planid = this.planoption[i].value
          break
        }
      }
      if (this.planid == '') {
        this.$showMessage('请选择计划')
        return false
      }
      await this.manyokput()
    },
    changenull () {
      this.showModal2 = false
      this.showModal3 = false
      this.planoption = []
      this.plan = ''
      this.check = ''
    },
    async okput () {
      let res = await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/UpCheckPlanItemTS`, {
        data: {

          condition: `it.id='` + this.needid + `'`,
          f_plan_id: this.planid,
          switchCheckAll: false,
          checkAll: false,
          f_operator: Vue.user.name
        }
      })
      await this.changenull()
      await this.getNewOrder()
    },
    async manyokput () {
      let res = await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/logic/UpCheckPlanItemTS`, {
        data: {
          columnName: 'it.id',
          condition: '1=1',
          f_plan_id: this.planid,
          switchCheckAll: true,
          param: this.planparam,
          checkAll: false,
          f_operator: Vue.user.name
        }
      })
      await this.changenull()
      await this.getNewOrder()
    },
    async plansearch () {
      this.planoption = []
      let condition = `1=1`
      if(this.check){
        condition += ` and f_checker_id = '${this.check}'`
      }
      if (this.plan){
        condition += ` and f_plan_name like '%${this.plan}%'`
      }
      let res = await this.$resetpost(`${this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/预约计划下发TS`, {
        data: {
          condition: condition,
          f_filialeids: this.f_filialeids,
          groupitem: '',
          orderitem: 'id'
        }
      })
      let resoult = res.data
      for (let i = 0; i < resoult.length; i++) {
        this.planoption.push({label: resoult[i].f_plan_name, selected: false, value: resoult[i].id})
      }
    },

    select (row, idx) {
      this.$set('planoption[' + idx + '].selected', true)
      for (let i = 0; i < this.planoption.length; i++) {
        if (i != idx) {
          this.planoption[i]['selected'] = false
        }
      }
    },
    planclose () {
      this.showModal2 = false
      this.showModal3 = false
    },
    queryplan (val) {
      this.needid = val
      this.showModal2 = true
    },
    queryplanmany () {

      this.showModal3 = true
    },
    reload () {
      // this.getAllArea()
      // this.getAllPlanName()
      // this.selfSearch()
      this.$refs.paged.loadPage(this.model.pageIndex)
    },
    cancelReserve (idx, id) {
      if (Vue.android) {
        let res = this.$androidUtil.bzLogic('BookingCheckTS', {dt: '', id: id})
        this.$set('model.rows[' + idx + '].f_prearranged_date', null)
        if (res.code == 200) {
          this.$showMessage('取消预约成功')
        }
      } else {
        this.$androidUtil.bzLogic('PCbookingCheckTS', {dt: '', id: id}).then((repanse) => {
          this.$set('model.rows[' + idx + '].f_prearranged_date', null)
          if (repanse.data.code == 200) {
            alert('取消预约成功!')
          }
        })
      }
    },
    genuineReserve () {
      if (Vue.android) {
        if (!this.f_preset_dt) {
          this.$showMessage('请选择一个日期')
          return
        }
        let pdt = this.f_preset_dt.replace('T', ' ')
        let respanse = this.$androidUtil.bzLogic('BookingCheckTS', {id: this.model.rows[this.param].id, dt: pdt})
        this.$set('model.rows[' + this.param + '].f_prearranged_date', pdt)
        if (respanse.code == 200) {
          this.$showMessage('预约成功!')
        }
        this.showModal = false
      } else {
        if (!this.f_preset_dt) {
          alert('请选择一个日期')
          return
        }
        let pdt = this.f_preset_dt.replace('T', ' ')
        this.$androidUtil.bzLogic('PCbookingCheckTS', {id: this.model.rows[this.param].id, dt: pdt}).then((res) => {
          this.$set('model.rows[' + this.param + '].f_prearranged_date', pdt)
          if (res.data.code == 200) {
            alert('预约成功!')
          }
          this.showModal = false
        })
      }
    },
    inspect (row) {
      if (this.enableButton) {
        return
      }
      this.enableButton = true
      var _this = this
      console.log('进入inspect')
      if (row.f_upload_state == '未传' || (row.f_upload_state == '已传' && row.f_state == '未检' && row.f_no_checkplan != '无计划安检')) {
        new HttpResetClass().load('POST', `${_this.$androidUtil.getProxyUrl()}/api/af-safecheck/sql/查询计划项表信息TS`, {data: {f_userid: row.f_userinfoid}}).then((response) => {
          console.log(JSON.stringify(response))
          row['f_plan_meters'] = response.data
          var pardate = {
            _this: _this,
            title: '安检单',
            safe: true
          }
          _this.$dispatch('gotoson', pardate)
          console.log('进入safecheck-order-v')
          this.enableButton = false
          _this.$goto('safecheck-order-v-ts', {
            f_plan_id: row.f_plan_id,
            item: row,
            role: 'inspect',
            buttonState: true
          }, 'self', _this.reload)
        }).catch((msg) => {
          _this.$showMessage('网络故障，请稍候再试!')
          this.enableButton = false
        })
      } else {
        this.$showMessage('该安检单已被上传！')
        this.enableButton = false
      }
    },
    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 () {
      this.getPlanCount()
      let condition = ''
      if (this.$refs.paged.$refs.cri.model.f_residential_area) {
        if (this.$refs.paged.$refs.cri.model.f_residential_area.toString().trim()) {
          condition += ' and ti.f_residential_area = \'' + this.$refs.paged.$refs.cri.model.f_residential_area + '\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_building) {
        if (this.$refs.paged.$refs.cri.model.f_building.toString().trim()) {
          condition += ' and ti.f_building = \'' + this.$refs.paged.$refs.cri.model.f_building + '\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_unit) {
        if (this.$refs.paged.$refs.cri.model.f_unit.toString().trim()) {
          condition += ' and ti.f_unit = \'' + this.$refs.paged.$refs.cri.model.f_unit + '\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_plan_name) {
        if (this.$refs.paged.$refs.cri.model.f_plan_name.toString().trim()) {
          condition += ' and f_plan_name like \'%' + this.$refs.paged.$refs.cri.model.f_plan_name + '%\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_userinfo_code) {
        if (this.$refs.paged.$refs.cri.model.f_userinfo_code.toString().trim()) {
          condition += ' and ti.f_userinfo_code like \'%' + this.$refs.paged.$refs.cri.model.f_userinfo_code + '%\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_keyword) {
        if (this.$refs.paged.$refs.cri.model.f_keyword.toString().trim()) {
          condition += ' and ti.f_address like \'%' + this.$refs.paged.$refs.cri.model.f_keyword + '%\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_user_name) {
        if (this.$refs.paged.$refs.cri.model.f_user_name.toString().trim()) {
          condition += ' and ti.f_user_name like \'%' + this.$refs.paged.$refs.cri.model.f_user_name + '%\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_state[0]) {
        if (this.$refs.paged.$refs.cri.model.f_state[0].toString().trim()) {
          condition += ' and ti.f_state=\'' + this.$refs.paged.$refs.cri.model.f_state[0] + '\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_user_type[0]) {
        if (this.$refs.paged.$refs.cri.model.f_user_type[0].toString().trim()) {
          condition += ' and ti.f_user_type=\'' + this.$refs.paged.$refs.cri.model.f_user_type[0] + '\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_meter_no) {
        if (this.$refs.paged.$refs.cri.model.f_meter_no.toString().trim()) {
          condition += ' and tm.f_meter_no like \'%' + this.$refs.paged.$refs.cri.model.f_meter_no + '%\''
        }
      }
      if (this.$refs.paged.$refs.cri.model.f_safecheck_type) {
        if (this.$refs.paged.$refs.cri.model.f_safecheck_type.toString().trim()) {
          condition += ' and ti.f_safecheck_type = \'' + this.$refs.paged.$refs.cri.model.f_safecheck_type + '\''
        }
      }

      // if(this.$refs.paged.$refs.cri.model.f_flow_direction[0])
      //   condition += " and tm.f_flow_direction = '"+this.$refs.paged.$refs.cri.model.f_flow_direction[0]+"'"
      console.log('condition ===> ' + condition)
      this.model.search('((f_complete = \'\' or f_complete = null or f_complete = \'未完成\') or (f_state = \'未检\')) and ti.f_no_checkplan = \'有计划安检\'' + condition)
    },
    getNewOrder () {
      HostApp.__this__ = this
      HostApp.logicWithHint({
        // logic别名，key必须为logic
        'logic': 'SafeCheckServiceTimeOutTS',
        // 回调执行方法名，key必须为callback
        'callback': 'javascript:HostApp.__this__.getNewOrderCallBack()',
        // logic执行需要的业务参数
        'data': {params: ''},
        // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
        // 执行回调方法传入key为backresult
        // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
        'backresult': 1
      })
    },
    getNewOrderCallBack () {
      this.selfSearch()
      this.getAllArea()
      this.getAllPlanName()
    },
    hidden () {
      this.criteriaShow = !this.criteriaShow
    },
    getAllArea () {
      this.residentialAreaOptions = []
      this.buildOptions = []
      this.unitOptions = []
      this.$refs.paged.$refs.cri.model.f_residential_area = ''
      this.$refs.paged.$refs.cri.model.f_building = ''
      this.$refs.paged.$refs.cri.model.f_unit = ''
      let criteria = {
        items: 'f_residential_area',
        tablename: 't_check_plan_item_ts',
        condition: `f_residential_area IS NOT NULL AND f_residential_area != '' AND ((f_complete = '' or f_complete = null or f_complete = '未完成') or (f_state = '未检'))`,
        groupitem: 'f_residential_area'
      }
      let result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      console.log('result ===> ' + JSON.stringify(result))
      if (result.code == 200) {
        result.data.rows.forEach(item => this.residentialAreaOptions.push({
          label: item.f_residential_area,
          value: item.f_residential_area
        }))
      }
      console.log('this.residentialAreaOptions ===> ' + JSON.stringify(this.residentialAreaOptions))
    },
    getbuilds (f_residential_area) {
      console.log('f_residential_area ===> ' + JSON.stringify(f_residential_area))
      this.buildOptions = []
      this.unitOptions = []
      this.$refs.paged.$refs.cri.model.f_building = ''
      this.$refs.paged.$refs.cri.model.f_unit = ''
      if (!f_residential_area) {
        return
      }
      let criteria = {
        items: 'f_building',
        tablename: 't_check_plan_item_ts',
        condition: `f_building IS NOT NULL AND f_building != '' AND ((f_complete = '' or f_complete = null or f_complete = '未完成') or (f_state = '未检')) AND f_residential_area = '${f_residential_area}'`,
        groupitem: 'f_building'
      }
      let result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      if (result.code == 200) {
        result.data.rows.forEach(item => this.buildOptions.push({label: item.f_building, value: item.f_building}))
      }
      console.log('this.buildOptions ===> ' + JSON.stringify(this.buildOptions))
    },
    getUnits (f_building) {
      f_building = f_building[0]
      console.log('f_building ===> ' + JSON.stringify(f_building))
      this.unitOptions = []
      this.$refs.paged.$refs.cri.model.f_unit = ''
      if (!f_building) {
        return
      }
      let criteria = {
        items: 'f_unit',
        tablename: 't_check_plan_item_ts',
        condition: `f_unit IS NOT NULL AND f_unit != '' AND ((f_complete = '' or f_complete = null or f_complete = '未完成') or (f_state = '未检')) AND f_residential_area = '${this.$refs.paged.$refs.cri.model.f_residential_area}' AND f_building = '${f_building}'`,
        groupitem: 'f_unit'
      }
      let result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      if (result.code == 200) {
        result.data.rows.forEach(item => this.unitOptions.push({label: item.f_unit, value: item.f_unit}))
      }
      console.log('this.unitOptions ===> ' + JSON.stringify(this.unitOptions))
    },
    getPlanCount () {
      this.upcomingCount = 0
      this.tempSaveCount = 0
      this.doneCount = 0
      this.allPlanCount = 0
      let criteria = {
        items: 'count(id) count',
        tablename: 't_check_plan_item_ts',
        condition: `f_state = '未检'`,
        groupitem: 'f_state'
      }
      let result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      if (result.code && result.code == 200) {
        if (result.data.rows[0] && !isNaN(result.data.rows[0].count)) {
          this.upcomingCount = result.data.rows[0].count
        }
      }
      criteria = {
        items: 'count(id) count',
        tablename: 't_check_plan_item_ts',
        condition: `(f_complete = '' or f_complete = null or f_complete = '未完成') AND f_state = '已检'`,
        groupitem: 'f_state'
      }
      result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      if (result.code && result.code == 200) {
        if (result.data.rows[0] && !isNaN(result.data.rows[0].count)) {
          this.tempSaveCount = result.data.rows[0].count
        }
      }
      criteria = {
        items: 'count(id) count',
        tablename: 't_check_plan_item_ts',
        condition: `f_complete = '已完成' AND f_state = '已检'`,
        groupitem: 'f_state'
      }
      result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      if (result.code && result.code == 200) {
        if (result.data.rows[0] && !isNaN(result.data.rows[0].count)) {
          this.doneCount = result.data.rows[0].count
        }
      }
      this.allPlanCount = this.upcomingCount + this.tempSaveCount + this.doneCount

      console.log('this.upcomingCount ===> ' + this.upcomingCount)
      console.log('this.tempSaveCount ===> ' + this.tempSaveCount)
      console.log('this.doneCount ===> ' + this.doneCount)
      console.log('this.allPlanCount ===> ' + this.allPlanCount)
    },
    getAllPlanName () {
      this.planNameOptions = []
      this.$refs.paged.$refs.cri.model.f_plan_name = ''
      let criteria = {
        items: 'f_plan_name',
        tablename: 't_check_plan_ts',
        condition: `f_plan_name IS NOT NULL AND f_plan_name != ''`,
        groupitem: 'f_plan_name'
      }
      let result = HostApp._executeTask({
        'type': 'sql',
        'data': {'alias': 'safe_singleTable_GroupBy', 'criteria': criteria}
      })
      console.log('result ===> ' + JSON.stringify(result))
      if (result.code == 200) {
        result.data.rows.forEach(item => this.planNameOptions.push({label: item.f_plan_name, value: item.f_plan_name}))
      }
      console.log('this.planNameOptions ===> ' + JSON.stringify(this.planNameOptions))
    },
    setPlanParam (detailsType, event) {
      if (event.srcElement.checked) {
        this.planparam.push(detailsType)
      } else {
        if (this.planparam.length > 0) {
          let planid = this.planparam.findIndex((value) => {
            return value === detailsType
          })
          this.planparam.splice(planid, 1)
        }
      }
    },
    selcheckAll (event) {
      if (event.srcElement.checked) {
        const ids = [];
        for (const row of this.$refs.paged.model.rows) {
          ids.push(row.id)
        }
        this.planparam = [...this.planparam, ...ids]
      } else {
        if (this.planparam.length > 0 && this.$refs.paged.model.rows.length > 0) {
          for (const planparamElement of this.$refs.paged.model.rows) {
            const planid = this.planparam.findIndex((value) => {
              return value === planparamElement.id
            })
            this.planparam.splice(planid, 1)
          }
        }
      }
    }
  }
}
</script>
