@ibiz-template/runtime 0.1.25 → 0.1.26

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 (44) hide show
  1. package/dist/index.esm.js +162 -36
  2. package/dist/index.system.min.js +1 -1
  3. package/dist/index.system.min.js.map +1 -1
  4. package/out/de-logic/de-logic-node/end-node/end-node.js +1 -1
  5. package/out/de-logic/utils/handle-src-val.js +1 -1
  6. package/out/global/global-util/global-util.d.ts +8 -1
  7. package/out/global/global-util/global-util.d.ts.map +1 -1
  8. package/out/global/global-util/global-util.js +8 -1
  9. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts +13 -1
  10. package/out/logic-scheduler/executor/app-ui-logic-executor.d.ts.map +1 -1
  11. package/out/logic-scheduler/executor/app-ui-logic-executor.js +106 -24
  12. package/out/service/service/control/control.service.d.ts.map +1 -1
  13. package/out/service/service/control/control.service.js +1 -1
  14. package/out/service/service/entity/de.service.d.ts.map +1 -1
  15. package/out/service/service/entity/de.service.js +1 -1
  16. package/out/service/service/entity/method/de-action.d.ts +1 -1
  17. package/out/service/service/entity/method/de-action.d.ts.map +1 -1
  18. package/out/service/service/entity/method/de-action.js +7 -7
  19. package/out/service/service/entity/method/method.d.ts +2 -2
  20. package/out/service/service/entity/method/method.d.ts.map +1 -1
  21. package/out/types.d.ts +11 -0
  22. package/out/types.d.ts.map +1 -1
  23. package/out/ui-logic/ui-logic-node/end-node/end-node.js +1 -1
  24. package/out/ui-logic/utils/handle-src-val.js +1 -1
  25. package/out/utils/index.d.ts +1 -0
  26. package/out/utils/index.d.ts.map +1 -1
  27. package/out/utils/index.js +1 -0
  28. package/out/utils/raw-value-util/raw-value-util.d.ts +23 -0
  29. package/out/utils/raw-value-util/raw-value-util.d.ts.map +1 -0
  30. package/out/utils/raw-value-util/raw-value-util.js +37 -0
  31. package/package.json +4 -4
  32. package/src/de-logic/de-logic-node/end-node/end-node.ts +1 -1
  33. package/src/de-logic/utils/handle-src-val.ts +1 -1
  34. package/src/global/global-util/global-util.ts +14 -1
  35. package/src/logic-scheduler/executor/app-ui-logic-executor.ts +129 -30
  36. package/src/service/service/control/control.service.ts +2 -2
  37. package/src/service/service/entity/de.service.ts +2 -2
  38. package/src/service/service/entity/method/de-action.ts +18 -12
  39. package/src/service/service/entity/method/method.ts +6 -6
  40. package/src/types.ts +12 -0
  41. package/src/ui-logic/ui-logic-node/end-node/end-node.ts +1 -1
  42. package/src/ui-logic/utils/handle-src-val.ts +1 -1
  43. package/src/utils/index.ts +1 -0
  44. package/src/utils/raw-value-util/raw-value-util.ts +37 -0
package/dist/index.esm.js CHANGED
@@ -8579,6 +8579,36 @@ var TextUtil = class {
8579
8579
  }
8580
8580
  };
8581
8581
 
8582
+ // src/utils/raw-value-util/raw-value-util.ts
8583
+ var RawValueUtil = class {
8584
+ /**
8585
+ * 字符串是否完全由整数/浮点数组成
8586
+ *
8587
+ * @param {string} str
8588
+ * @return {*}
8589
+ */
8590
+ isNumber(str) {
8591
+ return /^-?\d+(\.\d+)?$/.test(str);
8592
+ }
8593
+ /**
8594
+ * 转换直接值
8595
+ *
8596
+ * @param {string} val
8597
+ * @return {*}
8598
+ */
8599
+ format(val) {
8600
+ let tempVal = val;
8601
+ if (val !== void 0) {
8602
+ if (val === "true" || val === "false") {
8603
+ tempVal = val === "true";
8604
+ } else if (this.isNumber(val)) {
8605
+ tempVal = parseFloat(val);
8606
+ }
8607
+ }
8608
+ return tempVal;
8609
+ }
8610
+ };
8611
+
8582
8612
  // src/command/app/open-app-view/open-app-view.ts
