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.
218 lines
4.9 KiB
218 lines
4.9 KiB
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: '提示', |
|
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 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:'详细信息', |
|
level: 'ignore', |
|
handler() { |
|
const isHide = this.getText() === '详细信息'; |
|
Popover.element.css({ |
|
height: isHide ? '290' : '220', |
|
}); |
|
More.setVisible(isHide); |
|
this.setText(isHide ? '收起信息' : '详细信息'); |
|
}, |
|
}, |
|
{ |
|
type: Button, |
|
text:'返回', |
|
level: 'ignore', |
|
handler() { |
|
that.close(id); |
|
}, |
|
}, |
|
{ |
|
type: Button, |
|
text:'重新连接', |
|
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();
|
|
|