@ibiz-template/runtime 0.7.41-alpha.123 → 0.7.41-alpha.125

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 (72) hide show
  1. package/dist/index.esm.js +277 -121
  2. package/dist/index.system.min.js +1 -1
  3. package/out/application.d.ts +7 -0
  4. package/out/application.d.ts.map +1 -1
  5. package/out/application.js +21 -0
  6. package/out/config/global-config.d.ts.map +1 -1
  7. package/out/config/global-config.js +1 -0
  8. package/out/controller/control/form/form/form.controller.js +2 -2
  9. package/out/controller/control/form/form-detail/form-item/form-item.controller.d.ts.map +1 -1
  10. package/out/controller/control/form/form-detail/form-item/form-item.controller.js +1 -1
  11. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl-repeater.controller.d.ts +16 -2
  12. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl-repeater.controller.d.ts.map +1 -1
  13. package/out/controller/control/form/form-detail/form-mdctrl/form-mdctrl-repeater.controller.js +45 -4
  14. package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.d.ts.map +1 -1
  15. package/out/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.js +1 -1
  16. package/out/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.d.ts.map +1 -1
  17. package/out/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.js +1 -1
  18. package/out/controller/utils/data-file-util/data-file-util.js +2 -2
  19. package/out/interface/api/common/global-config/i-api-global-common-config.d.ts +9 -0
  20. package/out/interface/api/common/global-config/i-api-global-common-config.d.ts.map +1 -1
  21. package/out/interface/register/i-register-params.d.ts +20 -35
  22. package/out/interface/register/i-register-params.d.ts.map +1 -1
  23. package/out/locale/en/index.d.ts +11 -0
  24. package/out/locale/en/index.d.ts.map +1 -1
  25. package/out/locale/en/index.js +11 -0
  26. package/out/locale/zh-CN/index.d.ts +11 -0
  27. package/out/locale/zh-CN/index.d.ts.map +1 -1
  28. package/out/locale/zh-CN/index.js +11 -0
  29. package/out/logic-scheduler/scheduler/logic-scheduler.d.ts +8 -0
  30. package/out/logic-scheduler/scheduler/logic-scheduler.d.ts.map +1 -1
  31. package/out/logic-scheduler/scheduler/logic-scheduler.js +17 -0
  32. package/out/register/custom-register.d.ts +38 -22
  33. package/out/register/custom-register.d.ts.map +1 -1
  34. package/out/register/custom-register.js +123 -78
  35. package/out/register/helper/control-register.js +2 -2
  36. package/out/register/helper/de-method-register.d.ts +1 -1
  37. package/out/register/helper/de-method-register.d.ts.map +1 -1
  38. package/out/register/helper/de-method-register.js +4 -4
  39. package/out/register/helper/editor-register.d.ts +2 -3
  40. package/out/register/helper/editor-register.d.ts.map +1 -1
  41. package/out/register/helper/editor-register.js +4 -6
  42. package/out/register/helper/form-detail-register.js +3 -3
  43. package/out/register/helper/grid-column-register.d.ts +3 -3
  44. package/out/register/helper/grid-column-register.d.ts.map +1 -1
  45. package/out/register/helper/grid-column-register.js +9 -9
  46. package/out/register/helper/panel-item-register.js +4 -4
  47. package/out/register/helper/ui-action-register.js +2 -2
  48. package/out/register/helper/view-register.d.ts.map +1 -1
  49. package/out/register/helper/view-register.js +14 -0
  50. package/package.json +2 -2
  51. package/src/application.ts +23 -0
  52. package/src/config/global-config.ts +1 -0
  53. package/src/controller/control/form/form/form.controller.ts +2 -2
  54. package/src/controller/control/form/form-detail/form-item/form-item.controller.ts +0 -1
  55. package/src/controller/control/form/form-detail/form-mdctrl/form-mdctrl-repeater.controller.ts +59 -8
  56. package/src/controller/control/grid/grid-column/grid-field-column/grid-field-column.controller.ts +0 -1
  57. package/src/controller/control/grid/grid-column/grid-field-edit-column/grid-field-edit-column.controller.ts +0 -1
  58. package/src/controller/utils/data-file-util/data-file-util.ts +2 -2
  59. package/src/interface/api/common/global-config/i-api-global-common-config.ts +10 -0
  60. package/src/interface/register/i-register-params.ts +28 -38
  61. package/src/locale/en/index.ts +20 -0
  62. package/src/locale/zh-CN/index.ts +19 -0
  63. package/src/logic-scheduler/scheduler/logic-scheduler.ts +21 -0
  64. package/src/register/custom-register.ts +126 -81
  65. package/src/register/helper/control-register.ts +2 -2
  66. package/src/register/helper/de-method-register.ts +4 -4
  67. package/src/register/helper/editor-register.ts +4 -7
  68. package/src/register/helper/form-detail-register.ts +3 -3
  69. package/src/register/helper/grid-column-register.ts +9 -9
  70. package/src/register/helper/panel-item-register.ts +4 -4
  71. package/src/register/helper/ui-action-register.ts +2 -2
  72. package/src/register/helper/view-register.ts +15 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/runtime",