8583
8613
  import { ModelError as ModelError3, RuntimeError as RuntimeError4 } from "@ibiz-template/core";
8584
8614
  var _OpenAppViewCommand = class _OpenAppViewCommand {
@@ -12018,7 +12048,7 @@ var EndNode = class extends DELogicNode {
12018
12048
  ctx.result = null;
12019
12049
  break;
12020
12050
  case "SRCVALUE":
12021
- ctx.result = rawValue;
12051
+ ctx.result = ibiz.util.rawValue.format(rawValue);
12022
12052
  break;
12023
12053
  case "LOGICPARAM":
12024
12054
  ctx.result = ctx.params[returnParamId];
@@ -12056,7 +12086,7 @@ function handleSrcVal(ctx, srcValParams) {
12056
12086
  case "NONEVALUE":
12057
12087
  return void 0;
12058
12088
  case "SRCVALUE":
12059
- return srcValue;
12089
+ return ibiz.util.rawValue.format(srcValue);
12060
12090
  case "WEBCONTEXT":
12061
12091
  case "VIEWPARAM":
12062
12092
  value = ctx.viewParams;
@@ -12684,18 +12714,18 @@ var DEActionMethod = class extends Method {
12684
12714
  if (!deLogic) {
12685
12715
  throw new RuntimeModelError18(this.method, "\u7F3A\u5C11\u5B9E\u4F53\u5904\u7406\u903B\u8F91");
12686
12716
  }
12687
- return execDELogicAction(deLogic, context, data, params);
12717
+ return execDELogicAction(deLogic, context, data || {}, params || {});
12688
12718
  }
12689
- if (!this.isLocalMode) {
12719
+ if (data && !this.isLocalMode) {
12690
12720
  data = await this.input.handle(context, data);
12691
12721
  }
12692
- if (!["READ", "GETDRAFT"].includes(this.method.actionMode)) {
12693
- await execFieldLogics(this.entity, "change", context, data, params);
12722
+ if (data && !["READ", "GETDRAFT"].includes(this.method.actionMode)) {
12723
+ await execFieldLogics(this.entity, "change", context, data, params || {});
12694
12724
  }
12695
12725
  let result;
12696
12726
  switch (this.method.codeName) {
12697
12727
  case "Create":
12698
- result = await this.create(context, data, params);
12728
+ result = await this.create(context, data, params || {});
12699
12729
  break;
12700
12730
  case "Get":
12701
12731
  result = await this.get(context, params);
@@ -12727,14 +12757,20 @@ var DEActionMethod = class extends Method {
12727
12757
  default: {
12728
12758
  let path2 = this.calcPath(context);
12729
12759
  if (this.method.needResourceKey) {
12730
- path2 = "".concat(path2, "/").concat(context[this.entity.codeName.toLowerCase()] || data[this.entity.keyAppDEFieldId]);
12760
+ path2 = "".concat(path2, "/").concat(context[this.entity.codeName.toLowerCase()] || (data == null ? void 0 : data[this.entity.keyAppDEFieldId]));
12731
12761
  }
12732
12762
  const res = await this.request(path2, context, data, params);
12733
12763
  res.data = await this.result.handle(context, res.data);
12734
12764
  result = res;
12735
12765
  }
12736
12766
  }
12737
- await execFieldLogics(this.entity, "compute", context, result.data, params);
12767
+ await execFieldLogics(
12768
+ this.entity,
12769
+ "compute",
12770
+ context,
12771
+ result.data,
12772
+ params || {}
12773
+ );
12738
12774
  return result;
12739
12775
  }
12740
12776
  /**
@@ -13213,7 +13249,7 @@ var DEService = class {
13213
13249
  * @param {IParams} [params2={}] 查询参数
13214
13250
  * @return {*} {Promise<IHttpResponse>}
13215
13251
  */
13216
- exec(id, context, params = {}, params2 = {}) {
13252
+ exec(id, context, params, params2) {
13217
13253
  const method = this.getMethod(id);
13218
13254
  if (method) {
13219
13255
  return method.exec(context, params, params2);
@@ -13452,7 +13488,7 @@ var ControlService = class {
13452
13488
  * @param {IParams} [params={}] 视图参数或数据
13453
13489
  * @returns {*} {Promise<IHttpResponse>}
13454
13490
  */
13455
- async exec(methodName, context, data = {}, params = {}) {
13491
+ async exec(methodName, context, data, params) {
13456
13492
  const res = await this.app.deService.exec(
13457
13493
  this.model.appDataEntityId,
13458
13494
  methodName,
@@ -18388,7 +18424,7 @@ var EndNode2 = class extends UILogicNode {
18388
18424
  ctx.result = null;
18389
18425
  break;
18390
18426
  case "SRCVALUE":
18391
- ctx.result = rawValue;
18427
+ ctx.result = ibiz.util.rawValue.format(rawValue);
18392
18428
  break;
18393
18429
  case "LOGICPARAM":
18394
18430
  ctx.result = ctx.params[returnParamId];
@@ -18424,7 +18460,7 @@ function handleSrcVal2(ctx, srcValParams) {
18424
18460
  case "NONEVALUE":
18425
18461
  return void 0;
18426
18462
  case "SRCVALUE":
18427
- return srcValue;
18463
+ return ibiz.util.rawValue.format(srcValue);
18428
18464
  case "WEBCONTEXT":
18429
18465
  case "VIEWPARAM":
18430
18466
  value = ctx.viewParams;
@@ -28774,6 +28810,13 @@ var GlobalUtil = class {
28774
28810
  * @date 2023-08-28 23:08:59
28775
28811
  */
28776
28812
  this.hbs = new HandlebarsUtil();
28813
+ /**
28814
+ * 直接值工具
28815
+ *
28816
+ * @author zhujiamin
28817
+ * @date 2023-08-24 11:08:28
28818
+ */
28819
+ this.rawValue = new RawValueUtil();
28777
28820
  }
28778
28821
  /**
28779
28822
  * 显示应用级别的加载提示
@@ -29478,6 +29521,29 @@ var AppUILogicExecutor = class extends LogicExecutor {
29478
29521
  rest
29479
29522
  );
29480
29523
  }
29524
+ async calcOpenViewRef(appUILogic, parameters) {
29525
+ const appDataEntityId = parameters.view.model.appDataEntityId;
29526
+ const formTypeName = await getFormTypeFieldName(appDataEntityId);
29527
+ if (!formTypeName) {
29528
+ throw new RuntimeModelError56(
29529
+ appUILogic,
29530
+ "".concat(appDataEntityId, "\u5B9E\u4F53\u7F3A\u5C11\u8868\u5355\u7C7B\u578B\u5E94\u7528\u5B9E\u4F53\u5C5E\u6027")
29531
+ );
29532
+ }
29533
+ const { data } = parameters;
29534
+ const formTypeValue = data[0][formTypeName];
29535
+ if (!formTypeValue) {
29536
+ throw new RuntimeModelError56(appUILogic, "\u6570\u636E\u6E90\u65E0\u8868\u5355\u7C7B\u578B\u5E94\u7528\u5B9E\u4F53\u5C5E\u6027\u503C");
29537
+ }
29538
+ const openViewRefs = appUILogic.openDataAppViews;
29539
+ const findView = openViewRefs == null ? void 0 : openViewRefs.find((item) => item.refMode === formTypeValue);
29540
+ if (!findView) {
29541
+ throw new RuntimeError52(
29542
+ "\u6CA1\u6709\u627E\u5230\u4E0E\u8868\u5355\u7C7B\u578B".concat(formTypeValue, "\u76F8\u5173\u7684\u5B9E\u4F53\u7684\u7F16\u8F91\u89C6\u56FE")
29543
+ );
29544
+ }
29545
+ return findView;
29546
+ }
29481
29547
  /**
29482
29548
  * 执行应用预置界面逻辑newdata
29483
29549
  *
@@ -29492,7 +29558,7 @@ var AppUILogicExecutor = class extends LogicExecutor {
29492
29558
  */
29493
29559
  async executeNewDataAppUILogic(appUILogic, parameters) {
29494
29560
  const { context, params, ...rest } = parameters;
29495
- const { data } = parameters;
29561
+ const { data, view } = parameters;
29496
29562
  const { enableWizardAdd, enableBatchAdd, batchAddOnly, newDataAppView } = appUILogic;
29497
29563
  let newViewRef;
29498
29564
  if (enableWizardAdd) {
@@ -29501,7 +29567,19 @@ var AppUILogicExecutor = class extends LogicExecutor {
29501
29567
  return { ok: false };
29502
29568
  }
29503
29569
  } else if (enableBatchAdd) {
29504
- throw new ModelError30(appUILogic, "enableBatchAdd\u6682\u672A\u652F\u6301");
29570
+ const parentDeName = calcDeCodeNameById(
29571
+ view.parentView.model.appDataEntityId
29572
+ );
29573
+ const batchViews = appUILogic.batchAddAppViews;
29574
+ newViewRef = batchViews == null ? void 0 : batchViews.find((viewRef) => {
29575
+ return viewRef.refMode.toLowerCase() !== parentDeName;
29576
+ });
29577
+ if (!newViewRef) {
29578
+ throw new RuntimeModelError56(
29579
+ appUILogic,
29580
+ "\u6CA1\u6709\u627E\u5230\u6279\u6DFB\u52A0\u9700\u8981\u6253\u5F00\u7684\u9009\u62E9\u89C6\u56FE"
29581
+ );
29582
+ }
29505
29583
  } else if (batchAddOnly) {
29506
29584
  throw new ModelError30(appUILogic, "batchAddOnly\u6682\u672A\u652F\u6301");
29507
29585
  } else {
@@ -29529,13 +29607,17 @@ var AppUILogicExecutor = class extends LogicExecutor {
29529
29607
  _data.srfkey = void 0;
29530
29608
  tempParams = Object.assign(tempParams, _data.$origin);
29531
29609
  }
29532
- return ibiz.commands.execute(
29610
+ const result = await ibiz.commands.execute(
29533
29611
  OpenAppViewCommand.TAG,
29534
29612
  newViewRef.refAppViewId,
29535
29613
  tempContext,
29536
29614
  tempParams,
29537
29615
  rest
29538
29616
  );
29617
+ if (enableBatchAdd && result.data) {
29618
+ await this.doBatchAdd(appUILogic, result.data, context, newViewRef);
29619
+ }
29620
+ return result;
29539
29621
  }
29540
29622
  /**
29541
29623
  * 获取向导新建视图引用
@@ -29578,28 +29660,71 @@ var AppUILogicExecutor = class extends LogicExecutor {
29578
29660
  }
29579
29661
  return findView;
29580
29662
  }
29581
- async calcOpenViewRef(appUILogic, parameters) {
29582
- const appDataEntityId = parameters.view.model.appDataEntityId;
29583
- const formTypeName = await getFormTypeFieldName(appDataEntityId);
29584
- if (!formTypeName) {
29585
- throw new RuntimeModelError56(
29586
- appUILogic,
29587
- "".concat(appDataEntityId, "\u5B9E\u4F53\u7F3A\u5C11\u8868\u5355\u7C7B\u578B\u5E94\u7528\u5B9E\u4F53\u5C5E\u6027")
29588
- );
29589
- }
29590
- const { data } = parameters;
29591
- const formTypeValue = data[0][formTypeName];
29592
- if (!formTypeValue) {
29593
- throw new RuntimeModelError56(appUILogic, "\u6570\u636E\u6E90\u65E0\u8868\u5355\u7C7B\u578B\u5E94\u7528\u5B9E\u4F53\u5C5E\u6027\u503C");
29594
- }
29595
- const openViewRefs = appUILogic.openDataAppViews;
29596
- const findView = openViewRefs == null ? void 0 : openViewRefs.find((item) => item.refMode === formTypeValue);
29597
- if (!findView) {
29598
- throw new RuntimeError52(
29599
- "\u6CA1\u6709\u627E\u5230\u4E0E\u8868\u5355\u7C7B\u578B".concat(formTypeValue, "\u76F8\u5173\u7684\u5B9E\u4F53\u7684\u7F16\u8F91\u89C6\u56FE")
29663
+ /**
29664
+ * 拿选中的数据做批添加新建
29665
+ * @author lxm
29666
+ * @date 2023-09-15 05:20:02
29667
+ * @protected
29668
+ * @param {IAppUIOpenDataLogic} appUILogic
29669
+ * @param {IData[]} selections
29670
+ * @param {IContext} context
29671
+ * @param {IAppUILogicRefViewBase} newViewRef
29672
+ * @return {*} {Promise<void>}
29673
+ */
29674
+ async doBatchAdd(appUILogic, selections, context, newViewRef) {
29675
+ var _a;
29676
+ if (selections == null ? void 0 : selections.length) {
29677
+ const selfDe = await ibiz.hub.getAppDataEntity(
29678
+ appUILogic.appDataEntityId,
29679
+ context.srfappid
29600
29680
  );
29681
+ const minorDERs = selfDe.minorAppDERSs;
29682
+ const pickParentDeName = newViewRef.refMode.toLowerCase();
29683
+ if (!minorDERs) {
29684
+ throw new RuntimeModelError56(selfDe, "\u5B9E\u4F53\u6CA1\u6709\u4ECE\u5173\u7CFB\u96C6\u5408\uFF01");
29685
+ }
29686
+ let pickParentFieldName;
29687
+ minorDERs == null ? void 0 : minorDERs.forEach((item) => {
29688
+ const majorDeName = calcDeCodeNameById(item.majorAppDataEntityId);
29689
+ if (pickParentDeName === majorDeName) {
29690
+ pickParentFieldName = item.parentAppDEFieldId;
29691
+ }
29692
+ });
29693
+ const openViewKeyParam = (_a = newViewRef.navigateParams) == null ? void 0 : _a.find((navParam) => {
29694
+ return navParam.key === "keymapping";
29695
+ });
29696
+ let addData = [];
29697
+ if (openViewKeyParam) {
29698
+ const keyValuePairs = openViewKeyParam.value.split(";");
29699
+ const keyMapping = {};
29700
+ for (const pair of keyValuePairs) {
29701
+ const [sourceKey, targetKey] = pair.split(":");
29702
+ if (sourceKey && targetKey) {
29703
+ keyMapping[sourceKey] = targetKey;
29704
+ }
29705
+ }
29706
+ addData = selections.map((item) => {
29707
+ const tempData = {
29708
+ [pickParentFieldName]: item.srfkey
29709
+ };
29710
+ for (const key in keyMapping) {
29711
+ if (Object.prototype.hasOwnProperty.call(keyMapping, key)) {
29712
+ const targetKey = keyMapping[key];
29713
+ if (Object.prototype.hasOwnProperty.call(item, key)) {
29714
+ tempData[targetKey] = item[key];
29715
+ }
29716
+ }
29717
+ }
29718
+ return tempData;
29719
+ });
29720
+ } else {
29721
+ addData = selections.map((item) => ({
29722
+ [pickParentFieldName]: item.srfkey
29723
+ }));
29724
+ }
29725
+ const service = ibiz.hub.getApp(context.srfappid).deService;
29726
+ await service.exec(selfDe.id, "Create", context, addData);
29601
29727
  }
29602
- return findView;
29603
29728
  }
29604
29729
  };
29605
29730
 
@@ -29927,6 +30052,7 @@ export {
29927
30052
  PortletPartController,
29928
30053
  PortletPartState,
29929
30054
  QXEventEx,
30055
+ RawValueUtil,
29930
30056
  RegisterCenter,
29931
30057
  RemotePluginItem,
29932
30058
  ScriptFactory,