<template>
  <div class="auto">
    <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-12 col-md-6 app-row">
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">计划名称：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8" >
                    <input id="f_plan_name" class="search_input input-font"
                           v-model="model.f_plan_name" condition="f_plan_name like '%{}%'" />
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">计划类型：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8">
                    <v-select id="f_entry"
                              placeholder='计划类型'
                              :value.sync="model.f_plan_type"
                              :value-single="true"
                              :options='$parent.$parent.types'
                              v-model="model.f_plan_type"
                              condition="f_plan_type = '{}'"
                              close-on-select clear-button> </v-select>
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">下发起始：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8">
                    <datepicker placeholder="起始日期"
                                :value.sync="model.f_start"
                                v-model="model.f_start"
                                :disabled-days-of-Week="[]"
                                :format="'yyyy-MM-dd'"
                                condition="f_issue_time > '{} 00:00:00'"
                                :show-reset-button="false">
                    </datepicker>
                </div>
                </div>
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">下发截至：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8">
                    <datepicker placeholder="截至日期"
                                :value.sync="model.f_end"
                                v-model="model.f_end"
                                :disabled-days-of-Week="[]"
                                :format="'yyyy-MM-dd'"
                                condition="f_issue_time < '{} 23:59:59'"
                                :show-reset-button="false">
                    </datepicker>
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">运行区域：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8" >
                    <div class="col-xs-8 col-sm-8">
                      <v-select id="f_entry"
                                placeholder='运行区域'
                                :value.sync="model.f_opera_area"
                                :value-single="true"
                                :options='$parent.$parent.opera_areas'
                                v-model="model.f_opera_area"
                                condition="f_opera_area = '{}'"
                                close-on-select clear-button> </v-select>
                    </div>
                    <!--<input id="f_plan_name" class="search_input input-font"-->
                           <!--v-model="model.f_opera_area" condition="f_opera_area like '%{}%'" />-->
                  </div>
                </div>
                <div class="row col-xs-12 col-sm-6">
                  <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_plan_name" class="font text-left">隐患类型：</label>
                  </div>
                  <div class="col-xs-8 col-sm-8">
                    <v-select id="f_entry"
                              placeholder='隐患类型'
                              :value.sync="model.worhercontent"
                              :value-single="true"
                              :options='$parent.$parent.worhercontents'
                              v-model="model.worhercontent"
                              condition="cpii.worhercontent like '%{}%'"
                              close-on-select clear-button> </v-select>
                  </div>
                </div>

              </div>
              <div class="row app-row">
              </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="search()">查询</button>
              </div>
              <!--<div class="row col-xs-12 col-sm-12 col-md-6 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 col-xs-12 col-sm-12 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 text-left input-font">{{ row.f_plan_name }}</p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 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 text-left input-font">{{ row.f_plan_year }}/{{row.f_plan_month}}</p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 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 text-left input-font">{{ row.f_plan_type }}</p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 col-md-6" v-if="row.f_plan_type == '预约安检计划' || row.f_plan_type == '预约开户计划'">
                    <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">联系电话</p>
                    <p class="panel-title col-xs-8 text-left input-font" style="color: red"><strong>{{ row.f_user_phone }}</strong></p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 col-md-6" v-if="row.f_plan_type == '预约安检计划' || row.f_plan_type == '预约开户计划'">
                    <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">执行区域</p>
                    <p class="panel-title col-xs-8 text-left input-font" style="color: red"><strong>{{ row.f_opera_area }}</strong></p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 col-md-6" v-if="row.f_plan_type == '预约安检计划' || row.f_plan_type == '预约开户计划'">
                    <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">隐患类型</p>
                    <p class="panel-title col-xs-8 text-left input-font" style="color: red"><strong>{{ row.worhercontent }}</strong></p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 col-md-6" v-if="row.f_plan_type == '预约安检计划' || row.f_plan_type == '预约开户计划'">
                    <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">备&nbsp;&nbsp;&nbsp;&nbsp;注</p>
                    <p class="panel-title col-xs-8 text-left input-font" style="color: red"><strong>{{ row.f_remarks }}</strong></p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 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 text-left input-font">{{ row.item_counts }}</p>
                </div>
                  <div class="row col-xs-12 col-sm-12 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 text-left input-font">{{ row.f_issue_time }}</p>
                  </div>
                  <div class="row col-xs-12 col-sm-12 col-md-6" v-if="row.f_plan_type == '预约安检计划' || row.f_plan_type == '预约开户计划'">
                    <p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">是否下载</p>
                    <p class="panel-title col-xs-8 text-left input-font" style="color: red"><strong>{{ row.f_has_down }}</strong></p>
                  </div>
                  <!--<div class="row">-->
                    <!--<p class="panel-title col-xs-4 col-sm-4 col-md-4 text-left font">下发人员</p>-->
                    <!--<p class="panel-title col-xs-8 text-left input-font">{{ row.f_send_operator }}/{{row.f_plan_month}}</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.downHand(row)' v-if="$parent.$parent.$parent.isDown(row)">下载</button>&nbsp;
                    <button type="button" class="btn yybtn-color" v-on:click.stop.prevent='$parent.$parent.$parent.addPlanItem(row)' v-if="!$parent.$parent.$parent.isDown(row) && row.f_plan_type == '集中安检'">新增</button>&nbsp;
                    <button type="button" class="btn yybtn-color" v-on:click.stop.prevent='$parent.$parent.$parent.deletePlan(row)' v-if="!$parent.$parent.$parent.isDown(row)">删除</button>&nbsp;
                  </div>
                </div>
              </div>

            </div>
          </div>
        </list>
      </criteria-paged>
    </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="downHand()">共享计划下载</button>-->
      <!--&lt;!&ndash;<button type="button" class="btn btn-lg btn-font btn-color" style="width: 45%;" @click="database()">数据库导出</button>&ndash;&gt;-->
    <!--</div>-->
    <!-- <div class="auto" style="padding-top: 20px;" v-if='show'>
      <p class="text-warning" style="padding: 0 10px">正在下载抄表单...</p>
    </div> -->
    <!-- <hand-info v-if="show" :data="handinfo"></hand-info> -->
    <!-- <div class="auto" v-if="!show">
      <p class="text-warning" style="padding: 0 10px">
        暂无可操作的抄表信息
      </p>
    </div> -->
  </div>
  <modal :show.sync="showAddPlan" v-ref:modal :backdrop="isBack">
    <div slot="modal-header" class="modal-header">
      <span class="modal-title font">
        新增设备信息
      </span>
    </div>
    <div slot="modal-body" class="modal-body">
      <div style="width: 95%;margin: auto">
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">街道</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_street" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">小区</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_residential_area" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">起始楼号</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_start_building" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">截止楼号</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_end_building" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">起始单元</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_start_unit" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">截止单元</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_end_unit" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">起始楼层</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_start_floor" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">截止楼层</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_end_floor" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">起始房号</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_start_room" >
          </div>
        </div>
        <div class="row"  style="margin-top: 6px" >
          <label class="col-xs-4 control-label font text-left">截止房号</label>
          <div class="col-xs-8">
            <input type="text"  class="form-control" maxlength="100" v-model="addPlan.f_end_room" >
          </div>
        </div>
      </div>
    </div>
    <div slot="modal-footer" class="modal-footer">
      <button type="button" class="btn btn-cancel" @click="cancel()">取消</button>
      <button type="button" class="btn btn-save" @click="save()">确定</button>
    </div>
  </modal>

  <back-page :need-back='true'  @flag="$back()"></back-page>
