@ibiz-template/runtime 0.0.1-alpha.2 → 0.0.1-alpha.21

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 (55) hide show
  1. package/dist/system/index-de65cfae.system.js +1 -0
  2. package/out/command/app/open-app-view/open-app-view.d.ts +0 -11
  3. package/out/command/app/open-app-view/open-app-view.d.ts.map +1 -1
  4. package/out/command/app/open-app-view/open-app-view.js +6 -15
  5. package/out/index.d.ts +1 -0
  6. package/out/index.d.ts.map +1 -1
  7. package/out/index.js +1 -0
  8. package/out/install.d.ts.map +1 -1
  9. package/out/install.js +3 -0
  10. package/out/interface/index.d.ts +3 -0
  11. package/out/interface/index.d.ts.map +1 -1
  12. package/out/interface/index.js +3 -0
  13. package/out/interface/provider/i-editor-provider.d.ts +38 -0
  14. package/out/interface/provider/i-editor-provider.d.ts.map +1 -0
  15. package/out/interface/provider/i-editor-provider.js +1 -0
  16. package/out/interface/register/i-editor-register.d.ts +23 -0
  17. package/out/interface/register/i-editor-register.d.ts.map +1 -0
  18. package/out/interface/register/i-editor-register.js +1 -0
  19. package/out/interface/register/i-register.d.ts +38 -0
  20. package/out/interface/register/i-register.d.ts.map +1 -0
  21. package/out/interface/register/i-register.js +1 -0
  22. package/out/interface/util/i-loading-util/i-loading-util.d.ts +14 -0
  23. package/out/interface/util/i-loading-util/i-loading-util.d.ts.map +1 -1
  24. package/out/register/register.d.ts +20 -0
  25. package/out/register/register.d.ts.map +1 -0
  26. package/out/register/register.js +10 -0
  27. package/out/types.d.ts +9 -0
  28. package/out/types.d.ts.map +1 -1
  29. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts +11 -10
  30. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.d.ts.map +1 -1
  31. package/out/utils/app-de-ui-action-util/app-de-ui-action-util.js +52 -31
  32. package/out/utils/index.d.ts +1 -0
  33. package/out/utils/index.d.ts.map +1 -1
  34. package/out/utils/index.js +1 -0
  35. package/out/utils/open-redirect-view/open-redirect-view.d.ts +42 -0
  36. package/out/utils/open-redirect-view/open-redirect-view.d.ts.map +1 -0
  37. package/out/utils/open-redirect-view/open-redirect-view.js +149 -0
  38. package/out/view-logic/view-logic.d.ts +7 -6
  39. package/out/view-logic/view-logic.d.ts.map +1 -1
  40. package/out/view-logic/view-logic.js +20 -10
  41. package/package.json +20 -10
  42. package/src/command/app/open-app-view/open-app-view.ts +12 -26
  43. package/src/index.ts +1 -0
  44. package/src/install.ts +3 -0
  45. package/src/interface/index.ts +3 -0
  46. package/src/interface/provider/i-editor-provider.ts +44 -0
  47. package/src/interface/register/i-editor-register.ts +23 -0
  48. package/src/interface/register/i-register.ts +40 -0
  49. package/src/interface/util/i-loading-util/i-loading-util.ts +14 -0
  50. package/src/register/register.ts +20 -0
  51. package/src/types.ts +10 -0
  52. package/src/utils/app-de-ui-action-util/app-de-ui-action-util.ts +64 -41
  53. package/src/utils/index.ts +1 -0
  54. package/src/utils/open-redirect-view/open-redirect-view.ts +187 -0
  55. package/src/view-logic/view-logic.ts +31 -14
