|
|
|
import {Label, Vertical, CenterAdapt} from '@ui/index';
|
|
|
|
import LinkFail, {EVENT_CLOSE, EVENT_RETRY} from '../components/linkfail/linkfail';
|
|
|
|
|
|
|
|
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 {
|
|
|
|
const id = BI.UUID();
|
|
|
|
const linkFailWidget = BI.createWidget({
|
|
|
|
type: LinkFail,
|
|
|
|
text,
|
|
|
|
errMessage: more,
|
|
|
|
listeners: [
|
|
|
|
{
|
|
|
|
eventName: EVENT_CLOSE,
|
|
|
|
action: () => {
|
|
|
|
BI.Maskers.remove(id);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
eventName: EVENT_RETRY,
|
|
|
|
action: () => {
|
|
|
|
BI.Maskers.remove(id);
|
|
|
|
cb ? cb() : null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
BI.Maskers.create(id, null, {
|
|
|
|
render: linkFailWidget,
|
|
|
|
});
|
|
|
|
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();
|