@ibiz-template/runtime 0.0.1-alpha.32 → 0.0.1-alpha.34

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 (101) hide show
  1. package/dist/system/index.system.js +1 -1
  2. package/out/index.d.ts +1 -1
  3. package/out/index.d.ts.map +1 -1
  4. package/out/index.js +1 -1
  5. package/out/install.d.ts.map +1 -1
  6. package/out/install.js +3 -0
  7. package/out/interface/i-ui-action-handler/i-ui-action-handler.d.ts +27 -0
  8. package/out/interface/i-ui-action-handler/i-ui-action-handler.d.ts.map +1 -0
  9. package/out/interface/i-ui-action-handler/i-ui-action-handler.js +1 -0
  10. package/out/interface/index.d.ts +3 -1
  11. package/out/interface/index.d.ts.map +1 -1
  12. package/out/interface/index.js +2 -1
  13. package/out/interface/provider/i-ui-action-provider.d.ts +20 -0
  14. package/out/interface/provider/i-ui-action-provider.d.ts.map +1 -0
  15. package/out/interface/provider/i-ui-action-provider.js +1 -0
  16. package/out/interface/provider/index.d.ts +2 -0
  17. package/out/interface/provider/index.d.ts.map +1 -0
  18. package/out/interface/provider/index.js +1 -0
  19. package/out/interface/register/i-ui-action-register.d.ts +15 -0
  20. package/out/interface/register/i-ui-action-register.d.ts.map +1 -0
  21. package/out/interface/register/i-ui-action-register.js +1 -0
  22. package/out/interface/register/index.d.ts +3 -0
  23. package/out/interface/register/index.d.ts.map +1 -0
  24. package/out/interface/register/index.js +2 -0
  25. package/out/provider/index.d.ts +2 -0
  26. package/out/provider/index.d.ts.map +1 -0
  27. package/out/provider/index.js +1 -0
  28. package/out/provider/ui-action/backend-ui-action-provider.d.ts +15 -0
  29. package/out/provider/ui-action/backend-ui-action-provider.d.ts.map +1 -0
  30. package/out/provider/ui-action/backend-ui-action-provider.js +18 -0
  31. package/out/provider/ui-action/common-sys-ui-action-provider.d.ts +15 -0
  32. package/out/provider/ui-action/common-sys-ui-action-provider.d.ts.map +1 -0
  33. package/out/provider/ui-action/common-sys-ui-action-provider.js +18 -0
  34. package/out/provider/ui-action/front-ui-action-provider.d.ts +15 -0
  35. package/out/provider/ui-action/front-ui-action-provider.d.ts.map +1 -0
  36. package/out/provider/ui-action/front-ui-action-provider.js +18 -0
  37. package/out/provider/ui-action/index.d.ts +13 -0
  38. package/out/provider/ui-action/index.d.ts.map +1 -0
  39. package/out/provider/ui-action/index.js +44 -0
  40. package/out/register/index.d.ts +2 -0
  41. package/out/register/index.d.ts.map +1 -1
  42. package/out/register/index.js +2 -0
  43. package/out/register/register-center.d.ts +9 -0
  44. package/out/register/register-center.d.ts.map +1 -1
  45. package/out/register/register-center.js +11 -0
  46. package/out/register/ui-action-register.d.ts +17 -0
  47. package/out/register/ui-action-register.d.ts.map +1 -0
  48. package/out/register/ui-action-register.js +41 -0
  49. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts +0 -59
  50. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts.map +1 -1
  51. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.js +3 -251
  52. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.d.ts +17 -0
  53. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.d.ts.map +1 -0
  54. package/out/utils/app-de-ui-action-util/handler/backend-ui-action-handler.js +23 -0
  55. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.d.ts +17 -0
  56. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.d.ts.map +1 -0
  57. package/out/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.js +89 -0
  58. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.d.ts +17 -0
  59. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.d.ts.map +1 -0
  60. package/out/utils/app-de-ui-action-util/handler/front-ui-action-handler.js +22 -0
  61. package/out/utils/app-de-ui-action-util/handler/index.d.ts +5 -0
  62. package/out/utils/app-de-ui-action-util/handler/index.d.ts.map +1 -0
  63. package/out/utils/app-de-ui-action-util/handler/index.js +4 -0
  64. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.d.ts +82 -0
  65. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.d.ts.map +1 -0
  66. package/out/utils/app-de-ui-action-util/handler/ui-action-handler.js +143 -0
  67. package/out/utils/app-de-ui-action-util/index.d.ts +3 -0
  68. package/out/utils/app-de-ui-action-util/index.d.ts.map +1 -0
  69. package/out/utils/app-de-ui-action-util/index.js +2 -0
  70. package/out/utils/index.d.ts +1 -1
  71. package/out/utils/index.d.ts.map +1 -1
  72. package/out/utils/index.js +1 -1
  73. package/out/utils/open-redirect-view/open-redirect-view.d.ts +6 -5
  74. package/out/utils/open-redirect-view/open-redirect-view.d.ts.map +1 -1
  75. package/out/utils/open-redirect-view/open-redirect-view.js +30 -40
  76. package/package.json +7 -9
  77. package/src/index.ts +1 -1
  78. package/src/install.ts +3 -0
  79. package/src/interface/i-ui-action-handler/i-ui-action-handler.ts +33 -0
  80. package/src/interface/index.ts +3 -1
  81. package/src/interface/provider/i-ui-action-provider.ts +20 -0
  82. package/src/interface/provider/index.ts +1 -0
  83. package/src/interface/register/i-ui-action-register.ts +15 -0
  84. package/src/interface/register/index.ts +2 -0
  85. package/src/provider/index.ts +1 -0
  86. package/src/provider/ui-action/backend-ui-action-provider.ts +22 -0
  87. package/src/provider/ui-action/common-sys-ui-action-provider.ts +22 -0
  88. package/src/provider/ui-action/front-ui-action-provider.ts +22 -0
  89. package/src/provider/ui-action/index.ts +50 -0
  90. package/src/register/index.ts +2 -0
  91. package/src/register/register-center.ts +12 -1
  92. package/src/register/ui-action-register.ts +48 -0
  93. package/src/utils/app-de-ui-action-util/app-de-ui-action-util.ts +4 -336
  94. package/src/utils/app-de-ui-action-util/handler/backend-ui-action-handler.ts +32 -0
  95. package/src/utils/app-de-ui-action-util/handler/common-sys-ui-action-handler.ts +109 -0
  96. package/src/utils/app-de-ui-action-util/handler/front-ui-action-handler.ts +39 -0
  97. package/src/utils/app-de-ui-action-util/handler/index.ts +4 -0
  98. package/src/utils/app-de-ui-action-util/handler/ui-action-handler.ts +215 -0
  99. package/src/utils/app-de-ui-action-util/index.ts +2 -0
  100. package/src/utils/index.ts +1 -1
  101. package/src/utils/open-redirect-view/open-redirect-view.ts +31 -38