@@ -0,0 +1,187 @@
1
+ import { IBizContext } from '@ibiz-template/core';
2
+ import {
3
+ DefectModelError,
4
+ IPSAppDataEntity,
5
+ IPSAppDERedirectView,
6
+ IPSAppRedirectView,
7
+ UnsupportedModelError,
8
+ } from '@ibiz-template/model';
9
+ import { OpenAppViewCommand } from '../../command';
10
+ import { IModalData } from '../../interface';
11
+ import { convertNavData } from '../nav-params/nav-params';
12
+
13
+ /**
14
+ * 打开重定向视图
15
+ *
16
+ * @author chitanda
17
+ * @date 2022-09-28 16:09:13
18
+ * @export
19
+ * @param {IPSAppRedirectView} appView 应用重定向视图
20
+ * @param {IBizContext} [context=new IBizContext()]
21
+ * @param {IParams} [params={}]
22
+ * @param {IData} [data={}]
23
+ * @return {*} {Promise<IModalData>}
24
+ */
25
+ export async function openRedirectView(
26
+ appView: IPSAppRedirectView,
27
+ context: IBizContext = new IBizContext(),
28
+ params: IParams = {},
29
+ data: IData[] = [],
30
+ ): Promise<IModalData> {
31
+ if (appView.instanceof('app.view.IPSAppDERedirectView')) {
32
+ return openDERedirectView(
33
+ appView as IPSAppDERedirectView,
34
+ context,
35
+ params,
36
+ data,
37
+ );
38
+ }
39
+ throw new UnsupportedModelError(
40
+ appView,
41
+ `未支持的重定向视图类型: ${appView.viewType}`,
42
+ );
43
+ }
44
+
45
+ /**
46
+ * 打开实体重定向视图
47
+ *
48
+ * @author chitanda
49
+ * @date 2022-09-28 16:09:15
50
+ * @export
51
+ * @param {IPSAppDERedirectView} appView
52
+ * @param {IBizContext} [context=new IBizContext()]
53
+ * @param {IParams} [params={}]
54
+ * @param {IData[]} [data=[]]
55
+ * @return {*} {Promise<IModalData>}
56
+ */
57
+ export async function openDERedirectView(
58
+ appView: IPSAppDERedirectView,
59
+ context: IBizContext = new IBizContext(),
60
+ params: IParams = {},
61
+ data: IData[] = [],
62
+ ): Promise<IModalData> {
63
+ // 计算重定向视图上下文参数转换
64
+ const navContext = appView.getPSAppViewNavContexts() || [];
65
+ const navContextData = convertNavData(navContext, context, params);
66
+ context = new IBizContext(navContextData, context);
67
+ // 计算重定向视图视图参数转换
68
+ const navParams = appView.getPSAppViewNavParams() || [];
69
+ const navParamsData = convertNavData(navParams, context, params);
70
+ Object.assign(params, navParamsData);
71
+ // 重定向视图对应应用实体
72
+ const entity = appView.getPSAppDataEntity()!;
73
+ await entity.fill(true);
74
+ const key = entity.codeName.toLowerCase();
75
+ let curData: IData = data[0] || {};
76
+ // 将数据主键转换到上下文当中
77
+ context[key] = curData[key] || context[key] || params[key];
78
+ // 实体重定向视图获取数据行为
79
+ const action = appView.getGetDataPSAppDEAction();
80
+ const service = await ibiz.entityService.getService(entity.codeName);
81
+ ibiz.loading.showRedirect();
82
+ // 获取数据,未配置行为时,默认走 Get 行为
83
+ const res = await service.exec(
84
+ action ? action.codeName : 'Get',
85
+ context,
86
+ params,
87
+ );
88
+ ibiz.loading.hideRedirect();
89
+ if (res.ok) {
90
+ curData = res.data;
91
+ const linkUrl: string = curData.linkurl;
92
+ if (linkUrl) {
93
+ if (linkUrl.startsWith('http://') || linkUrl.startsWith('https://')) {
94
+ window.open(linkUrl, '_blank');
95
+ return { ok: true, data: [] };
96
+ }
97
+ return { ok: false, data: [] };
98
+ }
99
+ }
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
+ }
108
+ // 所有重定向引用视图
109
+ const allRefViews = appView.getRedirectPSAppViewRefs();
110
+ let refView = allRefViews?.find(view => {
111
+ return view.name === findRdTag;
112
+ });
113
+ if (!refView) {
114
+ findRdTag = `${rdTag.split(':')[0]}`;
115
+ refView = allRefViews?.find(view => {
116
+ return view.name === findRdTag;
117
+ });
118
+ }
119
+ if (refView) {
120
+ const view = refView.getRefPSAppView();
121
+ if (view) {
122
+ const result = await ibiz.commands.execute(
123
+ OpenAppViewCommand.TAG,
124
+ view,
125
+ context,
126
+ params,
127
+ { data: [curData] },
128
+ );
129
+ if (result) {
130
+ return result;
131
+ }
132
+ } else {
133
+ throw new DefectModelError(refView, `未配置实际引用视图`);
134
+ }
135
+ }
136
+ return { ok: true, data: [] };
137
+ }
138
+
139
+ /**
140
+ * 计算重定向标识
141
+ *
142
+ * @author chitanda
143
+ * @date 2022-09-28 16:09:47
144
+ * @export
145
+ * @param {IPSAppDERedirectView} rdView
146
+ * @param {boolean} isWf
147
+ * @param {IData} data
148
+ * @return {*} {Promise<string>}
149
+ */
150
+ export async function calcDERdTag(
151
+ entity: IPSAppDataEntity,
152
+ rdView: IPSAppDERedirectView,
153
+ isWf: boolean,
154
+ data: IData,
155
+ ): Promise<string> {
156
+ const multiFormField = entity.getFormTypePSAppDEField();
157
+ const indexTypeField = entity.getIndexTypePSAppDEField();
158
+ // 重定向视图标识
159
+ let rdTag = '';
160
+ // 重定向视图类别属性
161
+ const typeField = rdView.getTypePSAppDEField();
162
+ // 自定义重定向
163
+ if (typeField) {
164
+ const value = data[typeField.codeName.toLowerCase()];
165
+ if (value) {
166
+ return value;
167
+ }
168
+ }
169
+ let typeValue = '';
170
+ if (multiFormField) {
171
+ typeValue = data[multiFormField.codeName.toLowerCase()];
172
+ } else if (indexTypeField) {
173
+ typeValue = data[indexTypeField.codeName.toLowerCase()];
174
+ }
175
+ if (typeValue) {
176
+ if (isWf) {
177
+ rdTag = `WFEDITVIEW:${typeValue}`;
178
+ } else {
179
+ rdTag = `EDITVIEW:${typeValue}`;
180
+ }
181
+ } else if (isWf) {
182
+ rdTag = `WFEDITVIEW:`;
183
+ } else {
184
+ rdTag = `EDITVIEW:`;
185
+ }
186
+ return rdTag;
187
+ }
@@ -1,3 +1,4 @@
1
+ import { IBizContext } from '@ibiz-template/core';
1
2
  import { notNilEmpty } from 'qx-util';
