@ibiz-template/runtime 0.1.18 → 0.1.20

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 (123) hide show
  1. package/dist/index.esm.js +407 -147
  2. package/dist/index.system.min.js +1 -1
  3. package/dist/index.system.min.js.map +1 -1
  4. package/out/app-hub.d.ts +9 -0
  5. package/out/app-hub.d.ts.map +1 -1
  6. package/out/app-hub.js +14 -0
  7. package/out/application.d.ts.map +1 -1
  8. package/out/application.js +5 -12
  9. package/out/controller/common/control/control.controller.d.ts +13 -0
  10. package/out/controller/common/control/control.controller.d.ts.map +1 -1
  11. package/out/controller/common/control/control.controller.js +58 -0
  12. package/out/controller/common/control/md-control.controller.d.ts +7 -0
  13. package/out/controller/common/control/md-control.controller.d.ts.map +1 -1
  14. package/out/controller/common/control/md-control.controller.js +27 -2
  15. package/out/controller/control/dashboard/dashboard.controller.d.ts.map +1 -1
  16. package/out/controller/control/dashboard/dashboard.controller.js +3 -3
  17. package/out/controller/control/data-view/data-view.controller.d.ts.map +1 -1
  18. package/out/controller/control/data-view/data-view.controller.js +2 -1
  19. package/out/controller/control/form/edit-form/edit-form.controller.d.ts.map +1 -1
  20. package/out/controller/control/form/edit-form/edit-form.controller.js +54 -13
  21. package/out/controller/control/form/form/form.controller.d.ts +4 -0
  22. package/out/controller/control/form/form/form.controller.d.ts.map +1 -1
  23. package/out/controller/control/form/form/form.controller.js +7 -3
  24. package/out/controller/control/form/search-form/search-form.controller.d.ts.map +1 -1
  25. package/out/controller/control/form/search-form/search-form.controller.js +11 -1
  26. package/out/controller/control/grid/grid/grid.controller.d.ts +1 -1
  27. package/out/controller/control/grid/grid/grid.controller.d.ts.map +1 -1
  28. package/out/controller/control/grid/grid/grid.controller.js +43 -14
  29. package/out/controller/control/list/list.controller.d.ts.map +1 -1
  30. package/out/controller/control/list/list.controller.js +2 -1
  31. package/out/controller/control/tree/tree.controller.d.ts.map +1 -1
  32. package/out/controller/control/tree/tree.controller.js +4 -1
  33. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts +9 -0
  34. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts.map +1 -1
  35. package/out/interface/provider/model-loader.provider.d.ts +9 -0
  36. package/out/interface/provider/model-loader.provider.d.ts.map +1 -1
  37. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts +1 -0
  38. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts.map +1 -1
  39. package/out/logic-scheduler/executor/app-ui-logic-executor.js +33 -4
  40. package/out/logic-scheduler/trigger/control-event-trigger.js +1 -1
  41. package/out/logic-scheduler/trigger/view-event-trigger.js +1 -1
  42. package/out/model/data-entity/data-entity.d.ts +11 -0
  43. package/out/model/data-entity/data-entity.d.ts.map +1 -1
  44. package/out/model/data-entity/data-entity.js +14 -0
  45. package/out/model/index.d.ts +1 -0
  46. package/out/model/index.d.ts.map +1 -1
  47. package/out/model/index.js +1 -0
  48. package/out/model/panel/data-container.d.ts +11 -0
  49. package/out/model/panel/data-container.d.ts.map +1 -0
  50. package/out/model/panel/data-container.js +12 -0
  51. package/out/model/panel/index.d.ts +2 -0
  52. package/out/model/panel/index.d.ts.map +1 -0
  53. package/out/model/panel/index.js +1 -0
  54. package/out/service/app-data-entity/app-data-entity.d.ts +1 -0
  55. package/out/service/app-data-entity/app-data-entity.d.ts.map +1 -1
  56. package/out/service/app-data-entity/app-data-entity.js +11 -1
  57. package/out/service/dto/method.dto.d.ts +2 -1
  58. package/out/service/dto/method.dto.d.ts.map +1 -1
  59. package/out/service/dto/method.dto.js +9 -4
  60. package/out/service/service/authority/authority.service.js +1 -1
  61. package/out/service/service/entity/method/de-action.d.ts.map +1 -1
  62. package/out/service/service/entity/method/de-action.js +2 -1
  63. package/out/service/service/entity/method/fetch.d.ts.map +1 -1
  64. package/out/service/service/entity/method/fetch.js +2 -1
  65. package/out/service/service/entity/method/method-input.d.ts +6 -6
  66. package/out/service/service/entity/method/method-input.d.ts.map +1 -1
  67. package/out/service/service/entity/method/method-input.js +10 -6
  68. package/out/service/service/entity/method/method-renturn.d.ts +6 -5
  69. package/out/service/service/entity/method/method-renturn.d.ts.map +1 -1
  70. package/out/service/service/entity/method/method-renturn.js +10 -5
  71. package/out/service/service/entity/method/method.d.ts.map +1 -1
  72. package/out/service/service/entity/method/method.js +5 -2
  73. package/out/service/service/entity/util/util.d.ts +12 -0
  74. package/out/service/service/entity/util/util.d.ts.map +1 -0
  75. package/out/service/service/entity/util/util.js +13 -0
  76. package/out/service/vo/control.vo.js +2 -2
  77. package/out/ui-logic/ui-logic-node/msg-box-node/msg-box-node.d.ts.map +1 -1
  78. package/out/ui-logic/ui-logic-node/msg-box-node/msg-box-node.js +0 -1
  79. package/out/utils/handlebars/helpers/index.d.ts.map +1 -1
  80. package/out/utils/handlebars/helpers/index.js +4 -2
  81. package/out/utils/handlebars/helpers/json/json-parse.d.ts +16 -0
  82. package/out/utils/handlebars/helpers/json/json-parse.d.ts.map +1 -0
  83. package/out/utils/handlebars/helpers/json/json-parse.js +19 -0
  84. package/out/utils/handlebars/helpers/json/{json.d.ts → json-stringify.d.ts} +3 -3
  85. package/out/utils/handlebars/helpers/json/json-stringify.d.ts.map +1 -0
  86. package/out/utils/handlebars/helpers/json/{json.js → json-stringify.js} +2 -2
  87. package/package.json +3 -3
  88. package/src/app-hub.ts +15 -0
  89. package/src/application.ts +8 -17
  90. package/src/controller/common/control/control.controller.ts +67 -0
  91. package/src/controller/common/control/md-control.controller.ts +28 -2
  92. package/src/controller/control/dashboard/dashboard.controller.ts +3 -3
  93. package/src/controller/control/data-view/data-view.controller.ts +2 -1
  94. package/src/controller/control/form/edit-form/edit-form.controller.ts +64 -17
  95. package/src/controller/control/form/form/form.controller.ts +11 -3
  96. package/src/controller/control/form/search-form/search-form.controller.ts +10 -1
  97. package/src/controller/control/grid/grid/grid.controller.ts +54 -18
  98. package/src/controller/control/list/list.controller.ts +2 -1
  99. package/src/controller/control/tree/tree.controller.ts +7 -1
  100. package/src/interface/common/i-app-hub-service/i-app-hub-service.ts +10 -0
  101. package/src/interface/provider/model-loader.provider.ts +10 -0
  102. package/src/logic-scheduler/executor/app-ui-logic-executor.ts +44 -7
  103. package/src/logic-scheduler/trigger/control-event-trigger.ts +1 -1
  104. package/src/logic-scheduler/trigger/view-event-trigger.ts +1 -1
  105. package/src/model/data-entity/data-entity.ts +17 -0
  106. package/src/model/index.ts +1 -0
  107. package/src/model/panel/data-container.ts +18 -0
  108. package/src/model/panel/index.ts +1 -0
  109. package/src/service/app-data-entity/app-data-entity.ts +13 -1
  110. package/src/service/dto/method.dto.ts +8 -3
  111. package/src/service/service/authority/authority.service.ts +1 -1
  112. package/src/service/service/entity/method/de-action.ts +2 -1
  113. package/src/service/service/entity/method/fetch.ts +2 -1
  114. package/src/service/service/entity/method/method-input.ts +11 -6
  115. package/src/service/service/entity/method/method-renturn.ts +11 -5
  116. package/src/service/service/entity/method/method.ts +5 -2
  117. package/src/service/service/entity/util/util.ts +17 -0
  118. package/src/service/vo/control.vo.ts +2 -2
  119. package/src/ui-logic/ui-logic-node/msg-box-node/msg-box-node.ts +0 -1
  120. package/src/utils/handlebars/helpers/index.ts +4 -2
  121. package/src/utils/handlebars/helpers/json/json-parse.ts +21 -0
  122. package/src/utils/handlebars/helpers/json/{json.ts → json-stringify.ts} +2 -2
  123. package/out/utils/handlebars/helpers/json/json.d.ts.map +0 -1
