@ibiz-template/runtime 0.1.0 → 0.1.2

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 (57) hide show
  1. package/dist/index.esm.js +266 -146
  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/de-logic/index.d.ts +13 -0
  8. package/out/de-logic/index.d.ts.map +1 -1
  9. package/out/de-logic/index.js +34 -2
  10. package/out/engine/md-view.engine.d.ts +2 -2
  11. package/out/engine/md-view.engine.d.ts.map +1 -1
  12. package/out/engine/md-view.engine.js +6 -2
  13. package/out/engine/view-base.engine.d.ts.map +1 -1
  14. package/out/engine/view-base.engine.js +7 -6
  15. package/out/index.d.ts +2 -0
  16. package/out/index.d.ts.map +1 -1
  17. package/out/index.js +2 -0
  18. package/out/interface/controller/controller/control/i-pickup-view-panel.controller.d.ts +10 -0
  19. package/out/interface/controller/controller/control/i-pickup-view-panel.controller.d.ts.map +1 -1
  20. package/out/interface/controller/controller/control/i-tree-exp-bar.controller.d.ts +11 -0
  21. package/out/interface/controller/controller/control/i-tree-exp-bar.controller.d.ts.map +1 -1
  22. package/out/interface/controller/event/control/i-pickup-view-panel.event.d.ts +15 -0
  23. package/out/interface/controller/event/control/i-pickup-view-panel.event.d.ts.map +1 -1
  24. package/out/interface/controller/event/view/i-pickup-data-view.event.d.ts +27 -0
  25. package/out/interface/controller/event/view/i-pickup-data-view.event.d.ts.map +1 -0
  26. package/out/interface/controller/event/view/i-pickup-data-view.event.js +1 -0
  27. package/out/interface/controller/event/view/index.d.ts +1 -0
  28. package/out/interface/controller/event/view/index.d.ts.map +1 -1
  29. package/out/interface/controller/event/view/index.js +1 -0
  30. package/out/interface/controller/state/view/i-pickup-data-view.state.d.ts +22 -0
  31. package/out/interface/controller/state/view/i-pickup-data-view.state.d.ts.map +1 -0
  32. package/out/interface/controller/state/view/i-pickup-data-view.state.js +1 -0
  33. package/out/interface/controller/state/view/index.d.ts +1 -0
  34. package/out/interface/controller/state/view/index.d.ts.map +1 -1
  35. package/out/interface/controller/state/view/index.js +1 -0
  36. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts +13 -1
  37. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts.map +1 -1
  38. package/out/logic-scheduler/executor/app-ui-logic-executor.js +62 -18
  39. package/out/service/service/entity/method/fetch.d.ts +11 -0
  40. package/out/service/service/entity/method/fetch.d.ts.map +1 -1
  41. package/out/service/service/entity/method/fetch.js +40 -3
  42. package/package.json +8 -9
  43. package/src/command/app/open-app-view/open-app-view.ts +1 -1
  44. package/src/controller/utils/event/qx-event-ex.ts +5 -4
  45. package/src/de-logic/index.ts +50 -2
  46. package/src/engine/md-view.engine.ts +7 -2
  47. package/src/engine/view-base.engine.ts +7 -6
  48. package/src/index.ts +2 -0
  49. package/src/interface/controller/controller/control/i-pickup-view-panel.controller.ts +10 -0
  50. package/src/interface/controller/controller/control/i-tree-exp-bar.controller.ts +13 -1
  51. package/src/interface/controller/event/control/i-pickup-view-panel.event.ts +16 -0
  52. package/src/interface/controller/event/view/i-pickup-data-view.event.ts +25 -0
  53. package/src/interface/controller/event/view/index.ts +1 -0
  54. package/src/interface/controller/state/view/i-pickup-data-view.state.ts +22 -0
  55. package/src/interface/controller/state/view/index.ts +1 -0
  56. package/src/logic-scheduler/executor/app-ui-logic-executor.ts +86 -26
  57. package/src/service/service/entity/method/fetch.ts +62 -5
@@ -1,4 +1,4 @@
1
- import { HttpResponse } from '@ibiz-template/core';
1
+ import { HttpResponse, ModelError, RuntimeModelError, } from '@ibiz-template/core';
2
2
  import { ascSort, descSort } from 'qx-util';
