@ibiz-template/runtime 0.2.18-dev.1 → 0.2.18

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.
Files changed (106) hide show
  1. package/dist/index.esm.js +363 -195
  2. package/dist/index.system.min.js +2 -2
  3. package/dist/index.system.min.js.map +1 -1
  4. package/out/controller/control/form/form/form.controller.d.ts.map +1 -1
  5. package/out/controller/control/form/form/form.controller.js +5 -0
  6. package/out/controller/control/form/form-detail/form-button/form-button.controller.d.ts.map +1 -1
  7. package/out/controller/control/form/form-detail/form-button/form-button.controller.js +1 -0
  8. package/out/controller/control/form/form-detail/form-detail/form-detail.controller.d.ts +6 -0
  9. package/out/controller/control/form/form-detail/form-detail/form-detail.controller.d.ts.map +1 -1
  10. package/out/controller/control/form/form-detail/form-detail/form-detail.controller.js +13 -0
  11. package/out/controller/control/form/form-detail/form-item/form-item.controller.d.ts +18 -0
  12. package/out/controller/control/form/form-detail/form-item/form-item.controller.d.ts.map +1 -1
  13. package/out/controller/control/form/form-detail/form-item/form-item.controller.js +41 -0
  14. package/out/controller/control/panel/panel/panel-item.controller.d.ts.map +1 -1
  15. package/out/controller/control/panel/panel/panel-item.controller.js +2 -1
  16. package/out/controller/utils/data-file-util/data-file-util.d.ts +1 -1
  17. package/out/controller/utils/data-file-util/data-file-util.d.ts.map +1 -1
  18. package/out/controller/utils/data-file-util/data-file-util.js +10 -23
  19. package/out/install.d.ts.map +1 -1
  20. package/out/install.js +3 -1
  21. package/out/interface/controller/event/argument/form-detail.event.d.ts +48 -0
  22. package/out/interface/controller/event/argument/form-detail.event.d.ts.map +1 -0
  23. package/out/interface/controller/event/argument/form-detail.event.js +24 -0
  24. package/out/interface/controller/event/argument/index.d.ts +3 -0
  25. package/out/interface/controller/event/argument/index.d.ts.map +1 -1
  26. package/out/interface/controller/event/argument/index.js +2 -1
  27. package/out/interface/controller/event/argument/panel-item.event.d.ts +23 -1
  28. package/out/interface/controller/event/argument/panel-item.event.d.ts.map +1 -1
  29. package/out/interface/controller/event/argument/panel-item.event.js +24 -1
  30. package/out/interface/controller/event/control/i-form.event.d.ts +13 -1
  31. package/out/interface/controller/event/control/i-form.event.d.ts.map +1 -1
  32. package/out/interface/controller/event/view/i-map-view.event.d.ts +12 -0
  33. package/out/interface/controller/event/view/i-map-view.event.d.ts.map +1 -0
  34. package/out/interface/controller/event/view/i-map-view.event.js +1 -0
  35. package/out/interface/controller/event/view/index.d.ts +1 -0
  36. package/out/interface/controller/event/view/index.d.ts.map +1 -1
  37. package/out/interface/controller/event/view/index.js +1 -0
  38. package/out/interface/controller/state/view/i-map-view.state.d.ts +11 -0
  39. package/out/interface/controller/state/view/i-map-view.state.d.ts.map +1 -0
  40. package/out/interface/controller/state/view/i-map-view.state.js +1 -0
  41. package/out/interface/controller/state/view/index.d.ts +1 -0
  42. package/out/interface/controller/state/view/index.d.ts.map +1 -1
  43. package/out/interface/controller/state/view/index.js +1 -0
  44. package/out/interface/provider/i-async-action.provider.d.ts +27 -0
  45. package/out/interface/provider/i-async-action.provider.d.ts.map +1 -0
  46. package/out/interface/provider/i-async-action.provider.js +1 -0
  47. package/out/interface/provider/index.d.ts +1 -0
  48. package/out/interface/provider/index.d.ts.map +1 -1
  49. package/out/interface/service/service/i-async-action.service.d.ts +28 -0
  50. package/out/interface/service/service/i-async-action.service.d.ts.map +1 -0
  51. package/out/interface/service/service/i-async-action.service.js +1 -0
  52. package/out/interface/service/service/index.d.ts +1 -0
  53. package/out/interface/service/service/index.d.ts.map +1 -1
  54. package/out/model/utils/util.d.ts.map +1 -1
  55. package/out/model/utils/util.js +7 -2
  56. package/out/register/helper/async-action-register.d.ts +22 -0
  57. package/out/register/helper/async-action-register.d.ts.map +1 -0
  58. package/out/register/helper/async-action-register.js +35 -0
  59. package/out/register/helper/index.d.ts +1 -0
  60. package/out/register/helper/index.d.ts.map +1 -1
  61. package/out/register/helper/index.js +1 -0
  62. package/out/service/app-data-entity/app-data-entity.d.ts +3 -3
  63. package/out/service/app-data-entity/app-data-entity.d.ts.map +1 -1
  64. package/out/service/app-data-entity/app-data-entity.js +3 -3
  65. package/out/service/dto/method.dto.d.ts +14 -0
  66. package/out/service/dto/method.dto.d.ts.map +1 -1
  67. package/out/service/dto/method.dto.js +63 -23
  68. package/out/service/service/async-action/async-action.service.d.ts +28 -0
  69. package/out/service/service/async-action/async-action.service.d.ts.map +1 -0
  70. package/out/service/service/async-action/async-action.service.js +31 -0
  71. package/out/service/service/index.d.ts +1 -0
  72. package/out/service/service/index.d.ts.map +1 -1
  73. package/out/service/service/index.js +1 -0
  74. package/out/types.d.ts +9 -1
  75. package/out/types.d.ts.map +1 -1
  76. package/out/utils/handlebars/handlebars.d.ts.map +1 -1
  77. package/out/utils/handlebars/handlebars.js +3 -1
  78. package/package.json +3 -3
  79. package/src/controller/control/form/form/form.controller.ts +9 -0
  80. package/src/controller/control/form/form-detail/form-button/form-button.controller.ts +1 -0
  81. package/src/controller/control/form/form-detail/form-detail/form-detail.controller.ts +14 -0
  82. package/src/controller/control/form/form-detail/form-item/form-item.controller.ts +44 -0
  83. package/src/controller/control/panel/panel/panel-item.controller.ts +2 -1
  84. package/src/controller/utils/data-file-util/data-file-util.ts +16 -27
  85. package/src/install.ts +7 -1
  86. package/src/interface/controller/event/argument/form-detail.event.ts +51 -0
  87. package/src/interface/controller/event/argument/index.ts +3 -0
  88. package/src/interface/controller/event/argument/panel-item.event.ts +25 -1
  89. package/src/interface/controller/event/control/i-form.event.ts +14 -1
  90. package/src/interface/controller/event/view/i-map-view.event.ts +12 -0
  91. package/src/interface/controller/event/view/index.ts +1 -0
  92. package/src/interface/controller/state/view/i-map-view.state.ts +10 -0
  93. package/src/interface/controller/state/view/index.ts +1 -0
  94. package/src/interface/provider/i-async-action.provider.ts +29 -0
  95. package/src/interface/provider/index.ts +1 -0
  96. package/src/interface/service/service/i-async-action.service.ts +29 -0
  97. package/src/interface/service/service/index.ts +1 -0
  98. package/src/model/utils/util.ts +7 -4
  99. package/src/register/helper/async-action-register.ts +47 -0
  100. package/src/register/helper/index.ts +1 -0
  101. package/src/service/app-data-entity/app-data-entity.ts +3 -3
  102. package/src/service/dto/method.dto.ts +70 -26
  103. package/src/service/service/async-action/async-action.service.ts +37 -0
  104. package/src/service/service/index.ts +1 -0
  105. package/src/types.ts +10 -0
  106. package/src/utils/handlebars/handlebars.ts +3 -1