@@ -14,6 +14,7 @@ import {
14
14
  } from '../../../../interface';
15
15
  import { hasDeCodeName } from '../../../../model';
16
16
  import { Srfuf, ControlVO } from '../../../../service';
17
+ import { ScriptFactory } from '../../../../utils';
17
18
  import { FormNotifyState } from '../../../constant';
18
19
  import { FormController } from '../form';
19
20
  import { EditFormService } from './edit-form.service';
@@ -78,6 +79,9 @@ export class EditFormController
78
79
  res = await this.service.getDraft(this.context, queryParams);
79
80
  } catch (error) {
80
81
  await this.evt.emit('onLoadDraftError', undefined);
82
+ this.actionNotification('GETDRAFTERROR', {
83
+ error: error as Error,
84
+ });
81
85
  throw error;
82
86
  } finally {
83
87
  await this.endLoading();
@@ -90,6 +94,7 @@ export class EditFormController
90
94
  this.formStateNotify(FormNotifyState.DRAFT);
91
95
 
92
96
  await this.evt.emit('onLoadDraftSuccess', undefined);
97
+ this.actionNotification('GETDRAFTSUCCESS');
93
98
  this.state.isLoaded = true;
94
99
  return this.data;
95
100
  }
@@ -119,6 +124,9 @@ export class EditFormController
119
124
  res = await this.service.get(this.context, queryParams);
