<template>
  <div class="bg-white "style="overflow: hidden;">
    <div class="top" style="height: 0%">
      <readmeter-top v-if='showTop' :toptext='pageName'></readmeter-top>
    </div>
    <div class="row "style="height: 100%;" >
    <route v-ref:route :reuse="reuse"  name="handplanlist"></route>
    </div>
  </div>
</template>
<script>
  import Vue from 'vue'

  export default {
    title: 'home',
    data () {
      return {
        model: {
          selectstreet:{
            f_userinfo_code: '',
            f_userinfo_id: '',
            f_user_name: '',
            f_address: '',
            f_meternumber: '',
            startDate: '',
            endDate: '',
            name:'',
            returnData: [],
            gasArr: [],
            streetArr:[],
            pointArr: [],
            handinfo: [],
            show: false,
            f_street: '',
            f_gas_area: '',
            f_point_name: '',
            gasArr: [],
            pointArr: [],
            handcount: 0,
            f_point_name: ''
          },
          selectuser:{},
          f_userinfo_code: '',
          f_userinfo_id: '',
          f_user_name: '',
          f_address: '',
          f_meternumber: '',
          startDate: '',
          endDate: ''
        },
        reuse:true,
        pageName: '',
        name:'',
        showback: 'false',
        nowPage: 'home-page',
        showTop: false
      }
    },
    events: {
      'menu' (param) {
        this.showTop = true
        this.pageName = param
        if (param === '计划下载') {
          this.name = 'plan-down'
          this.reuse = true
          this.$refs.route.init(this.name)
        }else if (param === '临时周检') {
          this.name = 'check-online'
          this.reuse = true
          this.$refs.route.init(this.name)
        } else if (param === '表单上传') {
          this.reuse = true
          this.name = 'plan-update'
          this.$refs.route.init(this.name)
        } else if (param === '抄表管理') {
          this.reuse = true
          this.name = 'read-meter'
          this.$refs.route.init('read-meter',{data:this.model.selectstreet})
        } else if (param === '抄表记录') {
          this.reuse = true
          this.name = 'read-meter-info'
          this.$refs.route.init('read-meter-info')
        } else {
          this.reuse = true
          this.showTop = false
          this.name = 'home'
          this.$refs.route.init('home')
        }
      },
      'changepage' (val, param) {
        console.log(val)
        if (param === 'save') {
          window.currentPage = '抄表录入'
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {data: val, type: param})
        }else if (param === 'onlinecheck') {
          //选择用气点
          window.currentPage = '临时周检'
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {param: val, type: param})
        } else if (param === 'selectpoint') {
          //选择用气点
          window.currentPage = '选择用气点'
          this.name = 'read-meter-changan'
          this.$refs.route.init('read-meter-changan', {param: val, type: param})
        } else if (param === 'selectuser') {
          //选择用户
          // window.alert('选择用户')
          window.currentPage = '选择用户'

          console.log('传入的信息'+ JSON.stringify(val))
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {param: val, type: param,show:true})
        }else if (param === 'hadupload') {
          //选择用户
          // console.log('查看用户')
          window.currentPage = '已上传'
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {param: val, type: param,show:false})
        }
        else if (param === 'waitupload') {
          //选择用户
          // console.log('查看用户')
          window.currentPage = '待上传'
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {param: val, type: param,show:false})
        }
        else {
          window.currentPage = undefined
          this.name = 'phone-hand-home'
          this.$refs.route.init('phone-hand-home', {param: val, type: param})
        }
      },
      'returnPage' () {
        console.log('当前页面' + window.currentPage)
        if (window.currentPage && window.currentPage === '抄表录入') {
          this.showTop = true
          this.pageName = '抄表管理'
          window.currentPage = undefined
          this.$refs.route.init('read-meter')
          return
        }
        if (window.currentPage && window.currentPage === '临时周检') {
          this.showTop = true
          this.pageName = '临时周检'
          window.currentPage = undefined
          this.$refs.route.remove('phone-hand-home')
          this.$refs.route.init('check-online')
          return
        }
        if (window.currentPage && window.currentPage === '选择用气点') {
          this.showTop = true
          this.pageName = '选择用气点'
          window.currentPage = undefined
          this.$refs.route.init('read-meter',{data:this.model.selectstreet})

          return
        }
        if (window.currentPage && window.currentPage === '选择用户') {
          this.showTop = true
          this.pageName = '选择用户'
          window.currentPage = '选择用气点'
          this.$refs.route.init('read-meter-changan',{param:this.model.selectstreet})
          this.$refs.route.remove('phone-hand-home')
          return
        }
        if (window.currentPage && window.currentPage === '已上传') {
          this.showTop = true
          this.pageName = '抄表记录查看'
          window.currentPage = ''
          this.$refs.route.init('read-meter-info',{f_meter_state:'已抄表'})
          this.$refs.route.remove('phone-hand-home')
          return
        }
        if (window.currentPage && window.currentPage === '待上传') {
          this.showTop = true
          this.pageName = '抄表记录查看'
          window.currentPage = ''
          this.name = 'read-meter-info'
          this.$refs.route.init('read-meter-info',{f_meter_state:'待上传'})
          this.$refs.route.remove('phone-hand-home')
          return
        }
        // this.$dispatch('hideFullPage')
        this.showTop = false
        this.name = 'readmeter-homepage'
        this.$refs.route.init('readmeter-homepage')
      },
      'hand-success' (type) {
        // this.$dispatch('showFullPage')
        HostApp.alert('抄表成功')
        if (type === 'save') {
          this.name = 'read-meter'
          this.$refs.route.init('read-meter',null)
        } else {
          this.name = 'read-meter-info'
          this.$refs.route.init('read-meter-info',null)
        }
      }
    },
    ready () {
      this.name = 'readmeter-homepage'
      this.$refs.route.init('readmeter-homepage',null)
      this.showTop = false
    }
  }
</script>
<style>
  .have_top {
    padding-top: 60px;
  }
  /*.content{*/

  /*}*/
</style>