@@ -6,10 +6,10 @@ import {
6
6
  import { IAppDataEntity } from '@ibiz/model-core';
7
7
 
8
8
  // 异步导入URL
9
- const asyncImportUrl = '/asyncimportdata2';
9
+ const asyncImportUrl = 'asyncimportdata2';
10
10
 
11
11
  // 标准导入url
12
- const importUrl = '/importdata2';
12
+ const importUrl = 'importdata2';
13
13
 
14
14
  // 导入结果类型
15
15
  export type ImportDataResult = {
@@ -33,33 +33,17 @@ export type IExportDataResult = {
33
33
  * @param {string} id
34
34
  * @return {*} {Promise<ImportDataResult>}
35
35
  */
36
- function listenAsyncAction(id: string): Promise<ImportDataResult> {
36
+ function listenAsyncAction(id: string): Promise<void> {
37
37
  return new Promise(resolve => {
38
38
  const callBack = (msg: IPortalMessage): void => {
39
39
  // 兼容接口返回类型与实际返回类型不一致
40
40
  const messageid = msg.messageid || (msg.data as IData).asyncacitonid;
41
- if (
42
- id === messageid &&
43
- (msg.data as IPortalAsyncAction).actionstate === 30
44
- ) {
45
- // 返回结果是字符串, 需解析
46
- try {
47
- const result = JSON.parse(
48
- (msg.data as IPortalAsyncAction).actionresult as string,
49
- );
50
- resolve(result as ImportDataResult);
51
- } catch (error) {
52
- throw new RuntimeError('解析数据发生错误');
53
- } finally {
54
- // 异步作业结束 取消订阅
55
- ibiz.mc.command.asyncAction.off(callBack);
56
- }
57
- } else if ((msg.data as IPortalAsyncAction).actionstate === 40) {
58
- resolve({
59
- total: 0,
60
- success: 0,
61
- message: (msg.data as IPortalAsyncAction).actionresult as string,
62
- });
41
+ if (id !== messageid) {
42
+ return;
43
+ }
44
+ const state = (msg.data as IPortalAsyncAction).actionstate;
45
+ if (state === 30 || state === 40) {
46
+ resolve();
63
47
  // 异步作业结束 取消订阅
64
48
  ibiz.mc.command.asyncAction.off(callBack);
65
49
  }
@@ -81,7 +65,7 @@ function listenAsyncAction(id: string): Promise<ImportDataResult> {
81
65
  export async function asyncImportData(
82
66
  file: File,
83
67
  appDataEntity: IAppDataEntity,
84
- ): Promise<ImportDataResult> {
68
+ ): Promise<void> {
85
69
  const data = new FormData();
86
70
  data.append('file', file);
87
71
  const url = `${appDataEntity.codeName2!.toLowerCase()}/${asyncImportUrl}`;
@@ -90,7 +74,12 @@ export async function asyncImportData(
90
74
  data,
91
75
  headers: { 'Content-Type': 'multipart/form-data' },
92
76
  });
93
- return listenAsyncAction(res.data.asyncacitonid);
77
+ await listenAsyncAction(res.data.asyncacitonid);
78
+ // 模拟表单通知 刷新表格
79
+ ibiz.mc.command.send(
80
+ { srfdecodename: appDataEntity.codeName },
81
+ 'OBJECTCREATED',
82
+ );
94
83
  }
95
84
 
96
85
  /**
package/src/install.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  import { GlobalConfig } from './config/global-config';
2
2
  import { RegisterCenter } from './register/register-center';
3
3
  import { installCommand } from './command';
4
- import { presetAppCounterProvider, V7AuthService } from './service';
4
+ import {
5
+ AsyncActionService,
6
+ presetAppCounterProvider,
7
+ V7AuthService,
8
+ } from './service';
5
9
  import { AppHub } from './app-hub';
6
10
  import { EngineFactory } from './engine';
7
11
  import { GlobalUtil } from './global';
@@ -27,6 +31,8 @@ export function install(): void {
27
31
  ibiz.config = new GlobalConfig();
28
32
  // 挂载认证服务
29
33
  ibiz.auth = new V7AuthService();
34
+ // 挂载异步操作服务
35
+ ibiz.asyncAction = new AsyncActionService();
30
36
  // 挂载引擎工厂
31
37
  ibiz.engine = new EngineFactory();
32
38
  // 安装默认指令
@@ -0,0 +1,51 @@
1
+ import { EventBase } from './base.event';
2
+
3
+ /* eslint-disable no-shadow */
4
+ export enum FormDetailEventName {
5
+ /**
6
+ * 点击
7
+ */
8
+ CLICK = 'onClick',
9
+ /**
10
+ * 聚焦
11
+ */
12
+ FOCUS = 'onFocus',
13
+ /**
14
+ * 失焦
15
+ */
16
+ BLUR = 'onBlur',
17
+ /**
18
+ * 值变更
19
+ */
20
+ CHANGE = 'onChange',
21
+ /**
22
+ * 回车
23
+ */
24
+ ENTER = 'onEnter',
25
+ }
26
+
27
+ /**
28
+ * 表单成员事件
29
+ * @author lxm
30
+ * @date 2023-08-09 10:52:48
31
+ * @export
32
+ * @interface FormDetailEvent
33
+ * @extends {EventBase}
34
+ */
35
+ export interface FormDetailEvent extends EventBase {
36
+ /**
37
+ * 触发的表单成员名称
38
+ * @author lxm
39
+ * @date 2023-03-26 02:02:16
40
+ * @type {string}
41
+ */
42
+ formDetailName: string;
43
+
44
+ /**
45
+ * 触发的表单成员事件的名称
46
+ * @author lxm
47
+ * @date 2023-07-26 11:00:37
48
+ * @type {FormDetailEventName}
49
+ */
50
+ formDetailEventName: FormDetailEventName;
51
+ }
@@ -8,3 +8,6 @@ export type { ControlTriggerEvent } from './control-trigger.event';
8
8
  export type { NavViewChangeEvent } from './nav-view-change.event';
9
9
  export type { RowEditChangeEvent } from './row-edit-change.event';
10
10
  export type { PanelItemEvent } from './panel-item.event';
11
+ export type { FormDetailEvent } from './form-detail.event';
12
+ export { FormDetailEventName } from './form-detail.event';
13
+ export { PanelItemEventName } from './panel-item.event';
@@ -1,5 +1,29 @@
1
1
  import { EventBase } from './base.event';
2
2
 
3
+ /* eslint-disable no-shadow */
4
+ export enum PanelItemEventName {
5
+ /**
6
+ * 点击
7
+ */
8
+ CLICK = 'onClick',
9
+ /**
10
+ * 聚焦
11
+ */
12
+ FOCUS = 'onFocus',
13
+ /**
14
+ * 失焦
15
+ */
16
+ BLUR = 'onBlur',
17
+ /**
18
+ * 值变更
19
+ */
20
+ CHANGE = 'onChange',
21
+ /**
22
+ * 回车
23
+ */
24
+ ENTER = 'onEnter',
25
+ }
26
+
3
27
  /**
4
28
  * 面板成员事件
5
29
  * @author lxm
@@ -23,5 +47,5 @@ export interface PanelItemEvent extends EventBase {
23
47
  * @date 2023-07-26 11:00:37
24
48
  * @type {string}
25
49
  */
26
- panelItemEventName: string;
50
+ panelItemEventName: PanelItemEventName;
27
51
  }
@@ -1,4 +1,5 @@
1
- import { EventBase } from '../argument';
1
+ import { PartialWithObject } from '@ibiz-template/core';
2
+ import { EventBase, FormDetailEvent } from '../argument';
2
3
  import { IControlEvent } from './i-control.event';
3
4
 
4
5
  /**
@@ -51,4 +52,16 @@ export interface IFormEvent extends IControlEvent {
51
52
  event: EventBase;
52
53
  emitArgs: undefined;
53
54
  };
55
+
56
+ /**
57
+ * 表单里的成员事件监听
58
+ * @author lxm
59
+ * @date 2023-03-26 06:15:06
60
+ * @param {EventBase} event
61
+ * @return {*} {Promise<void>}
62
+ */
63
+ onFormDetailEvent: {
64
+ event: FormDetailEvent;
65
+ emitArgs: PartialWithObject<FormDetailEvent, EventBase>;
66
+ };
54
67
  }
@@ -0,0 +1,12 @@
1
+ import { IMDViewEvent } from './i-md-view.event';
2
+
3
+ /**
4
+ * 地图视图事件
5
+ *
6
+ * @author lxm
7
+ * @date 2022-09-13 10:09:00
8
+ * @export
9
+ * @interface IMapViewEvent
10
+ * @extends {IMDViewEvent}
11
+ */
12
+ export type IMapViewEvent = IMDViewEvent;
@@ -41,3 +41,4 @@ export * from './i-tree-grid-view.event';
41
41
  export * from './i-tree-grid-ex-view.event';
42
42
  export * from './i-medit-view9.event';
43
43
  export * from './i-chart-exp-view.event';
44
+ export * from './i-map-view.event';
@@ -0,0 +1,10 @@
1
+ import { IMDViewState } from './i-md-view.state';
2
+
3
+ /**
4
+ * 地图视图UI状态
5
+ *
6
+ * @export
7
+ * @class IMapViewState
8
+ * @extends {IMDViewState}
9
+ */
10
+ export interface IMapViewState extends IMDViewState {}
@@ -42,3 +42,4 @@ export * from './i-tree-grid-view.state';
42
42
  export * from './i-tree-grid-ex-view.state';
43
43
  export * from './i-medit-view9.state';
44
44
  export * from './i-chart-exp-view.state';
45
+ export * from './i-map-view.state';
@@ -0,0 +1,29 @@
1
+ import { IPortalAsyncAction } from '@ibiz-template/core';
2
+
3
+ /**
4
+ * 异步操作适配器的接口
5
+ *
6
+ * @author lxm
7
+ * @date 2022-09-19 19:09:10
8
+ * @export
9
+ * @interface IAsyncActionProvider
10
+ */
11
+ export interface IAsyncActionProvider {
12
+ /**
13
+ * 绘制组件
14
+ * @author lxm
15
+ * @date 2022-09-20 10:09:50
16
+ * @type {unknown}
17
+ */
18
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
+ component: any;
20
+
21
+ /**
22
+ * 点击事件
23
+ * @author lxm
24
+ * @date 2023-11-14 09:30:39
25
+ * @param {IPortalAsyncAction} asyncAction
26
+ * @param {MouseEvent} event
27
+ */
28
+ onClick(asyncAction: IPortalAsyncAction, event: MouseEvent): void;
29
+ }
@@ -10,3 +10,4 @@ export type * from './i-editor.provider';
10
10
  export type * from './i-portlet.provider';
11
11
  export type { IAppCounterProvider } from './i-app-counter.provider';
12
12
  export type { IUILogicNodeProvider } from './i-ui-login-node.provider';
13
+ export type { IAsyncActionProvider } from './i-async-action.provider';
@@ -0,0 +1,29 @@
1
+ import { IHttpResponse, IPortalAsyncAction } from '@ibiz-template/core';
2
+
3
+ /**
4
+ * 异步操作服务
5
+ *
6
+ * @author chitanda
7
+ * @date 2023-08-17 16:08:08
8
+ * @export
9
+ * @interface IAuthService
10
+ */
11
+ export interface IAsyncActionService {
12
+ /**
13
+ * 获取异步操作的集合
14
+ * @author lxm
15
+ * @date 2023-11-15 10:55:25
16
+ * @param {IParams} [params={}]
17
+ * @return {*} {Promise<IHttpResponse<IPortalAsyncAction[]>>}
18
+ */
19
+ fetch(params?: IParams): Promise<IHttpResponse<IPortalAsyncAction[]>>;
20
+
21
+ /**
22
+ * 获取单条异步操作
23
+ * @author lxm
24
+ * @date 2023-11-15 10:57:08
25
+ * @param {string} actionID
26
+ * @return {*} {Promise<IHttpResponse<IPortalAsyncAction[]>>}
27
+ */
28
+ get(actionID: string): Promise<IHttpResponse<IPortalAsyncAction[]>>;
29
+ }
@@ -4,3 +4,4 @@ export type { IAppDEService } from './i-app-de.service';
4
4
  export type { IAuthService } from './i-auth.service';
5
5
  export type { IFileService } from './i-file.service';
6
6
  export type { IWorkFlowService } from './i-wf.service';
7
+ export type { IAsyncActionService } from './i-async-action.service';
@@ -21,10 +21,13 @@ export function findModelChild(
21
21
  models: IModelObject[],
22
22
  id: string,
23
23
  ): IModelObject | null {
24
- if (models) {
25
- const model = models.find(
26
- item => item.id!.toLowerCase() === id.toLowerCase(),
27
- );
24
+ if (models && id) {
25
+ const model = models.find(item => {
26
+ if (item.id) {
27
+ return item.id.toLowerCase() === id.toLowerCase();
28
+ }
29
+ return false;
30
+ });
28
31
  if (model) {
29
32
  return model;
30
33
  }
@@ -0,0 +1,47 @@
1
+ import { RuntimeError } from '@ibiz-template/core';
2
+ import { IAsyncActionProvider } from '../../interface';
3
+
4
+ /** 界面行为适配器前缀 */
5
+ export const ASYNC_ACTION_PROVIDER_PREFIX = 'ASYNC_ACTION';
6
+
7
+ /**
8
+ * 注册界面行为适配器
9
+ * @author lxm
10
+ * @date 2023-05-06 09:14:16
11
+ * @export
12
+ * @param {string} key
13
+ * @param {() => IAsyncActionProvider} callback 生成界面行为适配器的回调
14
+ */
15
+ export function registerAsyncActionProvider(
16
+ key: string,
17
+ callback: () => IAsyncActionProvider,
18
+ ): void {
19
+ ibiz.register.register(`${ASYNC_ACTION_PROVIDER_PREFIX}_${key}`, callback);
20
+ }
21
+
22
+ function getProvider(key: string): IAsyncActionProvider | undefined {
23
+ return ibiz.register.get(
24
+ `${ASYNC_ACTION_PROVIDER_PREFIX}_${key}`,
25
+ ) as IAsyncActionProvider;
26
+ }
27
+
28
+ /**
29
+ * 获取界面行为适配器
30
+ * @author lxm
31
+ * @date 2023-05-06 09:29:23
32
+ * @export
33
+ * @param {IAppView} model
34
+ * @return {*} {Promise<IAsyncActionProvider>}
35
+ */
36
+ export function getAsyncActionProvider(
37
+ actiontype: string,
38
+ ): IAsyncActionProvider {
39
+ const provider: IAsyncActionProvider | undefined = getProvider(actiontype);
40
+
41
+ // 找异步操作类型
42
+ if (!provider) {
43
+ throw new RuntimeError(`找不异步操作类型${actiontype}对应的适配器`);
44
+ } else {
45
+ return provider;
46
+ }
47
+ }
@@ -8,3 +8,4 @@ export * from './portlet-register';
8
8
  export * from './ui-action-register';
9
9
  export * from './ui-logic-node-register';
10
10
  export * from './view-register';
11
+ export * from './async-action-register';
@@ -46,11 +46,11 @@ export class AppDataEntity implements IDataEntity {
46
46
  * Creates an instance of AppDataEntity.
47
47
  *
48
48
  * @author chitanda
49
- * @date 2022-10-11 21:10:21
49
+ * @date 2023-11-16 15:11:08
50
50
  * @param {IAppDataEntity} entity
51
- * @param {(IData | AppDataEntity)} data
51
+ * @param {(IData | AppDataEntity)} [data={}]
52
52
  */
53
- constructor(entity: IAppDataEntity, data: IData | AppDataEntity) {
53
+ constructor(entity: IAppDataEntity, data: IData | AppDataEntity = {}) {
54
54
  Object.defineProperty(this, '_entity', {
55
55
  enumerable: false,
56
56
  configurable: true,
@@ -9,6 +9,10 @@ import { Application } from '../../application';
9
9
  import { AppDataEntity } from '../app-data-entity/app-data-entity';
10
10
  import { findModelChild } from '../../model';
11
11
 
12
+ interface listMap {
13
+ [key: number]: IData;
14
+ }
15
+
12
16
  /**
13
17
  * 应用实体服务方法转换 DTO
14
18
  *
@@ -37,6 +41,35 @@ export class MethodDto {
37
41
  }
38
42
  }
39
43
 
44
+ /**
45
+ * 转换数组成ListMap
46
+ *
47
+ * @param {IData[]} arr
48
+ * @return {*} listMap
49
+ */
50
+ private convertArrayToListMap(arr: IData[]): listMap {
51
+ const result: listMap = {};
52
+ arr.forEach((obj, index) => {
53
+ result[index + 1] = obj;
54
+ });
55
+ return result;
56
+ }
57
+
58
+ /**
59
+ * 转换ListMap成数组
60
+ *
61
+ * @param {listMap} obj
62
+ * @return {*} IData[]
63
+ */
64
+ private convertListMapToArray(obj: listMap): IData[] {
65
+ const result: IData[] = [];
66
+ Object.keys(obj).forEach(key => {
67
+ const index = parseInt(key, 10);
68
+ result[index - 1] = obj[index];
69
+ });
70
+ return result;
71
+ }
72
+
40
73
  /**
41
74
  * 请求参数组合 DTO
42
75
  *
@@ -57,24 +90,31 @@ export class MethodDto {
57
90
  break;
58
91
  }
59
92
  case 'DTOS': {
60
- if (data[key] !== undefined) {
61
- break;
62
- }
63
- // 没有实体id的不处理
64
- if (!field.refAppDataEntityId) {
65
- break;
66
- }
67
- const dto = await this.getFieldDto(field);
68
- const service = await this.app!.deService.getService(
69
- field.refAppDataEntityId!,
70
- );
71
- const items: IData[] = service.local.getList(context);
72
- if (items) {
73
- const arr = [];
74
- for (let j = 0; j < items.length; j++) {
75
- arr.push(await dto.get(context, items[j]));
93
+ if (field.listMap) {
94
+ params[key] =
95
+ data[key] && data[key].length > 0
96
+ ? this.convertArrayToListMap(data[key])
97
+ : null;
98
+ } else {
99
+ if (data[key] !== undefined) {
100
+ break;
101
+ }
102
+ // 没有实体id的不处理
103
+ if (!field.refAppDataEntityId) {
104
+ break;
105
+ }
106
+ const dto = await this.getFieldDto(field);
107
+ const service = await this.app!.deService.getService(
108
+ field.refAppDataEntityId!,
109
+ );
110
+ const items: IData[] = service.local.getList(context);
111
+ if (items) {
112
+ const arr = [];
113
+ for (let j = 0; j < items.length; j++) {
114
+ arr.push(await dto.get(context, items[j]));
115
+ }
116
+ params[key] = arr;
76
117
  }
77
- params[key] = arr;
78
118
  }
79
119
  break;
80
120
  }
@@ -108,17 +148,21 @@ export class MethodDto {
108
148
  const all = this.fields
109
149
  .filter(field => field.type === 'DTOS')
110
150
  .map(async field => {
111
- // 没有实体id的不处理
112
- if (!field.refAppDataEntityId) {
113
- return;
114
- }
115
151
  const key = field.codeName!.toLowerCase();
116
- const dto = await this.getFieldDto(field);
117
- const items: IData[] = datum[key];
118
- if (items) {
119
- await dto.sets(context, items);
152
+ if (field.listMap && typeof datum[key] === 'object') {
153
+ datum[key] = this.convertListMapToArray(datum[key]);
120
154
  } else {
121
- await dto.sets(context, []);
155
+ // 没有实体id的不处理
156
+ if (!field.refAppDataEntityId) {
157
+ return;
158
+ }
159
+ const dto = await this.getFieldDto(field);
160
+ const items: IData[] = datum[key];
161
+ if (items) {
162
+ await dto.sets(context, items);
163
+ } else {
164
+ await dto.sets(context, []);
165
+ }
122
166
  }
123
167
  });
124
168
  for (let i = 0; i < all.length; i++) {
@@ -0,0 +1,37 @@
1
+ import { IHttpResponse, IPortalAsyncAction } from '@ibiz-template/core';
2
+ import { IAsyncActionService } from '../../../interface';
3
+
4
+ /**
5
+ * 异步操作服务
6
+ * @author lxm
7
+ * @date 2023-11-15 10:52:06
8
+ * @export
9
+ * @class AsyncActionService
10
+ */
11
+ export class AsyncActionService implements IAsyncActionService {
12
+ /**
13
+ * 获取异步操作的集合
14
+ * @author lxm
15
+ * @date 2023-11-15 10:55:25
16
+ * @param {IParams} [params={}]
17
+ * @return {*} {Promise<IHttpResponse<IPortalAsyncAction[]>>}
18
+ */
19
+ async fetch(
20
+ params: IParams = {},
21
+ ): Promise<IHttpResponse<IPortalAsyncAction[]>> {
22
+ const res = await ibiz.net.post('/portal/asyncaction/all', params);
23
+ return res as IHttpResponse<IPortalAsyncAction[]>;
24
+ }
25
+
26
+ /**
27
+ * 获取单条异步操作
28
+ * @author lxm
29
+ * @date 2023-11-15 10:57:08
30
+ * @param {string} actionID
31
+ * @return {*} {Promise<IHttpResponse<IPortalAsyncAction[]>>}
32
+ */
33
+ async get(actionID: string): Promise<IHttpResponse<IPortalAsyncAction[]>> {
34
+ const res = await ibiz.net.get(`/portal/asyncaction/${actionID}`);
35
+ return res as IHttpResponse<IPortalAsyncAction[]>;
36
+ }
37
+ }
@@ -6,3 +6,4 @@ export { WorkFlowService } from './work-flow/work-flow.service';
6
6
  export * from './control';
7
7
  export * from './authority';
8
8
  export { V7AuthService } from './auth/v7-auth.service';
9
+ export { AsyncActionService } from './async-action/async-action.service';
package/src/types.ts CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  IGlobalConfig,
14
14
  IAppHubService,
15
15
  IAuthService,
16
+ IAsyncActionService,
16
17
  } from './interface';
17
18
  import { LogicSchedulerCenter } from './logic-scheduler';
18
19
  import { RegisterCenter } from './register/register-center';
@@ -132,6 +133,15 @@ declare module '@ibiz-template/core' {
132
133
  */
133
134
  auth: IAuthService;
134
135
 
136
+ /**
137
+ * 异步操作服务
138
+ *
139
+ * @author chitanda
140
+ * @date 2022-07-20 10:07:33
141
+ * @type {IAuthService}
142
+ */
143
+ asyncAction: IAsyncActionService;
144
+
135
145
  /**
136
146
  * 引擎工厂
137
147
  * @author lxm
@@ -49,7 +49,9 @@ export class HandlebarsUtil {
49
49
  return this.p;
50
50
  }
51
51
  this.p = import('handlebars');
52
- this.hsb = await this.p;
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ const module = (await this.p) as any;
54
+ this.hsb = module.default || module;
53
55
  this.p = null;
54
56
  installHelpers(this.hsb);
55
57
  return this.hsb;