@ibiz-template/runtime 0.1.29-dev.0 → 0.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +866 -603
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/out/command/app/open-app-view/open-app-view.d.ts +1 -1
- package/out/command/app/open-app-view/open-app-view.d.ts.map +1 -1
- package/out/command/app/open-app-view/open-app-view.js +16 -5
- package/out/config/global-config.js +1 -1
- package/out/controller/common/control/control.controller.d.ts +18 -0
- package/out/controller/common/control/control.controller.d.ts.map +1 -1
- package/out/controller/common/control/control.controller.js +29 -1
- package/out/controller/common/control/md-control.controller.d.ts.map +1 -1
- package/out/controller/common/control/md-control.controller.js +2 -1
- package/out/controller/control/dashboard/dashboard.controller.d.ts.map +1 -1
- package/out/controller/control/dashboard/dashboard.controller.js +2 -6
- package/out/controller/control/dashboard/portlet/index.d.ts +1 -0
- package/out/controller/control/dashboard/portlet/index.d.ts.map +1 -1
- package/out/controller/control/dashboard/portlet/index.js +1 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/index.d.ts +2 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/index.d.ts.map +1 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/index.js +1 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/menu-portlet.controller.d.ts +5 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/menu-portlet.controller.d.ts.map +1 -0
- package/out/controller/control/dashboard/portlet/menu-portlet/menu-portlet.controller.js +3 -0
- package/out/controller/control/exp-bar/exp-bar.controller.d.ts +10 -0
- package/out/controller/control/exp-bar/exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/exp-bar.controller.js +29 -2
- package/out/controller/control/exp-bar/tree-exp-bar.controller.d.ts.map +1 -1
- package/out/controller/control/exp-bar/tree-exp-bar.controller.js +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.d.ts +11 -2
- package/out/controller/control/form/edit-form/edit-form.controller.d.ts.map +1 -1
- package/out/controller/control/form/edit-form/edit-form.controller.js +56 -2
- package/out/controller/control/form/edit-form/edit-form.service.js +1 -1
- package/out/controller/control/form/form/form.controller.d.ts.map +1 -1
- package/out/controller/control/form/form/form.controller.js +2 -6
- package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
- package/out/controller/control/grid/grid/grid.controller.js +5 -10
- package/out/controller/control/tab-exp-panel/tab-exp-panel.controller.d.ts +10 -0
- package/out/controller/control/tab-exp-panel/tab-exp-panel.controller.d.ts.map +1 -1
- package/out/controller/control/tab-exp-panel/tab-exp-panel.controller.js +19 -0
- package/out/controller/control/toolbar/toolbar.controllerr.d.ts.map +1 -1
- package/out/controller/control/toolbar/toolbar.controllerr.js +8 -8
- package/out/controller/control/tree/tree.service.d.ts.map +1 -1
- package/out/controller/control/tree/tree.service.js +6 -11
- package/out/engine/md-view.engine.d.ts.map +1 -1
- package/out/engine/md-view.engine.js +5 -4
- package/out/global/global-util/global-util.d.ts +8 -0
- package/out/global/global-util/global-util.d.ts.map +1 -1
- package/out/global/global-util/global-util.js +8 -0
- package/out/interface/common/i-error-handler/i-error-handler.d.ts +17 -0
- package/out/interface/common/i-error-handler/i-error-handler.d.ts.map +1 -0
- package/out/interface/common/i-error-handler/i-error-handler.js +1 -0
- package/out/interface/common/i-global-config/i-global-view-config.d.ts +5 -3
- package/out/interface/common/i-global-config/i-global-view-config.d.ts.map +1 -1
- package/out/interface/common/index.d.ts +1 -0
- package/out/interface/common/index.d.ts.map +1 -1
- package/out/interface/controller/common/i-nav-view-msg/i-nav-view-msg.d.ts +9 -0
- package/out/interface/controller/common/i-nav-view-msg/i-nav-view-msg.d.ts.map +1 -1
- package/out/interface/controller/state/view/i-edit-view.state.d.ts +8 -0
- package/out/interface/controller/state/view/i-edit-view.state.d.ts.map +1 -1
- package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts.map +1 -1
- package/out/logic-scheduler/executor/app-ui-logic-executor.js +10 -4
- package/out/logic-scheduler/trigger/item-dyna-logic-trigger.d.ts.map +1 -1
- package/out/logic-scheduler/trigger/item-dyna-logic-trigger.js +1 -4
- package/out/model/data-entity/data-entity.js +2 -2
- package/out/register/helper/control-register.d.ts.map +1 -1
- package/out/register/helper/control-register.js +6 -1
- package/out/service/app-data-entity/app-data-entity.d.ts.map +1 -1
- package/out/service/app-data-entity/app-data-entity.js +4 -0
- package/out/service/service/entity/method/method-renturn.d.ts.map +1 -1
- package/out/service/service/entity/method/method-renturn.js +4 -0
- package/out/ui-action/provider/ui-action-provider-base.js +1 -1
- package/out/utils/error-handler/default-error-handler.d.ts +13 -0
- package/out/utils/error-handler/default-error-handler.d.ts.map +1 -0
- package/out/utils/error-handler/default-error-handler.js +36 -0
- package/out/utils/error-handler/error-handler-center.d.ts +41 -0
- package/out/utils/error-handler/error-handler-center.d.ts.map +1 -0
- package/out/utils/error-handler/error-handler-center.js +59 -0
- package/out/utils/error-handler/index.d.ts +3 -0
- package/out/utils/error-handler/index.d.ts.map +1 -0
- package/out/utils/error-handler/index.js +2 -0
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/promise/promise.d.ts +15 -0
- package/out/utils/promise/promise.d.ts.map +1 -0
- package/out/utils/promise/promise.js +38 -0
- package/package.json +2 -2
- package/src/command/app/open-app-view/open-app-view.ts +18 -5
- package/src/config/global-config.ts +1 -1
- package/src/controller/common/control/control.controller.ts +31 -2
- package/src/controller/common/control/md-control.controller.ts +2 -1
- package/src/controller/control/dashboard/dashboard.controller.ts +2 -6
- package/src/controller/control/dashboard/portlet/index.ts +1 -0
- package/src/controller/control/dashboard/portlet/menu-portlet/index.ts +1 -0
- package/src/controller/control/dashboard/portlet/menu-portlet/menu-portlet.controller.ts +4 -0
- package/src/controller/control/exp-bar/exp-bar.controller.ts +30 -2
- package/src/controller/control/exp-bar/tree-exp-bar.controller.ts +1 -0
- package/src/controller/control/form/edit-form/edit-form.controller.ts +71 -3
- package/src/controller/control/form/edit-form/edit-form.service.ts +1 -1
- package/src/controller/control/form/form/form.controller.ts +2 -6
- package/src/controller/control/grid/grid/grid.controller.ts +5 -9
- package/src/controller/control/tab-exp-panel/tab-exp-panel.controller.ts +20 -0
- package/src/controller/control/toolbar/toolbar.controllerr.ts +14 -8
- package/src/controller/control/tree/tree.service.ts +8 -9
- package/src/engine/md-view.engine.ts +6 -4
- package/src/global/global-util/global-util.ts +15 -0
- package/src/interface/common/i-error-handler/i-error-handler.ts +16 -0
- package/src/interface/common/i-global-config/i-global-view-config.ts +5 -3
- package/src/interface/common/index.ts +1 -0
- package/src/interface/controller/common/i-nav-view-msg/i-nav-view-msg.ts +10 -0
- package/src/interface/controller/state/view/i-edit-view.state.ts +10 -1
- package/src/logic-scheduler/executor/app-ui-logic-executor.ts +13 -4
- package/src/logic-scheduler/trigger/item-dyna-logic-trigger.ts +1 -4
- package/src/model/data-entity/data-entity.ts +2 -2
- package/src/register/helper/control-register.ts +6 -1
- package/src/service/app-data-entity/app-data-entity.ts +5 -0
- package/src/service/service/entity/method/method-renturn.ts +4 -0
- package/src/ui-action/provider/ui-action-provider-base.ts +1 -1
- package/src/utils/error-handler/default-error-handler.ts +40 -0
- package/src/utils/error-handler/error-handler-center.ts +61 -0
- package/src/utils/error-handler/index.ts +2 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/promise/promise.ts +41 -0
|
@@ -124,7 +124,7 @@ export class ToolbarController<
|
|
|
124
124
|
},
|
|
125
125
|
{ childrenFields: ['detoolbarItems'] },
|
|
126
126
|
);
|
|
127
|
-
await this.
|
|
127
|
+
await this.calcButtonState();
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
@@ -164,7 +164,11 @@ export class ToolbarController<
|
|
|
164
164
|
await this.state.buttonsState.update(_data, appDeId);
|
|
165
165
|
|
|
166
166
|
// 计算菜单项逻辑的预置逻辑
|
|
167
|
-
if (this.scheduler
|
|
167
|
+
if (this.scheduler) {
|
|
168
|
+
const logicParams: IData = {};
|
|
169
|
+
if (_data) {
|
|
170
|
+
logicParams.data = [_data];
|
|
171
|
+
}
|
|
168
172
|
// 遍历所有的项
|
|
169
173
|
recursiveIterate(
|
|
170
174
|
this.model,
|
|
@@ -172,9 +176,10 @@ export class ToolbarController<
|
|
|
172
176
|
const itemState = this.state.buttonsState[item.id!] as IButtonState;
|
|
173
177
|
// 计算项显示逻辑
|
|
174
178
|
if (itemState.visible) {
|
|
175
|
-
const dynaVisible = this.scheduler!.triggerItemVisible(
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
const dynaVisible = this.scheduler!.triggerItemVisible(
|
|
180
|
+
item.id!,
|
|
181
|
+
logicParams,
|
|
182
|
+
);
|
|
178
183
|
if (dynaVisible !== undefined) {
|
|
179
184
|
itemState.visible = dynaVisible;
|
|
180
185
|
}
|
|
@@ -182,9 +187,10 @@ export class ToolbarController<
|
|
|
182
187
|
|
|
183
188
|
// 计算项启用逻辑
|
|
184
189
|
if (!itemState.disabled) {
|
|
185
|
-
const dynaEnable = this.scheduler!.triggerItemEnable(
|
|
186
|
-
|
|
187
|
-
|
|
190
|
+
const dynaEnable = this.scheduler!.triggerItemEnable(
|
|
191
|
+
item.id!,
|
|
192
|
+
logicParams,
|
|
193
|
+
);
|
|
188
194
|
if (dynaEnable !== undefined) {
|
|
189
195
|
itemState.disabled = !dynaEnable;
|
|
190
196
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
TreeDataSetNodeData,
|
|
20
20
|
TreeCodeListNodeData,
|
|
21
21
|
} from '../../../service';
|
|
22
|
-
import { calcNavParams } from '../../../utils';
|
|
22
|
+
import { calcNavParams, handleAllSettled } from '../../../utils';
|
|
23
23
|
|
|
24
24
|
export interface TreeFetchOpts {
|
|
25
25
|
/**
|
|
@@ -104,7 +104,7 @@ export class TreeService extends MDControlService<IDETree> {
|
|
|
104
104
|
if (childNodeRSs.length === 0) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
const results = await
|
|
107
|
+
const results = await handleAllSettled(
|
|
108
108
|
childNodeRSs.map(async childNodeRS => {
|
|
109
109
|
const childNode = getTreeNode(
|
|
110
110
|
this.model,
|
|
@@ -117,14 +117,11 @@ export class TreeService extends MDControlService<IDETree> {
|
|
|
117
117
|
opts,
|
|
118
118
|
);
|
|
119
119
|
}),
|
|
120
|
+
false,
|
|
120
121
|
);
|
|
121
122
|
|
|
122
123
|
results.forEach(result => {
|
|
123
|
-
|
|
124
|
-
childrenNodes.push(...result.value);
|
|
125
|
-
} else if (result.status === 'rejected') {
|
|
126
|
-
ibiz.log.error(result.reason);
|
|
127
|
-
}
|
|
124
|
+
childrenNodes.push(...result);
|
|
128
125
|
});
|
|
129
126
|
}
|
|
130
127
|
return childrenNodes;
|
|
@@ -352,9 +349,11 @@ export class TreeService extends MDControlService<IDETree> {
|
|
|
352
349
|
// 设置查询长度
|
|
353
350
|
params.size = nodeModel.maxSize || 1000;
|
|
354
351
|
// 排序属性
|
|
355
|
-
if (nodeModel.sortAppDEFieldId
|
|
352
|
+
if (nodeModel.sortAppDEFieldId) {
|
|
356
353
|
Object.assign(params, {
|
|
357
|
-
sort: `${nodeModel.sortAppDEFieldId.toLowerCase()},${
|
|
354
|
+
sort: `${nodeModel.sortAppDEFieldId.toLowerCase()},${
|
|
355
|
+
nodeModel.sortDir ? nodeModel.sortDir.toLowerCase() : 'asc'
|
|
356
|
+
}`,
|
|
358
357
|
});
|
|
359
358
|
}
|
|
360
359
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RuntimeModelError } from '@ibiz-template/core';
|
|
2
2
|
import { IAppDEMultiDataView } from '@ibiz/model-core';
|
|
3
|
+
import { clone } from 'ramda';
|
|
3
4
|
import { SysUIActionTag, ViewCallTag } from '../constant';
|
|
4
5
|
import { ViewController } from '../controller';
|
|
5
6
|
import {
|
|
@@ -262,13 +263,14 @@ export class MDViewEngine extends ViewEngineBase {
|
|
|
262
263
|
throw new RuntimeModelError(this.view.model, `缺少newdata的视图逻辑`);
|
|
263
264
|
}
|
|
264
265
|
|
|
265
|
-
const
|
|
266
|
+
const params = clone(this.view.params);
|
|
266
267
|
if (copyMode) {
|
|
267
|
-
|
|
268
|
+
params.srfcopymode = copyMode;
|
|
268
269
|
}
|
|
270
|
+
|
|
269
271
|
const result = await this.view.scheduler?.triggerCustom('newdata', {
|
|
270
|
-
context,
|
|
271
|
-
params
|
|
272
|
+
context: this.view.context,
|
|
273
|
+
params,
|
|
272
274
|
data,
|
|
273
275
|
event,
|
|
274
276
|
view: this.view,
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
HandlebarsUtil,
|
|
6
6
|
RawValueUtil,
|
|
7
7
|
} from '../../utils';
|
|
8
|
+
import {
|
|
9
|
+
DefaultErrorHandler,
|
|
10
|
+
ErrorHandlerCenter,
|
|
11
|
+
} from '../../utils/error-handler';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* 全局工具方法或对象
|
|
@@ -47,6 +51,17 @@ export class GlobalUtil {
|
|
|
47
51
|
*/
|
|
48
52
|
readonly rawValue = new RawValueUtil();
|
|
49
53
|
|
|
54
|
+
/**
|
|
55
|
+
* 错误处理中心
|
|
56
|
+
* @author lxm
|
|
57
|
+
* @date 2023-09-26 05:04:26
|
|
58
|
+
*/
|
|
59
|
+
readonly error = new ErrorHandlerCenter();
|
|
60
|
+
|
|
61
|
+
constructor() {
|
|
62
|
+
this.error.register(new DefaultErrorHandler());
|
|
63
|
+
}
|
|
64
|
+
|
|
50
65
|
/**
|
|
51
66
|
* 获取导出Excel工具类对象
|
|
52
67
|
* @author lxm
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 错误处理器接口
|
|
3
|
+
* @author lxm
|
|
4
|
+
* @date 2023-09-26 04:51:18
|
|
5
|
+
* @export
|
|
6
|
+
* @interface IErrorHandler
|
|
7
|
+
*/
|
|
8
|
+
export interface IErrorHandler {
|
|
9
|
+
/**
|
|
10
|
+
* 处理错误,如果处理了该异常则返回true,后续处理器的就不会处理该异常
|
|
11
|
+
* @author lxm
|
|
12
|
+
* @date 2023-09-26 04:48:57
|
|
13
|
+
* @param {unknown} error
|
|
14
|
+
*/
|
|
15
|
+
handle(error: unknown): boolean | undefined;
|
|
16
|
+
}
|
|
@@ -20,11 +20,13 @@ export interface IGlobalViewConfig {
|
|
|
20
20
|
enableDataInfoBar: boolean;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* 用于控制全局哪些导航部件启用缓存,全大写。TABEXPPANEL:GRIDEXPBAR: - :分隔每个导航部件的缓存开关,必须用:结尾,如:TABEXPPANEL:开启表格导航部件缓存,GRIDEXPBAR:开启分页导航部件缓存
|
|
24
24
|
*
|
|
25
|
+
* @default 'TABEXPPANEL:'
|
|
26
|
+
* @description 判断时将使用 `部件类型:` 的方式进行判断,如:TABEXPPANEL:,表示开启表格导航视图的缓存
|
|
25
27
|
* @author chitanda
|
|
26
28
|
* @date 2023-09-15 12:09:09
|
|
27
|
-
* @type {
|
|
29
|
+
* @type {string}
|
|
28
30
|
*/
|
|
29
|
-
|
|
31
|
+
expCacheMode: string;
|
|
30
32
|
}
|
|
@@ -7,4 +7,13 @@ import { IViewState } from './i-view.state';
|
|
|
7
7
|
* @interface IEditViewState
|
|
8
8
|
* @extends {IViewState}
|
|
9
9
|
*/
|
|
10
|
-
export interface IEditViewState extends IViewState {
|
|
10
|
+
export interface IEditViewState extends IViewState {
|
|
11
|
+
/**
|
|
12
|
+
* 是否为复制模式
|
|
13
|
+
*
|
|
14
|
+
* @author chitanda
|
|
15
|
+
* @date 2023-09-26 17:09:21
|
|
16
|
+
* @type {boolean}
|
|
17
|
+
*/
|
|
18
|
+
copyMode?: boolean;
|
|
19
|
+
}
|
|
@@ -15,6 +15,7 @@ import { IModalData, IUILogicParams } from '../../interface';
|
|
|
15
15
|
import { calcDeCodeNameById, getFormTypeFieldName } from '../../model';
|
|
16
16
|
import { convertNavData } from '../../utils';
|
|
17
17
|
import { LogicExecutor } from './logic-executor';
|
|
18
|
+
import { Srfuf } from '../../service';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* 应用预置界面逻辑
|
|
@@ -216,12 +217,20 @@ export class AppUILogicExecutor extends LogicExecutor {
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
// 拷贝数据处理
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
220
|
+
if (params.srfcopymode) {
|
|
221
|
+
const entity = await ibiz.hub.getAppDataEntity(
|
|
222
|
+
view.model.appDataEntityId!,
|
|
223
|
+
);
|
|
224
|
+
const key = entity.keyAppDEFieldId;
|
|
225
|
+
if (key && _data) {
|
|
226
|
+
tempParams[key] = _data.srfkey;
|
|
227
|
+
tempParams.srfcopymode = true;
|
|
228
|
+
}
|
|
223
229
|
}
|
|
224
230
|
|
|
231
|
+
// 特殊处理标记,标记当前是新建数据。在打开视图前会被删除,具体在 open-app-view.ts 中处理
|
|
232
|
+
tempParams.srfuf = Srfuf.CREATE;
|
|
233
|
+
|
|
225
234
|
// 打开视图
|
|
226
235
|
const result: IModalData = await ibiz.commands.execute(
|
|
227
236
|
OpenAppViewCommand.TAG,
|
|
@@ -48,9 +48,6 @@ export class ItemDynaLogicTrigger extends LogicTrigger {
|
|
|
48
48
|
|
|
49
49
|
execute(executeParams: IUILogicParams): boolean {
|
|
50
50
|
const result = this.executor.execute(executeParams);
|
|
51
|
-
|
|
52
|
-
return result;
|
|
53
|
-
}
|
|
54
|
-
throw new RuntimeError(`${this.logic.id}逻辑返回值不是布尔值`);
|
|
51
|
+
return !!result;
|
|
55
52
|
}
|
|
56
53
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
IAppDEField,
|
|
5
5
|
IDELogic,
|
|
6
6
|
} from '@ibiz/model-core';
|
|
7
|
-
import {
|
|
7
|
+
import { notNilEmpty } from 'qx-util';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 从实体id计算实体codeName(小写)
|
|
@@ -31,7 +31,7 @@ export function calcDeCodeNameById(id: string): string {
|
|
|
31
31
|
*/
|
|
32
32
|
export function hasDeCodeName(params: IParams, entityId: string): boolean {
|
|
33
33
|
const codeName = calcDeCodeNameById(entityId);
|
|
34
|
-
return
|
|
34
|
+
return notNilEmpty(params[codeName]);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -72,7 +72,12 @@ export async function getControlProvider(
|
|
|
72
72
|
provider = getProvider(controlType);
|
|
73
73
|
|
|
74
74
|
if (!provider) {
|
|
75
|
-
|
|
75
|
+
switch (controlType) {
|
|
76
|
+
case 'DATAINFOBAR':
|
|
77
|
+
return;
|
|
78
|
+
default:
|
|
79
|
+
ibiz.log.error(`找不到部件类型${controlType}对应的适配器`);
|
|
80
|
+
}
|
|
76
81
|
} else {
|
|
77
82
|
return provider;
|
|
78
83
|
}
|
|
@@ -205,6 +205,11 @@ export class AppDataEntity implements IDataEntity {
|
|
|
205
205
|
* @return {*} {unknown}
|
|
206
206
|
*/
|
|
207
207
|
protected convertVal(value: unknown, dataType: number | undefined): unknown {
|
|
208
|
+
// 空值不转换
|
|
209
|
+
if (value == null) {
|
|
210
|
+
return value;
|
|
211
|
+
}
|
|
212
|
+
|
|
208
213
|
// 没有数据类型的给原值
|
|
209
214
|
if (isNil(dataType)) {
|
|
210
215
|
return value;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IAppDataEntity, IAppDEMethod } from '@ibiz/model-core';
|
|
2
|
+
import { isNilOrEmpty } from 'qx-util';
|
|
2
3
|
import { MethodDto } from '../../../dto/method.dto';
|
|
3
4
|
import { AppDataEntity } from '../../../app-data-entity/app-data-entity';
|
|
4
5
|
import { findModelChild } from '../../../../model';
|
|
@@ -58,6 +59,9 @@ export class MethodReturn {
|
|
|
58
59
|
const items = await this.dto.sets(context, [data]);
|
|
59
60
|
return items[0];
|
|
60
61
|
}
|
|
62
|
+
if (isNilOrEmpty(data)) {
|
|
63
|
+
data = {};
|
|
64
|
+
}
|
|
61
65
|
return new AppDataEntity(this.entity, data);
|
|
62
66
|
}
|
|
63
67
|
}
|
|
@@ -116,7 +116,7 @@ export abstract class UIActionProviderBase implements IUIActionProvider {
|
|
|
116
116
|
): Promise<boolean> {
|
|
117
117
|
const confirmMsg = this.calcMessage('confirm', action, args);
|
|
118
118
|
if (action.enableConfirm && confirmMsg) {
|
|
119
|
-
return ibiz.
|
|
119
|
+
return ibiz.confirm.warning({ title: '操作确认', desc: confirmMsg });
|
|
120
120
|
}
|
|
121
121
|
return true;
|
|
122
122
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RuntimeModelError,
|
|
3
|
+
ModelError,
|
|
4
|
+
HttpError,
|
|
5
|
+
NoticeError,
|
|
6
|
+
RuntimeError,
|
|
7
|
+
} from '@ibiz-template/core';
|
|
8
|
+
import { IErrorHandler } from '../../interface';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 默认处理器
|
|
12
|
+
* @author lxm
|
|
13
|
+
* @date 2023-09-26 04:52:18
|
|
14
|
+
* @export
|
|
15
|
+
* @class DefaultErrorHandler
|
|
16
|
+
* @implements {IErrorHandler}
|
|
17
|
+
*/
|
|
18
|
+
export class DefaultErrorHandler implements IErrorHandler {
|
|
19
|
+
handle(error: unknown): boolean | undefined {
|
|
20
|
+
if (error instanceof RuntimeModelError || error instanceof ModelError) {
|
|
21
|
+
ibiz.message.error(error.message, 10, true);
|
|
22
|
+
} else if (error instanceof HttpError) {
|
|
23
|
+
if (error.status === 401) {
|
|
24
|
+
ibiz.message.error('没有注册无权限错误处理器');
|
|
25
|
+
} else {
|
|
26
|
+
ibiz.notification.error({
|
|
27
|
+
title: '',
|
|
28
|
+
desc: error.message,
|
|
29
|
+
duration: 10,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
} else if (error instanceof NoticeError) {
|
|
33
|
+
ibiz.message.error(error.message, error.duration, error.duration === 0);
|
|
34
|
+
} else if (error instanceof RuntimeError) {
|
|
35
|
+
ibiz.message.error(error.message, 10, true);
|
|
36
|
+
}
|
|
37
|
+
ibiz.log.error(error);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { IErrorHandler } from '../../interface';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 事件处理工具
|
|
5
|
+
*
|
|
6
|
+
* @author lxm
|
|
7
|
+
* @date 2022-09-21 18:09:31
|
|
8
|
+
* @export
|
|
9
|
+
* @class ErrorHandler
|
|
10
|
+
*/
|
|
11
|
+
export class ErrorHandlerCenter {
|
|
12
|
+
/**
|
|
13
|
+
* 处理器集合
|
|
14
|
+
* @author lxm
|
|
15
|
+
* @date 2023-09-26 04:56:29
|
|
16
|
+
* @type {IErrorHandler[]}
|
|
17
|
+
*/
|
|
18
|
+
protected handlers: IErrorHandler[] = [];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 注册处理器(后注册的优先级更高)
|
|
22
|
+
* @author lxm
|
|
23
|
+
* @date 2023-09-26 04:59:06
|
|
24
|
+
* @param {IErrorHandler} handler
|
|
25
|
+
*/
|
|
26
|
+
register(handler: IErrorHandler): void {
|
|
27
|
+
this.handlers.unshift(handler);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 处理单个报错
|
|
32
|
+
* @author lxm
|
|
33
|
+
* @date 2023-09-26 05:18:18
|
|
34
|
+
* @protected
|
|
35
|
+
* @param {unknown} error
|
|
36
|
+
*/
|
|
37
|
+
protected handleSingle(error: unknown): void {
|
|
38
|
+
const find = this.handlers.find(item => {
|
|
39
|
+
return !!item.handle(error);
|
|
40
|
+
});
|
|
41
|
+
if (!find) {
|
|
42
|
+
ibiz.log.error('没有找到能处理该错误的处理器', error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 按顺序检测处理器,最先满足条件的处理该异常
|
|
48
|
+
* @author lxm
|
|
49
|
+
* @date 2023-09-26 05:01:08
|
|
50
|
+
* @param {unknown} error
|
|
51
|
+
*/
|
|
52
|
+
handle(error: unknown): void {
|
|
53
|
+
if (error instanceof Array) {
|
|
54
|
+
error.forEach(item => {
|
|
55
|
+
this.handleSingle(item);
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
this.handleSingle(error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 异步等待所有promise完成后才会结束异步
|
|
3
|
+
* 只返回成功的promise的返回值集合
|
|
4
|
+
* - 如果isThrow为true,有异常时抛出异常
|
|
5
|
+
* - 如果isThrow为false,有异常时用全局异常处理弹提示,逻辑不会中断
|
|
6
|
+
* @author lxm
|
|
7
|
+
* @date 2023-09-26 06:57:33
|
|
8
|
+
* @export
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {(Iterable<T | PromiseLike<T>>)} values
|
|
11
|
+
* @param {boolean} [isThrow=true]
|
|
12
|
+
* @return {*} {Promise<Awaited<T>[]>}
|
|
13
|
+
*/
|
|
14
|
+
export async function handleAllSettled<T>(
|
|
15
|
+
values: Iterable<T | PromiseLike<T>>,
|
|
16
|
+
isThrow = true,
|
|
17
|
+
): Promise<Awaited<T>[]> {
|
|
18
|
+
const allResults = await Promise.allSettled(values);
|
|
19
|
+
const successResult: Awaited<T>[] = [];
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const errorResult: any[] = [];
|
|
22
|
+
allResults.forEach(item => {
|
|
23
|
+
if (item.status === 'fulfilled') {
|
|
24
|
+
successResult.push(item.value);
|
|
25
|
+
} else {
|
|
26
|
+
errorResult.push(item.reason);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// 有报错时根据是否抛出处理,抛出就抛,不抛就拿全局的异常处理弹提示。
|
|
31
|
+
if (errorResult.length > 0) {
|
|
32
|
+
const error = errorResult.length === 1 ? errorResult[0] : errorResult;
|
|
33
|
+
if (isThrow) {
|
|
34
|
+
throw error;
|
|
35
|
+
} else {
|
|
36
|
+
ibiz.util.error.handle(error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return successResult;
|
|
41
|
+
}
|