@ibiz-template/runtime 0.1.0 → 0.1.1

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 (36) hide show
  1. package/dist/index.esm.js +193 -97
  2. package/dist/index.system.min.js +1 -1
  3. package/dist/index.system.min.js.map +1 -1
  4. package/out/command/app/open-app-view/open-app-view.js +1 -1
  5. package/out/controller/utils/event/qx-event-ex.d.ts.map +1 -1
  6. package/out/controller/utils/event/qx-event-ex.js +5 -4
  7. package/out/engine/view-base.engine.d.ts.map +1 -1
  8. package/out/engine/view-base.engine.js +7 -6
  9. package/out/interface/controller/event/view/i-pickup-data-view.event.d.ts +27 -0
  10. package/out/interface/controller/event/view/i-pickup-data-view.event.d.ts.map +1 -0
  11. package/out/interface/controller/event/view/i-pickup-data-view.event.js +1 -0
  12. package/out/interface/controller/event/view/index.d.ts +1 -0
  13. package/out/interface/controller/event/view/index.d.ts.map +1 -1
  14. package/out/interface/controller/event/view/index.js +1 -0
  15. package/out/interface/controller/state/view/i-pickup-data-view.state.d.ts +22 -0
  16. package/out/interface/controller/state/view/i-pickup-data-view.state.d.ts.map +1 -0
  17. package/out/interface/controller/state/view/i-pickup-data-view.state.js +1 -0
  18. package/out/interface/controller/state/view/index.d.ts +1 -0
  19. package/out/interface/controller/state/view/index.d.ts.map +1 -1
  20. package/out/interface/controller/state/view/index.js +1 -0
  21. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts +13 -1
  22. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts.map +1 -1
  23. package/out/logic-scheduler/executor/app-ui-logic-executor.js +62 -18
  24. package/out/service/service/entity/method/fetch.d.ts +11 -0
  25. package/out/service/service/entity/method/fetch.d.ts.map +1 -1
  26. package/out/service/service/entity/method/fetch.js +40 -3
  27. package/package.json +8 -10
  28. package/src/command/app/open-app-view/open-app-view.ts +1 -1
  29. package/src/controller/utils/event/qx-event-ex.ts +5 -4
  30. package/src/engine/view-base.engine.ts +7 -6
  31. package/src/interface/controller/event/view/i-pickup-data-view.event.ts +25 -0
  32. package/src/interface/controller/event/view/index.ts +1 -0
  33. package/src/interface/controller/state/view/i-pickup-data-view.state.ts +22 -0
  34. package/src/interface/controller/state/view/index.ts +1 -0
  35. package/src/logic-scheduler/executor/app-ui-logic-executor.ts +86 -26
  36. package/src/service/service/entity/method/fetch.ts +62 -5
@@ -1,12 +1,17 @@
1
- import { RuntimeError, RuntimeModelError } from '@ibiz-template/core';
1
+ import {
2
+ ModelError,
3
+ RuntimeError,
4
+ RuntimeModelError,
5
+ } from '@ibiz-template/core';
2
6
  import {
3
7
  IAppUIOpenDataLogic,
4
8
  INavigateParam,
5
9
  IAppUINewDataLogic,
10
+ IAppUILogicRefViewBase,
6
11
  } from '@ibiz/model-core';
7
12
  import { notNilEmpty } from 'qx-util';
8
13
  import { OpenAppViewCommand } from '../../command';
9
- import { IUILogicParams } from '../../interface';
14
+ import { IModalData, IUILogicParams } from '../../interface';
10
15
  import { convertNavData } from '../../utils';
11
16
  import { LogicExecutor } from './logic-executor';
12
17
 
