@ibiz-template/runtime 0.2.5 → 0.2.6

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 (67) hide show
  1. package/dist/index.esm.js +123 -32
  2. package/dist/index.system.min.js +1 -1
  3. package/dist/index.system.min.js.map +1 -1
  4. package/out/controller/common/control/control.controller.d.ts +13 -0
  5. package/out/controller/common/control/control.controller.d.ts.map +1 -1
  6. package/out/controller/common/control/control.controller.js +33 -2
  7. package/out/controller/control/dashboard/dashboard.controller.d.ts.map +1 -1
  8. package/out/controller/control/dashboard/dashboard.controller.js +9 -1
  9. package/out/controller/control/dashboard/portlet/actionbar-portlet/actionbar-portlet.controller.d.ts +5 -0
  10. package/out/controller/control/dashboard/portlet/actionbar-portlet/actionbar-portlet.controller.d.ts.map +1 -0
  11. package/out/controller/control/dashboard/portlet/actionbar-portlet/actionbar-portlet.controller.js +3 -0
  12. package/out/controller/control/dashboard/portlet/actionbar-portlet/index.d.ts +2 -0
  13. package/out/controller/control/dashboard/portlet/actionbar-portlet/index.d.ts.map +1 -0
  14. package/out/controller/control/dashboard/portlet/actionbar-portlet/index.js +1 -0
  15. package/out/controller/control/dashboard/portlet/html-portlet/html-portlet.controller.d.ts +5 -0
  16. package/out/controller/control/dashboard/portlet/html-portlet/html-portlet.controller.d.ts.map +1 -0
  17. package/out/controller/control/dashboard/portlet/html-portlet/html-portlet.controller.js +3 -0
  18. package/out/controller/control/dashboard/portlet/html-portlet/index.d.ts +2 -0
  19. package/out/controller/control/dashboard/portlet/html-portlet/index.d.ts.map +1 -0
  20. package/out/controller/control/dashboard/portlet/html-portlet/index.js +1 -0
  21. package/out/controller/control/dashboard/portlet/index.d.ts +4 -0
  22. package/out/controller/control/dashboard/portlet/index.d.ts.map +1 -1
  23. package/out/controller/control/dashboard/portlet/index.js +4 -0
  24. package/out/controller/control/dashboard/portlet/list-portlet/index.d.ts +2 -0
  25. package/out/controller/control/dashboard/portlet/list-portlet/index.d.ts.map +1 -0
  26. package/out/controller/control/dashboard/portlet/list-portlet/index.js +1 -0
  27. package/out/controller/control/dashboard/portlet/list-portlet/list-portlet.controller.d.ts +5 -0
  28. package/out/controller/control/dashboard/portlet/list-portlet/list-portlet.controller.d.ts.map +1 -0
  29. package/out/controller/control/dashboard/portlet/list-portlet/list-portlet.controller.js +3 -0
  30. package/out/controller/control/dashboard/portlet/rawitem-portlet/index.d.ts +2 -0
  31. package/out/controller/control/dashboard/portlet/rawitem-portlet/index.d.ts.map +1 -0
  32. package/out/controller/control/dashboard/portlet/rawitem-portlet/index.js +1 -0
  33. package/out/controller/control/dashboard/portlet/rawitem-portlet/rawitem-portlet.controller.d.ts +5 -0
  34. package/out/controller/control/dashboard/portlet/rawitem-portlet/rawitem-portlet.controller.d.ts.map +1 -0
  35. package/out/controller/control/dashboard/portlet/rawitem-portlet/rawitem-portlet.controller.js +3 -0
  36. package/out/controller/control/form/form-detail/form-detail/form-detail.controller.d.ts +2 -2
  37. package/out/controller/control/form/form-detail/form-detail/form-detail.controller.d.ts.map +1 -1
  38. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl-content-type.controller.d.ts.map +1 -1
  39. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl-content-type.controller.js +11 -2
  40. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl.controller.d.ts +2 -8
  41. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl.controller.d.ts.map +1 -1
  42. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl.controller.js +9 -10
  43. package/out/controller/control/grid/grid/grid.controller.d.ts +17 -1
  44. package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
  45. package/out/controller/control/grid/grid/grid.controller.js +37 -9
  46. package/out/interface/controller/controller/control/i-control.controller.d.ts +11 -0
  47. package/out/interface/controller/controller/control/i-control.controller.d.ts.map +1 -1
  48. package/out/service/utils/res-path/res-path.d.ts.map +1 -1
  49. package/out/service/utils/res-path/res-path.js +4 -2
  50. package/package.json +3 -3
  51. package/src/controller/common/control/control.controller.ts +50 -3
  52. package/src/controller/control/dashboard/dashboard.controller.ts +11 -1
  53. package/src/controller/control/dashboard/portlet/actionbar-portlet/actionbar-portlet.controller.ts +4 -0
  54. package/src/controller/control/dashboard/portlet/actionbar-portlet/index.ts +1 -0
  55. package/src/controller/control/dashboard/portlet/html-portlet/html-portlet.controller.ts +4 -0
  56. package/src/controller/control/dashboard/portlet/html-portlet/index.ts +1 -0
  57. package/src/controller/control/dashboard/portlet/index.ts +4 -0
  58. package/src/controller/control/dashboard/portlet/list-portlet/index.ts +1 -0
  59. package/src/controller/control/dashboard/portlet/list-portlet/list-portlet.controller.ts +4 -0
  60. package/src/controller/control/dashboard/portlet/rawitem-portlet/index.ts +1 -0
  61. package/src/controller/control/dashboard/portlet/rawitem-portlet/rawitem-portlet.controller.ts +4 -0
  62. package/src/controller/control/form/form-detail/form-detail/form-detail.controller.ts +2 -2
  63. package/src/controller/control/form/form-detail/form-mdctrl/form-mdctrl-content-type.controller.ts +9 -2
  64. package/src/controller/control/form/form-detail/form-mdctrl/form-mdctrl.controller.ts +12 -11
  65. package/src/controller/control/grid/grid/grid.controller.ts +46 -15
  66. package/src/interface/controller/controller/control/i-control.controller.ts +9 -0
  67. package/src/service/utils/res-path/res-path.ts +4 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/runtime",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "控制器包",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -29,7 +29,7 @@
