帆软决策平台数据连接界面库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

265 lines
6.0 KiB

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 dialogMore = null;
let showErrMessage = false;
const id = BI.UUID();
const body = {
type: Vertical,
items: [
{
type: CenterAdapt,
cls: 'bi-card',
vgap: 10,
items: [
{
type: Vertical,
vgap: 10,
items: [
{
type: Layout,
cls: 'dcm-error-icon',
width: 270,
height: 100,
textAlign: 'center',
},
{
type: Label,
text,
},
{
type: VerticalAdapt,
hgap: 5,
items: [
{
type: Button,
text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'),
level: 'ignore',
handler() {
showErrMessage = !showErrMessage;
dialogMore.setVisible(showErrMessage);
this.setText(showErrMessage ? 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: () => {
this.remove(id);
},
},
{
type: Button,
text: BI.i18nText('Dec-Dcm_Connection_ReConnect'),
handler: () => {
this.remove(id);
cb ? cb() : null;
},
},
],
},
],
},
],
}, {
type: Label,
cls: 'bi-header-background',
text: more,
invisible: !showErrMessage,
textAlign: 'left',
height: 73,
width: 400,
vgap: 10,
lgap: 5,
ref: _ref => {
dialogMore = _ref;
},
},
],
};
BI.Maskers.create(id, null, {
render: {
type: CenterAdapt,
cls: 'bi-z-index-mask',
items: [{
el: {
type: CenterAdapt,
cls: 'bi-card',
width: 450,
items: [body],
},
}],
},
});
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();