@@ -55,7 +60,8 @@ export class AppUILogicExecutor extends LogicExecutor {
55
60
  appUILogic: IAppUIOpenDataLogic,
56
61
  parameters: IUILogicParams,
57
62
  ): Promise<void> {
58
- const { context, params, data, ...rest } = parameters;
63
+ const { context, params, ...rest } = parameters;
64
+ const { data } = parameters;
59
65
  if (!data?.[0]) {
60
66
  throw new RuntimeError('opendata没有可操作数据!');
61
67
  }
@@ -116,21 +122,33 @@ export class AppUILogicExecutor extends LogicExecutor {
116
122
  appUILogic: IAppUINewDataLogic,
117
123
  parameters: IUILogicParams,
118
124
  ): Promise<void> {
119
- const { context, params, data, ...rest } = parameters;
120
- // 准备需要的模型
121
- const newViewRef = appUILogic.newDataAppView;
122
- if (!newViewRef) {
123
- throw new RuntimeModelError(
124
- appUILogic,
125
- 'newdata视图逻辑没有配置默认新建数据视图',
126
- );
127
- }
128
- const newView = newViewRef.refAppViewId;
129
- if (!newView) {
130
- throw new RuntimeModelError(
131
- appUILogic,
132
- 'newdata视图逻辑的默认新建数据视图没有实际引用视图',
133
- );
125
+ const { context, params, ...rest } = parameters;
126
+ const { data } = parameters;
127
+ const { enableWizardAdd, enableBatchAdd, batchAddOnly, newDataAppView } =
128
+ appUILogic;
129
+
130
+ let newViewRef: IAppUILogicRefViewBase | undefined;
131
+ if (enableWizardAdd) {
132
+ newViewRef = await this.getWizardNewViewRef(appUILogic, parameters);
133
+ if (!newViewRef) {
134
+ // 选择视图取消操作直接返回
135
+ return;
136
+ }
137
+ } else if (enableBatchAdd) {
138
+ // todo 批添加
139
+ throw new ModelError(appUILogic, 'enableBatchAdd暂未支持');
140
+ } else if (batchAddOnly) {
141
+ // todo 只支持批添加
142
+ throw new ModelError(appUILogic, 'batchAddOnly暂未支持');
143
+ } else {
144
+ // 准备需要的模型
145
+ newViewRef = newDataAppView;
146
+ if (!newViewRef || !newViewRef.refAppViewId) {
147
+ throw new RuntimeModelError(
148
+ appUILogic,
149
+ 'newdata视图逻辑没有配置默认新建数据视图',
150
+ );
151
+ }
134
152
  }
135
153
 
136
154
  // 处理导航参数
@@ -154,21 +172,63 @@ export class AppUILogicExecutor extends LogicExecutor {
154
172
  _data.srfkey = undefined;
155
173
  tempParams = Object.assign(tempParams, _data.$origin);
156
174
  }
157
- if (appUILogic.enableWizardAdd) {
158
- // todo 向导添加
159
- } else if (appUILogic.enableBatchAdd) {
160
- // todo 批添加
161
- } else if (appUILogic.batchAddOnly) {
162
- // todo 只支持批添加
163
- }
164
175
 
165
176
  // 打开视图
166
177
  await ibiz.commands.execute(
167
178
  OpenAppViewCommand.TAG,
168
- newView,
179
+ newViewRef.refAppViewId,
169
180
  tempContext,
170
181
  tempParams,
171
182
  rest,
172
183
  );
173
184
  }
185
+
186
+ /**
187
+ * 获取向导新建视图引用
188
+ * 返回undefined为取消操作
189
+ * 找不到会报错
190
+ * @author lxm
191
+ * @date 2023-08-03 06:37:22
192
+ * @protected
193
+ * @param {IAppUINewDataLogic} appUILogic
194
+ * @param {IUILogicParams} parameters
195
+ * @return {*} {(Promise<IAppUILogicRefViewBase | undefined>)}
196
+ */
197
+ protected async getWizardNewViewRef(
198
+ appUILogic: IAppUINewDataLogic,
199
+ parameters: IUILogicParams,
200
+ ): Promise<IAppUILogicRefViewBase | undefined> {
201
+ const { wizardAppView, newDataAppViews } = appUILogic;
202
+ const { context, params, ...rest } = parameters;
203
+ // 索引实体的向导添加
204
+ if (!wizardAppView || !wizardAppView.refAppViewId) {
205
+ throw new RuntimeModelError(appUILogic, '缺少默认索引实体选择视图');
206
+ }
207
+
208
+ // 打开视图
209
+ const result = await ibiz.commands.execute<IModalData>(
210
+ OpenAppViewCommand.TAG,
211
+ wizardAppView.refAppViewId,
212
+ context,
213
+ params,
214
+ { ...rest, openMode: 'POPUPMODAL' },
215
+ );
216
+
217
+ if (!result.ok) {
218
+ // 取消
219
+ return;
220
+ }
221
+ const selectData = result.data?.[0];
222
+ if (!selectData) {
223
+ throw new RuntimeError('请选中一条数据');
224
+ }
225
+ const indexType = selectData.srfkey;
226
+ const findView = newDataAppViews?.find(item => item.refMode === indexType);
227
+ if (!findView) {
228
+ throw new RuntimeError(
229
+ `没有找到与索引类型${indexType}相关的实体的编辑视图`,
230
+ );
231
+ }
232
+ return findView;
233
+ }
174
234
  }
@@ -1,6 +1,11 @@
1
- import { HttpResponse } from '@ibiz-template/core';
1
+ import {
2
+ HttpResponse,
3
+ ModelError,
4
+ RuntimeModelError,
5
+ } from '@ibiz-template/core';
2
6
  import { ascSort, descSort } from 'qx-util';
3
7
  import { clone, equals, isEmpty, isNil, where } from 'ramda';
8
+ import { IAppDEDataSet } from '@ibiz/model-core';
4
9
  import { PSDEDQCondEngine, SearchFilter } from '../../../utils';
5
10
  import { Method } from './method';
6
11
  import { IDataEntity } from '../../../../interface';
@@ -16,20 +21,43 @@ import { execFieldLogics } from '../../../../de-logic';
16
21
  * @extends {Method}
17
22
  */
18
23
  export class FetchMethod extends Method {
24
+ declare method: IAppDEDataSet;
25
+
19
26
  async exec(
20
27
  context: IParams,
21
28
  data: IData,
22
29
  params: IParams,
23
30
  ): Promise<HttpResponse<IDataEntity[]>> {
24
31
  if (this.isLocalMode) {
32
+ // 临时数据
25
33
  const items = await this.searchLocal(
26
34
  null,
27
35
  new SearchFilter(context, data),
28
36
  );
29
37
  return new HttpResponse<IDataEntity[]>(items, 200);
30
38
  }
31
- const path = this.calcPath(context);
32
- const res = await this.request(path, context, data, params);
39
+
40
+ // 根据数据集合来源查询数据
41
+ let res: HttpResponse<IData[]>;
42
+ switch (this.method.dataSetType) {
43
+ case 'INDEXDE':
44
+ case 'CODELIST':
45
+ res = await this.fetchCodeListSet(context, params);
46
+ break;
47
+ case 'REMOTE':
48
+ {
49
+ const path = this.calcPath(context);
50
+ res = await this.request(path, context, data, params);
51
+ }
52
+ break;
53
+ default:
54
+ throw new ModelError(
55
+ this.method,
56
+ `数据来源类型${this.method.dataSetType}暂未支持`,
57
+ );
58
+ }
59
+
60
+ // 转换实体对象
33
61
  const items: IData[] = res.data || [];
34
62
  res.data = items.map(item => this.createEntity(item));
35
63
 
@@ -41,8 +69,7 @@ export class FetchMethod extends Method {
41
69
  ),
42
70
  );
43
71
  }
44
-
45
- return res;
72
+ return res as HttpResponse<IDataEntity[]>;
46
73
  }
