import {Label, Vertical, Button, Layout, CenterAdapt, VerticalAdapt} 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', vgap: 40, hgap: 20, items: [ { type: 'bi.layout', cls: 'dcm-comfirm-icon', width: 50, height: 50, }, { type: 'bi.label', textHeight: 50, lgap: 10, 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: 'bi-card', width: 450, height: 220, items: [ { type: Vertical, items: [ { type: 'bi.layout', cls: 'dcm-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: 'bi-card', items: [ { type: Vertical, items: [ { type: 'bi.layout', cls: 'dcm-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: 'bi-card', items: [ { type: Vertical, items: [ { type: 'bi.layout', cls: 'dcm-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 dialogPopover = null; let dialogMore = null; const id = BI.UUID(); const that = this; const body = { type: Vertical, items: [ { type: 'bi.center_adapt', cls: 'bi-card', tgap: 10, items: [ { type: Vertical, vgap: 10, items: [ { type: Layout, cls: 'dcm-error-icon', width: 270, height: 100, textAlign: 'center', }, { type: Label, text, }, { type: VerticalAdapt, cls: 'buttons', hgap: 5, items: [ { type: Button, text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'), level: 'ignore', handler() { const isHide = !dialogMore.isVisible(); dialogPopover.element.css({ height: isHide ? '290' : '220', }); dialogMore.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.remove(id); }, }, { type: Button, text: BI.i18nText('Dec-Dcm_Connection_ReConnect'), handler() { that.close(id); cb ? cb() : null; }, }, ], }, ], }, ], }, { type: Label, cls: 'bi-header-background', text: more, invisible: true, height: 73, width: 400, value: false, ref: _ref => { dialogMore = _ref; }, }, ], }; BI.Maskers.create(id, null, { render: { type: CenterAdapt, cls: 'bi-z-index-mask', items: [{ el: { type: 'bi.center_adapt', cls: 'bi-card', width: 450, height: 220, items: [body], ref: _ref => { dialogPopover = _ref; }, }, }], }, }); BI.Maskers.show(id); return id; } public close(id: string): void{ BI.Popovers.close(id); } public remove(id: string): void{ BI.Maskers.remove(id); } public show(body: any, autoClose = 0): string { const name = BI.UUID(); BI.Maskers.create(name, null, { render: { type: CenterAdapt, cls: 'bi-z-index-mask', items: [{ el: { ...body, }, }], }, }); BI.Maskers.show(name); if (autoClose > 0) { setTimeout(() => { BI.Maskers.remove(name); }, autoClose); } return name; } } export default new Dialog();