import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';

@Component({
    selector: 'page-person-info',
    templateUrl: 'person-info.html',
})
export class PersonInfoPage {

    title;
    personInfo;
    list = {
        age_segment: {},
        postLevel: {},
        postLevel_Leader: {},
        workage_segment: {},
    }

    constructor(public navCtrl: NavController, public navParams: NavParams) {
        this.personInfo = this.navParams.get('item');
        this.title = this.navParams.get('title');
        this.personInfo.postLevel.forEach(e => {
            this.list.postLevel[e.POSTLEVEL_CN] = e.NUM;
        })
        this.personInfo.postLevel_Leader.forEach(e => {
            this.list.postLevel_Leader[e.POSTLEVEL_LEADER_CN] = e.NUM;
        })
        this.personInfo.age_segment.forEach(e => {
            this.list.age_segment[`${e.EDUCATION_CN}_${e.AGE_SEGMENT_CN}`] = e.NUM;
            console.log(JSON.stringify(this.list.age_segment))
        })
        this.personInfo.workage_segment.forEach(e => {
            this.list.workage_segment[`${e.EDUCATION_CN}_${e.WORKAGE_SEGMENT_CN}`] = e.NUM;
        })
        console.log(this.list);
    }

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

}