@@ -0,0 +1,215 @@
1
+ import { IBizContext, RuntimeError } from '@ibiz-template/core';
2
+ import { IPSAppDEUIAction, IPSNavigateContext } from '@ibiz-template/model';
3
+ import { notNilEmpty } from 'qx-util';
4
+ import { IUIActionHandler, IUIActionResult } from '../../../interface';
5
+ import { convertNavData } from '../../nav-params/nav-params';
6
+ import { AppDEUIActionUtil } from '../app-de-ui-action-util';
7
+
8
+ /**
9
+ * 界面行为处理器基类
10
+ *
11
+ * @author lxm
12
+ * @date 2022-10-25 14:10:31
13
+ * @export
14
+ * @class UIActionHandler
15
+ */
16
+ export abstract class UIActionHandler implements IUIActionHandler {
17
+ async exec(
18
+ action: IPSAppDEUIAction,
19
+ context: IBizContext,
20
+ data: IData[] | null,
21
+ params: IParams,
22
+ opts?: IData | undefined,
23
+ ): Promise<IUIActionResult> {
24
+ // **用户操作确认**
25
+ if (!(await this.isConfirm(action))) {
26
+ return {};
27
+ }
28
+
29
+ const { neuron } = opts!;
30
+ const result: IUIActionResult = {
31
+ refresh: action.reloadData,
32
+ closeView: action.closeEditView,
33
+ };
34
+
35
+ // 执行不同类型的界面行为独有逻辑,并且合并result
36
+ const _result = await this.execAction(action, context, data, params, opts);
37
+ Object.assign(result, _result);
38
+
39
+ await this.doNextAction(action, context, data, params, opts);
40
+ await this.handleResult(result, neuron);
41
+ return result;
42
+ }
43
+
44
+ /**
45
+ * 用户操作确认
46
+ *
47
+ * @author lxm
48
+ * @date 2022-10-25 14:10:55
49
+ * @param {IPSAppDEUIAction} action 界面行为模型
50
+ * @returns {*} {Promise<boolean>}
51
+ */
52
+ async isConfirm(action: IPSAppDEUIAction): Promise<boolean> {
53
+ if (action.enableConfirm && action.confirmMsg) {
54
+ return ibiz.modal.confirm({ title: action.confirmMsg });
55
+ }
56
+ return true;
57
+ }
58
+
59
+ /**
60
+ * 执行具体界面行为的独有逻辑(子类重写)
61
+ *
62
+ * @author lxm
63
+ * @date 2022-10-25 15:10:03
64
+ * @abstract
65
+ * @param {IPSAppDEUIAction} action
66
+ * @param {IBizContext} context
67
+ * @param {(IData[] | null)} data
68
+ * @param {IParams} params
69
+ * @param {(IData | undefined)} [opts]
70
+ * @returns {*} {Promise<IUIActionResult>}
71
+ */
72
+ abstract execAction(
73
+ action: IPSAppDEUIAction,
74
+ context: IBizContext,
75
+ data: IData[] | null,
76
+ params: IParams,
77
+ opts?: IData | undefined,
78
+ ): Promise<IUIActionResult>;
79
+
80
+ /**
81
+ * 执行后续界面行为
82
+ *
83
+ * @author lxm
84
+ * @date 2022-10-25 15:10:54
85
+ * @param {IPSAppDEUIAction} action
86
+ * @param {IBizContext} context
87
+ * @param {(IData[] | null)} data
88
+ * @param {IParams} params
89
+ * @param {(IData | undefined)} [opts]
90
+ * @returns {*} {Promise<void>}
91
+ */
92
+ async doNextAction(
93
+ action: IPSAppDEUIAction,
94
+ context: IBizContext,
95
+ data: IData[] | null,
96
+ params: IParams,
97
+ opts?: IData | undefined,
98
+ ): Promise<void> {
99
+ const nextAction = action.getNextPSUIAction() as IPSAppDEUIAction;
100
+ if (nextAction) {
101
+ await AppDEUIActionUtil.exec(nextAction, context, data, params, opts);
102
+ }
103
+ }
104
+
105
+ /**
106
+ * 处理结果(刷新和关闭视图)
107
+ *
108
+ * @author lxm
109
+ * @date 2022-10-25 14:10:11
110
+ * @param {IUIActionResult} result
111
+ * @param {IData} neuron
112
+ */
113
+ async handleResult(result: IUIActionResult, neuron: IData): Promise<void> {
114
+ // *关闭引用视图,关闭后不再执行刷新
115
+ if (result.closeView) {
116
+ if (!neuron.call.closeView) {
117
+ throw new RuntimeError(`该视图不存在关闭视图能力`);
118
+ }
119
+ await neuron.call.closeView();
120
+ return;
121
+ }
122
+
123
+ // *刷新引用视图
124
+ if (result.refresh) {
125
+ if (!neuron.call.refresh) {
126
+ throw new RuntimeError(`该视图不存在刷新能力`);
127
+ }
128
+ await neuron.call.refresh();
129
+ }
130
+ }
131
+
132
+ /**
133
+ * 参数处理(根据数据目标和数据参数,导航参数)
134
+ *
135
+ * @author lxm
136
+ * @date 2022-08-29 17:08:00
137
+ * @protected
138
+ * @static
139
+ * @param {IPSAppDEUIAction} action 界面行为
140
+ * @param {IBizContext} context 上下文
141
+ * @param {(IData[] | null)} data 数据集合
142
+ * @param {IParams} params 视图参数
143
+ * @returns {*} {Promise<{
144
+ * resultContext: IBizContext; 处理后的上下文
145
+ * resultData: IData[]; 处理后的数据集合
146
+ * resultParams: IParams; 处理后的视图参数
147
+ * }>}
148
+ */
149
+ protected static async handleParams(
150
+ action: IPSAppDEUIAction,
151
+ context: IBizContext,
152
+ data: IData[] | null,
153
+ params: IParams,
154
+ ): Promise<{
155
+ resultContext: IBizContext;
156
+ resultData: IData[];
157
+ resultParams: IParams;
158
+ }> {
159
+ let resultData = data || [];
160
+ // 数据目标不支持提示
161
+ if (
162
+ ['SINGLEDATA', 'MULTIDATA', 'MULTIKEY'].indexOf(action.actionTarget) !==
163
+ -1
164
+ ) {
165
+ throw new Error(
166
+ `数据类型${action.actionTarget}暂未支持,请配置无数据或单项数据主键`,
167
+ );
168
+ }
169
+
170
+ // 数据目标为无数据时,清空数据
171
+ if (action.actionTarget === 'NONE') {
172
+ resultData = [];
173
+ }
174
+
175
+ // 处理上下文导航参数
176
+ let tempContext = {};
177
+ const navContexts = action.getPSNavigateContexts() || [];
178
+
179
+ // 单项数据主键时,在导航参数开头加一个主键的导航参数,可以被配置的同名导航参数覆盖。
180
+ const appDataEntity = action.getPSAppDataEntity();
181
+ if (appDataEntity && action.actionTarget === 'SINGLEKEY') {
182
+ await appDataEntity?.fill(true);
183
+ const appDeName = appDataEntity.codeName.toLowerCase();
184
+ const { valueItem } = action;
185
+ navContexts.unshift({
186
+ key: appDeName,
187
+ value: valueItem || 'srfkey',
188
+ rawValue: false,
189
+ } as IPSNavigateContext);
190
+ }
191
+
192
+ if (notNilEmpty(navContexts)) {
193
+ tempContext = convertNavData(
194
+ navContexts!,
195
+ context,
196
+ params,
197
+ data?.[0] || {},
198
+ );
199
+ }
200
+ const resultContext = new IBizContext(tempContext, context);
201
+
202
+ // 处理导航视图参数
203
+ let resultParams: IData = {};
204
+ const navParams = action.getPSNavigateParams();
205
+ if (notNilEmpty(navParams)) {
206
+ resultParams = convertNavData(
207
+ navParams!,
208
+ context,
209
+ params,
210
+ data?.[0] || {},
211
+ );
212
+ }
213
+ return { resultContext, resultData, resultParams };
214
+ }
215
+ }
@@ -0,0 +1,2 @@
1
+ export * from './handler';
2
+ export * from './app-de-ui-action-util';
@@ -1,3 +1,3 @@
1
- export { AppDEUIActionUtil } from './app-de-ui-action-util/app-de-ui-action-util';
2
1
  export * from './nav-params/nav-params';
