import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {NewsService} from "./news.service";
import * as Mock from "mockjs";
import {DealPage} from "../deal/deal";
import {DoSupervisePage} from "../home/do-supervise/do-supervise";
import {DealDetailPage} from "../deal/deal-detail/deal-detail";

@IonicPage()
@Component({
    selector: 'page-news',
    templateUrl: 'news.html',
})
export class NewsPage {
    newList = [];

    constructor(public navCtrl: NavController, public navParams: NavParams,
                private newSer: NewsService) {
    }

    ionViewDidEnter() {
        this.getList();
    }

    getList() {
        const data = {
            page: 1,
            limit: 1000
        };
        this.newSer.noticeSearch(data).subscribe(
            (res) => {
                res.page.list.notice.forEach(e => {
                    e.title = e.type == "1" ? "督办提醒" : "待办提醒";
                });
                this.newList = res.page.list.notice;
            }
        )
    }

    goDetail(item) {
        const data = {
            id: item.scheduleid,
            type: item.unittype == 1 ? "1" : "2",
        };
        this.navCtrl.push(DealDetailPage, {"item": data});
    }

}
