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

@IonicPage()
@Component({
    selector: 'page-report-search',
    templateUrl: 'report-search.html',
})
export class ReportSearchPage {

    premanager;
    searchValue = '';
    items;
    id;
    picture: string = AppGlobal.picture;

    constructor(public navCtrl: NavController, public navParams: NavParams,
                public appService: AppService, public storage: Storage) {
    }

    ionViewDidEnter() {
        this.premanager = this.navParams.get('premanager');
        this.id = this.navParams.get('id');
        this.searchUser();
    }

    clearValue() {
        this.searchValue = "";
    }

    searchUser() {
        const data = {
            name: this.searchValue,
            id: this.id
        };
        this.appService.ObserverHttpPostOption('/wisdomgroup/modules/premanager/getUserAboutPre', data).subscribe((res) => {
            this.items = res.json();
        })
    }


    //协助报备
    goReport(item) {

        this.storage.remove("temp_userpre");
        this.storage.remove("managerId");
        this.storage.remove("city");
        this.storage.remove("cityList");
        this.storage.remove("person");

        this.storage.set('premanager', this.premanager);
        this.storage.set('person', item);
        this.navCtrl.push('OutGoingReportEditPage', {premanager: this.premanager});
    }

}