</template>
<script>
  import AppData from '../../stores/AppData'
  import { PagedList } from 'vue-client'
  import * as Util from '../Util'
  import co from 'co'
  import Vue from 'vue'
  const downloadHand = function * (self, row) {
    let res = yield self.$showMessage('正在进行安检计划下载，请确认！', ['confirm', 'cancel'])
    let flag = false
    if (res === 'confirm') {
      flag = true
    }
    if (flag) {
      HostApp.__this__ = self
      self.logicWithHint('DownCheckPlanInfo', {
        id: row.id,
        checker:Vue.user.name,
        f_plan_type:row.f_plan_type
      }, 'javascript:HostApp.__this__.downloadCallBack()', 1)
      //安卓端
      //PC端模拟安卓
      // if (result.data.state === 0) {
      //   console.log(result.data.data)
      //   if (result.data.data.length > 0) {
      //     self.handcount = result.data.data.length
      //     self.handinfo = [...result.data.data]
      //     self.$showMessage(`下载成功`)
      //     self.reload()
      //   } else {
      //     self.$showMessage('无可下载的共享计划！')
      //   }
      // } else {
      //   self.$showMessage('下载失败！')
      // }
    }
  }

  export default {
    title: '计划下载',
    data () {
      return {
        model: new PagedList( `${this.$androidUtil.getProxyUrl()}/rs/sql/getSafecheckShareCheckPlan`,20,{f_fengongsi:`'${Vue.user.f_fengongsi}'`}),
        checkPlanInfo: [],
        localcheckPlanInfo:[],
        types:[
          {label: '全部', value: ''},
          {label: '集中安检', value: '集中安检'},
          {label: '抄表', value: '抄表'},
          {label: '点火通气计划', value: '点火通气计划'},
          {label: '预约安检计划', value: '预约安检计划'},
          {label: '预约开户计划', value: '预约开户计划'},
          {label: '一级隐患跟进计划', value: '一级隐患跟进计划'},
          {label: '重点用户跟进计划', value: '重点用户跟进计划'},
          {label: '隐患跟进计划', value: '隐患跟进计划'},
          {label: '偷盗气用户跟进计划', value: '偷盗气用户跟进计划'},
          {label: '临街商铺安检计划', value: '临街商铺安检计划'},
          {label: '大锅灶安检计划', value: '大锅灶安检计划'},
          {label: '隐患用户查询跟进', value: '隐患用户查询跟进'},
          {label: '重点用户查询跟进', value: '重点用户查询跟进'},
        ],
        opera_areas: [
          {label: '全部', value: ''},
          {label: '航天', value: '航天'},
          {label: '韦曲', value: '韦曲'},
          {label: '高新', value: '高新'},
          {label: '沣东', value: '沣东'},
          {label: '中心站', value: '中心站'}
        ],
        addPlan:{
          f_start_building:'',
          f_end_building:'',
          f_street:'',
          f_residential_area:'',
          f_start_unit:'',
          f_end_unit:'',
          f_start_floor:'',
          f_end_floor:'',
          f_start_room:'',
          f_end_room:''
        },
        f_plan_type:'',
        worhercontents:[
          {label: '全部', value: ''}, {label: '安检复查', value: '安检复查'}, {label: '强检', value: '强检'}, {label: '验收解卡', value: '验收解卡'},{label: '强检关阀', value: '强检关阀'},
          {label: '过户', value: '过户'}, {label: '预约安检', value: '预约安检'},{label: '预约安检（长期未检）', value: '预约安检（长期未检）'}, {label: '查看锅炉', value: '查看锅炉'},{label: 'ERR-4',value: 'ERR-4'},{label:'换表',value: '换表'},{label:'无气--验收解卡', value: '无气--验收解卡'},
          {label: '老旧改单户安装', value: '老旧改单户安装'},{label: '其他', value: '其他'}
        ],
        addPlans:[],
        showAddPlan:false,
        row:''
      }
    },
    ready () {
      // Vue.user.f_fengongsi = '中海油.海南分公司'
      this.getlocalCheckPlan()
    },
    methods: {
      // search(arg){
      //   console.log('arg',arg)
      //   console.log('this.$refs.paged.$refs.cri',this.$refs.paged.$refs.cri.condition)
      //   // this.model.f_plan_type = this.$refs.paged.$refs.cri.model.f_plan_type
      //   // this.f_plan_type = this.$refs.paged.$refs.cri.model.f_plan_type
      //   this.model.search(arg.condition)
      // },
      reload(){
        console.log('页面刷新 ')
        this.$refs.paged.loadPage(this.$refs.paged.model.pageIndex)
      },
      getlocalCheckPlan(){
        let value = this.$androidUtil.path({alias: 'getLocalCheckPlan', data:{}})
        console.log(value)
        this.localcheckPlanInfo = value.data
        // this.$androidUtil.path({alias: 'getLocalCheckPlan', data:{}}).then((value)=>{
        //   console.log(value)
        //   this.localcheckPlanInfo = value.data
        // })
      },
      downHand (row) {
        // TODO: 先检查网络情况
        // this.show = true
        // this.$showAlert('正在下载抄表单,请勿操作！', 'success', 1000)
        const fun = downloadHand(this, row)
        co(fun)
      },
      addPlanItem (row) {
        this.showAddPlan = true
        this.row = row
      },
      save(){
        //TODO 详细地址拼接出现undefined
        console.log('isNaN(this.addPlan.f_end_building)==>'+isNaN(this.addPlan.f_end_building))
        console.log('isNaN(this.addPlan.f_start_building)==>'+isNaN(this.addPlan.f_start_building))
        if(isNaN(this.addPlan.f_end_building) && isNaN(this.addPlan.f_start_building)){
          console.log('isNaN(this.addPlan.f_end_unit)==>'+isNaN(this.addPlan.f_end_unit))
          console.log('isNaN(this.addPlan.f_start_unit)==>'+isNaN(this.addPlan.f_start_unit))
          if(isNaN(this.addPlan.f_end_unit) && isNaN(this.addPlan.f_start_unit)){
            console.log('Number(this.addPlan.f_end_floor)==>'+Number(this.addPlan.f_end_floor))
            console.log('Number(this.addPlan.f_start_floor)==>'+Number(this.addPlan.f_start_floor))
            console.log('(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor))==>'+(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)))
            for (let k=0; k<(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)+1);k++){
              for (let h=0; h<(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room)+1);h++){
                this.addPlans.push({
                  f_card_id:0,
                  id:Util.guid(),
                  f_user_type:'民用',
                  f_building:this.addPlan.f_start_building,
                  f_unit:this.addPlan.f_start_unit,
                  f_floor:Number(this.addPlan.f_start_floor)+k,
                  f_room:Number(this.addPlan.f_start_room)+h,
                  f_plan_id: this.row.id,
                  f_residential_area:this.addPlan.f_residential_area,
                  f_street:this.addPlan.f_street,
                  f_state:'未检',
                  f_upload_state:'未传',
                  f_approved:'未审核',
                  f_no_checkplan:'集中安检单',
                  f_create_time:Util.toStandardTimeString(),
                  f_address:`${this.f_street?this.f_street:''}${this.f_residential_area?this.f_residential_area:''}${this.addPlan.f_start_building?this.addPlan.f_start_building+'栋':''}${this.addPlan.f_start_unit?this.addPlan.f_start_unit+'单元':''}${Number(this.addPlan.f_start_floor)+k}楼${Number(this.addPlan.f_start_room)+h}室`,
                  version:1
                })
              }
            }
          }else{
            console.log('unit是数字')
            console.log('Number(this.addPlan.f_start_unit)==>'+Number(this.addPlan.f_start_unit))
            console.log('Number(this.addPlan.f_end_unit)==>'+Number(this.addPlan.f_end_unit))
            console.log('(Number(this.addPlan.f_end_unit)-Number(this.addPlan.f_start_unit))==>'+(Number(this.addPlan.f_end_unit)-Number(this.addPlan.f_start_unit)))
            console.log('Number(this.addPlan.f_end_floor)==>'+Number(this.addPlan.f_end_floor))
            console.log('Number(this.addPlan.f_start_floor)==>'+Number(this.addPlan.f_start_floor))
            console.log('(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor))==>'+(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)))
            console.log('Number(this.addPlan.f_end_room)==>'+Number(this.addPlan.f_end_room))
            console.log('Number(this.addPlan.f_start_room)==>'+Number(this.addPlan.f_start_room))
            console.log('(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room))==>'+(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room)))
            for (let j=0; j<(Number(this.addPlan.f_end_unit)-Number(this.addPlan.f_start_unit)+1);j++){
              console.log('jjjjj==>'+j)
              for (let k=0; k<(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)+1);k++){
                console.log('kkkk==>'+k)
                for (let h=0; h<(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room)+1);h++){
                  console.log('hhhhh==>'+h)
                  this.addPlans.push({
                    f_card_id:0,
                    id:Util.guid(),
                    f_user_type:'民用',
                    f_building:this.addPlan.f_start_building,
                    f_unit:Number(this.addPlan.f_start_unit)+j,
                    f_floor:Number(this.addPlan.f_start_floor)+k,
                    f_room:Number(this.addPlan.f_start_room)+h,
                    f_plan_id: this.row.id,
                    f_residential_area:this.addPlan.f_residential_area,
                    f_street:this.addPlan.f_street,
                    f_state:'未检',
                    f_upload_state:'未传',
                    f_approved:'未审核',
                    f_no_checkplan:'集中安检单',
                    f_create_time:Util.toStandardTimeString(),
                    f_address:`${this.f_street?this.f_street:''}${this.f_residential_area?this.f_residential_area:''}${this.addPlan.f_start_building?this.addPlan.f_start_building+'栋':''}${Number(this.addPlan.f_start_unit)+j}单元${Number(this.addPlan.f_start_floor)+k}楼${Number(this.addPlan.f_start_room)+h}室`,
                    version:1,
                  })
                }
              }
            }
          }
        }else{
          console.log('Number(this.addPlan.f_end_building)==>'+Number(this.addPlan.f_end_building))
          console.log('Number(this.addPlan.f_start_building)==>'+Number(this.addPlan.f_start_building))
          console.log('(Number(this.addPlan.f_end_building)-Number(this.addPlan.f_start_building))==>'+(Number(this.addPlan.f_end_building)-Number(this.addPlan.f_start_building)))
          for (let i=0;i< (Number(this.addPlan.f_end_building)-Number(this.addPlan.f_start_building)+1);i++ ){
            if(isNaN(this.addPlan.f_end_unit) && isNaN(this.addPlan.f_start_unit)){
              for (let k=0; k<(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)+1);k++){
                for (let h=0; h<(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room)+1);h++){
                  this.addPlans.push({
                    f_card_id:0,
                    id:Util.guid(),
                    f_user_type:'民用',
                    f_building:Number(this.addPlan.f_start_building)+i,
                    f_unit:this.addPlan.f_start_unit,
                    f_floor:Number(this.addPlan.f_start_floor)+k,
                    f_room:Number(this.addPlan.f_start_room)+h,
                    f_plan_id: this.row.id,
                    f_residential_area:this.addPlan.f_residential_area,
                    f_street:this.addPlan.f_street,
                    f_state:'未检',
                    f_upload_state:'未传',
                    f_approved:'未审核',
                    f_no_checkplan:'集中安检单',
                    f_create_time:Util.toStandardTimeString(),
                    f_address:`${this.f_street?this.f_street:''}${this.f_residential_area?this.f_residential_area:''}${Number(this.addPlan.f_start_building)+i}栋${this.addPlan.f_unit?this.addPlan.f_unit+'单元':''}${Number(this.addPlan.f_start_floor)+k}楼${Number(this.addPlan.f_start_room)+h}室`,
                    version:1
                  })
                }
              }
            }else{
              for (let j=0; j<(Number(this.addPlan.f_end_unit)-Number(this.addPlan.f_start_unit)+1);j++){
                for (let k=0; k<(Number(this.addPlan.f_end_floor)-Number(this.addPlan.f_start_floor)+1);k++){
                  for (let h=0; h<(Number(this.addPlan.f_end_room)-Number(this.addPlan.f_start_room)+1);h++){
                    this.addPlans.push({
                      f_card_id:0,
                      id:Util.guid(),
                      f_user_type:'民用',
                      f_building:this.addPlan.f_start_building,
                      f_unit:Number(this.addPlan.f_start_unit)+j,
                      f_floor:Number(this.addPlan.f_start_floor)+k,
                      f_room:Number(this.addPlan.f_start_room)+h,
                      f_plan_id: this.row.id,
                      f_residential_area:this.addPlan.f_residential_area,
                      f_street:this.addPlan.f_street,
                      f_state:'未检',
                      f_upload_state:'未传',
                      f_approved:'未审核',
                      f_no_checkplan:'集中安检单',
                      f_create_time:Util.toStandardTimeString(),
                      f_address:`${this.f_street?this.f_street:''}${this.f_residential_area?this.f_residential_area:''}${Number(this.addPlan.f_start_building)}栋${Number(this.addPlan.f_start_unit)+j}单元${Number(this.addPlan.f_start_floor)+k}楼${Number(this.addPlan.f_start_room)+h}室`,
                      version:1
                    })
                  }
                }
              }
            }
          }
        }
        console.log('this.addPlans===>'+JSON.stringify(this.addPlans))
        HostApp.__this__ = this
        this.logicWithHint('AddCheckPlanInfo', {
          addPlans:this.addPlans
        }, 'javascript:HostApp.__this__.AddPlanCallBack()', 1)
      },
      cancel(){
        this.row = ''
        this.showAddPlan = false
        this.addPlans = []
      },
      deletePlan (row) {
        this.$showMessage('确认删除该计划？', ['confirm', 'cancel']).then((res)=>{
          if(res == 'confirm'){
            HostApp.__this__ = this
            this.logicWithHint('DeleteCheckPlanInfo', {
              id: row.id
            }, 'javascript:HostApp.__this__.deletePlanCallBack()', 1)
          }
        })
      },
      downloadCallBack(jo){
        console.log(jo)
        if (jo.state == 'ok') {
          let result = JSON.parse(jo.result)
          if (result.state === 0) {
            if (result.data.pcServices.length > 0) {
              this.getlocalCheckPlan()
              this.$showMessage(`下载成功，您可前往计划导航进行查看！`)
            } else {
              this.$showMessage('无可下载的共享计划！')
            }
          } else {
            this.$showMessage('下载失败！')
          }
        } else {
          this.$showMessage('服务器内部错误,下载失败！')
        }
      },
      deletePlanCallBack(jo){
        if (jo.state == 'ok') {
          let result = JSON.parse(jo.result)
          if (result.code === 200) {
            this.getlocalCheckPlan()
            this.$showMessage(`删除成功！`)
          } else {
            this.$showMessage('删除失败！')
          }
        } else {
          this.$showMessage('服务器内部错误,删除失败！')
        }
      },
      AddPlanCallBack(jo){
        if (jo.state == 'ok') {
          let result = JSON.parse(jo.result)
          if (result.code === 200) {
            this.cancel()
            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
        })
      },
    },
    computed:{
      isDown(){
        return function (row) {
          for (let info of this.localcheckPlanInfo) {
            if(info.id == row.id){
              return false
            }
          }
          return true
        }
      },
      // worhercontents(){
      //   console.log('AppData.getParam(\'安检隐患\')=====>'+JSON.stringify(AppData.getParam('安检隐患')))
      //   return AppData.getParam('安检隐患')
      // },
    }
  }
</script>
<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>