3
- "version": "0.7.41-alpha.123",
3
+ "version": "0.7.41-alpha.125",
4
4
  "description": "运行时逻辑库",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -70,5 +70,5 @@
70
70
  "qx-util": "^0.4.8",
71
71
  "ramda": "^0.29.0"
72
72
  },
73
- "gitHead": "f1cf42a4ab139d6ca4eab2f2a51f566744b446b2"
73
+ "gitHead": "e240a35b3bcaabb0502fadb01723c85661f8ce23"
74
74
  }
@@ -169,6 +169,7 @@ export class Application implements IAppService {
169
169
  await this.loadAppModelStyle();
170
170
  await this.loadAppLang();
171
171
  await this.loadGlobalAppUtil();
172
+ await this.loadExtensionPlugin();
172
173
  await this.loadReplaceDefaultPlugin();
173
174
  }
174
175
 
@@ -236,6 +237,28 @@ export class Application implements IAppService {
236
237
  await ibiz.plugin.loadPlugin(globalAppUtilPlugin as ISysPFPlugin);
237
238
  }
238
239
 
240
+ /**
241
+ * @description 加载扩展插件
242
+ * @protected
243
+ * @returns {*} {Promise<void>}
244
+ * @memberof Application
245
+ */
246
+ protected async loadExtensionPlugin(): Promise<void> {
247
+ try {
248
+ await ibiz.plugin.loadPlugin({
249
+ runtimeObject: true,
250
+ rtobjectName: 'ExtensionPlugin',
251
+ rtobjectRepo: `${ibiz.env.baseUrl}/${this.appId}${ibiz.env.remoteModelUrl}/ext`,
252
+ } as IAppPFPluginRef);
253
+ } catch (error) {
254
+ ibiz.log.warn(
255
+ ibiz.i18n.t('runtime.application.noExtensionPlugin', {
256
+ appId: this.appId,
257
+ }),
258
+ );
259
+ }
260
+ }
261
+
239
262
  /**
240
263
  * @description 加载替换默认插件(仅主应用执行)
241
264
  * @protected
@@ -136,6 +136,7 @@ export class GlobalConfig implements IGlobalConfig {
136
136
  importTemplNameMode: 'default',
137
137
  aiUploadMaxSize: 5242880,
138
138
  aiAutoQuestion: true,
139
+ asyncImport: false,
139
140
  };
140
141
 
141
142
  // 全局分页流布局配置
@@ -338,9 +338,9 @@ export abstract class FormController<
338
338
  );
339
339
 
340
340
  // 监听表单成员事件,触发对应部件逻辑
341
- this._evt.on('onFormDetailEvent', event => {
341
+ this._evt.on('onFormDetailEvent', async event => {
342
342
  if (this.state.formIsDestroyed) return;
343
- this.scheduler?.triggerControlEvent(
343
+ await this.scheduler?.triggerControlItemEvent(
344
344
  event.formDetailName,
345
345
  event.formDetailEventName,
346
346
  event,
@@ -224,7 +224,6 @@ export class FormItemController
224
224
  if (this.model.editor && this.model.editor.editorType !== 'HIDDEN') {
225
225
  this.editorProvider = await getEditorProvider(
226
226
  this.model.editor,
227
- this.model,
228
227
  this.form.model,
229
228
  );
230
229
  if (this.editorProvider) {
@@ -23,6 +23,8 @@ export class FormMDCtrlRepeaterController
23
23
  extends FormMDCtrlController
24
24
  implements IFormMDCtrlRepeaterController
25
25
  {
26
+ form!: EditFormController;
27
+
26
28
  /**
27
29
  * @description 多数据重复器对应的表单里的值
28
30
  * @readonly
@@ -192,7 +194,7 @@ export class FormMDCtrlRepeaterController
192
194
  setRepeaterController(id: string, controller: IEditFormController): void {
193
195
  this.repeaterMap.set(id, controller);
194
196
  if (this.value && this.repeaterMap.size === this.value.length) {
195
- (this.form as EditFormController).evt.emit('onMDCtrlChange', {
197
+ this.form.evt.emit('onMDCtrlChange', {
196
198
  name: this.name,
197
199
  args: this,
198
200
  });
@@ -206,7 +208,9 @@ export class FormMDCtrlRepeaterController
206
208
  */
