import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {ContactDetailPage} from "../contact-detail/contact-detail";
import * as Mock from "mockjs";
import {HomeService} from "../home.service";
import {GlobalData} from "../../../core/GlobleData";

@Component({
    selector: 'page-contact-list',
    templateUrl: 'contact-list.html',
})
export class ContactListPage {

    area;
    page = {
        list: [],
        isLoad: false
    }

    constructor(public navCtrl: NavController, public navParams: NavParams,
                private globle:GlobalData,
                private homeSer: HomeService) {
        this.area = this.navParams.get('area');
    }

    ionViewDidLoad() {
        this.getPersonList();
    }

    //人员列表
    getPersonList() {
        const data = {
            page: 1,
            limit: 1000,
            areacode:this.area.code
        };
        this.homeSer.getOrgList(data).subscribe(
            (res) => {
                this.page.list = res.list.user.filter(e => e.areacode == this.area.code);
                this.page.isLoad = true;
            }
        )
    }

    //人员详情
    goToInfo(person) {
        this.navCtrl.push(ContactDetailPage, {person: person});
    }

}