120
125
  } catch (error) {
121
126
  await this.evt.emit('onLoadError', undefined);
127
+ this.actionNotification('GETERROR', {
128
+ error: error as Error,
129
+ });
122
130
  throw error;
123
131
  } finally {
124
132
  await this.endLoading();
@@ -129,6 +137,7 @@ export class EditFormController
129
137
  this.formStateNotify(FormNotifyState.LOAD);
130
138
 
131
139
  await this.evt.emit('onLoadSuccess', undefined);
140
+ this.actionNotification('GETSUCCESS');
132
141
  this.state.isLoaded = true;
133
142
  return this.data;
134
143
  }
@@ -152,14 +161,17 @@ export class EditFormController
152
161
  }
153
162
  await this.startLoading();
154
163
  await this.evt.emit('onBeforeSave', undefined);
164
+ const isCreate = this.data.srfuf === Srfuf.CREATE;
155
165
  let res;
156
166
  try {
157
- res =
158
- this.data.srfuf === Srfuf.CREATE
159
- ? await this.service.create(this.context, this.data)
160
- : await this.service.update(this.context, this.data);
167
+ res = isCreate
168
+ ? await this.service.create(this.context, this.data)
169
+ : await this.service.update(this.context, this.data);
161
170
  } catch (error) {
162
171
  await this.evt.emit('onSaveError', undefined);
172
+ this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}ERROR`, {
173
+ error: error as Error,
174
+ });
163
175
  throw error;
164
176
  } finally {
165
177
  await this.endLoading();
@@ -171,7 +183,9 @@ export class EditFormController
171
183
  this.state.modified = false;
172
184
  await this.evt.emit('onSaveSuccess', undefined);
173
185
  this.formStateNotify(FormNotifyState.SAVE);
174
- ibiz.message.success(`${this.data.srfmajortext || ''}保存成功`);
186
+ this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}SUCCESS`, {
187
+ default: `${this.data.srfmajortext || ''}保存成功`,
188
+ });
175
189
  return this.data;
176
190
  }
177
191
 
@@ -202,6 +216,9 @@ export class EditFormController
202
216
  res = await this.service.remove(this.context, this.params);
203
217
  } catch (error) {
204
218
  await this.evt.emit('onRemoveError', undefined);
219
+ this.actionNotification('REMOVEERROR', {
220
+ error: error as Error,
221
+ });
205
222
  throw error;
206
223
  } finally {
207
224
  await this.endLoading();
@@ -213,6 +230,7 @@ export class EditFormController
213
230
  this.state.data = new ControlVO();
214
231
  this.state.modified = false;
215
232
  await this.evt.emit('onRemoveSuccess', undefined);
233
+ this.actionNotification('REMOVESUCCESS');
216
234
 
217
235
  return ok;
218
236
  }
@@ -255,20 +273,39 @@ export class EditFormController
255
273
  throw new RuntimeError(`没找到${formItemUpdateId}表单项更新`);
256
274
  }
257
275
 
258
- const { appDEMethodId, defiupdateDetails } = formItemUpdate;
276
+ const { appDEMethodId, defiupdateDetails, customCode, scriptCode } =
277
+ formItemUpdate;
259
278
  const updateItems = defiupdateDetails!.map(item => item.id!);
260
279
 
