import {Component} from '@angular/core';
import {IonicPage, ModalController, NavController, NavParams} from 'ionic-angular';
import {SearchPersonComponent} from "../../../components/search-person/search-person";
import {ContactListPage} from "../contact-list/contact-list";
import * as Mock from "mockjs"
import {HomeService} from "../home.service";

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

    organizationList = []; //组织列表
    constructor(public navCtrl: NavController, public navParams: NavParams,
                private ModalCtrl: ModalController, private homeSer: HomeService) {
    }

    ionViewDidLoad() {
        this.getOrgList();
    }

    getOrgList() {
        const data = {
            page:1,
            limit:10
        }
        this.homeSer.getOrgList(data).subscribe(
            (res) => {
                this.organizationList = res.list.user;
            }
        )
    }

    //跳转页面
    goTo(page) {
        this.navCtrl.push(page);
    }

    //人员列表
    goToList(org) {
        this.navCtrl.push(ContactListPage, {org: org});
    }

    //查询人员
    search() {
        let modal = this.ModalCtrl.create(SearchPersonComponent, {
            enterAnimation: 'modal-scale-enter',
            leaveAnimation: 'modal-scale-leave'
        });
        modal.onDidDismiss(data => {
            if (data) {
            }
        });
        modal.present();
    }

}