2
+ export * from './app-de-ui-action-util';
3
3
  export { openRedirectView } from './open-redirect-view/open-redirect-view';
@@ -6,6 +6,7 @@ import {
6
6
  IPSAppRedirectView,
7
7
  UnsupportedModelError,
8
8
  } from '@ibiz-template/model';
9
+ import { isNilOrEmpty, notNilEmpty } from 'qx-util';
9
10
  import { OpenAppViewCommand } from '../../command';
10
11
  import { IModalData } from '../../interface';
11
12
  import { convertNavData } from '../nav-params/nav-params';
@@ -97,25 +98,14 @@ export async function openDERedirectView(
97
98
  return { ok: false, data: [] };
98
99
  }
99
100
  }
100
- // 根据参数中是否给了 srfwf 来判断是否为工作流
101
- const isWf = !!params.srfwf;
102
- const rdTag = await calcDERdTag(entity, appView, isWf, curData);
103
- // 用于查找实际重定向视图的标识,根据不同重定向类型后续做不同处理
104
- let findRdTag = rdTag;
105
- if (isWf) {
106
- findRdTag = `${rdTag.split(':')[0]}:${params.srfwf.toUpperCase()}`;
107
- }
101
+ const rdTag = await calcDERdTag(entity, appView, params.srfwf, curData);
102
+ // 拼接当前重定向视图所在应用实体名称为前缀
103
+ const deRdTag = `${entity.name.toUpperCase()}:${rdTag}`;
108
104
  // 所有重定向引用视图