29
29
  "author": "chitanda",
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
- "@ibiz-template/core": "^0.2.4",
32
+ "@ibiz-template/core": "^0.2.6",
33
33
  "@ibiz/model-core": "^0.0.19",
34
34
  "@types/path-browserify": "^1.0.0",
35
35
  "@types/qs": "^6.9.8",
@@ -59,5 +59,5 @@
59
59
  "qx-util": "^0.4.8",
60
60
  "ramda": "^0.29.0"
61
61
  },
62
- "gitHead": "fab2e0edf52082dcbd450b48716dac8b63809b3f"
62
+ "gitHead": "9e2ff8788567c10c7f048f95797e1a533b0027e8"
63
63
  }
@@ -1,5 +1,10 @@
1
- import { IControl, IControlLogic, IViewLayoutPanel } from '@ibiz/model-core';
2
- import { NoticeError } from '@ibiz-template/core';
1
+ import {
2
+ IControl,
3
+ IControlLogic,
4
+ IMDControl,
5
+ IViewLayoutPanel,
6
+ } from '@ibiz/model-core';
7
+ import { IBizContext, IBizParams, NoticeError } from '@ibiz-template/core';
3
8
  import { isNil } from 'ramda';
4
9
  import { notNilEmpty } from 'qx-util';
5
10
  import { BaseController } from '..';
@@ -82,6 +87,8 @@ export class ControlController<
82
87
  */
83
88
  providers: { [key: string]: IProvider } = {};
84
89
 
90
+ declare params: IBizParams;
91
+
85
92
  /**
86
93
  * Creates an instance of ControlController.
87
94
  *
@@ -92,7 +99,12 @@ export class ControlController<
92
99
  * @param {IParams} [params={}]
93
100
  */
