<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 col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_building" class="font text-left">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input id="f_building" class="search_input input-font"
                       v-model="model.f_building" condition="f_building = '{}'" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_unit" class="font text-left">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input id="f_unit" class="search_input input-font"
                       v-model="model.f_unit" condition="f_unit = '{}'" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_unit" class="font text-left">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;层：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input id="f_floor" class="search_input input-font"
                       v-model="model.f_floor" condition="f_floor = '{}'" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-6 col-md-6 app-row">
              <div class="col-xs-4 col-sm-4 col-md-4">
                <img src="../../assets/小区.png" style="width: 20px;margin-bottom: 5px" alt="">
                <label for="f_unit" class="font text-left">房&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label>
              </div>
              <div class="col-xs-8 col-sm-8 col-md-8" >
                <input id="f_floor" class="search_input input-font"
                       v-model="model.f_room" condition="f_room = '{}'" />
              </div>
            </div>
            <div class="row col-xs-12 col-sm-12 col-md-6 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 style="height: auto;" class="row col-xs-12 col-sm-12 col-md-12">-->
              <!--<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 col-xs-12 col-sm-12 col-md-12">-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">全部:{{ $parent.$parent.totalItems }}</span>-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">已安检:{{ $parent.$parent.countYijian }}</span>-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">入户:{{ $parent.$parent.countRuhu }}</span>-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">拒访:{{ $parent.$parent.countJufang }}</span>-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">无人:{{ $parent.$parent.countWuren }}</span>-->
                      <!--<span class="panel-title col-xs-3 col-sm-3 col-md-3 text-left font" style="width: 20%">隐患户数:{{ $parent.$parent.countDefects }}</span>-->
                    <!--</div>-->
                  <!--</div>-->
                <!--</div>-->
              <!--</div>-->
            <!--</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 col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">小区名称</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_residential_area }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">街&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;道</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_street }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;栋</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_building }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;元</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_unit }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">楼&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;层</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_floor }}</p>
                </div>
                <div class="row col-xs-12 col-sm-6 col-md-6">
                  <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">房&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号</p>
                  <p class="panel-title col-xs-8 col-sm-8 col-md-8 text-left input-font">{{ row.f_room }}</p>
                </div>
                <!--<div class="row col-xs-12 col-sm-12 col-md-6 text-right">-->
                  <!--<button type="button" class="btn yybtn-color" v-on:click.stop.prevent='$parent.$parent.$parent.deletePlan(row)'>删除</button>&nbsp;-->
                <!--</div>-->
              </div>
            </div>
          </div>
        </div>
      </list>
    </criteria-paged>
    <back-page :need-back='true'  @flag="$back()"></back-page>
  </div>
</template>

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

  export default {
    title: '本地小区楼栋信息',
    props:['item'],
    data() {
      return {
        model:Vue.android? new LocalPagedList('getLocalArea',20,{condition:'this.condition'}): new PagedList( 'AndroidRest/rs/sql/getLocalArea',20,{condition:"cpi.f_no_checkplan not like '%跟进单%' "}),
        showModal: false,
        param: null,
      }
    },
    ready(){
      console.log('进入地址详情页面')
      // this.startTime = Util.toStandardDateString()+' 00:00:00'
      // this.endTime = Util.toStandardDateString()+' 23:59:59'
      // this.$resetpost('rs/logic/getDownPlanName',{data:{}}).then((res)=>{
      //   this.CollectTodayPapers()
      //   console.log('计划名称'+JSON.stringify(res.data))
      //   if(res.data.code == 200 ){
      //     if(res.data.data.length > 0){
      //       for (let i in res.data.data){
      //         let val = {
      //           label:res.data.data[i].f_plan_name,
      //           value:res.data.data[i].f_plan_name
      //         }
      //         console.log('val',val)
      //         this.planNames.push(val)
      //         console.log('this.planNames',this.planNames)
      //       }
      //     }
      //   }
      // })
      // let res = this.$androidUtil.bzLogic('getDownPlanName',{condition:" cpi.f_no_checkplan != '跟进单' and cpi.f_no_checkplan !='无计划安检'"})
      // console.log('计划名称'+JSON.stringify(res))
      // if(res.code == 200 ){
      //   if(res.data.length > 0){
      //     for (let i in res.data){
      //       let val = {
      //               label:res.data[i].f_plan_name,
      //               value:res.data[i].f_plan_name
      //       }
      //       this.planNames.push(val)
      //     }
      //   }
      // }
      // this.CollectTodayPapers()
    },
    methods: {
      reload(){
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
        // this.CollectTodayPapers()
      },
      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)
      },
      deletePlan(row){
        this.$showMessage('确认删除该户地址信息？', ['confirm', 'cancel']).then((res)=>{
          if(res == 'confirm'){
            HostApp.__this__ = this
            this.logicWithHint('DeleteLocalAreaInfo', {
              id: row.id
            }, 'javascript:HostApp.__this__.deleteAreaCallBack()', 1)
          }
        })
      },
      deleteAreaCallBack(jo){
        if (jo.state == 'ok') {
          let result = JSON.parse(jo.result)
          if (result.code === 200) {
            this.$showMessage(`删除成功！`)
          } else {
            this.$showMessage('删除失败！')
          }
        } else {
          this.$showMessage('服务器内部错误,删除失败！')
        }
      },
      logicWithHint(logic, data, callback, backresult) {
        HostApp.logicWithHint({
          // logic别名，key必须为logic
          'logic': logic,
          // 回调执行方法名，key必须为callback
          'callback': callback,
          // logic执行需要的业务参数
          'data': data,
          // 固定key，代表是否将logic执行结果作为参数传入回调方法，1代表true，0代表false，
          // 执行回调方法传入key为backresult
          // 如需额外拼接参数，写在logic返回值的params，例如xxlogic返回:{"params": "success"}
          'backresult': backresult
        })
      },
      selfSearch () {
        let condition = ""
        if(this.$refs.paged.$refs.cri.model.f_residential_area)
          condition += " and f_residential_area like '%"+this.$refs.paged.$refs.cri.model.f_residential_area+"%'"
        if(this.$refs.paged.$refs.cri.model.f_building)
          condition += " and f_building = '"+this.$refs.paged.$refs.cri.model.f_building+"'"
        if(this.$refs.paged.$refs.cri.model.f_unit)
          condition += " and f_unit = '"+this.$refs.paged.$refs.cri.model.f_unit+"'"
        if(this.$refs.paged.$refs.cri.model.f_floor)
          condition += " and f_floor = '"+this.$refs.paged.$refs.cri.model.f_floor+"'"
        if(this.$refs.paged.$refs.cri.model.f_room)
          condition += " and f_room = '"+this.$refs.paged.$refs.cri.model.f_room+"'"
          this.model.search("f_area_id = '"+this.item.id+"'" + condition)
      },
    },
    watch:{
      // '$refs.paged.$refs.cri.model'(val){
      //   console.log('当前计划名称'+val)
      //   this.CollectTodayPapers()
      // }
    }
  }
</script>