261
- const params = { ...this.params, ...this.data.getOrigin() };
262
- const res = await this.service.updateFormItem(
263
- appDEMethodId!,
264
- this.context,
265
- params,
266
- );
267
- const result = res.data;
268
- if (result && updateItems?.length) {
280
+ let updateData: IData; // 要修改的数据
281
+ if (customCode && scriptCode) {
282
+ // 脚本模式获取修改数据
283
+ updateData = ScriptFactory.execScriptFn(
284
+ {
285
+ ...this.getEventArgs(),
286
+ data: this.data,
287
+ },
288
+ scriptCode,
289
+ {
290
+ isAsync: false,
291
+ },
292
+ ) as IData;
293
+ } else {
294
+ // 后台服务获取修改数据
295
+ const params = { ...this.params, ...this.data.getOrigin() };
296
+ const res = await this.service.updateFormItem(
297
+ appDEMethodId!,
298
+ this.context,
299
+ params,
300
+ );
301
+ updateData = res.data;
302
+ }
303
+
304
+ // 修改表单项更新的值
305
+ if (updateData && updateItems?.length) {
269
306
  await Promise.all(
270
307
  updateItems.map(itemName =>
271
- this.setDataValue(itemName, result[itemName]),
308
+ this.setDataValue(itemName, updateData[itemName]),
272
309
  ),
273
310
  );
274
311
  }
@@ -297,10 +334,15 @@ export class EditFormController
297
334
  },
298
335
  this.data,
299
336
  );
337
+ } catch (error) {
338
+ this.actionNotification('WFSTARTERROR', {
339
+ error: error as Error,
340
+ });
341
+ throw error;
300
342
  } finally {
301
343
  await this.endLoading();
302
344
  }
303
- ibiz.message.success('流程启动成功');
345
+ this.actionNotification('WFSTARTSUCCESS', { default: '流程启动成功' });
304
346
  }
305
347
 
306
348
  /**
@@ -326,10 +368,15 @@ export class EditFormController
326
368
  },
327
369
  this.data,
328
370
  );
371
+ } catch (error) {
372
+ this.actionNotification('WFSUBMITERROR', {
373
+ error: error as Error,
374
+ });
375
+ throw error;
329
376
  } finally {
330
377
  await this.endLoading();
331
378
  }
332
- ibiz.message.success('流程提交成功');
379
+ this.actionNotification('WFSUBMITSUCCESS', { default: '流程提交成功' });
333
380
  }
334
381
 
335
382
  async dataChangeNotify(names: string[]): Promise<void> {
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-param-reassign */
2
- import { RuntimeError, debounceAndAsyncMerge } from '@ibiz-template/core';
2
+ import { debounceAndAsyncMerge } from '@ibiz-template/core';
3
3
  import { IDEForm, IDEFormDetail } from '@ibiz/model-core';
4
4
  import {
5
5
  IFormState,
@@ -102,9 +102,10 @@ export abstract class FormController<
102
102
  return detail.dataChangeNotify(names);
103
103
  }),
104
104
  );
105
- if (values.find(item => item.status === 'rejected')) {
105
+ const rejectedValue = values.find(item => item.status === 'rejected');
106
+ if (rejectedValue) {
106
107
  ibiz.log.error('dataChangeNotify报错', values);
107
- throw new RuntimeError('数据变更后有错误');
108
+ throw (rejectedValue as PromiseRejectedResult).reason;
108
109
  }
109
110
  }
110
111
 
@@ -268,4 +269,11 @@ export abstract class FormController<
268
269
  // 找不到value为false即全部是true
269
270
  return values.findIndex(value => !value) === -1;
270
271
  }
272
+
273
+ actionNotification(
274
+ tag: string,
275
+ opts?: { default?: string; error?: Error },
276
+ ): void {
277
+ super.actionNotification(tag, { data: this.data, ...(opts || {}) });
278
+ }
271
279
  }
@@ -55,11 +55,20 @@ export class SearchFormController
55
55
  const params = await this.getDraftParams();
56
56
  Object.assign(queryParams, params);
57
57
  await this.evt.emit('onBeforeLoadDraft', { params: queryParams });
58
- const res = await this.service.getDraft(this.context, queryParams);
58
+ let res;
59
+ try {
60
+ res = await this.service.getDraft(this.context, queryParams);
61
+ } catch (error) {
62
+ this.actionNotification('GETDRAFTERROR', {
63
+ error: error as Error,
64
+ });
65
+ throw error;
66
+ }
59
67
  this.state.data = res.data;
60
68
  mergeDefaultInLeft(this.data, params);
61
69
  this.state.isLoaded = true;
62
70
  this.formStateNotify(FormNotifyState.DRAFT);