207
209
  async validate(): Promise<boolean> {
208
210
  const values = await Promise.all(
209
- Array.from(this.repeaterMap.values()).map(form => form.validate()),
211
+ Array.from(this.repeaterMap.values()).map(
212
+ form => form.state.isLoaded && form.validate(),
213
+ ),
210
214
  );
211
215
 
212
216
  // 找不到value为false即全部是true
@@ -220,7 +224,9 @@ export class FormMDCtrlRepeaterController
220
224
  */
221
225
  async silentValidate(): Promise<boolean> {
222
226
  const values = await Promise.all(
223
- Array.from(this.repeaterMap.values()).map(form => form.silentValidate()),
227
+ Array.from(this.repeaterMap.values()).map(
228
+ form => form.state.isLoaded && form.silentValidate(),
229
+ ),
224
230
  );
225
231
 
226
232
  // 找不到value为false即全部是true
@@ -243,15 +249,43 @@ export class FormMDCtrlRepeaterController
243
249
  });
244
250
  }
245
251
 
252
+ /**
253
+ * @description 自定义事件
254
+ * @private
255
+ * @param {{
256
+ * eventName: string;
257
+ * index?: number;
258
+ * eventArg: IData;
259
+ * }} args
260
+ * @returns {*} {Promise<void>}
261
+ * @memberof FormMDCtrlRepeaterController
262
+ */
263
+ private async onCustomAction(args: {
264
+ eventName: string;
265
+ index?: number;
266
+ eventArg: IData;
267
+ }): Promise<void> {
268
+ await this.form.evt.emit('onFormDetailEvent', {
269
+ formDetailName: this.name || this.model.id!,
270
+ formDetailEventName: FormDetailEventName.CUSTOMACTION,
271
+ args: { ...args, data: this.value },
272
+ });
273
+ }
274
+
246
275
  /**
247
276
  * @description 添加或创建一条数据
248
277
  * @param {number} [index]
249
278
  * @memberof FormMDCtrlRepeaterController
250
279
  */
