import { Component, OnInit, ViewChild, Input, ElementRef } from '@angular/core'; // import { NotifyService, NotifyOptions, BsModalService } from '@farris/ui-notify'; import { NotifyService, NotifyOptions } from '@farris/ui-notify'; @Component({ selector: 'app-notify-demo', templateUrl: './notify-demo.component.html', styleUrls: ['./notify-demo.component.scss'] }) export class NotifyDemoComponent implements OnInit { codePath = { baseDemo: 'assets/codes/notify/basedemo' }; state = false; timer = 300000; private notifies = { 1: { type: 'default', msg: '您有新的消息请注意查收。' }, 2: { type: 'info', msg: '您的报销申请提交审批成功,请留意短信。' }, 3: { type: 'success', msg: '单据审核撤消成功!' }, 4: { type: 'error', msg: 'ID 重复,请检查!' }, 5: { type: 'warning', msg: '系统中已存在当前记录' }, }; @ViewChild('pos') pos: ElementRef; constructor(private notifyService: NotifyService) { } ngOnInit() { this.notifyService.config.position = this.pos.nativeElement.value; // this.notifyService.config.left = 20; // this.notifyService.config.right = 21; // this.notifyService.config.top = 30; // this.notifyService.config.bottom = 31; } changePosition(pos) { this.notifyService.config.position = pos; } show(notifyType: string) { this.notifyService[this.notifies[notifyType].type]({ msg: this.notifies[notifyType].msg }); } showNoTitle(notifyType: string) { this.notifyService[this.notifies[notifyType].type]({ msg: this.notifies[notifyType].msg, timeout: this.timer }); } showMessage(t: string) { this.notifyService[this.notifies[t].type]( this.notifies[t].msg ); } showBtn() { this.notifyService.warning({ id: 'notifyWithBtn', type: 'warning', timeout: 0, msg: '普通没有标题的消息:掌控你们脖颈上的绳', buttons: [ { 'text': '转跳链接', 'handle': (ev: Event, cmp: any) => { ev.stopPropagation(); window.open('https://www.baidu.com'); cmp.state = true; } }, { 'text': '我知道了', 'handle': (ev, cmp) => { ev.stopPropagation(); cmp.state = true; } } ] }) } clearBtn(id) { if (id) { this.notifyService.clear(id); } else { this.notifyService.clearAll(); } } }