|
|
|
@ -17,30 +17,48 @@ import {
|
|
|
|
|
i18nText, |
|
|
|
|
KeyCode, |
|
|
|
|
isPlainObject, |
|
|
|
|
SIZE_CONSANTS |
|
|
|
|
SIZE_CONSANTS, |
|
|
|
|
CenterAdaptLayout, |
|
|
|
|
VerticalLayout, |
|
|
|
|
HTapeLayout, |
|
|
|
|
RightVerticalAdaptLayout |
|
|
|
|
} from "../../core"; |
|
|
|
|
import { Toast } from "../single"; |
|
|
|
|
import { Button, IconLabel, Label, Toast } from "../single"; |
|
|
|
|
|
|
|
|
|
export const Msg = (() => { |
|
|
|
|
let $mask, $pop; |
|
|
|
|
let $mask, $pop; |
|
|
|
|
|
|
|
|
|
const messageShows = []; |
|
|
|
|
const messageShows = []; |
|
|
|
|
|
|
|
|
|
const toastStack = []; |
|
|
|
|
const toastStack = []; |
|
|
|
|
|
|
|
|
|
const defaultConfig = { |
|
|
|
|
buttonHeight: 24, |
|
|
|
|
}; |
|
|
|
|
const AlertLevel = { |
|
|
|
|
WARNING: 'warning', |
|
|
|
|
INFO: 'info', |
|
|
|
|
ERROR: 'error', |
|
|
|
|
SUCCESS: 'success', |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
alert(title, message, callback, config = defaultConfig) { |
|
|
|
|
this._show(false, title, message, callback, config); |
|
|
|
|
}, |
|
|
|
|
confirm(title, message, callback, config = defaultConfig) { |
|
|
|
|
this._show(true, title, message, callback, config); |
|
|
|
|
function getIconCls(level) { |
|
|
|
|
switch (level) { |
|
|
|
|
case AlertLevel.ERROR: |
|
|
|
|
return 'alert-error-font'; |
|
|
|
|
case AlertLevel.SUCCESS: |
|
|
|
|
return 'alert-success-font'; |
|
|
|
|
case AlertLevel.INFO: |
|
|
|
|
return 'alert-info-font'; |
|
|
|
|
case AlertLevel.WARNING: |
|
|
|
|
default: |
|
|
|
|
return 'alert-warning-font'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const Msg = { |
|
|
|
|
alert(title, message, callback, config) { |
|
|
|
|
_show(false, title, message, callback, config); |
|
|
|
|
}, |
|
|
|
|
prompt(title, message, value, callback, min_width) { |
|
|
|
|
// Msg.prompt(title, message, value, callback, min_width);
|
|
|
|
|
confirm(title, message, callback, config) { |
|
|
|
|
_show(true, title, message, callback, config); |
|
|
|
|
}, |
|
|
|
|
toast(message, options, context) { |
|
|
|
|
isString(options) && (options = { level: options }); |
|
|
|
@ -101,7 +119,16 @@ export const Msg = (() => {
|
|
|
|
|
toast.destroy?.(); |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
_show(hasCancel, title, message, callback, config) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function _show(hasCancel, title, message, callback, config = {}) { |
|
|
|
|
config = { |
|
|
|
|
buttonHeight: 28, |
|
|
|
|
cancelText: i18nText("BI-Basic_Cancel"), |
|
|
|
|
sureText: i18nText("BI-Basic_OK"), |
|
|
|
|
level: AlertLevel.WARNING, |
|
|
|
|
...config, |
|
|
|
|
} |
|
|
|
|
isNull($mask) && |
|
|
|
|
($mask = Widget._renderEngine |
|
|
|
|
.createElement("<div class=\"bi-z-index-mask\">") |
|
|
|
@ -140,9 +167,9 @@ export const Msg = (() => {
|
|
|
|
|
if (hasCancel === true) { |
|
|
|
|
controlItems.push({ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.button", |
|
|
|
|
type: Button.xtype, |
|
|
|
|
height: config.buttonHeight, |
|
|
|
|
text: i18nText("BI-Basic_Cancel"), |
|
|
|
|
text: config.cancelText, |
|
|
|
|
light: true, |
|
|
|
|
handler() { |
|
|
|
|
close(); |
|
|
|
@ -155,9 +182,9 @@ export const Msg = (() => {
|
|
|
|
|
} |
|
|
|
|
controlItems.push({ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.button", |
|
|
|
|
type: Button.xtype, |
|
|
|
|
height: config.buttonHeight, |
|
|
|
|
text: i18nText("BI-Basic_OK"), |
|
|
|
|
text: config.sureText, |
|
|
|
|
handler() { |
|
|
|
|
close(); |
|
|
|
|
if (isFunction(callback)) { |
|
|
|
@ -168,10 +195,13 @@ export const Msg = (() => {
|
|
|
|
|
}); |
|
|
|
|
const conf = { |
|
|
|
|
element: $pop, |
|
|
|
|
type: "bi.center_adapt", |
|
|
|
|
type: CenterAdaptLayout.xtype, |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
type: "bi.border", |
|
|
|
|
type: VerticalLayout.xtype, |
|
|
|
|
cls: "bi-card bi-border-radius", |
|
|
|
|
width: 450, |
|
|
|
|
hgap: 32, |
|
|
|
|
attributes: { |
|
|
|
|
tabIndex: 1, |
|
|
|
|
}, |
|
|
|
@ -196,79 +226,61 @@ export const Msg = (() => {
|
|
|
|
|
} catch (e) { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
cls: "bi-card", |
|
|
|
|
items: { |
|
|
|
|
north: { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.border", |
|
|
|
|
cls: "bi-message-title bi-background", |
|
|
|
|
items: { |
|
|
|
|
center: { |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.label", |
|
|
|
|
cls: "bi-font-bold", |
|
|
|
|
text: title || i18nText("BI-Basic_Prompt"), |
|
|
|
|
textAlign: "left", |
|
|
|
|
hgap: 20, |
|
|
|
|
height: 40, |
|
|
|
|
}, |
|
|
|
|
type: HTapeLayout.xtype, |
|
|
|
|
height: 24, |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
type: IconLabel.xtype, |
|
|
|
|
cls: `${getIconCls(config.level)} icon-size-20`, |
|
|
|
|
width: 24, |
|
|
|
|
height: 24, |
|
|
|
|
}, |
|
|
|
|
east: { |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.icon_button", |
|
|
|
|
cls: "bi-message-close close-font", |
|
|
|
|
// height: 50,
|
|
|
|
|
handler() { |
|
|
|
|
close(); |
|
|
|
|
if (isFunction(callback)) { |
|
|
|
|
callback.apply(null, [false]); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
width: 56, |
|
|
|
|
type: Label.xtype, |
|
|
|
|
css: {"font-size": 16}, |
|
|
|
|
cls: 'bi-font-bold', // 16px
|
|
|
|
|
textAlign: 'left', |
|
|
|
|
text: title || i18nText('BI-Basic_Prompt'), |
|
|
|
|
lgap: 16, |
|
|
|
|
}, |
|
|
|
|
width: 'fill', |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
height: 40, |
|
|
|
|
tgap: 32, |
|
|
|
|
}, |
|
|
|
|
center: { |
|
|
|
|
{ |
|
|
|
|
el: isPlainObject(message) |
|
|
|
|
? message |
|
|
|
|
: { |
|
|
|
|
type: "bi.label", |
|
|
|
|
vgap: 10, |
|
|
|
|
hgap: 20, |
|
|
|
|
whiteSpace: "normal", |
|
|
|
|
type: Label.xtype, |
|
|
|
|
css: { "font-size": 14 }, |
|
|
|
|
cls: 'alert-content', |
|
|
|
|
textAlign: 'left', |
|
|
|
|
text: message, |
|
|
|
|
whiteSpace: 'normal', |
|
|
|
|
}, |
|
|
|
|
height: 'fill', |
|
|
|
|
tgap: 12, |
|
|
|
|
lgap: 40, |
|
|
|
|
}, |
|
|
|
|
south: { |
|
|
|
|
el: { |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
el: { |
|
|
|
|
type: "bi.right_vertical_adapt", |
|
|
|
|
lgap: 10, |
|
|
|
|
el: config.footer && isFunction(config.footer) ? config.footer(close) : { |
|
|
|
|
type: RightVerticalAdaptLayout.xtype, |
|
|
|
|
lgap: 12, |
|
|
|
|
items: controlItems, |
|
|
|
|
}, |
|
|
|
|
top: 0, |
|
|
|
|
left: 20, |
|
|
|
|
right: 20, |
|
|
|
|
bottom: 0, |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
height: 44, |
|
|
|
|
tgap: 32, |
|
|
|
|
bgap: 24, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
width: 450, |
|
|
|
|
height: 200, |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
messageShows[messageShows.length] = createWidget(conf); |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
})(); |
|
|
|
|
} |
|
|
|
|