@ibiz-template/runtime 0.5.3-beta.5 → 0.5.3-beta.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.
package/dist/index.esm.js CHANGED
@@ -2861,14 +2861,31 @@ var UIDomain = class {
2861
2861
  */
2862
2862
  constructor(id) {
2863
2863
  /**
2864
- * DTO 父子关系映射
2864
+ * 状态
2865
+ *
2866
+ * @author chitanda
2867
+ * @date 2024-01-15 19:01:51
2868
+ * @type {{ rsInit: boolean }} 关系是否已经初始化
2869
+ */
2870
+ this.state = { rsInit: false };
2871
+ /**
2872
+ * DTO 子父关系映射
2865
2873
  *
2866
2874
  * @author chitanda
2867
2875
  * @date 2023-12-26 15:12:13
2868
2876
  * @protected
2869
- * @type {Map<string, IAppDERS[]>}
2877
+ * @type {Map<string, IAppDERS[]>} Map<子实体, 当前实体的父关系>
2870
2878
  */
2871
2879
  this.rsMap = /* @__PURE__ */ new Map();
2880
+ /**
2881
+ * DTO 父子关系映射
2882
+ *
2883
+ * @author chitanda
2884
+ * @date 2024-01-15 17:01:42
2885
+ * @protected
2886
+ * @type {Map<string, IAppDERS[]>}
2887
+ */
2888
+ this.rs2Map = /* @__PURE__ */ new Map();
2872
2889
  if (id) {
2873
2890
  this.id = id;
2874
2891
  } else {
@@ -2880,26 +2897,46 @@ var UIDomain = class {
2880
2897
  *
2881
2898
  * @author chitanda
2882
2899
  * @date 2023-12-26 15:12:31
2883
- * @param {string} entity
2900
+ * @param {string} appDataEntityId
2884
2901
  * @param {IAppDERS} configs
2885
2902
  */
2886
- setDERConfig(deCodeName, configs) {
2887
- this.rsMap.set(deCodeName, configs);
2903
+ setDERConfig(appDataEntityId, configs) {
2904
+ this.rsMap.set(appDataEntityId, configs);
2888
2905
  }
2889
2906
  /**
2890
2907
  * 获取当前界面域下,具体实体的关系(在数据加载完成之后才有值)
2891
2908
  *
2892
2909
  * @author chitanda
2893
2910
  * @date 2023-12-26 16:12:07
2894
- * @param {string} deCodeName
2911
+ * @param {string} appDataEntityId
2895
2912
  * @return {*} {IAppDERS[]}
2896
2913
  */
2897
- getDERConfig(deCodeName) {
2898
- if (this.rsMap.has(deCodeName)) {
2899
- return this.rsMap.get(deCodeName);
2914
+ getDERConfig(appDataEntityId) {
2915
+ if (this.rsMap.has(appDataEntityId)) {
2916
+ return this.rsMap.get(appDataEntityId);
2900
2917
  }
2901
2918
  return [];
2902
2919
  }
2920
+ /**
2921
+ * 根据模型给的子实体中的父关系模型,计算每个实体的子关系模型
2922
+ *
2923
+ * @author chitanda
2924
+ * @date 2024-01-15 19:01:49
2925
+ */
2926
+ calcParentRs() {
2927
+ this.rs2Map.clear();
2928
+ this.rsMap.forEach((configs, appDataEntityId) => {
2929
+ configs.forEach((config) => {
2930
+ config.minorAppDataEntityId = appDataEntityId;
2931
+ const major = config.majorAppDataEntityId;
2932
+ if (!this.rs2Map.has(major)) {
2933
+ this.rs2Map.set(major, []);
2934
+ }
2935
+ this.rs2Map.get(major).push(config);
2936
+ });
2937
+ });
2938
+ console.log(Array.from(this.rs2Map.values()));
2939
+ }
2903
2940
  /**
2904
2941
  * 界面域销毁
2905
2942
  *
@@ -3652,7 +3689,7 @@ function getProvider6(key) {
3652
3689
  async function getPanelItemProvider(model) {
3653
3690
  var _a;
3654
3691
  let provider;
3655
- const { itemType, sysPFPluginId, appId: appId2 } = model;
3692
+ const { itemType, sysPFPluginId, appId: appId2, controlRenders } = model;
3656
3693
  if (sysPFPluginId) {
3657
3694
  const pluginKey = await getPluginRegisterKey(sysPFPluginId, appId2);
3658
3695
  if (pluginKey) {
@@ -3664,41 +3701,45 @@ async function getPanelItemProvider(model) {
3664
3701
  return provider;
3665
3702
  }
3666
3703
  }
3667
- if (itemType === "CONTAINER") {
3668
- const predefinedType = model.predefinedType || "DEFAULT";
3669
- const key = "CONTAINER_".concat(predefinedType);
3670
- provider = getProvider6(key);
3671
- if (!provider) {
3672
- ibiz.log.error(
3673
- "\u627E\u4E0D\u5230\u9762\u677F\u5BB9\u5668\u9884\u7F6E\u7C7B\u578B\u4E3A".concat(predefinedType, "\u7684\u9002\u914D\u5668\uFF0C\u6CE8\u518Ckey\u4E3A").concat(key)
3674
- );
3675
- } else {
3676
- return provider;
3677
- }
3678
- }
3679
- if (itemType === "RAWITEM") {
3680
- const predefinedType = ((_a = model.rawItem) == null ? void 0 : _a.predefinedType) || "DEFAULT";
3681
- const key = "RAWITEM_".concat(predefinedType);
3682
- provider = getProvider6(key);
3683
- if (!provider) {
3684
- ibiz.log.error(
3685
- "\u627E\u4E0D\u5230\u9762\u677F\u6210\u5458\u76F4\u63A5\u5185\u5BB9\u9884\u7F6E\u7C7B\u578B\u4E3A".concat(predefinedType, "\u7684\u9002\u914D\u5668\uFF0C\u6CE8\u518Ckey\u4E3A").concat(key)
3686
- );
3687
- } else {
3688
- return provider;
3704
+ if (controlRenders && controlRenders.length > 0) {
3705
+ provider = getProvider6("PREDEFINE_RENDER");
3706
+ } else {
3707
+ if (itemType === "CONTAINER") {
3708
+ const predefinedType = model.predefinedType || "DEFAULT";
3709
+ const key = "CONTAINER_".concat(predefinedType);
3710
+ provider = getProvider6(key);
3711
+ if (!provider) {
3712
+ ibiz.log.error(
3713
+ "\u627E\u4E0D\u5230\u9762\u677F\u5BB9\u5668\u9884\u7F6E\u7C7B\u578B\u4E3A".concat(predefinedType, "\u7684\u9002\u914D\u5668\uFF0C\u6CE8\u518Ckey\u4E3A").concat(key)
3714
+ );
3715
+ } else {
3716
+ return provider;
3717
+ }
3689
3718
  }
3690
- }
3691
- if (itemType === "FIELD") {
3692
- const { editor } = model;
3693
- if (editor && editor.predefinedType) {
3694
- const key = "FIELD_".concat(editor.predefinedType.toUpperCase());
3719
+ if (itemType === "RAWITEM") {
3720
+ const predefinedType = ((_a = model.rawItem) == null ? void 0 : _a.predefinedType) || "DEFAULT";
3721
+ const key = "RAWITEM_".concat(predefinedType);
3695
3722
  provider = getProvider6(key);
3696
- if (provider) {
3723
+ if (!provider) {
3724
+ ibiz.log.error(
3725
+ "\u627E\u4E0D\u5230\u9762\u677F\u6210\u5458\u76F4\u63A5\u5185\u5BB9\u9884\u7F6E\u7C7B\u578B\u4E3A".concat(predefinedType, "\u7684\u9002\u914D\u5668\uFF0C\u6CE8\u518Ckey\u4E3A").concat(key)
3726
+ );
3727
+ } else {
3697
3728
  return provider;
3698
3729
  }
3699
3730
  }
3731
+ if (itemType === "FIELD") {
3732
+ const { editor } = model;
3733
+ if (editor && editor.predefinedType) {
3734
+ const key = "FIELD_".concat(editor.predefinedType.toUpperCase());
3735
+ provider = getProvider6(key);
3736
+ if (provider) {
3737
+ return provider;
3738
+ }
3739
+ }
3740
+ }
3741
+ provider = getProvider6(itemType);
3700
3742
  }
3701
- provider = getProvider6(itemType);
3702
3743
  if (!provider) {
3703
3744
  ibiz.log.error("\u627E\u4E0D\u5230\u9762\u677F\u6210\u5458\u7C7B\u578B".concat(itemType, "\u5BF9\u5E94\u7684\u9002\u914D\u5668"));
3704
3745
  } else {
@@ -4528,16 +4569,16 @@ var DynamicCodeListCache = class {
4528
4569
  );
4529
4570
  let resultItems = [];
4530
4571
  if (res.data.length) {
4531
- res.data.forEach((item) => {
4532
- if (pvalueAppDEFieldId) {
4533
- const tempItems = this.prepareTreeData(res.data);
4534
- if (tempItems) {
4535
- resultItems = tempItems;
4536
- }
4537
- } else {
4538
- resultItems.push(this.convertData(item));
4572
+ if (pvalueAppDEFieldId) {
4573
+ const tempItems = this.prepareTreeData(res.data);
4574
+ if (tempItems) {
4575
+ resultItems = tempItems;
4539
4576
  }
4540
- });
4577
+ } else {
4578
+ res.data.forEach((item) => {
4579
+ resultItems.push(this.convertData(item));
4580
+ });
4581
+ }
4541
4582
  }
4542
4583
  return Object.freeze(resultItems);
4543
4584
  }
@@ -5982,15 +6023,6 @@ var MethodDto = class {
5982
6023
  this.dto = dto;
5983
6024
  this.inSelfLoop = inSelfLoop;
5984
6025
  this.dtoMap = /* @__PURE__ */ new Map();
5985
- /**
5986
- * 当前 DTO 是否已经计算过关系相关逻辑
5987
- *
5988
- * @link this.calcRs
5989
- * @author chitanda
5990
- * @date 2023-12-26 16:12:18
5991
- * @protected
5992
- */
5993
- this.isCalcRs = false;
5994
6026
  if (dto) {
5995
6027
  this.app = ibiz.hub.getApp(entity.appId);
5996
6028
  this.fields = dto.appDEMethodDTOFields || [];
@@ -6122,7 +6154,12 @@ var MethodDto = class {
6122
6154
  if (this.isLocalMode && !this.inSelfLoop) {
6123
6155
  this.service.local.clear();
6124
6156
  }
6125
- await this.calcRs(context);
6157
+ const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
6158
+ if (uiDomain && uiDomain.state.rsInit !== true) {
6159
+ await this.calcRs(context);
6160
+ uiDomain.calcParentRs();
6161
+ uiDomain.state.rsInit = true;
6162
+ }
6126
6163
  return Promise.all(
6127
6164
  data.map(async (datum) => {
6128
6165
  const all = this.fields.filter((field) => field.type === "DTOS").map(async (field) => {
@@ -6170,10 +6207,9 @@ var MethodDto = class {
6170
6207
  * @return {*} {Promise<void>}
6171
6208
  */
6172
6209
  async calcRs(context, depth = 0) {
6173
- if (this.isCalcRs || depth > 10) {
6210
+ if (depth > 10) {
6174
6211
  return;
6175
6212
  }
6176
- this.isCalcRs = true;
6177
6213
  depth += 1;
6178
6214
  const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
6179
6215
  const dtoFields = this.fields.filter((field) => field.type === "DTOS");
@@ -8982,35 +9018,36 @@ import { ascSort, descSort } from "qx-util";
8982
9018
  var FetchMethod = class extends Method {
8983
9019
  async exec(context, params, params2) {
8984
9020
  const searchParams = params && !isArray7(params) ? params : params2 || {};
9021
+ let res;
8985
9022
  if (this.isLocalMode) {
8986
9023
  const cond = DEDQCondUtil.getCond(this.method);
8987
- const items2 = await this.searchLocal(
9024
+ const items = await this.searchLocal(
8988
9025
  cond,
8989
9026
  new SearchFilter(context, searchParams)
8990
9027
  );
8991
- return new HttpResponse4(items2, 200);
8992
- }
8993
- let res;
8994
- switch (this.method.dataSetType) {
8995
- case "INDEXDE":
8996
- case "CODELIST":
8997
- case "MULTIFORM":
8998
- res = await this.fetchCodeListSet(context, searchParams);
8999
- break;
9000
- case "REMOTE":
9001
- {
9002
- const path2 = this.calcPath(context);
9003
- res = await this.request(path2, context, params, params2);
9004
- }
9005
- break;
9006
- default:
9007
- throw new ModelError14(
9008
- this.method,
9009
- "\u6570\u636E\u6765\u6E90\u7C7B\u578B".concat(this.method.dataSetType, "\u6682\u672A\u652F\u6301")
9010
- );
9028
+ res = new HttpResponse4(items, 200);
9029
+ } else {
9030
+ switch (this.method.dataSetType) {
9031
+ case "INDEXDE":
9032
+ case "CODELIST":
9033
+ case "MULTIFORM":
9034
+ res = await this.fetchCodeListSet(context, searchParams);
9035
+ break;
9036
+ case "REMOTE":
9037
+ {
9038
+ const path2 = this.calcPath(context);
9039
+ res = await this.request(path2, context, params, params2);
9040
+ }
9041
+ break;
9042
+ default:
9043
+ throw new ModelError14(
9044
+ this.method,
9045
+ "\u6570\u636E\u6765\u6E90\u7C7B\u578B".concat(this.method.dataSetType, "\u6682\u672A\u652F\u6301")
9046
+ );
9047
+ }
9048
+ const items = res.data || [];
9049
+ res.data = items.map((item) => this.createEntity(item));
9011
9050
  }
9012
- const items = res.data || [];
9013
- res.data = items.map((item) => this.createEntity(item));
9014
9051
  if (res.data) {
9015
9052
  await execFieldLogics(
9016
9053
  this.entity,
@@ -30587,6 +30624,15 @@ var AppHub = class {
30587
30624
  * @type {Map<string, string>} Map<视图 id, 视图所属应用>
30588
30625
  */
30589
30626
  this.view2appMap = /* @__PURE__ */ new Map();
30627
+ /**
30628
+ * 当前注册的应用视图优先级
30629
+ *
30630
+ * @author chitanda
30631
+ * @date 2024-01-15 15:01:57
30632
+ * @protected
30633
+ * @type {Map<string, number>}
30634
+ */
30635
+ this.view2appPriorityMap = /* @__PURE__ */ new Map();
30590
30636
  /**
30591
30637
  * 实例化的应用视图模型
30592
30638
  *
@@ -30678,13 +30724,23 @@ var AppHub = class {
30678
30724
  * 设置应用视图所属应用
30679
30725
  *
30680
30726
  * @author chitanda
30681
- * @date 2023-04-17 23:04:37
30727
+ * @date 2024-01-15 15:01:41
30682
30728
  * @param {string} tag 视图 codeName 或者视图 id
30683
30729
  * @param {string} [appId=ibiz.env.appId]
30730
+ * @param {number} [priority=-1] 视图的优先级,值越小优先级越高。1为最高优先级
30684
30731
  */
30685
- setAppView(tag, appId2 = ibiz.env.appId) {
30732
+ setAppView(tag, appId2 = ibiz.env.appId, priority = -1) {
30686
30733
  const id = this.calcAppViewId(tag);
30734
+ if (this.view2appMap.has(id)) {
30735
+ const _priority = this.view2appPriorityMap.get(id);
30736
+ if (_priority && _priority < priority) {
30737
+ return;
30738
+ }
30739
+ }
30687
30740
  this.view2appMap.set(id, appId2);
30741
+ if (priority !== -1) {
30742
+ this.view2appPriorityMap.set(id, priority);
30743
+ }
30688
30744
  }
30689
30745
  /**
30690
30746
  * 判断应用视图是否存在