251
- create(index?: number): void {
280
+ async create(index?: number): Promise<void> {
252
281
  const item = {};
253
282
  // 设置新建默认值
254
283
  this.setDefaultValue(item, 'create');
284
+ await this.onCustomAction({
285
+ index,
286
+ eventArg: item,
287
+ eventName: 'onBeforeNew',
288
+ });
255
289
  if (this.isSingleData) {
256
290
  this.setValue(item);
257
291
  } else {
@@ -265,7 +299,12 @@ export class FormMDCtrlRepeaterController
265
299
  }
266
300
  this.setValue(tempValue);
267
301
  }
268
- (this.form as EditFormController).evt.emit('onMDCtrlNew', {
302
+ await this.onCustomAction({
303
+ index,
304
+ eventArg: item,
305
+ eventName: 'onNewSuccess',
306
+ });
307
+ this.form.evt.emit('onMDCtrlNew', {
269
308
  args: item,
270
309
  });
271
310
  }
@@ -276,7 +315,15 @@ export class FormMDCtrlRepeaterController
276
315
  * @returns {*} {void}
277
316
  * @memberof FormMDCtrlRepeaterController
278
317
  */
279
- remove(index?: number): void {
318
+ async remove(index?: number): Promise<void> {
319
+ const item = this.isSingleData
320
+ ? (this.value as IData)
321
+ : (this.value as IData[])[index!];
322
+ await this.onCustomAction({
323
+ index,
324
+ eventArg: item,
325
+ eventName: 'onBeforeRemove',
326
+ });
280
327
  if (this.isSingleData) {
281
328
  // 单项数据的时候删除就是清空
282
329
  this.setValue(null);
@@ -285,9 +332,13 @@ export class FormMDCtrlRepeaterController
285
332
  const newArr = (this.value! as IData[]).filter((_, i) => {
286
333
  return index !== i;
287
334
  });
288
-
289
335
  this.setValue(newArr);
290
- (this.form as EditFormController).evt.emit('onMDCtrlRemove', {
336
+ await this.onCustomAction({
337
+ index,
338
+ eventArg: item,
339
+ eventName: 'onRemoveSuccess',
340
+ });
341
+ this.form.evt.emit('onMDCtrlRemove', {
291
342
  args: newArr,
292
343
  });
293
344
  }
@@ -151,7 +151,6 @@ export class GridFieldColumnController
151
151
  ) {
152
152
  this.filterEditorProvider = await getEditorProvider(
153
153
  filterEditor,
154
- this.model,
155
154
  this.grid.model,
156
155
  );
157
156
  if (this.filterEditorProvider) {
@@ -133,7 +133,6 @@ export class GridFieldEditColumnController
133
133
  ) {
134
134
  this.editorProvider = await getEditorProvider(
135
135
  this.editItem.editor,
136
- this.model,
137
136
  this.grid.model,
138
137
  );
139
138
  if (this.editorProvider) {
@@ -256,9 +256,9 @@ export async function importData2(opts: {
256
256
  params?: IParams;
257
257
  }): Promise<ImportDataResult> {
258
258
  const result: ImportDataResult = {
259
- isAsync: ibiz.env.enableMqtt,
259
+ isAsync: ibiz.config.common.asyncImport,
260
260
  };
261
- if (ibiz.env.enableMqtt) {
261
+ if (ibiz.config.common.asyncImport) {
262
262
  // 异步导入不需要等待
263
263
  asyncImportData(
264
264
  opts.selectedFile,
@@ -288,4 +288,14 @@ export interface IApiGlobalCommonConfig {
288
288
  * @memberof IApiGlobalCommonConfig
289
289
  */
290
290
  aiAutoQuestion: boolean;
291
+
292
+ /**
293
+ * @description 是否启用异步导入
294
+ * @type {boolean}
295
+ * @default false
296
+ * @platform web
297
+ * @platform mob
298
+ * @memberof IApiGlobalCommonConfig
299
+ */
300
+ asyncImport: boolean;
291
301
  }
@@ -13,57 +13,47 @@ import {
13
13
  */
14
14
  export interface IRegisterParams {
15
15
  /**
16
- * 部件项模型
17
- *
18
- * @author ljx
19
- * @date 2024-04-15 16:10:54
20
- * @type {IModel}
21
- */
22
- controlItemModel?: IControlItem;
23
-
24
- /**
25
- * 部件模型
26
- *
27
- * @author ljx
28
- * @date 2024-04-15 16:10:54
29
- * @type {IPanel}
30
- */
31
- controlModel?: IControl;
32
-
33
- /**
34
- * 视图模型
35
- *
36
- * @author ljx
37
- * @date 2024-04-15 16:10:54
16
+ * @description 部件模型
38
17
  * @type {IControl}
39
- */
40
- viewModel?: IAppView;
41
-
42
- /**
43
- * @description 界面行为模型
44
- * @type {IAppUIAction}
45
18
  * @memberof IRegisterParams
46
19
  */
47
- uiActionModel?: IAppUIAction;
20
+ control?: IControl;
48
21
 
49
22
  /**
50
- * @description 实体方法模型
51
- * @type {IDEMethodProvider}
23
+ * @description 视图模型
24
+ * @type {IAppView}
52
25
  * @memberof IRegisterParams
53
26
  */
54
- deMethodModel?: IAppDEMethod;
27
+ view?: IAppView;
55
28
 
56
29
  /**
57
- * @description 实体模型
58
- * @type {string}
30
+ * @description 应用实体模型
31
+ * @type {IAppDataEntity}
59
32
  * @memberof IRegisterParams
60
33
  */
61
- entityModel?: IAppDataEntity;
34
+ entity?: IAppDataEntity;
62
35
 
63
36
  /**
64
- * @description 编辑器模型
65
- * @type {IEditor}
37
+ * @description 主模型
38
+ * @type {
39
+ * | IAppView
40
+ * | IAppDataEntity
41
+ * | IAppDEMethod
42
+ * | IAppUIAction
43
+ * | IControl
44
+ * | IControlItem
45
+ * | IEditor
46
+ * | IAppDEMethod
47
+ * }
66
48
  * @memberof IRegisterParams
67
49
  */
68
- editorModel?: IEditor;
50
+ mainModel:
51
+ | IAppView
52
+ | IAppDataEntity
53
+ | IAppDEMethod
54
+ | IAppUIAction
55
+ | IControl
56
+ | IControlItem
57
+ | IAppDEMethod
58
+ | IEditor;
69
59
  }
@@ -444,6 +444,10 @@ export const en = {
444
444
  noImplementedRouting:
445
445
  'Getting view routing parameter variables is not implemented',
446
446
  },
447
+ application: {
448
+ noExtensionPlugin:
449
+ 'Attempted to load application [{appId}] extension plugin, but no extension plugin was found',
450
+ },
447
451
  hub: {
448
452
  failedParse: 'View parameter {paramsName} failed to parse: {error}',
449
453
  noExist: 'View [{id}] does not exist',
@@ -578,6 +582,22 @@ export const en = {
578
582
  'Cannot find the adapter corresponding to the toolbar item plugin {pluginKey}.',
579
583
  acItem:
580
584
  'Cannot find the adapter corresponding to the ac item plugin {pluginKey}.',
585
+ viewCustomRegistration:
586
+ '[Custom Extended View] Cannot find an adapter with a custom registration ID of [{registerKey}].',
587
+ ctrlCustomRegistration:
588
+ '[Custom Extended Control] Cannot find an adapter with a custom registration ID of [{registerKey}].',
589
+ panelItemCustomRegistration:
590
+ '[Custom Extended Panel Item] Cannot find an adapter with a custom registration ID of [{registerKey}].',
591
+ formDetailCustomRegistration:
592
+ '[Custom Extended Form Detail] Cannot find an adapter with a custom registration ID of [{registerKey}].',
593
+ gridColumnCustomRegistration:
594
+ '[Custom Extended Grid Column] Cannot find an adapter with a custom registration ID of [{registerKey}].',
595
+ editorCustomRegistration:
596
+ '[Custom Extended Editor] Cannot find an adapter with a custom registration ID of [{registerKey}].',
597
+ uiactionCustomRegistration:
598
+ '[Custom Extended UIAction] Cannot find an adapter with a custom registration ID of [{registerKey}].',
599
+ deMethodCustomRegistration:
600
+ '[Custom Extended DEMethod] Cannot find an adapter with a custom registration ID of [{registerKey}].',
581
601
  },
582
602
  },
583
603
  service: {
@@ -371,6 +371,9 @@ export const zhCn = {
371
371
  global: {
372
372
  noImplemented: '获取应用全局变量没有实现',
373
373
  },
374
+ application: {
375
+ noExtensionPlugin: '尝试加载应用[{appId}]扩展插件,暂未找到扩展插件',
376
+ },
374
377
  hub: {
375
378
  failedParse: '视图参数 {paramsName} 解析失败:{error}',
376
379
  noExist: '视图[{id}]不存在',
@@ -468,6 +471,22 @@ export const zhCn = {
468
471
  '找不到视图类型:[{viewType}]的视图样式:[{viewStyle}]对应的适配器',
469
472
  toolbarItem: '找不到工具栏项插件{pluginKey}对应的适配器',
470
473
  acItem: '找不到自填列表项插件{pluginKey}对应的适配器',
474
+ viewCustomRegistration:
475
+ '[自定义扩展视图] 找不到自定义注册标识为[{registerKey}]对应的适配器',
476
+ ctrlCustomRegistration:
477
+ '[自定义扩展部件] 找不到自定义注册标识为[{registerKey}]对应的适配器',
478
+ panelItemCustomRegistration:
479
+ '[自定义扩展面板项] 找不到自定义注册标识为[{registerKey}]对应的适配器',
480
+ formDetailCustomRegistration:
481
+ '[自定义扩展表单成员] 找不到自定义注册标识为[{registerKey}]对应的适配器',
482
+ gridColumnCustomRegistration:
483
+ '[自定义扩展表格列] 找不到自定义注册标识为[{registerKey}]对应的适配器',
484
+ editorCustomRegistration:
485
+ '[自定义扩展编辑器] 找不到自定义注册标识为[{registerKey}]对应的适配器',
486
+ uiactionCustomRegistration:
487
+ '[自定义扩展界面行为] 找不到自定义注册标识为[{registerKey}]对应的适配器',
488
+ deMethodCustomRegistration:
489
+ '[自定义扩展实体方法] 找不到自定义注册标识为[{registerKey}]对应的适配器',
471
490
  },
472
491
  },
473
492
  service: {
@@ -296,4 +296,25 @@ export class LogicScheduler {
296
296
  } as const;
297
297
  this.triggerAndExecute(matchParams, executeParams);
298
298
  }
299
+
300
+ /**
301
+ * @description 触发部件项事件
302
+ * @param {string} ctrlItemName 部件项名称
303
+ * @param {string} eventName 事件名称
304
+ * @param {Partial<IUILogicParams>} [executeParams] 执行参数
305
+ * @memberof LogicScheduler
306
+ */
307
+ async triggerControlItemEvent(
308
+ ctrlItemName: string,
309
+ eventName: string,
310
+ executeParams?: Partial<IUILogicParams>,
311
+ ): Promise<void> {
312
+ const matchParams = {
313
+ eventName,
314
+ ctrlName: ctrlItemName,
315
+ triggerType: 'CTRLEVENT',
316
+ } as const;
317
+ const result = this.triggerAndExecute(matchParams, executeParams);
318
+ if (result) await Promise.all(result);
319
+ }
299
320
  }