109
105
  const allRefViews = appView.getRedirectPSAppViewRefs();
110
- let refView = allRefViews?.find(view => {
111
- return view.name === findRdTag;
106
+ const refView = allRefViews?.find(view => {
107
+ return view.name === deRdTag || view.name === rdTag;
112
108
  });
113
- if (!refView) {
114
- findRdTag = `${rdTag.split(':')[0]}`;
115
- refView = allRefViews?.find(view => {
116
- return view.name === findRdTag;
117
- });
118
- }
119
109
  if (refView) {
120
110
  const view = refView.getRefPSAppView();
121
111
  if (view) {
@@ -140,48 +130,51 @@ export async function openDERedirectView(
140
130
  * 计算重定向标识
141
131
  *
142
132
  * @author chitanda
143
- * @date 2022-09-28 16:09:47
133
+ * @date 2022-10-25 16:10:48
144
134
  * @export
145
- * @param {IPSAppDERedirectView} rdView
146
- * @param {boolean} isWf
147
- * @param {IData} data
135
+ * @param {IPSAppDataEntity} entity 重定向视图所在应用实体
136
+ * @param {IPSAppDERedirectView} rdView 重定向视图
137
+ * @param {string} wfStep 流程步骤
138
+ * @param {IData} data 当前数据
148
139
  * @return {*} {Promise<string>}
149
140
  */
150
141
  export async function calcDERdTag(
151
142
  entity: IPSAppDataEntity,
152
143
  rdView: IPSAppDERedirectView,
153
- isWf: boolean,
144
+ wfStep: string,
154
145
  data: IData,
155
146
  ): Promise<string> {
156
- const multiFormField = entity.getFormTypePSAppDEField();
157
- const indexTypeField = entity.getIndexTypePSAppDEField();
158
- // 重定向视图标识
159
147
  let rdTag = '';
160
- // 重定向视图类别属性
148
+ // 重定向视图自定义类别属性
161
149
  const typeField = rdView.getTypePSAppDEField();
162
150
  // 自定义重定向
163
151
  if (typeField) {
164
152
  const value = data[typeField.codeName.toLowerCase()];
165
- if (value) {
166
- return value;
153
+ if (notNilEmpty(value)) {
154
+ return `RDITEM:${value}`;
167
155
  }
168
156
  }
157
+ // 如果流程步骤存在,按照工作流优先
158
+ if (notNilEmpty(wfStep)) {
159
+ return `EDITVIEW:${wfStep.toUpperCase()}`;
160
+ }
169
161
  let typeValue = '';
170
- if (multiFormField) {
171
- typeValue = data[multiFormField.codeName.toLowerCase()];
172
- } else if (indexTypeField) {
162
+ // 从索引属性获取重定向视图类型
163
+ const indexTypeField = entity.getIndexTypePSAppDEField();
164
+ if (indexTypeField) {
173
165
  typeValue = data[indexTypeField.codeName.toLowerCase()];
174
166
  }
175
- if (typeValue) {
176
- if (isWf) {
177
- rdTag = `WFEDITVIEW:${typeValue}`;
178
- } else {
179
- rdTag = `EDITVIEW:${typeValue}`;
167
+ if (isNilOrEmpty(typeValue)) {
168
+ // 从多表单属性判断重定向视图类型
169
+ const multiFormField = entity.getFormTypePSAppDEField();
170
+ if (multiFormField) {
171
+ typeValue = data[multiFormField.codeName.toLowerCase()];
180
172
  }
181
- } else if (isWf) {
182
- rdTag = `WFEDITVIEW:`;
173
+ }
174
+ if (notNilEmpty(typeValue)) {
175
+ rdTag = `EDITVIEW:${typeValue}`;
183
176
  } else {
184
- rdTag = `EDITVIEW:`;
177
+ rdTag = `EDITVIEW`;
185
178
  }
186
179
  return rdTag;
187
180
  }