import {Component} from '@angular/core';
import {NavParams, ViewController} from "ionic-angular";

@Component({
    selector: 'filter',
    templateUrl: 'filter.html'
})
export class FilterComponent {

    text: string;
    approvaList = [
        {name: "全部", type: "0"},
        {name: "事业单位", type: "1"},
        {name: "机关群团", type: "2"},
        {name: "其他", type: "3"},
    ];
    approvalObj;


    areaObj;
    areaList = [
        {name: "市属", code: "310000"},
        {name: "静安区", code: "310106"},
        {name: "徐汇区", code: "310104"},
        {name: "宝山区", code: "310113"},
        {name: "虹口区", code: "310109"},
        {name: "闵行区", code: "310112"},
        {name: "崇明区", code: "310230"},
        {name: "长宁区", code: "310105"},
        {name: "普陀区", code: "310107"},
        {name: "松江区", code: "310117"},
        {name: "浦东新区", code: "310115"},
        {name: "黄浦区", code: "310101"},
        {name: "杨浦区", code: "310110"},
        {name: "嘉定区", code: "310114"},
        {name: "金山区", code: "310116"},
        {name: "奉贤区", code: "310226"},
        {name: "青浦区", code: "310118"},
    ];

    constructor(private viewCtrl: ViewController,private params:NavParams) {
        this.areaObj = this.params.get("areaObj");
        this.approvalObj = this.params.get("approvalObj");
    }

    selectApproval(approval) {
        this.approvalObj = approval;
    }

    //区域选择
    selectArea(area) {
        this.areaObj = area;
    }

    //重置
    reset() {
        this.approvalObj = null;
        this.areaObj = null;
    }

    //确定
    confirm() {
        const data = {
            approval: this.approvalObj,
            area: this.areaObj
        };
        this.viewCtrl.dismiss(data);
    }

}