47
74
 
48
75
  /**
@@ -174,4 +201,34 @@ export class FetchMethod extends Method {
174
201
  const items = list.slice(start, end).map(item => clone(item));
175
202
  return items;
176
203
  }
204
+
205
+ /**
206
+ * 获取代码表数据来源的集合
207
+ * @author lxm
208
+ * @date 2023-08-03 02:55:00
209
+ * @param {IParams} context
210
+ * @param {IParams} params
211
+ * @return {*} {Promise<HttpResponse<IData[]>>}
212
+ */
213
+ protected async fetchCodeListSet(
214
+ context: IParams,
215
+ params: IParams,
216
+ ): Promise<HttpResponse<IData[]>> {
217
+ const { appCodeListId } = this.method;
218
+ if (!appCodeListId) {
219
+ throw new RuntimeModelError(this.method, '没有指定数据来源代码表');
220
+ }
221
+ const codeItems = await this.app.codeList.get(
222
+ appCodeListId,
223
+ context,
224
+ params,
225
+ );
226
+ const { keyAppDEFieldId, majorAppDEFieldId } = this.entity;
227
+ const dataSet = codeItems.map(item => ({
228
+ [keyAppDEFieldId!]: item.value,
229
+ [majorAppDEFieldId!]: item.text,
230
+ }));
231
+
232
+ return new HttpResponse(dataSet, 200);
233
+ }
177
234
  }