94
101
  constructor(model: T, context: IContext, params: IParams, ctx: CTX) {
95
- super(model, context, params, ctx);
102
+ super(
103
+ model,
104
+ IBizContext.create({}, context),
105
+ new IBizParams({}, params),
106
+ ctx,
107
+ );
96
108
  this.registerToCtx();
97
109
  const panelModel = ibiz.util.layoutPanel.get(
98
110
  `${model.controlType}_DEFAULT`,
@@ -100,6 +112,8 @@ export class ControlController<
100
112
  if (panelModel) {
101
113
  this.controlPanel = panelModel;
102
114
  }
115
+
116
+ this.updateContextParams({});
103
117
  }
104
118
 
105
119
  /**
@@ -170,6 +184,39 @@ export class ControlController<
170
184
  if (this.scheduler) {
171
185
  this.scheduler.destroy();
172
186
  }
187
+ this.params.destroy();
188
+ }
189
+
190
+ /**
191
+ * 处理上下文和导航参数相关的,如自定义导航参数的处理
192
+ *
193
+ * @author lxm
194
+ * @date 2022-09-08 15:09:47
195
+ * @protected
196
+ */
197
+ updateContextParams(opts: { context?: IContext; params?: IParams }): void {
198
+ // 不改变引用的情况下,重置控制器里的上下文和视图参数。
199
+ if (opts.context) {
200
+ this.context.reset({}, opts.context);
201
+ }
202
+ if (opts.params) {
203
+ this.params.reset({}, opts.params);
204
+ }
205
+
206
+ const { controlNavContexts, controlNavParams } = this.model as IMDControl;
207
+ // 处理自定义导航上下文
208
+ let context = {};
209
+ if (notNilEmpty(controlNavContexts)) {
210
+ context = convertNavData(controlNavContexts!, this.params, this.context);
211
+ }
212
+ Object.assign(this.context, context);
213
+
214
+ // 处理自定义视图参数
215
+ let params = {};
216
+ if (notNilEmpty(controlNavParams)) {
217
+ params = convertNavData(controlNavParams!, this.params, this.context);
218
+ }
219
+ Object.assign(this.params, params);
173
220
  }
174
221
 
175
222
  /**
@@ -84,9 +84,19 @@ export class DashboardController
84
84
  if (!portletModels?.length) {
85
85
  return;
86
86
  }
87
+ // 这块只初始化子门户部件,忽略子门户部件里面嵌入的部件
88
+ const ignorePortletTypes: string[] = [
89
+ ControlType.CHART,
90
+ ControlType.APP_MENU,
91
+ ControlType.TOOLBAR,
92
+ ControlType.LIST,
93
+ ];
87
94
  await Promise.all(
88
95
  portletModels.map(async portlet => {
89
- if (portlet.controlType === ControlType.CHART) {
96
+ if (
97
+ portlet.controlType &&
98
+ ignorePortletTypes.includes(portlet.controlType)
99
+ ) {
90
100
  return;
91
101
  }
92
102
  const provider = await getPortletProvider(portlet);
@@ -0,0 +1,4 @@
1
+ import { IDBToolbarPortlet } from '@ibiz/model-core';
2
+ import { PortletPartController } from '../portlet-part/portlet-part.controller';
3
+
4
+ export class ActionBarPortletController extends PortletPartController<IDBToolbarPortlet> {}
@@ -0,0 +1 @@
1
+ export * from './actionbar-portlet.controller';
@@ -0,0 +1,4 @@
1
+ import { IDBHtmlPortletPart } from '@ibiz/model-core';
2
+ import { PortletPartController } from '../portlet-part/portlet-part.controller';
3
+
4
+ export class HtmlPortletController extends PortletPartController<IDBHtmlPortletPart> {}
@@ -0,0 +1 @@
1
+ export * from './html-portlet.controller';
@@ -3,3 +3,7 @@ export * from './container-portlet';
3
3
  export * from './view-portlet';
4
4
  export * from './menu-portlet';
5
5
  export * from './chart-portlet';
6
+ export * from './actionbar-portlet';
7
+ export * from './html-portlet';
8
+ export * from './list-portlet';
9
+ export * from './rawitem-portlet';
@@ -0,0 +1 @@
1
+ export * from './list-portlet.controller';
@@ -0,0 +1,4 @@
1
+ import { IDBListPortletPart } from '@ibiz/model-core';
2
+ import { PortletPartController } from '../portlet-part/portlet-part.controller';
3
+
4
+ export class ListPortletController extends PortletPartController<IDBListPortletPart> {}
@@ -0,0 +1 @@
1
+ export * from './rawitem-portlet.controller';
@@ -0,0 +1,4 @@
1
+ import { IDBRawItemPortletPart } from '@ibiz/model-core';
2
+ import { PortletPartController } from '../portlet-part/portlet-part.controller';
3
+
4
+ export class RawItemPortletController extends PortletPartController<IDBRawItemPortletPart> {}
@@ -7,8 +7,8 @@ import {
7
7
  import { calcLayoutHeightWidth, calcDynaClass } from '../../../../../model';
8
8
  import { verifyFormGroupLogic } from '../../../../../utils';
9
9
  import { FormNotifyState } from '../../../../constant';
10
- import { FormController } from '../../form/form.controller';
11
10
  import { FormDetailState } from './form-detail.state';
11
+ import { FormController } from '../../form';
12
12
 
13
13
  export class FormDetailController<T extends IDEFormDetail = IDEFormDetail>
14
14
  implements IFormDetailController
@@ -45,7 +45,7 @@ export class FormDetailController<T extends IDEFormDetail = IDEFormDetail>
45
45
  *
46
46
  * @author lxm
47
47
  * @date 2022-08-24 22:08:59
48
- * @type {FormController}
48
+ * @type {IFormDetailContainerController}
49
49
  */
50
50
  readonly parent?: IFormDetailContainerController;
51
51
 
@@ -114,13 +114,20 @@ export class FormMDCtrlContentTypeController {
114
114
  const name =
115
115
  this.model.appDEFieldId || this.model.fieldName || this.model.id;
116
116
  if (name) {
117
+ const data = this.parent.data[name];
117
118
  if (
118
119
  this.model.contentType === 'REPEATER' &&
119
120
  this.model.detailStyle === 'STYLE3'
120
121
  ) {
121
- this.parent.state.contentCtrlData = this.parent.data[name] || {};
122
+ if (Array.isArray(data)) {
123
+ this.parent.state.contentCtrlData = {};
124
+ } else {
125
+ this.parent.state.contentCtrlData = data || {};
126
+ }
127
+ } else if (!Array.isArray(data)) {
128
+ this.parent.state.contentCtrlData = [];
122
129
  } else {
123
- this.parent.state.contentCtrlData = this.parent.data[name] || [];
130
+ this.parent.state.contentCtrlData = data || [];
124
131
  }
125
132
  }
126
133
  }
@@ -9,6 +9,7 @@ import { FormMDCtrlRepeaterFormOneController } from './form-mdctrl-repeater/form
9
9
  import { FormMDCtrlRepeaterFormController } from './form-mdctrl-repeater/form-mdctrl-repeater-form/form-mdctrl-repeater-form.controller';
10
10
  import { FormMDCtrlRepeaterGridController } from './form-mdctrl-repeater/form-mdctrl-repeater-grid/form-mdctrl-repeater-grid.controller';
11
11
  import { FormMDCtrlState } from './form-mdctrl.state';
12
+ import { EditFormController } from '../../edit-form';
12
13
 
13
14
  /**
14
15
  * 表单多数据部件控制器
@@ -30,6 +31,8 @@ export class FormMDCtrlController extends FormDetailController<IDEFormMDCtrl> {
30
31
  */
31
32
  declare state: FormMDCtrlState;
32
33
 
34
+ declare form: EditFormController;
35
+
33
36
  /**
34
37
  * Creates an instance of FormMDCtrlController.
35
38
  *
@@ -101,6 +104,15 @@ export class FormMDCtrlController extends FormDetailController<IDEFormMDCtrl> {
101
104
  if (this.mdCtrlContentController) {
102
105
  await this.mdCtrlContentController.onInit();
103
106
  }
107
+ if (this.form.state.isLoaded) {
108
+ this.mdCtrlContentController.initData();
109
+ }
110
+ this.form.evt.on('onLoadDraftSuccess', () => {
111
+ this.mdCtrlContentController.initData();
112
+ });
113
+ this.form.evt.on('onLoadSuccess', () => {
114
+ this.mdCtrlContentController.initData();
115
+ });
104
116
  }
105
117
 
106
118
  /**
@@ -118,17 +130,6 @@ export class FormMDCtrlController extends FormDetailController<IDEFormMDCtrl> {
118
130
  }
119
131
  }
120
132
 
121
- /**
122
- * 加载数据,要在表单加载完成之后再去加载
123
- *
124
- * @author zk
125
- * @date 2023-07-28 11:07:09
126
- * @memberof FormMDCtrlController
127
- */
128
- async loadData(): Promise<void> {
129
- await this.mdCtrlContentController.initData();
130
- }
131
-
132
133
  /**
133
134
  * 表单校验,通知子表单进行校验
134
135
  *
@@ -25,6 +25,7 @@ import {
25
25
  IGridColumnProvider,
26
26
  CodeListItem,
27
27
  MDCtrlLoadParams,
28
+ IGridRowState,
28
29
  } from '../../../../interface';
29
30
  import { calcDeCodeNameById } from '../../../../model';
30
31
  import { getGridColumnProvider } from '../../../../register';
@@ -393,9 +394,7 @@ export class GridController
393
394
  afterRemove(data: IData): void {
394
395
  super.afterRemove(data);
395
396
  // 删除this.state.rows里的表格行数据
396
- const index = this.state.rows.findIndex(
397
- item => item.data.srfkey === data.srfkey,
398
- );
397
+ const index = this.findRowStateIndex(data);
399
398
  this.state.rows.splice(index, 1);
400
399
 
401
400
  // 删除分组里的那条数据
@@ -419,18 +418,21 @@ export class GridController
419
418
  */
420
419
  async newRow(): Promise<void> {
421
420
  const { enableRowEdit, enableRowNew } = this.model;
421
+ const { editShowMode } = ibiz.config.grid;
422
422
  if (
423
423
  !enableRowEdit ||
424
424
  !enableRowNew ||
425
- ibiz.config.grid.editShowMode !== 'row'
425
+ !['row', 'all'].includes(editShowMode)
426
426
  ) {
427
427
  ibiz.log.error('不支持新建行');
428
428
  return;
429
429
  }
430
430
 
431
- const editingRow = this.state.rows.find(item => item.showRowEdit);
432
- if (editingRow) {
433
- throw new RuntimeError('请先完成当前行编辑中的行的操作');
431
+ if (editShowMode === 'row') {
432
+ const editingRow = this.state.rows.find(item => item.showRowEdit);
433
+ if (editingRow) {
434
+ throw new RuntimeError('请先完成当前行编辑中的行的操作');
435
+ }
434
436
  }
435
437
 
436
438
  const queryParams = { ...this.params };
@@ -456,7 +458,11 @@ export class GridController
456
458
  const newRow = new GridRowState(draftData, this);
457
459
  this.state.rows.unshift(newRow);
458
460
  this.gridStateNotify(newRow, GridNotifyState.DRAFT);
459
- this.switchRowEdit(this.state.rows[0], true);
461
+
462
+ if (editShowMode === 'row') {
463
+ this.switchRowEdit(this.state.rows[0], true);
464
+ }
465
+
460
466
  this.actionNotification('GETDRAFTSUCCESS', { data: draftData });
461
467
  }
462
468
 
@@ -472,9 +478,10 @@ export class GridController
472
478
  if (this.state.isSimple) {
473
479
  return;
474
480
  }
475
- const rowState = this.state.rows.find(
476
- item => item.data.srfkey === data.srfkey,
477
- );
481
+
482
+ const isCreate = data.srfuf === Srfuf.CREATE;
483
+
484
+ const rowState = this.findRowState(data);
478
485
  if (!rowState) {
479
486
  throw new RuntimeError('行数据不存在');
480
487
  }
@@ -495,7 +502,6 @@ export class GridController
495
502
  }
496
503
  await this.startLoading();
497
504
  let res;
498
- const isCreate = data.srfuf === Srfuf.CREATE;
499
505
  const deName = calcDeCodeNameById(this.model.appDataEntityId!);
500
506
  const tempContext = this.context.clone();
501
507
  tempContext[deName] = data.srfkey;
@@ -514,9 +520,7 @@ export class GridController
514
520
  await this.endLoading();
515
521
  }
