|
@@ -295,7 +295,7 @@ export class ToolsHelper {
|
|
static closeAlertDialog(dialogTag: string) {
|
|
static closeAlertDialog(dialogTag: string) {
|
|
if (ToolsHelper.mapAlertDialog.get(dialogTag)) {
|
|
if (ToolsHelper.mapAlertDialog.get(dialogTag)) {
|
|
try {
|
|
try {
|
|
- GlobalContext.getUiContext().getPromptAction().closeCustomDialog(ToolsHelper.mapAlertDialog.get(dialogTag))
|
|
|
|
|
|
+ GlobalContext.getUiContext()?.getPromptAction().closeCustomDialog(ToolsHelper.mapAlertDialog.get(dialogTag))
|
|
} catch (err) {
|
|
} catch (err) {
|
|
}
|
|
}
|
|
ToolsHelper.mapAlertDialog.remove(dialogTag)
|
|
ToolsHelper.mapAlertDialog.remove(dialogTag)
|
|
@@ -309,34 +309,45 @@ export class ToolsHelper {
|
|
static showAlertDialog(options: AlertOptions) {
|
|
static showAlertDialog(options: AlertOptions) {
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const ui = GlobalContext.getUiContext()
|
|
const ui = GlobalContext.getUiContext()
|
|
- const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
- new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
|
|
|
- ui.getPromptAction().openCustomDialog(c, {
|
|
|
|
- autoCancel: false
|
|
|
|
- }).then(() => {
|
|
|
|
- ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
|
|
- }).catch(() => {
|
|
|
|
- try {
|
|
|
|
- promptAction.showDialog({
|
|
|
|
- alignment: DialogAlignment.Center,
|
|
|
|
- title: options.title,
|
|
|
|
- message: options.msg,
|
|
|
|
- buttons: [{
|
|
|
|
- text: options.action?.text ?? "确定",
|
|
|
|
- color: options.action?.color ?? "#000000",
|
|
|
|
- }]
|
|
|
|
|
|
+ if (ui) {
|
|
|
|
+ const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
+ new AlertBean({ title: options.title, msg: options.msg, confirm: options.action }, dialogTag))
|
|
|
|
+ ui.getPromptAction().openCustomDialog(c, {
|
|
|
|
+ autoCancel: false
|
|
|
|
+ }).then(() => {
|
|
|
|
+ ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ ToolsHelper.showCommonAlert(options)
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ ToolsHelper.showCommonAlert(options)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static showCommonAlert(options: AlertOptions) {
|
|
|
|
+ try {
|
|
|
|
+ promptAction.showDialog({
|
|
|
|
+ alignment: DialogAlignment.Center,
|
|
|
|
+ title: options.title,
|
|
|
|
+ message: options.msg,
|
|
|
|
+ buttons: [{
|
|
|
|
+ text: options.action?.text ?? "确定",
|
|
|
|
+ color: options.action?.color ?? "#000000",
|
|
|
|
+ }]
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+ options.action?.onClick && options.action?.onClick()
|
|
})
|
|
})
|
|
- .then(() => {
|
|
|
|
- options.action?.onClick && options.action?.onClick()
|
|
|
|
- })
|
|
|
|
- .catch((err: Error) => {
|
|
|
|
|
|
+ .catch((err: Error) => {
|
|
|
|
+ if (err.message === 'cancel') {
|
|
|
|
+ } else {
|
|
ToolsHelper.showMessage(err.message)
|
|
ToolsHelper.showMessage(err.message)
|
|
- })
|
|
|
|
- } catch (error) {
|
|
|
|
- let message = (error as BusinessError).message
|
|
|
|
- ToolsHelper.showMessage(message)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } catch (error) {
|
|
|
|
+ let message = (error as BusinessError).message
|
|
|
|
+ ToolsHelper.showMessage(message)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -347,47 +358,59 @@ export class ToolsHelper {
|
|
|
|
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const dialogTag = ToolsHelper.getUuid()
|
|
const ui = GlobalContext.getUiContext()
|
|
const ui = GlobalContext.getUiContext()
|
|
- const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
- new AlertBean({
|
|
|
|
- title: options.title,
|
|
|
|
- msg: options.msg,
|
|
|
|
- cancel: options.cancel ?? {},
|
|
|
|
- confirm: options.confirm
|
|
|
|
- }, dialogTag))
|
|
|
|
- ui.getPromptAction().openCustomDialog(c, {
|
|
|
|
- autoCancel: false
|
|
|
|
- }).then(() => {
|
|
|
|
- ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
|
|
- }).catch(() => {
|
|
|
|
- try {
|
|
|
|
- promptAction.showDialog({
|
|
|
|
- alignment: 1,
|
|
|
|
|
|
+ if (ui) {
|
|
|
|
+ const c = new ComponentContent(ui, wrapBuilder(alertDialogBuilder),
|
|
|
|
+ new AlertBean({
|
|
title: options.title,
|
|
title: options.title,
|
|
- message: options.msg,
|
|
|
|
- buttons: [{
|
|
|
|
- text: options.cancel?.text ?? "取消",
|
|
|
|
- color: options.cancel?.color ?? "#666666",
|
|
|
|
- }, {
|
|
|
|
- text: options.confirm?.text ?? "确定",
|
|
|
|
- color: options.confirm?.color ?? "#000000",
|
|
|
|
- },]
|
|
|
|
|
|
+ msg: options.msg,
|
|
|
|
+ cancel: options.cancel ?? {},
|
|
|
|
+ confirm: options.confirm
|
|
|
|
+ }, dialogTag))
|
|
|
|
+ ui.getPromptAction().openCustomDialog(c, {
|
|
|
|
+ autoCancel: false
|
|
|
|
+ }).then(() => {
|
|
|
|
+ ToolsHelper.mapAlertDialog.set(dialogTag, c)
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ ToolsHelper.showCommonConfirm(options)
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ ToolsHelper.showCommonConfirm(options)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ static showCommonConfirm(options: ConfirmOptions) {
|
|
|
|
+ try {
|
|
|
|
+ promptAction.showDialog({
|
|
|
|
+ alignment: 1,
|
|
|
|
+ title: options.title,
|
|
|
|
+ message: options.msg,
|
|
|
|
+ buttons: [{
|
|
|
|
+ text: options.cancel?.text ?? "取消",
|
|
|
|
+ color: options.cancel?.color ?? "#666666",
|
|
|
|
+ }, {
|
|
|
|
+ text: options.confirm?.text ?? "确定",
|
|
|
|
+ color: options.confirm?.color ?? "#000000",
|
|
|
|
+ },]
|
|
|
|
+ })
|
|
|
|
+ .then((data) => {
|
|
|
|
+ if (data.index === 0) {
|
|
|
|
+ options.cancel?.onClick && options.cancel.onClick()
|
|
|
|
+ } else {
|
|
|
|
+ options.confirm?.onClick && options.confirm.onClick()
|
|
|
|
+ }
|
|
})
|
|
})
|
|
- .then((data) => {
|
|
|
|
- if (data.index === 0) {
|
|
|
|
- options.cancel?.onClick && options.cancel.onClick()
|
|
|
|
- } else {
|
|
|
|
- options.confirm?.onClick && options.confirm.onClick()
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- .catch((err: Error) => {
|
|
|
|
|
|
+ .catch((err: Error) => {
|
|
|
|
+ if (err.message === 'cancel') {
|
|
|
|
+ options.cancel?.onClick && options.cancel.onClick()
|
|
|
|
+ } else {
|
|
ToolsHelper.showMessage(err.message)
|
|
ToolsHelper.showMessage(err.message)
|
|
- })
|
|
|
|
- } catch (error) {
|
|
|
|
- let message = (error as BusinessError).message
|
|
|
|
- ToolsHelper.showMessage(message)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } catch (error) {
|
|
|
|
+ let message = (error as BusinessError).message
|
|
|
|
+ ToolsHelper.showMessage(message)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
public static mapDialog = new HashMap<string, number>()
|
|
public static mapDialog = new HashMap<string, number>()
|