import {Label, Vertical, Left, Button, Layout} from '@ui/index'; class Dialog { /** * 提示 * @param message * @param onConfirm */ public confirm(message: string, onConfirm: Function): string { const id = BI.UUID(); BI.Popovers.create(id, { type: 'bi.bar_popover', size: 'normal', header: BI.i18nText('Dec-Dcm_Tips'), width: 450, height: 220, body: { type: 'bi.left', cls: 'comfirm-content', items: [ { type: 'bi.layout', cls: 'comfirm-icon', width: 50, height: 50, }, { type: 'bi.label', text: message, }, ], }, listeners: [ { eventName: 'EVENT_CONFIRM', action () { onConfirm ? onConfirm(true) : null; }, }, { eventName: 'EVENT_CANCEL', action () { onConfirm ? onConfirm(false) : null; }, }, ], }).open(id); return id; } public loading(message: string): string { const body = { type: 'bi.center_adapt', cls: 'show-content', items: [ { type: Vertical, items:[ { type: 'bi.layout', cls: 'loading-icon', width: 100, height: 100, }, { type: Label, text: message, }, ], }, ], }; return this.show(body); } public success(message: string): string { const body = { type: 'bi.center_adapt', cls: 'show-content', items: [ { type: Vertical, items:[ { type: 'bi.layout', cls: 'success-icon', width: 100, height: 100, }, { type: Label, text: message, }, ], }, ], }; return this.show(body, 1000); } public error(message: string): string { const body = { type: 'bi.center_adapt', cls: 'show-content', items: [ { type: Vertical, items:[ { type: 'bi.layout', cls: 'error-icon', width: 100, height: 100, }, { type: Label, text: message, }, ], }, ], }; return this.show(body, 2000); } public linkFail(text: string, more: string, cb?: Function): string { let Popover: any = null; let More: any = null; const id = BI.UUID(); const that = this; const body = { type: Vertical, items: [ { type: 'bi.center_adapt', cls: 'show-content', tgap:10, items: [ { type: Vertical, items:[ { type: Layout, cls: 'error-icon', width: 100, height: 100, }, { type: Label, text, }, { type: Left, cls:'buttons', items:[ { type: Button, text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'), level: 'ignore', handler() { const isHide = this.getText() === BI.i18nText('Dec-Dcm_Connection_Detailed_Information'); Popover.element.css({ height: isHide ? '290' : '220', }); More.setVisible(isHide); this.setText(isHide ? BI.i18nText('Dec-Dcm_Connection_Handup_Information') : BI.i18nText('Dec-Dcm_Connection_Detailed_Information')); }, }, { type: Button, text: BI.i18nText('Dec-Dcm_Back'), level: 'ignore', handler() { that.close(id); }, }, { type: Button, text: BI.i18nText('Dec-Dcm_Connection_ReConnect'), handler() { that.close(id); cb ? cb() : null; }, }, ], }, ], }, ], }, { type: Label, cls:'show-more', text:more, invisible: true, ref(ref: any) { More = ref; }, }, ], }; BI.Popovers.create(id, { type: 'bi.popover', cls:'popover-notitle', extraCls:'bi-custom-show', size: 'normal', width: 450, height: 220, body, ref(ref: any) { Popover = ref; }, }).open(id); return id; } public close(id: string): void{ BI.Popovers.close(id); } public show(body: any, autoClose = 0): string { const id = BI.UUID(); BI.Popovers.create(id, { type: 'bi.popover', cls:'popover-notitle', extraCls:'bi-custom-show', size: 'normal', width: 450, height: 220, body, }).open(id); if (autoClose > 0) { setTimeout(() => { this.close(id); }, autoClose); } return id; } } export default new Dialog();