import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams} from 'ionic-angular';
import { Response } from '@angular/http';
import { Storage } from '@ionic/storage';
import { AppService, AppGlobal } from '../../../service/appHttpService';


@IonicPage()
@Component({
  selector: 'page-outGoingReportView',
  templateUrl: 'outGoingReportView.html',
})
export class OutGoingReportViewPage {

  //报备
  premanager;

  dategap:string = "";

  //个人报备详情
  userpre;

  picture: string;

  //离沪地点显示
  locations : string;

  //离沪说明
  detailsdesc : string;

   //详细说明展示
   isCover: boolean = false;
   //具体介绍
   hidden() {
     this.isCover = false;
   }
   show() {
     this.isCover = true;
   }

   isleaveFlag = false;

   //是否 截止未报备
   isNotSignAndHasOverTime :boolean =  false;

  constructor(
    public navCtrl: NavController,
    public navParams: NavParams,
    public appService: AppService,
    public storage: Storage
  ) {
    this.premanager = this.navParams.get("premanager");
    //加载报备的图片
    this.picture = AppGlobal.picture +  this.premanager["uploadPic"];
    //是否未报备已截止
    if(!this.premanager["reported"] && this.premanager["isOverTimeFlag"]){
      this.isNotSignAndHasOverTime = true;
    }

    //this.appService.alert(this.isNotSignAndHasOverTime);    

     //编辑初始化：查询
     if(this.premanager!=null ){
        if(this.premanager["reported"]){
          this.appService.ObserverHttpPost("/wisdomgroup/modules/userpre/getUserpre",{premanagerId:this.premanager.id.toString()})
                  .subscribe((res: Response) => {
                    let resultback = res.json();
                    this.locations = "";
                    for (let index = 0; index < resultback.areaList.length; index++) {
                      const element = resultback.areaList[index];         
                      this.locations +=  element["areaName"]+",";          
                    }
                    this.locations = this.locations.substring(0,this.locations.lastIndexOf(","));
                    this.dategap = resultback.formshTime+"~"+resultback.comeshTime;
                    this.detailsdesc = resultback.userpreDesc;
                    if(resultback.isorFromsh == 1){     
                      this.isleaveFlag  = true;
                    }

                  }, error => {        
                    this.appService.alert('网络异常！');    
                }   
            );
          }
      }
    }

  ionViewDidLoad() {
    console.log('ionViewDidLoad OutGoingReportViewPage');
  }
}