516
522
  // 后续处理
517
- const index = this.state.items.findIndex(
518
- item => item.srfkey === data.srfkey,
519
- );
523
+ const index = this.findRowStateIndex(data);
520
524
  this.state.items.splice(index, 1, res.data);
521
525
  rowState.data = res.data;
522
526
  rowState.modified = false;
@@ -1035,4 +1039,31 @@ export class GridController
1035
1039
  });
1036
1040
  return result;
1037
1041
  }
1042
+
1043
+ /**
1044
+ * 查找rowState
1045
+ * @author lxm
1046
+ * @date 2023-10-27 07:27:48
1047
+ * @param {IData} data
1048
+ * @return {*} {(IGridRowState)}
1049
+ */
1050
+ findRowStateIndex(data: IData): number {
1051
+ const isCreate = data.srfuf === Srfuf.CREATE;
1052
+ const compareKey = isCreate ? 'tempsrfkey' : 'srfkey';
1053
+ return this.state.rows.findIndex(
1054
+ item => item.data[compareKey] === data[compareKey],
1055
+ );
1056
+ }
1057
+
1058
+ /**
1059
+ * 查找rowState
1060
+ * @author lxm
1061
+ * @date 2023-10-27 07:27:48
1062
+ * @param {IData} data
1063
+ * @return {*} {(IGridRowState | undefined)}
1064
+ */
1065
+ findRowState(data: IData): IGridRowState | undefined {
1066
+ const index = this.findRowStateIndex(data);
1067
+ return index !== -1 ? this.state.rows[index] : undefined;
1068
+ }
1038
1069
  }
