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";
import {LoginService} from "../../login/login.service";
import {ContactRolePage} from "../contact-role/contact-role";

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

    organizationList = []; //组织列表
    areaList;

    constructor(public navCtrl: NavController, public navParams: NavParams,
                private loginSer: LoginService,
                private ModalCtrl: ModalController, private homeSer: HomeService) {
    }

    ionViewDidLoad() {
        this.getArea();
    }

    //获取区属
    getArea() {
        const data = {};
        this.loginSer.getArea(data).subscribe(
            (res) => {
                if (res.list) {
                    this.areaList = res.list;
                    this.areaList.map(x => { if(x.code == '310000') x.role = 4 })
                }
            }
        )
    }

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

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

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

}