2
3
  import {
3
4
  AppEntityModel,
@@ -19,14 +20,14 @@ import { AppDEUIActionUtil, convertNavData } from '../utils';
19
20
  * @date 2022-08-22 09:08:40
20
21
  * @export
21
22
  * @param {IPSAppViewLogic} viewLogic 视图逻辑模型对象
22
- * @param {IContext} context 上下文参数
23
+ * @param {IBizContext} context 上下文参数
23
24
  * @param {IParams} params 视图参数
24
25
  * @param {(IData | null)} data 数据集合
25
26
  * @param {IData} [opts] 额外参数,event是js原生事件
26
27
  */
27
28
  export async function executeViewLogic(
28
29
  viewLogic: IPSAppViewLogic,
29
- context: IContext,
30
+ context: IBizContext,
30
31
  data: IData[] | null,
31
32
  params: IParams,
32
33
  opts: IData = {},
@@ -41,7 +42,7 @@ export async function executeViewLogic(
41
42
  opts,
42
43
  );
43
44
  }
44
- if (viewLogic.name === 'newdata') {
45
+ if (viewLogic.name === 'newdata' && viewLogic.getPSAppUILogic()) {
45
46
  // 执行新建数据逻辑
46
47
  return executeNewDataAppUILogic(
47
48
  viewLogic.getPSAppUILogic() as IPSAppUINewDataLogic,
@@ -69,14 +70,14 @@ export async function executeViewLogic(
69
70
  * @date 2022-08-22 14:08:03
70
71
  * @export
71
72
  * @param {IPSAppUIOpenDataLogic} appUILogic 应用预置界面逻辑opendata模型对象
72
- * @param {IContext} context 上下文参数
73
+ * @param {IBizContext} context 上下文参数
73
74
  * @param {(IData | null)} data 数据集合
74
75
  * @param {IParams} params 视图参数
75
76
  * @param {IData} [opts] 额外参数,event是js原生事件
76
77
  */
77
78
  export async function executeOpenDataAppUILogic(
78
79
  appUILogic: IPSAppUIOpenDataLogic,
79
- context: IContext,
80
+ context: IBizContext,
80
81
  data: IData[] | null,
81
82
  params: IParams,
82
83
  opts: IData = {},
@@ -94,7 +95,6 @@ export async function executeOpenDataAppUILogic(
94
95
  await appDataEntity.init();
95
96
 
96
97
  // 处理导航参数
97
- let tempContext: IData = {};
98
98
  // 处理上下文导航参数
99
99
  const navContexts: IPSNavigateParam[] =
100
100
  openViewRef.getPSNavigateContexts() || [];
@@ -107,7 +107,10 @@ export async function executeOpenDataAppUILogic(
107
107
  rawValue: false,
108
108
  } as IPSNavigateParam);
109
109
  }
110
- tempContext = convertNavData(navContexts!, context, params, data[0]);
110
+ const tempContext = new IBizContext(
111
+ convertNavData(navContexts!, context, params, data[0]),
112
+ context,
113
+ );
111
114
 
112
115
  // 处理导航视图参数
113
116
  let tempParams: IData = {};
@@ -117,13 +120,19 @@ export async function executeOpenDataAppUILogic(
117
120
  }
118
121
 
119
122
  // 打开视图
120
- return ibiz.commands.execute(
123
+ await ibiz.commands.execute(
121
124
  OpenAppViewCommand.TAG,
122
125
  openView,
123
126
  tempContext,
124
127
  tempParams,
125
128
  opts,
126
129
  );
130
+
131
+ // 刷新上一个视图
132
+ const { neuron } = opts!;
133
+ neuron.call.refresh();
134
+
135
+ return {};
127
136
  }
128
137
 
129
138
  /**
@@ -133,14 +142,14 @@ export async function executeOpenDataAppUILogic(
133
142
  * @date 2022-08-22 14:08:03
134
143
  * @export
135
144
  * @param {IPSAppUINewDataLogic} appUILogic 应用预置界面逻辑newdata模型对象
136
- * @param {IContext} context 上下文参数
145
+ * @param {IBizContext} context 上下文参数
137
146
  * @param {(IData | null)} data 数据集合
138
147
  * @param {IParams} params 视图参数
139
148
  * @param {IData} [opts] 额外参数,event是js原生事件
140
149
  */
141
150
  export async function executeNewDataAppUILogic(
142
151
  appUILogic: IPSAppUINewDataLogic,
143
- context: IContext,
152
+ context: IBizContext,
144
153
  data: IData[] | null,
145
154
  params: IParams,
146
155
  opts: IData = {},
@@ -162,14 +171,16 @@ export async function executeNewDataAppUILogic(
162
171
  if (notNilEmpty(navContexts)) {
163
172
  tempContext = convertNavData(navContexts!, context, params, _data);
164
173
  }
174
+ tempContext = new IBizContext(tempContext, context);
175
+ // 删除上下文内的主键
176
+ delete tempContext[appDataEntity.deName.toLowerCase()];
177
+ tempContext[appDataEntity.deName.toLowerCase()] = undefined;
178
+
165
179
  const navParams = newViewRef.getPSNavigateParams();
166
180
  if (notNilEmpty(navParams)) {
167
181
  tempParams = convertNavData(navParams!, params, context, _data);
168
182
  }
169
183
 
170
- // 删除上下文内的主键
171
- delete tempContext[appDataEntity.deName.toLowerCase()];
172
-
173
184
  // todo 拷贝
174
185
  if (appUILogic.enableWizardAdd) {
175
186
  // todo 向导添加
@@ -180,11 +191,17 @@ export async function executeNewDataAppUILogic(
180
191
  }
181
192
 
182
193
  // 打开视图
183
- return ibiz.commands.execute(
194
+ await ibiz.commands.execute(
184
195
  OpenAppViewCommand.TAG,
185
196
  newView,
186
197
  tempContext,
187
198
  tempParams,
188
199
  opts,
189
200
  );
201
+
202
+ // 刷新上一个视图
203
+ const { neuron } = opts!;
204
+ neuron.call.refresh();
205
+
206
+ return {};
190
207
  }