帆软决策平台数据连接界面库
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.

289 lines
6.5 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 Popover: any = null;
let More: any = 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 = !More.isVisible();
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.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: any) {
More = 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: any) {
Popover = 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 show1(body: any, autoClose = 0): string {
const id = BI.UUID();
BI.Popovers.create(id, {
type: 'bi.popover',
cls: 'popover-notitle bi-custom-show',
size: 'small',
width: 450,
height: 220,
body,
}).open(id);
if (autoClose > 0) {
setTimeout(() => {
this.close(id);
}, autoClose);
}
return 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();