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