71
+ this.actionNotification('GETDRAFTSUCCESS');
63
72
  return this.data;
64
73
  }
65
74
 
@@ -430,13 +430,23 @@ export class GridController
430
430
  throw new RuntimeError('请先完成当前行编辑中的行的操作');
431
431
  }
432
432
 
433
- const res = await this.service.getDraft(this.context, this.params);
433
+ let res;
434
+ try {
435
+ res = await this.service.getDraft(this.context, this.params);
436
+ } catch (error) {
437
+ this.actionNotification('GETDRAFTERROR', {
438
+ error: error as Error,
439
+ });
440
+ throw error;
441
+ }
442
+
434
443
  // 加载完后续处理
435
444
  this.state.items.unshift(res.data);
436
445
  const newRow = new GridRowState(res.data, this);
437
446
  this.state.rows.unshift(newRow);
438
447
  this.gridStateNotify(newRow, GridNotifyState.DRAFT);
439
448
  this.switchRowEdit(this.state.rows[0], true);
449
+ this.actionNotification('GETDRAFTSUCCESS', { data: res.data });
440
450
  }
441
451
 
442
452
  /**
@@ -482,6 +492,13 @@ export class GridController
482
492
  res = isCreate
483
493
  ? await this.service.create(tempContext, data)
484
494
  : await this.service.update(tempContext, data);
495
+ } catch (error) {
496
+ await this.evt.emit('onSaveError', undefined);
497
+ this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}ERROR`, {
498
+ error: error as Error,
499
+ data: rowState.data,
500
+ });
501
+ throw error;
485
502
  } finally {
486
503
  await this.endLoading();
487
504
  }
@@ -494,6 +511,10 @@ export class GridController
494
511
  rowState.modified = false;
495
512
 
496
513
  ibiz.message.success(`${res.data.srfmajortext || ''}保存成功`);
514
+ this.actionNotification(`${isCreate ? 'CREATE' : 'UPDATE'}SUCCESS`, {
515
+ default: `${res.data.srfmajortext || ''}保存成功`,
516
+ data: res.data,
517
+ });
497
518
  this.gridStateNotify(rowState, GridNotifyState.SAVE);
498
519
  await this.evt.emit('onSaveSuccess', undefined);
499
520
  }
@@ -670,9 +691,10 @@ export class GridController
670
691
  return column.dataChangeNotify(row, names);
671
692
  }),
672
693
  );
673
- if (values.find(item => item.status === 'rejected')) {
694
+ const rejectedValue = values.find(item => item.status === 'rejected');
695
+ if (rejectedValue) {
674
696
  ibiz.log.error('dataChangeNotify报错', values);
675
- throw new RuntimeError('数据变更后有错误');
697
+ throw (rejectedValue as PromiseRejectedResult).reason;
676
698
  }
677
699
  }
678
700
 
@@ -773,14 +795,16 @@ export class GridController
773
795
  * @param {string} key 排序字段
774
796
  * @param {string} order 排序顺序
775
797
  */
