@ibiz-template/runtime 0.5.3-beta.5 → 0.5.3-beta.7

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 (48) hide show
  1. package/dist/index.esm.js +157 -92
  2. package/dist/index.system.min.js +1 -1
  3. package/out/app-hub.d.ts +12 -2
  4. package/out/app-hub.d.ts.map +1 -1
  5. package/out/app-hub.js +22 -2
  6. package/out/application.js +1 -1
  7. package/out/de-logic/utils/handle-src-val.d.ts +15 -0
  8. package/out/de-logic/utils/handle-src-val.d.ts.map +1 -1
  9. package/out/de-logic/utils/handle-src-val.js +10 -1
  10. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts +4 -3
  11. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts.map +1 -1
  12. package/out/register/helper/panel-item-register.d.ts.map +1 -1
  13. package/out/register/helper/panel-item-register.js +36 -30
  14. package/out/service/dto/method.dto.d.ts +0 -9
  15. package/out/service/dto/method.dto.d.ts.map +1 -1
  16. package/out/service/dto/method.dto.js +7 -12
  17. package/out/service/mqtt/mqtt.service.js +2 -2
  18. package/out/service/service/auth/v7-auth.service.d.ts.map +1 -1
  19. package/out/service/service/auth/v7-auth.service.js +2 -0
  20. package/out/service/service/entity/method/fetch.d.ts.map +1 -1
  21. package/out/service/service/entity/method/fetch.js +22 -20
  22. package/out/service/utils/dynamic-code-list/dynamic-code-list.js +9 -9
  23. package/out/service/utils/res-path/res-path.d.ts +2 -2
  24. package/out/service/utils/res-path/res-path.d.ts.map +1 -1
  25. package/out/service/utils/res-path/res-path.js +1 -1
  26. package/out/ui-logic/ui-logic-node/debug-param-node/debug-param-node.js +1 -1
  27. package/out/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.d.ts.map +1 -1
  28. package/out/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.js +0 -1
  29. package/out/utils/script/script-function.js +1 -1
  30. package/out/utils/ui-domain/ui-domain.d.ts +32 -6
  31. package/out/utils/ui-domain/ui-domain.d.ts.map +1 -1
  32. package/out/utils/ui-domain/ui-domain.js +45 -9
  33. package/package.json +3 -3
  34. package/src/app-hub.ts +27 -2
  35. package/src/application.ts +1 -1
  36. package/src/de-logic/utils/handle-src-val.ts +29 -1
  37. package/src/interface/common/i-app-hub-service/i-app-hub-service.ts +4 -3
  38. package/src/register/helper/panel-item-register.ts +43 -37
  39. package/src/service/dto/method.dto.ts +7 -13
  40. package/src/service/mqtt/mqtt.service.ts +2 -2
  41. package/src/service/service/auth/v7-auth.service.ts +2 -0
  42. package/src/service/service/entity/method/fetch.ts +26 -25
  43. package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +9 -9
  44. package/src/service/utils/res-path/res-path.ts +2 -2
  45. package/src/ui-logic/ui-logic-node/debug-param-node/debug-param-node.ts +1 -1
  46. package/src/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.ts +0 -1
  47. package/src/utils/script/script-function.ts +1 -1
  48. package/src/utils/ui-domain/ui-domain.ts +48 -9
package/dist/index.esm.js CHANGED
@@ -1501,7 +1501,7 @@ var ScriptFunction = class {
1501
1501
  try {
1502
1502
  return fn.apply({}, args);
1503
1503
  } catch (error) {
1504
- console.log("\u62A5\u9519\u811A\u672C", code);
1504
+ ibiz.log.error("\u62A5\u9519\u811A\u672C", code);
1505
1505
  throw error;
1506
1506
  }
1507
1507
  };