3
3
  import { clone, equals, isEmpty, isNil, where } from 'ramda';
4
4
  import { SearchFilter } from '../../../utils';
@@ -16,11 +16,27 @@ import { execFieldLogics } from '../../../../de-logic';
16
16
  export class FetchMethod extends Method {
17
17
  async exec(context, data, params) {
18
18
  if (this.isLocalMode) {
19
+ // 临时数据
19
20
  const items = await this.searchLocal(null, new SearchFilter(context, data));
20
21
  return new HttpResponse(items, 200);
21
22
  }
22
- const path = this.calcPath(context);
23
- const res = await this.request(path, context, data, params);
23
+ // 根据数据集合来源查询数据
24
+ let res;
25
+ switch (this.method.dataSetType) {
26
+ case 'INDEXDE':
27
+ case 'CODELIST':
28
+ res = await this.fetchCodeListSet(context, params);
29
+ break;
30
+ case 'REMOTE':
31
+ {
32
+ const path = this.calcPath(context);
33
+ res = await this.request(path, context, data, params);
34
+ }
35
+ break;
36
+ default:
37
+ throw new ModelError(this.method, `数据来源类型${this.method.dataSetType}暂未支持`);
38
+ }
39
+ // 转换实体对象
24
40
  const items = res.data || [];
25
41
  res.data = items.map(item => this.createEntity(item));
26
42
  // 计算属性逻辑,每条数据走一遍
@@ -152,4 +168,25 @@ export class FetchMethod extends Method {
152
168
  const items = list.slice(start, end).map(item => clone(item));
153
169
  return items;
154
170
  }
171
+ /**
172
+ * 获取代码表数据来源的集合
173
+ * @author lxm
174
+ * @date 2023-08-03 02:55:00
175
+ * @param {IParams} context
176
+ * @param {IParams} params
177
+ * @return {*} {Promise<HttpResponse<IData[]>>}
178
+ */
179
+ async fetchCodeListSet(context, params) {
180
+ const { appCodeListId } = this.method;
181
+ if (!appCodeListId) {
182
+ throw new RuntimeModelError(this.method, '没有指定数据来源代码表');
183
+ }
184
+ const codeItems = await this.app.codeList.get(appCodeListId, context, params);
185
+ const { keyAppDEFieldId, majorAppDEFieldId } = this.entity;
186
+ const dataSet = codeItems.map(item => ({
187
+ [keyAppDEFieldId]: item.value,
188
+ [majorAppDEFieldId]: item.text,
189
+ }));
190
+ return new HttpResponse(dataSet, 200);
191
+ }
155
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/runtime",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "控制器包",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -21,16 +21,15 @@
21
21
  "build:rollup": "rollup -c",
22
22
  "lint": "eslint 'src/**/*.ts'",
23
23
  "lint:fix": "eslint --fix 'src/**/*.ts'",
24
- "prepublish": "npm run build",
25
- "publish:next": "npm publish --access public --tag=next",
26
- "publish:dev": "npm publish --access public --tag=dev",
27
- "publish:beta": "npm publish --access public --tag=beta",
28
- "publish:npm": "npm publish --access public --registry=https://registry.npmjs.org/"
24
+ "publish:next": "npm run build && npm publish --access public --tag=next",
25
+ "publish:dev": "npm run build && npm publish --access public --tag=dev",
26
+ "publish:beta": "npm run build && npm publish --access public --tag=beta",
27
+ "publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/"
29
28
  },
30
29
  "author": "chitanda",
31
30
  "license": "MIT",
32
31
  "devDependencies": {
33
- "@ibiz-template/core": "^0.1.0",
32
+ "@ibiz-template/core": "^0.1.1",
34
33
  "@ibiz/model-core": "^0.0.14",
35
34
  "@types/path-browserify": "^1.0.0",
36
35
  "@types/qs": "^6.9.7",
@@ -44,7 +43,7 @@
44
43
  "ramda": "^0.29.0"
45
44
  },
46
45
  "peerDependencies": {
47
- "@ibiz-template/core": "^0.0.4-beta.35",
46
+ "@ibiz-template/core": "^0.1.0",
48
47
  "@ibiz/model-core": "^0.0.14",
49
48
  "async-validator": "^4.2.5",
50
49
  "dayjs": "^1.11.7",
@@ -54,5 +53,5 @@
54
53
  "qx-util": "^0.4.8",
55
54
  "ramda": "^0.29.0"
56
55
  },
57
- "gitHead": "764e1420d9056bd84442181ab3d68218c984515d"
56
+ "gitHead": "f3d39488212f0fd0b65bc4a5aae8bd9541fb1cd6"
58
57
  }