@@ -49,4 +49,13 @@ export interface IControlController<
49
49
  * @date 2022-09-19 14:09:09
50
50
  */
51
51
  endLoading(): Promise<void>;
52
+
53
+ /**
54
+ * 在不改变引用的前提下,更新上下文和导航参数
55
+ * 并处理如自定义导航参数的后续处理
56
+ * @author lxm
57
+ * @date 2023-10-27 01:47:59
58
+ * @param {{ context?: IContext; params?: IParams }} opts
59
+ */
60
+ updateContextParams(opts: { context?: IContext; params?: IParams }): void;
52
61
  }
@@ -1,7 +1,7 @@
1
1
  import { IAppDataEntity } from '@ibiz/model-core';
2
2
 
3
3
  // 匹配 ${} 中间的内容
4
- const reg = /(?<=\$\{)(.*?)(?=\})/g;
4
+ const reg = /\$\{(.*?)\}/g;
5
5
 
6
6
  /**
7
7
  * 获取匹配的资源路径
@@ -23,9 +23,11 @@ export function getMatchResPath(
23
23
  const pathItems = entity.requestPaths || [];
24
24
  // 获取所有的路径需要匹配的参数
25
25
  const items: { path: string; keys: string[] }[] = pathItems.map(str => {
26
+ const match = str.match(reg);
27
+ const keys = match?.map(item => item.substring(2, item.length - 1)) || [];
26
28
  return {
27
29
  path: str,
28
- keys: str.match(reg) || [],
30
+ keys,
29
31
  };
30
32
  });
31
33
  // 过滤掉所有不能满足填充的路径, 并且按照填充参数个数排序,填充参数最多的优先依次递减排序