@@ -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,45 @@ 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
+ }
2903
2939
  /**
2904
2940
  * 界面域销毁
2905
2941
  *
@@ -3652,7 +3688,7 @@ function getProvider6(key) {
3652
3688
  async function getPanelItemProvider(model) {
3653
3689
  var _a;
3654
3690
  let provider;
3655
- const { itemType, sysPFPluginId, appId: appId2 } = model;
3691
+ const { itemType, sysPFPluginId, appId: appId2, controlRenders } = model;
3656
3692
  if (sysPFPluginId) {
3657
3693
  const pluginKey = await getPluginRegisterKey(sysPFPluginId, appId2);
3658
3694
  if (pluginKey) {
@@ -3664,41 +3700,45 @@ async function getPanelItemProvider(model) {
3664
3700
  return provider;
3665
3701
  }
3666
3702
  }
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;
3703
+ if (controlRenders && controlRenders.length > 0) {
3704
+ provider = getProvider6("PREDEFINE_RENDER");
3705
+ } else {
3706
+ if (itemType === "CONTAINER") {
3707
+ const predefinedType = model.predefinedType || "DEFAULT";
3708
+ const key = "CONTAINER_".concat(predefinedType);
3709
+ provider = getProvider6(key);
3710
+ if (!provider) {
3711
+ ibiz.log.error(
3712
+ "\u627E\u4E0D\u5230\u9762\u677F\u5BB9\u5668\u9884\u7F6E\u7C7B\u578B\u4E3A".concat(predefinedType, "\u7684\u9002\u914D\u5668\uFF0C\u6CE8\u518Ckey\u4E3A").concat(key)
3713
+ );
3714
+ } else {
3715
+ return provider;
3716
+ }
3689
3717
  }
3690
- }
3691
- if (itemType === "FIELD") {
3692
- const { editor } = model;
3693
- if (editor && editor.predefinedType) {
3694
- const key = "FIELD_".concat(editor.predefinedType.toUpperCase());
3718
+ if (itemType === "RAWITEM") {
3719
+ const predefinedType = ((_a = model.rawItem) == null ? void 0 : _a.predefinedType) || "DEFAULT";
3720
+ const key = "RAWITEM_".concat(predefinedType);
3695
3721
  provider = getProvider6(key);
3696
- if (provider) {
3722
+ if (!provider) {
3723
+ ibiz.log.error(
3724
+ "\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)
3725
+ );
3726
+ } else {
3697
3727
  return provider;
3698
3728
  }
3699
3729
  }
3730
+ if (itemType === "FIELD") {
3731
+ const { editor } = model;
3732
+ if (editor && editor.predefinedType) {
3733
+ const key = "FIELD_".concat(editor.predefinedType.toUpperCase());
3734
+ provider = getProvider6(key);
3735
+ if (provider) {
3736
+ return provider;
3737
+ }
3738
+ }
3739
+ }
3740
+ provider = getProvider6(itemType);
3700
3741
  }
3701
- provider = getProvider6(itemType);
3702
3742
  if (!provider) {
3703
3743
  ibiz.log.error("\u627E\u4E0D\u5230\u9762\u677F\u6210\u5458\u7C7B\u578B".concat(itemType, "\u5BF9\u5E94\u7684\u9002\u914D\u5668"));
3704
3744
  } else {
@@ -4528,16 +4568,16 @@ var DynamicCodeListCache = class {
4528
4568
  );
4529
4569
  let resultItems = [];
4530
4570
  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));
4571
+ if (pvalueAppDEFieldId) {
4572
+ const tempItems = this.prepareTreeData(res.data);
4573
+ if (tempItems) {
4574
+ resultItems = tempItems;
4539
4575
  }
4540
- });
4576
+ } else {
4577
+ res.data.forEach((item) => {
4578
+ resultItems.push(this.convertData(item));
4579
+ });
4580
+ }
4541
4581
  }
4542
4582
  return Object.freeze(resultItems);
4543
4583
  }
@@ -5982,15 +6022,6 @@ var MethodDto = class {
5982
6022
  this.dto = dto;
5983
6023
  this.inSelfLoop = inSelfLoop;
5984
6024
  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
6025
  if (dto) {
5995
6026
  this.app = ibiz.hub.getApp(entity.appId);
5996
6027
  this.fields = dto.appDEMethodDTOFields || [];
@@ -6122,7 +6153,12 @@ var MethodDto = class {
6122
6153
  if (this.isLocalMode && !this.inSelfLoop) {
6123
6154
  this.service.local.clear();
6124
6155
  }
6125
- await this.calcRs(context);
6156
+ const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
6157
+ if (uiDomain && uiDomain.state.rsInit !== true) {
6158
+ await this.calcRs(context);
6159
+ uiDomain.calcParentRs();
6160
+ uiDomain.state.rsInit = true;
6161
+ }
6126
6162
  return Promise.all(
6127
6163
  data.map(async (datum) => {
6128
6164
  const all = this.fields.filter((field) => field.type === "DTOS").map(async (field) => {
@@ -6170,10 +6206,9 @@ var MethodDto = class {
6170
6206
  * @return {*} {Promise<void>}
6171
6207
  */