@@ -58,7 +58,7 @@ export class OpenAppViewCommand {
58
58
  );
59
59
  }
60
60
  const { openMode = 'INDEXVIEWTAB' } = appView;
61
- switch (openMode) {
61
+ switch (opts.openMode || openMode) {
62
62
  case 'INDEXVIEWTAB':
63
63
  if (opts.noWaitRoute) {
64
64
  this.openIndexViewTab(appView, context, params);
@@ -43,12 +43,13 @@ export class QXEventEx<T extends QXEmitter<T>> extends QXEvent<T> {
43
43
  name: K,
44
44
  ...args: Parameters<T[K]>
45
45
  ): Promise<Awaited<ReturnType<T[K]>>[]> {
46
- const result = await super.asyncEmit(name, ...args);
46
+ const resultPromise1 = super.asyncEmit(name, ...args);
47
47
  // 任意事件监听回调执行,并把执行结果展开合并入原始结果集合
48
48
  const all = this.anyEventFns.map(fn => fn(name, ...args));
49
- const resultArr = await Promise.all(all);
50
- result.concat(...resultArr);
51
- return result;
49
+ const resultPromise2 = Promise.all(all);
50
+ const resultArr1 = await resultPromise1;
51
+ const resultArr2 = await resultPromise2;
52
+ return resultArr1.concat(...resultArr2);
52
53
  }
53
54
 
54
55
  reset(): void {
@@ -1,6 +1,6 @@
1
- import { HttpError, HttpResponse } from '@ibiz-template/core';
1
+ import { HttpError, HttpResponse, RuntimeError } from '@ibiz-template/core';
2
2
  import { IAppDataEntity, IAppDELogic } from '@ibiz/model-core';
3
- import { filterFieldLogics } from '../model';
3
+ import { filterFieldLogics, findDELogic } from '../model';
4
4
  import { DELogic } from './de-logic';
5
5
 
6
6
  /**
@@ -8,6 +8,24 @@ import { DELogic } from './de-logic';
8
8
  */
9
9
  const deLogicMap: WeakMap<IAppDELogic, DELogic> = new Map();
10
10
 
11
+ /**
12
+ * 找到实体逻辑模型
13
+ * @author lxm
14
+ * @date 2023-08-04 02:47:16
15
+ * @param {string} deDELogicId
16
+ * @param {string} dataEntityId
17
+ * @param {string} [appId]
18
+ * @return {*} {(Promise<IAppDELogic | undefined>)}
19
+ */
20
+ async function findDeLogic(
21
+ deDELogicId: string,
22
+ dataEntityId: string,
23
+ appId?: string,
24
+ ): Promise<IAppDELogic | undefined> {
25
+ const appDataEntity = await ibiz.hub.getAppDataEntity(dataEntityId, appId);
26
+ return findDELogic(deDELogicId, appDataEntity);
27
+ }
28
+
11
29
  /**
12
30
  * 执行实体处理逻辑
13
31
  *
@@ -34,6 +52,36 @@ export async function execDELogic(
34
52
  return deLogic.exec(context, data, params);
35
53
  }
36
54
 
55
+ /**
56
+ * 通过id执行实体逻辑
57
+ * @author lxm
58
+ * @date 2023-08-04 02:49:44
59
+ * @export
60
+ * @param {string} deDELogicId
61
+ * @param {string} dataEntityId
62
+ * @param {IParams} context
63
+ * @param {IData} data
64
+ * @param {IParams} params
65
+ * @return {*} {Promise<unknown>}
66
+ */
67
+ export async function execDELogicById(
68
+ deDELogicId: string,
69
+ dataEntityId: string,
70
+ context: IParams,
71
+ data: IData,
72
+ params: IParams,
73
+ ): Promise<unknown> {
74
+ const deLogic = await findDeLogic(
75
+ deDELogicId,
76
+ dataEntityId,
77
+ context.srfappid,
78
+ );
79
+ if (!deLogic) {
80
+ throw new RuntimeError(`${dataEntityId}找不到实体逻辑${deDELogicId}`);
81
+ }
82
+ return execDELogic(deLogic, context, data, params);
83
+ }
84
+
37
85
  /**
38
86
  * 执行实体方法的实体逻辑并返回对应的response
39
87
  * @author lxm
@@ -9,6 +9,7 @@ import {
9
9
  ISearchFormController,
10
10
  MDCtrlRemoveParams,
11
11
  ISearchBarController,
12
+ MDCtrlLoadParams,
12
13
  } from '../interface';
13
14
  import { calcDeCodeNameById } from '../model';
14
15
  import { ViewEngineBase } from './view-base.engine';
@@ -168,6 +169,10 @@ export class MDViewEngine extends ViewEngineBase {
168
169
  this.copy(args);
169
170
  return null;
170
171
  }
172
+ if (key === 'load') {
173
+ this.load(args);
174
+ return null;
175
+ }
171
176
  return super.call(key, args);
172
177
  }
173
178
 
@@ -267,8 +272,8 @@ export class MDViewEngine extends ViewEngineBase {
267
272
  * @date 2023-05-22 03:17:33
268
273
  * @return {*} {Promise<void>}
269
274
  */
270
- protected async load(): Promise<void> {
271
- await this.xdataControl.load({ isInitialLoad: true });
275
+ protected async load(args: MDCtrlLoadParams = {}): Promise<void> {
276
+ await this.xdataControl.load({ isInitialLoad: true, ...args });
272
277
  }
273
278
 
274
279
  /**
@@ -239,12 +239,13 @@ export class ViewEngineBase implements IViewEngine {
239
239
  params,
240
240
  );
241
241
 
242
- if (res.data) {
243
- this.view.state.srfactiveviewdata = res.data;
244
- evt.emit('onDataChange', { actionType: 'LOAD', data: [res.data] });
245
- const info: IData = {};
246
- info.dataInfo = res.data.srfmajortext || '';
247
- evt.emit('onViewInfoChange', info);
242
+ const { data } = res;
243
+ if (data) {
244
+ this.view.state.srfactiveviewdata = data;
245
+ evt.emit('onDataChange', { actionType: 'LOAD', data: [data] });
246
+ if (data.srfkey) {
247
+ evt.emit('onViewInfoChange', { dataInfo: data.srfmajortext || '' });
248
+ }
248
249
  }
249
250
  }
250
251
  }
package/src/index.ts CHANGED
@@ -10,6 +10,8 @@ export * from './service';
10
10
  export * from './utils';
11
11
  export * from './controller';
12
12
  export * from './ui-action';
13
+ export * from './ui-logic';
14
+ export * from './de-logic';
13
15
  export * from './engine';
14
16
  export * from './model';
15
17
  export { Application } from './application';
@@ -1,6 +1,7 @@
1
1
  import { IDEPickupViewPanel } from '@ibiz/model-core';
2
2
  import { IPickupViewPanelEvent } from '../../event';
3
3
  import { IPickupViewPanelState } from '../../state';
4
+ import { IViewController } from '../view';
4
5
  import { IControlController } from './i-control.controller';
5
6
 
6
7
  /**
@@ -16,6 +17,15 @@ export interface IPickupViewPanelController
16
17
  IPickupViewPanelState,
17
18
  IPickupViewPanelEvent
18
19
  > {
20
+ /**
21
+ * 选择视图嵌入视图控制器
22
+ *
23
+ * @author zk
24
+ * @date 2023-08-04 08:08:43
25
+ * @type {IViewController}
26
+ * @memberof IPickupViewPanelController
27
+ */
28
+ embedView: IViewController;
19
29
  /**
20
30
  * 获取选中数据
21
31
  *
@@ -2,6 +2,7 @@ import { ITreeExpBar } from '@ibiz/model-core';
2
2
  import { ITreeExpBarEvent } from '../../event';
3
3
  import { ITreeExpBarState } from '../../state';
4
4
  import { IExpBarControlController } from './i-exp-bar-control.controller';
5
+ import { INavViewMsg } from './panel-item';
5
6
 
6
7
  /**
7
8
  * 树导航栏控制器
@@ -15,4 +16,15 @@ export interface ITreeExpBarController
15
16
  ITreeExpBar,
16
17
  ITreeExpBarState,
17
18
  ITreeExpBarEvent
18
- > {}
19
+ > {
20
+ /**
21
+ * 获取导航视图消息
22
+ *
23
+ * @author zk
24
+ * @date 2023-08-04 08:08:27
25
+ * @param {IData[]} data
26
+ * @return {*} {(INavViewMsg | undefined)}
27
+ * @memberof ITreeExpBarController
28
+ */
29
+ getNavViewMsg(data: IData[]): INavViewMsg | undefined;
30
+ }
@@ -38,4 +38,20 @@ export interface IPickupViewPanelEvent extends IControlEvent {
38
38
  event: EventBase;
39
39
  emitArgs: { data: IData[] };
40
40
  };
41
+
42
+ /**
43
+ * 选择视图初始化
44
+ *
45
+ * @author zk
46
+ * @date 2023-08-04 05:08:37
47
+ * @type {{
48
+ * event: EventBase;
49
+ * emitArgs: { data: IViewController };
50
+ * }}
51
+ * @memberof IPickupViewPanelEvent
52
+ */
53
+ onPickUpViewMounted: {
54
+ event: EventBase;
55
+ emitArgs: undefined;
56
+ };
41
57
  }
@@ -0,0 +1,25 @@
1
+ import { EventBase } from '../argument';
2
+ import { IDataViewEvent } from './i-data-view.event';
3
+
4
+ /**
5
+ * 选择数据视图事件
6
+ *
7
+ * @author lxm
8
+ * @date 2022-09-13 10:09:00
9
+ * @export
10
+ * @interface IPickupDataViewEvent
11
+ * @extends {IGridViewEvent}
12
+ */
13
+ export interface IPickupDataViewEvent extends IDataViewEvent {
14
+ /**
15
+ * 选中数据变更事件
16
+ *
17
+ * @author lxm
18
+ * @date 2022-08-31 14:08:12
19
+ * @param {IData[]} selection 选中的数据集合
20
+ */
21
+ onSelectionChange: {
22
+ event: EventBase;
23
+ emitArgs: { data: IData[] };
24
+ };
25
+ }
@@ -12,6 +12,7 @@ export * from './i-tree-view.event';
12
12
  export * from './i-pickup-view.event';
13
13
  export * from './i-mpickup-view.event';
14
14
  export * from './i-pickup-grid-view.event';
15
+ export * from './i-pickup-data-view.event';
15
16
  export * from './i-wf-edit-view.event';
16
17
  export * from './i-wf-dyna-edit-view.event';
17
18
  export * from './i-wf-dyna-edit-view3.event';
@@ -0,0 +1,22 @@
1
+ import { IDataViewState } from './i-data-view.state';
2
+
3
+ /**
4
+ * 表格选择视图UI状态
5
+ *
6
+ * @author zk
7
+ * @date 2023-05-25 05:05:43
8
+ * @export
9
+ * @interface IPickupDataViewState
10
+ * @extends {IGridViewState}
11
+ */
12
+ export interface IPickupDataViewState extends IDataViewState {
13
+ /**
14
+ * 是否单选
15
+ *
16
+ * @author zk
17
+ * @date 2023-05-26 05:05:02
18
+ * @type {boolean}
19
+ * @memberof IPickupDataViewState
20
+ */
21
+ singleSelect: boolean;
22
+ }
@@ -9,6 +9,7 @@ export * from './i-opt-view.state';
9
9
  export * from './i-mpickup-view.state';
10
10
  export * from './i-pickup-view.state';
11
11
  export * from './i-pickup-grid-view.state';
12
+ export * from './i-pickup-data-view.state';
12
13
  export * from './i-tab-exp-view.state';
13
14
  export * from './i-exp-view.state';
14
15
  export * from './i-grid-exp-view.state';
@@ -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
  }