776
- setSort(key?: string, order?: 'asc' | 'desc'): void {
777
- if (key && order) {
778
- super.setSort(key, order);
798
+ setSort(fieldId?: string, order?: 'asc' | 'desc'): void {
799
+ if (fieldId && order) {
800
+ const fieldName = this.fieldIdNameMap.get(fieldId)!.toLowerCase();
801
+ super.setSort(fieldName, order);
779
802
  } else {
780
803
  // 设置默认排序或者置空
781
804
  const { minorSortAppDEFieldId, minorSortDir } = this.model;
782
805
  if (minorSortAppDEFieldId && minorSortDir) {
783
- this.state.sortQuery = `${minorSortAppDEFieldId.toLowerCase()},${minorSortDir.toLowerCase()}`;
806
+ const fieldName = this.fieldIdNameMap.get(minorSortAppDEFieldId)!;
807
+ this.state.sortQuery = `${fieldName.toLowerCase()},${minorSortDir.toLowerCase()}`;
784
808
  } else {
785
809
  this.state.sortQuery = '';
786
810
  }
@@ -807,25 +831,37 @@ export class GridController
807
831
  const { appDEMethodId, degeiupdateDetails, customCode, scriptCode } =
808
832
  findUpdate;
809
833
  const updateItems = degeiupdateDetails!.map(item => item.id!);
834
+
835
+ let updateData: IData; // 要修改的数据
810
836
  if (customCode && scriptCode) {
811
- ScriptFactory.execScriptFn({ data: row.data }, scriptCode, {
812
- isAsync: false,
813
- });
837
+ // 脚本模式获取修改数据
838
+ updateData = ScriptFactory.execScriptFn(
839
+ {
840
+ ...this.getEventArgs(),
841
+ data: row.data,
842
+ },
843
+ scriptCode,
844
+ {
845
+ isAsync: false,
846
+ },
847
+ ) as IData;
814
848
  } else {
849
+ // 后台服务获取修改数据
815
850
  const params = { ...this.params, ...row.data.getOrigin() };
816
851
  const res = await this.service.updateGridEditItem(
817
852
  appDEMethodId!,
818
853
  this.context,
819
854
  params,
820
855
  );
821
- const result = res.data;
822
- if (result && updateItems?.length) {
823
- await Promise.all(
824
- updateItems.map(itemName => {
825
- return this.setRowValue(row, itemName, result![itemName]);
826
- }),
827
- );
828
- }
856
+ updateData = res.data;
857
+ }
858
+ // 修改更新的值
859
+ if (updateData && updateItems?.length) {
860
+ await Promise.all(
861
+ updateItems.map(itemName => {
862
+ return this.setRowValue(row, itemName, updateData![itemName]);
863
+ }),
864
+ );
829
865
  }
830
866
  }
831
867
 
@@ -44,7 +44,8 @@ export class ListController
44
44
  // 设置默认排序或者置空
45
45
  const { minorSortAppDEFieldId, minorSortDir } = this.model;
46
46
  if (minorSortAppDEFieldId && minorSortDir) {
47
- this.state.sortQuery = `${minorSortAppDEFieldId.toLowerCase()},${minorSortDir.toLowerCase()}`;
47
+ const fieldName = this.fieldIdNameMap.get(minorSortAppDEFieldId)!;
48
+ this.state.sortQuery = `${fieldName.toLowerCase()},${minorSortDir.toLowerCase()}`;
48
49
  } else {
49
50
  this.state.sortQuery = '';
50
51
  }
@@ -184,7 +184,13 @@ export class TreeController
184
184
 
185
185
  setSelection(selection: IData[]): void {
186
186
  // todo 当自己点选中时,父节点选不选中,如果选中需要在这边优化
187
- super.setSelection(selection);
187
+
188
+ // 通过id过滤出原始的树节点数据,避免外部使用的时候传入的选中数据有问题。
189
+ const selectionIds = selection.map(item => item.id);
190
+ const filterArr = this.state.items.filter(item =>
191
+ selectionIds.includes(item.id),
192
+ );
193
+ super.setSelection(filterArr);
188
194
  }
189
195
 
190
196
  /**
@@ -105,6 +105,16 @@ export interface IAppHubService {
105
105
  */
106
106
  hasAppView(tag: string): boolean;
107
107
 
108
+ /**
109
+ * 获取应用模型样式内容
110
+ *
111
+ * @author chitanda
112
+ * @date 2023-09-06 10:09:07
113
+ * @param {string} appId
114
+ * @return {*} {(Promise<string | null>)}
115
+ */
116
+ getAppStyle(appId: string): Promise<string | null>;
117
+
108
118
  /**
109
119
  * 根据应用视图 codeName 或 id 获取应用视图模型
110
120
  *
@@ -52,4 +52,14 @@ export interface ModelLoaderProvider {
52
52
  appId: string,
53
53
  codeName: string,
54
54
  ): Promise<IAppDataEntity>;
55
+
56
+ /**
57
+ * 获取应用样式表
58
+ *
59
+ * @author chitanda
60
+ * @date 2023-09-06 10:09:14
61
+ * @param {string} appId
62
+ * @return {*} {(Promise<string | null>)}
63
+ */
64
+ getAppStyle(appId: string): Promise<string | null>;
55
65
  }
@@ -12,6 +12,7 @@ import {
12
12
  import { notNilEmpty } from 'qx-util';
13
13
  import { OpenAppViewCommand } from '../../command';
14
14
  import { IModalData, IUILogicParams } from '../../interface';
15
+ import { getFormTypeFieldName } from '../../model';
15
16
  import { convertNavData } from '../../utils';
16
17
  import { LogicExecutor } from './logic-executor';
17
18
 
@@ -65,13 +66,19 @@ export class AppUILogicExecutor extends LogicExecutor {
65
66
  if (!data?.[0]) {
66
67
  throw new RuntimeError('opendata没有可操作数据!');
67
68
  }
68
- // 准备需要的模型
69
- const openViewRef = appUILogic.openDataAppView;
70
- if (!openViewRef) {
71
- throw new RuntimeModelError(
72
- appUILogic,
73
- 'opendata视图逻辑没有配置默认打开视图',
74
- );
69
+ const openViewRefs = appUILogic.openDataAppViews;
70
+ let openViewRef: IAppUILogicRefViewBase | undefined;
71
+ if (openViewRefs) {
72
+ openViewRef = await this.calcOpenViewRef(appUILogic, parameters);
73
+ } else {
74
+ // 准备需要的模型
75
+ openViewRef = appUILogic.openDataAppView;
76
+ if (!openViewRef) {
77
+ throw new RuntimeModelError(
78
+ appUILogic,
79
+ 'opendata视图逻辑没有配置默认打开视图',
80
+ );
81
+ }
75
82
  }
76
83
  const openView = openViewRef.refAppViewId;
77
84
  if (!openView) {
@@ -231,4 +238,34 @@ export class AppUILogicExecutor extends LogicExecutor {
231
238
  }
232
239
  return findView;
233
240
  }
241
+
242
+ protected async calcOpenViewRef(
243
+ appUILogic: IAppUIOpenDataLogic,
244
+ parameters: IUILogicParams,
245
+ ): Promise<IAppUILogicRefViewBase> {
246
+ const appDataEntityId = parameters.view.model.appDataEntityId!;
247
+ // 表单类型属性
248
+ const formTypeName = await getFormTypeFieldName(appDataEntityId);
249
+ if (!formTypeName) {
250
+ throw new RuntimeModelError(
251
+ appUILogic,
252
+ `${appDataEntityId}实体缺少表单类型应用实体属性`,
253
+ );
254
+ }
255
+ const { data } = parameters;
256
+ // 表单类型值
257
+ const formTypeValue = data[0][formTypeName];
258
+ if (!formTypeValue) {
259
+ throw new RuntimeModelError(appUILogic, '数据源无表单类型应用实体属性值');
260
+ }
261
+ const openViewRefs = appUILogic.openDataAppViews;
262
+ // 根据表单类型值找到实际打开的视图
263
+ const findView = openViewRefs?.find(item => item.refMode === formTypeValue);
264
+ if (!findView) {
265
+ throw new RuntimeError(
266
+ `没有找到与表单类型${formTypeValue}相关的实体的编辑视图`,
267
+ );
268
+ }
269
+ return findView;
270
+ }
234
271
  }
@@ -28,7 +28,7 @@ export class ControlEventTrigger extends LogicTrigger {
28
28
  protected scheduler: LogicScheduler,
29
29
  ) {
30
30
  super(logic, scheduler);
31
- const names = logic.eventNames!.split(',');
31
+ const names = logic.eventNames!.split(';');
32
32
  this.listenEventNames = names.map(
33
33
  name => StudioControlEvents[name as keyof StudioControlEvents] || name,
34
34
  );
@@ -28,7 +28,7 @@ export class ViewEventTrigger extends LogicTrigger {
28
28
  protected scheduler: LogicScheduler,
29
29
  ) {
30
30
  super(logic, scheduler);
31
- const names = logic.eventNames!.split(',');
31
+ const names = logic.eventNames!.split(';');
32
32
  this.listenEventNames = names.map(
33
33
  name => StudioViewEvents[name as keyof StudioViewEvents] || name,
34
34
  );
@@ -52,6 +52,23 @@ export async function getDeACMode(
52
52
  return deACMode;
53
53
  }
54
54
 
55
+ /**
56
+ * 从实体里找到表单类型应用实体属性
57
+ *
58
+ * @author zk
59
+ * @date 2023-09-07 05:09:41
60
+ * @export
61
+ * @param {string} entityId
62
+ * @param {string} [srfappid]
63
+ * @return {*} {(Promise<string | undefined>)}
64
+ */
65
+ export async function getFormTypeFieldName(
66
+ entityId: string,
67
+ ): Promise<string | undefined> {
68
+ const appDataEntity = await ibiz.hub.getAppDataEntity(entityId)!;
69
+ return appDataEntity.formTypeAppDEFieldId;
70
+ }
71
+
55
72
  /**
56
73
  * 从实体里找到实体逻辑
57
74
  * @author lxm
@@ -7,3 +7,4 @@ export * from './tree/index';
7
7
  export * from './grid/index';
8
8
  export * from './form/index';
9
9
  export * from './view/view';
10
+ export * from './panel/index';
@@ -0,0 +1,18 @@
1
+ import { IPanelContainer, IPanelItem } from '@ibiz/model-core';
2
+
3
+ /**
4
+ * 判断面板成员模型是否是数据容器
5
+ * @author lxm
6
+ * @date 2023-09-06 04:56:01
7
+ * @export
8
+ * @param {IPanelItem} panelItem
9
+ * @return {*} {boolean}
10
+ */
11
+ export function isDataContainer(panelItem: IPanelItem): boolean {
12
+ return (
13
+ panelItem.itemType === 'CONTAINER' &&
14
+ ['CONTAINER_MULTIDATA', 'CONTAINER_SINGLEDATA'].includes(
15
+ (panelItem as IPanelContainer).predefinedType!,
16
+ )
17
+ );
18
+ }
@@ -0,0 +1 @@
1
+ export * from './data-container';
@@ -32,6 +32,8 @@ export class AppDataEntity implements IDataEntity {
32
32
 
33
33
  declare srfkey: string;
34
34
 
35
+ declare srfsourcekey: string;
36
+
35
37
  declare srfmajortext: string;
36
38
 
37
39
  get srfuf(): Srfuf {
@@ -87,6 +89,14 @@ export class AppDataEntity implements IDataEntity {
87
89
  return this._data[key] || _srfkey;
88
90
  },
89
91
  });
92
+ Object.defineProperty(this, 'srfsourcekey', {
93
+ set(val: unknown) {
94
+ this._data[key] = val;
95
+ },
96
+ get() {
97
+ return this._data[key];
98
+ },
99
+ });
90
100
  } else {
91
101
  ibiz.log.warn(`实体[${entity.codeName}]未配置主键字段`);
92
102
  }
@@ -162,7 +172,9 @@ export class AppDataEntity implements IDataEntity {
162
172
  * @return {*} {AppDataEntity}
163
173
  */
164
174
  clone(): AppDataEntity {
165
- return new AppDataEntity(this._entity, this._data);
175
+ const entity = new AppDataEntity(this._entity, this._data);
176
+ entity.srfkey = this.srfkey;
177
+ return entity;
166
178
  }
167
179
 
168
180
  /**
@@ -27,6 +27,7 @@ export class MethodDto {
27
27
 
28
28
  constructor(
29
29
  protected entity: IAppDataEntity,
30
+ protected isLocalMode?: boolean,
30
31
  protected dto?: IAppDEMethodDTO,
31
32
  ) {
32
33
  if (dto) {
@@ -102,7 +103,9 @@ export class MethodDto {
102
103
  */
103
104
  async sets(context: IParams, data: IData[]): Promise<AppDataEntity[]> {
104
105
  const service = await this.app!.deService.getService(this.entity.id!);
105
- service.local.clear(context);
106
+ if (this.isLocalMode) {
107
+ service.local.clear(context);
108
+ }
106
109
  return Promise.all(
107
110
  data.map(async datum => {
108
111
  const all = this.fields
@@ -123,7 +126,9 @@ export class MethodDto {
123
126
  await all[i];
124
127
  }
125
128
  const entityData = new AppDataEntity(this.entity, datum);
126
- await service.local.add(context, entityData);
129
+ if (this.isLocalMode) {
130
+ await service.local.add(context, entityData);
131
+ }
127
132
  return entityData;
128
133
  }),
129
134
  );
@@ -150,7 +155,7 @@ export class MethodDto {
150
155
  entity.appDEMethodDTOs || [],
151
156
  field.refAppDEMethodDTOId!,
152
157
  )!;
153
- const dto = new MethodDto(entity, methodDto);
158
+ const dto = new MethodDto(entity, this.isLocalMode, methodDto);
154
159
  this.dtoMap.set(field.codeName!, dto);
155
160
  return dto;
156
161
  }
@@ -117,7 +117,7 @@ export class AuthorityService {
117
117
  */
118
118
  async init(appData = ibiz.appData): Promise<void> {
119
119
  if (!appData) {
120
- throw new RuntimeError('没有appData数据');
120
+ return;
121
121
  }
122
122
  // 设置当前用户拥有的统一标识集合
123
123
  if (appData.unires) {
@@ -8,6 +8,7 @@ import { Method } from './method';
8
8
  import { IDataEntity } from '../../../../interface';
9
9
  import { findDELogic } from '../../../../model';
10
10
  import { execDELogicAction, execFieldLogics } from '../../../../de-logic';
11
+ import { isLocalMode } from '../util/util';
11
12
 
12
13
  /**
13
14
  * 实体行为方法
@@ -31,7 +32,7 @@ export class DEActionMethod extends Method {
31
32
  * @type {boolean}
32
33
  */
33
34
  protected get isLocalMode(): boolean {
34
- return this.method.actionType === 'BUILTIN';
35
+ return isLocalMode(this.method);
35
36
  }
36
37
 
37
38
  async exec(