6172
6208
  async calcRs(context, depth = 0) {
6173
- if (this.isCalcRs || depth > 10) {
6209
+ if (depth > 10) {
6174
6210
  return;
6175
6211
  }
6176
- this.isCalcRs = true;
6177
6212
  depth += 1;
6178
6213
  const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
6179
6214
  const dtoFields = this.fields.filter((field) => field.type === "DTOS");
@@ -7194,6 +7229,8 @@ var V7AuthService = class {
7194
7229
  clearCookie(CoreConst.TOKEN_EXPIRES);
7195
7230
  clearCookie(CoreConst.TOKEN_REMEMBER);
7196
7231
  clearCookie(CoreConst.IS_ANONYMOUS);
7232
+ ibiz.appData = void 0;
7233
+ ibiz.orgData = void 0;
7197
7234
  return true;
7198
7235
  } catch (err) {
7199
7236
  ibiz.notification.error({
@@ -7926,7 +7963,7 @@ import { clone as clone10 } from "ramda";
7926
7963
  import { ModelError as ModelError10 } from "@ibiz-template/core";
7927
7964
  import { clone as clone9 } from "ramda";
7928
7965
  function handleSrcVal(ctx, srcValParams) {
7929
- const { srcDELogicParamId, srcFieldName, srcValue } = srcValParams;
7966
+ const { srcDELogicParamId, srcFieldName, srcValue, expression } = srcValParams;
7930
7967
  const srcValueType = srcValParams.srcValueType || "SRCDLPARAM";
7931
7968
  let srcField = srcFieldName;
7932
7969
  let value;
@@ -7956,6 +7993,15 @@ function handleSrcVal(ctx, srcValParams) {
7956
7993
  case "ENVPARAM":
7957
7994
  value = clone9(ibiz.env);
7958
7995
  break;
7996
+ case "EXPRESSION":
7997
+ if (!expression) {
7998
+ throw new ModelError10(srcValParams, "\u8868\u8FBE\u5F0F\u4E3A\u7A7A");
7999
+ }
8000
+ value = ScriptFactory.execScriptFn(ctx, expression, {
8001
+ singleRowReturn: true,
8002
+ isAsync: false
8003
+ });
8004
+ break;
7959
8005
  default:
7960
8006
  throw new ModelError10(srcValParams, "\u6682\u672A\u652F\u6301\u6E90\u503C\u7C7B\u578B".concat(srcValueType));
7961
8007
  }
@@ -8982,35 +9028,36 @@ import { ascSort, descSort } from "qx-util";
8982
9028
  var FetchMethod = class extends Method {
8983
9029
  async exec(context, params, params2) {
8984
9030
  const searchParams = params && !isArray7(params) ? params : params2 || {};
9031
+ let res;
8985
9032
  if (this.isLocalMode) {
8986
9033
  const cond = DEDQCondUtil.getCond(this.method);
8987
- const items2 = await this.searchLocal(
9034
+ const items = await this.searchLocal(
8988
9035
  cond,
8989
9036
  new SearchFilter(context, searchParams)
8990
9037
  );
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
- );
9038
+ res = new HttpResponse4(items, 200);
9039
+ } else {
9040
+ switch (this.method.dataSetType) {
9041
+ case "INDEXDE":
9042
+ case "CODELIST":
9043
+ case "MULTIFORM":
9044
+ res = await this.fetchCodeListSet(context, searchParams);
9045
+ break;
9046
+ case "REMOTE":
9047
+ {
9048
+ const path2 = this.calcPath(context);
9049
+ res = await this.request(path2, context, params, params2);
9050
+ }
9051
+ break;
9052
+ default:
9053
+ throw new ModelError14(
9054
+ this.method,
9055
+ "\u6570\u636E\u6765\u6E90\u7C7B\u578B".concat(this.method.dataSetType, "\u6682\u672A\u652F\u6301")
9056
+ );
9057
+ }
9058
+ const items = res.data || [];
9059
+ res.data = items.map((item) => this.createEntity(item));
9011
9060
  }
9012
- const items = res.data || [];
9013
- res.data = items.map((item) => this.createEntity(item));
9014
9061
  if (res.data) {
9015
9062
  await execFieldLogics(
9016
9063
  this.entity,
@@ -9927,10 +9974,10 @@ var MqttService = class {
9927
9974
  ibiz.log.debug("mqtt message", topic, payload.toString());
9928
9975
  });
9929
9976
  this.client.on("reconnect", () => {
9930
- ibiz.log.debug("mqtt reconnect");
9977
+ ibiz.log.warn("mqtt reconnect");
9931
9978
  });
9932
9979
  this.client.on("close", () => {
9933
- console.debug("mqtt close");
9980
+ ibiz.log.warn("mqtt close");
9934
9981
  });
9935
9982
  }
9936
9983
  /**
@@ -10418,7 +10465,7 @@ var Application = class {
10418
10465
  async init() {
10419
10466
  await this.authority.init();
10420
10467
  await this.loadAppModelStyle();
10421
- if (ibiz.env.enableMqtt && ibiz.appData) {
10468
+ if (ibiz.env.enableMqtt && ibiz.appData && ibiz.auth.isAnonymous !== true) {
10422
10469
  this.mqtt = new MqttService(
10423
10470
  ibiz.appData.mqtttopic,
10424
10471
  getToken(),
@@ -15980,7 +16027,7 @@ var DebugParamNode = class extends UILogicNode {
15980
16027
  throw new RuntimeModelError38(this.model, "\u7F3A\u5C11\u76EE\u6807\u53C2\u6570\u5BF9\u8C61\u914D\u7F6E");
15981
16028
  }
15982
16029
  const param = ctx.params[dstDEUILogicParamId];
15983
- console.log("\u903B\u8F91\u8282\u70B9".concat(name, "\u64CD\u4F5C\u53C2\u6570\u503C:"), param);
16030
+ ibiz.log.debug("\u903B\u8F91\u8282\u70B9".concat(name, "\u64CD\u4F5C\u53C2\u6570\u503C:"), param);
15984
16031
  }
15985
16032
  };
15986
16033
 
@@ -16172,7 +16219,6 @@ var ExecuteDELogicNode = class extends UILogicNode {
16172
16219
  // src/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.ts
16173
16220
  var RawJSCodeNode = class extends UILogicNode {
16174
16221
  async exec(ctx) {
16175
- console.log(ctx);
16176
16222
  ScriptFactory.execScriptFn(
16177
16223
  {
16178
16224
  view: ctx.view,
@@ -30587,6 +30633,15 @@ var AppHub = class {
30587
30633
  * @type {Map<string, string>} Map<视图 id, 视图所属应用>
30588
30634
  */
30589
30635
  this.view2appMap = /* @__PURE__ */ new Map();
30636
+ /**
30637
+ * 当前注册的应用视图优先级
30638
+ *
30639
+ * @author chitanda
30640
+ * @date 2024-01-15 15:01:57
30641
+ * @protected
30642
+ * @type {Map<string, number>}
30643
+ */
30644
+ this.view2appPriorityMap = /* @__PURE__ */ new Map();
30590
30645
  /**
30591
30646
  * 实例化的应用视图模型
30592
30647
  *
@@ -30678,13 +30733,23 @@ var AppHub = class {
30678
30733
  * 设置应用视图所属应用
30679
30734
  *
30680
30735
  * @author chitanda
30681
- * @date 2023-04-17 23:04:37
30736
+ * @date 2024-01-15 15:01:41
30682
30737
  * @param {string} tag 视图 codeName 或者视图 id
30683
30738
  * @param {string} [appId=ibiz.env.appId]
30739
+ * @param {number} [priority=-1] 视图的优先级,值越小优先级越高。1为最高优先级
30684
30740
  */
30685
- setAppView(tag, appId2 = ibiz.env.appId) {
30741
+ setAppView(tag, appId2 = ibiz.env.appId, priority = -1) {
30686
30742
  const id = this.calcAppViewId(tag);
30743
+ if (this.view2appMap.has(id)) {
30744
+ const _priority = this.view2appPriorityMap.get(id);
30745
+ if (_priority && _priority < priority) {
30746
+ return;
30747
+ }
30748
+ }
30687
30749
  this.view2appMap.set(id, appId2);
30750
+ if (priority !== -1) {
30751
+ this.view2appPriorityMap.set(id, priority);
30752
+ }
30688
30753
  }
30689
30754
  /**
30690
30755
  * 判断应用视图是否存在