@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.2

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 (98) hide show
  1. package/out/breakpoint/shared/utils.js +1 -19
  2. package/out/breakpoint/shared/utils.js.map +1 -1
  3. package/out/breakpoint/store/core.js +1 -1
  4. package/out/breakpoint/store/core.js.map +1 -1
  5. package/out/common/BaseNode.d.ts +9 -0
  6. package/out/common/BaseNode.js +15 -0
  7. package/out/common/BaseNode.js.map +1 -1
  8. package/out/common/Command.js +1 -0
  9. package/out/common/Command.js.map +1 -1
  10. package/out/common/EventEmitter.d.ts +1 -1
  11. package/out/common/EventEmitter.js +0 -4
  12. package/out/common/EventEmitter.js.map +1 -1
  13. package/out/concepts/AnonymousFunction__.d.ts +6 -1
  14. package/out/concepts/AnonymousFunction__.js +34 -16
  15. package/out/concepts/AnonymousFunction__.js.map +1 -1
  16. package/out/concepts/App__.d.ts +29 -0
  17. package/out/concepts/App__.js +120 -21
  18. package/out/concepts/App__.js.map +1 -1
  19. package/out/concepts/BindAttribute__.js.map +1 -1
  20. package/out/concepts/BindEvent__.js +2 -2
  21. package/out/concepts/BindEvent__.js.map +1 -1
  22. package/out/concepts/BusinessComponent__.d.ts +1 -1
  23. package/out/concepts/BusinessComponent__.js +107 -87
  24. package/out/concepts/BusinessComponent__.js.map +1 -1
  25. package/out/concepts/CallEvent__.d.ts +4 -0
  26. package/out/concepts/CallEvent__.js +18 -1
  27. package/out/concepts/CallEvent__.js.map +1 -1
  28. package/out/concepts/CallFunction__.d.ts +0 -1
  29. package/out/concepts/CallFunction__.js +0 -8
  30. package/out/concepts/CallFunction__.js.map +1 -1
  31. package/out/concepts/Destination__.js +3 -3
  32. package/out/concepts/Destination__.js.map +1 -1
  33. package/out/concepts/Entity__.d.ts +1 -1
  34. package/out/concepts/Entity__.js +2 -0
  35. package/out/concepts/Entity__.js.map +1 -1
  36. package/out/concepts/Logic__.js +15 -8
  37. package/out/concepts/Logic__.js.map +1 -1
  38. package/out/concepts/Match__.d.ts +1 -1
  39. package/out/concepts/ValidationRule__.js +2 -1
  40. package/out/concepts/ValidationRule__.js.map +1 -1
  41. package/out/concepts/ViewElement__.d.ts +1 -0
  42. package/out/concepts/ViewElement__.js +20 -3
  43. package/out/concepts/ViewElement__.js.map +1 -1
  44. package/out/concepts/View__.js +19 -18
  45. package/out/concepts/View__.js.map +1 -1
  46. package/out/server/extendBaseNode.js +18 -0
  47. package/out/server/extendBaseNode.js.map +1 -1
  48. package/out/server/getProcesses.js +3 -3
  49. package/out/server/getProcesses.js.map +1 -1
  50. package/out/server/naslServer.js +16 -12
  51. package/out/server/naslServer.js.map +1 -1
  52. package/out/service/storage/init.js +24 -1
  53. package/out/service/storage/init.js.map +1 -1
  54. package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
  55. package/out/templator/genCurdMultipleKeyBlock.js +673 -1
  56. package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
  57. package/out/templator/genGetBlock.js +2 -1
  58. package/out/templator/genGetBlock.js.map +1 -1
  59. package/out/templator/genTableBlock.d.ts +2 -0
  60. package/out/templator/genTableBlock.js +114 -1
  61. package/out/templator/genTableBlock.js.map +1 -1
  62. package/out/templator/genUpdateBlock.js +2 -1
  63. package/out/templator/genUpdateBlock.js.map +1 -1
  64. package/out/translator/utils.js +30 -1
  65. package/out/translator/utils.js.map +1 -1
  66. package/out/utils/index.d.ts +17 -0
  67. package/out/utils/index.js +184 -1
  68. package/out/utils/index.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/breakpoint/shared/utils.ts +2 -24
  71. package/src/breakpoint/store/core.ts +1 -1
  72. package/src/common/BaseNode.ts +19 -0
  73. package/src/common/Command.ts +1 -0
  74. package/src/common/EventEmitter.ts +1 -6
  75. package/src/concepts/AnonymousFunction__.ts +36 -18
  76. package/src/concepts/App__.ts +132 -21
  77. package/src/concepts/BindAttribute__.ts +0 -1
  78. package/src/concepts/BindEvent__.ts +2 -2
  79. package/src/concepts/BusinessComponent__.ts +122 -98
  80. package/src/concepts/CallEvent__.ts +19 -2
  81. package/src/concepts/CallFunction__.ts +0 -11
  82. package/src/concepts/Destination__.ts +3 -3
  83. package/src/concepts/Entity__.ts +3 -1
  84. package/src/concepts/Logic__.ts +15 -9
  85. package/src/concepts/ValidationRule__.ts +6 -1
  86. package/src/concepts/ViewElement__.ts +26 -3
  87. package/src/concepts/View__.ts +19 -18
  88. package/src/server/extendBaseNode.ts +21 -0
  89. package/src/server/getProcesses.ts +3 -3
  90. package/src/server/naslServer.ts +17 -11
  91. package/src/service/storage/init.ts +31 -1
  92. package/src/templator/genCurdMultipleKeyBlock.ts +781 -57
  93. package/src/templator/genGetBlock.ts +2 -1
  94. package/src/templator/genTableBlock.ts +127 -2
  95. package/src/templator/genUpdateBlock.ts +2 -1
  96. package/src/translator/utils.ts +32 -1
  97. package/src/utils/index.ts +211 -1
  98. package/ts-worker/src/index.js +1 -0
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.genReloadLogic = exports.genGridViewMultipleKeyBlock = exports.genCurdMultipleKeyBlock = exports.genUpdateSubmitLogic = exports.genSubmitLogic = void 0;
26
+ exports.genCurdMultipleKeyBlockForTableDesigner = exports.genDelModalTemplate = exports.genFilterTemplateTableDesigner = exports.genExportExcelLogic = exports.genResetLogic = exports.genReloadLogic = exports.genGridViewMultipleKeyBlock = exports.genCurdMultipleKeyBlock = exports.genUpdateSubmitLogic = exports.genSubmitLogic = void 0;
27
27
  /**
28
28
  * 1. 从genCurdBlock组件复制,算是工行的定制化需求多主键(联合主键的支持)
29
29
  * 2. 改动了原来判断id的逻辑
@@ -450,6 +450,56 @@ function genModifyLogic(entity, nameGroup) {
450
450
  playground: [],
451
451
  });
452
452
  }
453
+ function genDetailLogic(entity, nameGroup) {
454
+ const lowerEntityName = utils.firstLowerCase(entity.name);
455
+ return utils_1.NaslNode.Logic({
456
+ name: nameGroup.viewLogicPreview,
457
+ description: '',
458
+ params: [],
459
+ returns: [],
460
+ variables: [],
461
+ body: [
462
+ utils_1.NaslLogicItem.Start,
463
+ utils_1.NaslLogicItem.Assignment({
464
+ left: utils_1.NaslLogicItem.Identifier({
465
+ name: nameGroup.viewVariablePreview,
466
+ }),
467
+ right: utils_1.NaslLogicItem.Identifier({
468
+ name: 'true',
469
+ }),
470
+ }),
471
+ utils_1.NaslLogicItem.Assignment({
472
+ left: utils_1.NaslLogicItem.Identifier({
473
+ name: nameGroup.viewVariableInput,
474
+ }),
475
+ right: utils_1.NaslLogicItem.CallFunction({
476
+ calleeName: 'Clone',
477
+ arguments: [
478
+ utils_1.NaslLogicItem.Argument({
479
+ keyword: 'obj',
480
+ expression: utils_1.NaslLogicItem.MemberExpression({
481
+ object: utils_1.NaslLogicItem.MemberExpression({
482
+ object: utils_1.NaslLogicItem.Identifier({
483
+ name: 'current',
484
+ }),
485
+ property: utils_1.NaslLogicItem.Identifier({
486
+ name: 'item',
487
+ }),
488
+ }),
489
+ property: utils_1.NaslLogicItem.Identifier({
490
+ name: lowerEntityName,
491
+ }),
492
+ }),
493
+ }),
494
+ ],
495
+ }),
496
+ }),
497
+ (0, _1.genCallComponentLogic)(nameGroup.viewElementSaveModal, 'open'),
498
+ utils_1.NaslLogicItem.End,
499
+ ],
500
+ playground: [],
501
+ });
502
+ }
453
503
  // 列表(全)
454
504
  function genCurdMultipleKeyBlock(entity, oldNode) {
455
505
  const likeComponent = oldNode?.likeComponent;
@@ -703,4 +753,626 @@ function genReloadLogic(nameGroup) {
703
753
  });
704
754
  }
705
755
  exports.genReloadLogic = genReloadLogic;
756
+ function genResetLogic(nameGroup) {
757
+ return utils_1.NaslNode.Logic({
758
+ name: nameGroup.viewLogicReset,
759
+ params: [],
760
+ returns: [],
761
+ variables: [
762
+ utils_1.NaslNode.Variable({
763
+ name: 'validateResult',
764
+ typeAnnotation: utils_1.NaslUITypeAnnotation.ValidateEvent,
765
+ }),
766
+ ],
767
+ body: [
768
+ utils_1.NaslLogicItem.Start,
769
+ utils_1.NaslLogicItem.CallFunction({
770
+ calleeName: 'Clear',
771
+ arguments: [
772
+ utils_1.NaslLogicItem.Argument({
773
+ keyword: 'struct',
774
+ expression: utils_1.NaslLogicItem.Identifier({
775
+ name: nameGroup.viewVariableFilter,
776
+ }),
777
+ }),
778
+ ],
779
+ }),
780
+ (0, _1.genCallComponentLogic)(nameGroup.viewElementMainView, 'reload'),
781
+ utils_1.NaslLogicItem.End,
782
+ ],
783
+ playground: [],
784
+ });
785
+ }
786
+ exports.genResetLogic = genResetLogic;
787
+ function genExportExcelLogic(nameGroup) {
788
+ return utils_1.NaslNode.Logic({
789
+ name: nameGroup.viewLogicExportData,
790
+ params: [],
791
+ returns: [],
792
+ variables: [],
793
+ body: [
794
+ utils_1.NaslLogicItem.Start,
795
+ utils_1.NaslLogicItem.CallLogic({
796
+ calleeNamespace: `elements.${nameGroup.viewElementMainView}.logics`,
797
+ calleeName: 'exportExcel',
798
+ arguments: [
799
+ utils_1.NaslLogicItem.Argument({
800
+ keyword: 'page',
801
+ expression: {
802
+ concept: 'NumericLiteral',
803
+ value: '1',
804
+ typeAnnotation: {
805
+ concept: 'TypeAnnotation',
806
+ typeKind: 'primitive',
807
+ typeNamespace: 'nasl.core',
808
+ typeName: 'Long',
809
+ },
810
+ },
811
+ }),
812
+ utils_1.NaslLogicItem.Argument({
813
+ keyword: 'size',
814
+ expression: {
815
+ concept: 'NumericLiteral',
816
+ value: '9999',
817
+ typeAnnotation: {
818
+ concept: 'TypeAnnotation',
819
+ typeKind: 'primitive',
820
+ typeNamespace: 'nasl.core',
821
+ typeName: 'Long',
822
+ },
823
+ },
824
+ }),
825
+ utils_1.NaslLogicItem.Argument({
826
+ keyword: 'filename',
827
+ expression: null,
828
+ }),
829
+ utils_1.NaslLogicItem.Argument({
830
+ keyword: 'sort',
831
+ expression: null,
832
+ }),
833
+ utils_1.NaslLogicItem.Argument({
834
+ keyword: 'order',
835
+ expression: null,
836
+ }),
837
+ utils_1.NaslLogicItem.Argument({
838
+ keyword: 'excludeColumns',
839
+ expression: null,
840
+ }),
841
+ ],
842
+ }),
843
+ utils_1.NaslLogicItem.End,
844
+ ],
845
+ playground: [],
846
+ });
847
+ }
848
+ exports.genExportExcelLogic = genExportExcelLogic;
849
+ function genCloseModalLogic(nameGroup) {
850
+ return utils_1.NaslNode.Logic({
851
+ name: nameGroup.viewLogicCloseModal,
852
+ description: '',
853
+ params: [],
854
+ returns: [],
855
+ variables: [],
856
+ body: [
857
+ utils_1.NaslLogicItem.Start,
858
+ utils_1.NaslLogicItem.Assignment({
859
+ left: utils_1.NaslLogicItem.Identifier({
860
+ name: nameGroup.viewVariablePreview,
861
+ }),
862
+ right: utils_1.NaslLogicItem.Identifier({
863
+ name: 'false',
864
+ }),
865
+ }),
866
+ utils_1.NaslLogicItem.End,
867
+ ],
868
+ playground: [],
869
+ });
870
+ }
871
+ function genOpenDelModalLogic(entity, nameGroup) {
872
+ const lowerEntityName = utils.firstLowerCase(entity.name);
873
+ return utils_1.NaslNode.Logic({
874
+ name: nameGroup.viewLogicOpenDelModal,
875
+ description: '',
876
+ params: [],
877
+ returns: [],
878
+ variables: [],
879
+ body: [
880
+ utils_1.NaslLogicItem.Start,
881
+ utils_1.NaslLogicItem.Assignment({
882
+ left: utils_1.NaslLogicItem.Identifier({
883
+ name: nameGroup.viewVariableInput,
884
+ }),
885
+ right: utils_1.NaslLogicItem.CallFunction({
886
+ calleeName: 'Clone',
887
+ arguments: [
888
+ utils_1.NaslLogicItem.Argument({
889
+ keyword: 'obj',
890
+ expression: utils_1.NaslLogicItem.MemberExpression({
891
+ object: utils_1.NaslLogicItem.MemberExpression({
892
+ object: utils_1.NaslLogicItem.Identifier({
893
+ name: 'current',
894
+ }),
895
+ property: utils_1.NaslLogicItem.Identifier({
896
+ name: 'item',
897
+ }),
898
+ }),
899
+ property: utils_1.NaslLogicItem.Identifier({
900
+ name: lowerEntityName,
901
+ }),
902
+ }),
903
+ }),
904
+ ],
905
+ }),
906
+ }),
907
+ (0, _1.genCallComponentLogic)(nameGroup.viewElementDelModal, 'open'),
908
+ utils_1.NaslLogicItem.End,
909
+ ],
910
+ playground: [],
911
+ });
912
+ }
913
+ function genCloseDelModalLogic(nameGroup) {
914
+ return utils_1.NaslNode.Logic({
915
+ name: nameGroup.viewLogicCloseDelModal,
916
+ body: [utils_1.NaslLogicItem.Start, (0, _1.genCallComponentLogic)(nameGroup.viewElementDelModal, 'close'), utils_1.NaslLogicItem.End],
917
+ });
918
+ }
919
+ function genDelModalSubmitLogic(entity, nameGroup) {
920
+ const { ns } = entity;
921
+ const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
922
+ return utils_1.NaslNode.Logic({
923
+ name: nameGroup.viewLogicDelModalSubmit,
924
+ params: [],
925
+ returns: [],
926
+ variables: [],
927
+ body: [
928
+ utils_1.NaslLogicItem.Start,
929
+ utils_1.NaslLogicItem.CallLogic({
930
+ calleeNamespace: deleteLogic.getNamespace(),
931
+ calleeName: deleteLogic.name,
932
+ arguments: [
933
+ {
934
+ concept: 'Argument',
935
+ keyword: 'id',
936
+ expression: {
937
+ concept: 'MemberExpression',
938
+ object: {
939
+ concept: 'Identifier',
940
+ name: 'input',
941
+ },
942
+ property: {
943
+ concept: 'Identifier',
944
+ name: 'id',
945
+ },
946
+ },
947
+ },
948
+ ],
949
+ }),
950
+ (0, _1.genCallComponentLogic)(nameGroup.viewElementDelModal, 'close'),
951
+ (0, _1.genCallComponentLogic)(nameGroup.viewElementMainView, 'reload'),
952
+ utils_1.NaslLogicItem.End,
953
+ ],
954
+ });
955
+ }
956
+ function genFilterTemplateTableDesigner(entity, nameGroup, selectNameGroupMap, optionsMap) {
957
+ const dataSource = entity.parentNode;
958
+ const properties = entity.properties.filter((0, _1.filterProperty)('inFilter'));
959
+ const getCol = (code) => `<u-grid-layout-column span="6" style="padding: 10px 0;">${code}</u-grid-layout-column>`;
960
+ return `<u-form style="margin-bottom: 6px;padding: 15px 15px 5px 15px;background: #fff;">
961
+ <u-grid-layout>
962
+ <u-grid-layout-row repeat="24">
963
+ ${properties
964
+ .map((property) => {
965
+ const vModel = `${nameGroup.viewVariableFilter}.${property.name}`;
966
+ const label = (property.label || property.name).replace(/"/g, '&quot;');
967
+ let formItem = `<u-form-item layout="center"><template #label><u-text text="${label}"></u-text></template>`;
968
+ const { typeAnnotation } = property || {};
969
+ const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
970
+ const propertyTypeMaxLength = Number(property.rules
971
+ .find((item) => item.indexOf('max') > -1)
972
+ ?.split('(')[1]
973
+ .slice(0, -1)) || 0;
974
+ if (optionsMap?.[property.name]) {
975
+ const options = optionsMap?.[property.name];
976
+ const multiple = property?.typeAnnotation?.typeName === 'List';
977
+ formItem += `
978
+ <u-select clearable v-model="${vModel}" placeholder="请选择" ${multiple ? 'multiple' : ''}>
979
+ ${options.map((option) => `<u-select-item value="${option.value}">${option.label}</u-select-item>`).join('')}
980
+ </u-select>
981
+ `;
982
+ }
983
+ else if (property.relationEntity) {
984
+ // 有外键关联
985
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
986
+ if (relationEntity) {
987
+ const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
988
+ const displayedProperty = (0, _1.getFirstDisplayedProperty)(relationEntity);
989
+ if (displayedProperty) {
990
+ const lowerEntityName = utils.firstLowerCase(relationEntity.name);
991
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
992
+ const key = [property.name, relationEntity.name].join('-');
993
+ const selectNameGroup = selectNameGroupMap.get(key);
994
+ let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
995
+ formItem += `
996
+ <u-select clearable placeholder="请选择${label}" :data-source="${dataSourceValue}" :page-size="50"
997
+ text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pagination="true" v-model="${vModel}">
998
+ </u-select>
999
+ `;
1000
+ }
1001
+ else
1002
+ return '';
1003
+ }
1004
+ else
1005
+ return '';
1006
+ }
1007
+ else if (propertyTypeName === 'Boolean') {
1008
+ formItem += `
1009
+ <u-select clearable v-model="${vModel}" placeholder="请输入${label}">
1010
+ <u-select-item :value="true" text="是">是</u-select-item>
1011
+ <u-select-item :value="false" text="否">否</u-select-item>
1012
+ </u-select>
1013
+ `;
1014
+ }
1015
+ else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
1016
+ formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}"></u-number-input>`;
1017
+ }
1018
+ else if (propertyTypeName === 'Double') {
1019
+ formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
1020
+ }
1021
+ else if (propertyTypeName === 'Decimal') {
1022
+ formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
1023
+ }
1024
+ else if (propertyTypeName === 'String' && propertyTypeMaxLength > 256) {
1025
+ formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}"></u-textarea>`;
1026
+ }
1027
+ else if (propertyTypeName === 'Date') {
1028
+ formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}"></u-date-picker>`;
1029
+ }
1030
+ else if (propertyTypeName === 'Time') {
1031
+ formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}"></u-time-picker>`;
1032
+ }
1033
+ else if (propertyTypeName === 'DateTime') {
1034
+ formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}"></u-date-time-picker>`;
1035
+ }
1036
+ else {
1037
+ const namespaceArr = propertyTypeNamespace.split('.');
1038
+ const type = namespaceArr.pop();
1039
+ if (type === 'enums') {
1040
+ const Enum = dataSource.app.findNodeByCompleteName(`${propertyTypeNamespace}.${propertyTypeName}`);
1041
+ formItem += (0, _1.genEnumSelectBlock)(Enum, `${vModel}`, '', `请选择${label}`, true);
1042
+ }
1043
+ else {
1044
+ formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
1045
+ }
1046
+ }
1047
+ formItem += `</u-form-item>`;
1048
+ return getCol(formItem);
1049
+ })
1050
+ .join('')}
1051
+ ${getCol(`<u-form-item layout="center" label-size="auto">
1052
+ <u-button color="primary" style="margin-right: 5px" @click="${nameGroup.viewLogicReload}">查 询</u-button>
1053
+ <u-button @click="${nameGroup.viewLogicReset}">重 置</u-button>
1054
+ </u-form-item>`)}
1055
+ </u-grid-layout-row>
1056
+ </u-grid-layout>
1057
+ </u-form>
1058
+ `;
1059
+ }
1060
+ exports.genFilterTemplateTableDesigner = genFilterTemplateTableDesigner;
1061
+ function genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate) {
1062
+ const dataSource = entity.parentNode;
1063
+ const properties = entity.properties.filter((0, _1.filterProperty)('inForm'));
1064
+ const formStr = ` <u-form ref="${nameGroup.viewElementSaveModalForm}" :preview="${nameGroup.viewVariablePreview}">
1065
+ ${properties
1066
+ .map((property) => {
1067
+ const vModel = `${nameGroup.viewVariableInput}.${property.name}`;
1068
+ const label = (property.label || property.name).replace(/"/g, '&quot;');
1069
+ const required = !!property.required;
1070
+ const rules = [];
1071
+ if (property.rules && property.rules.length) {
1072
+ property.rules.forEach((rule) => rules.push(rule));
1073
+ }
1074
+ if (required)
1075
+ rules.push('required');
1076
+ const rulesStr = rules.join(' | ');
1077
+ let formItem = `<u-form-item ${required ? 'required' : ''} ${rulesStr.length ? `rules="${rulesStr}"` : ''} layout="center"><template #label><u-text text="${label}"></u-text></template>`;
1078
+ const { typeAnnotation } = property || {};
1079
+ const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
1080
+ const propertyTypeMaxLength = Number(property.rules
1081
+ .find((item) => item.indexOf('max') > -1)
1082
+ ?.split('(')[1]
1083
+ .slice(0, -1)) || 0;
1084
+ if (property.relationEntity) {
1085
+ // 有外键关联
1086
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
1087
+ if (relationEntity) {
1088
+ const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
1089
+ const displayedProperty = (0, _1.getFirstDisplayedProperty)(relationEntity);
1090
+ if (displayedProperty) {
1091
+ const lowerEntityName = utils.firstLowerCase(relationEntity.name);
1092
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
1093
+ const key = [property.name, relationEntity.name].join('-');
1094
+ const selectNameGroup = selectNameGroupMap.get(key);
1095
+ let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
1096
+ formItem += `
1097
+ <u-select clearable placeholder="请选择${label}"
1098
+ text-field="${lowerEntityName}.${displayedProperty.name}"
1099
+ value-field="${lowerEntityName}.${relationProperty.name}"
1100
+ :data-source="${dataSourceValue}" :page-size="50"
1101
+ :pagination="true"
1102
+ ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}
1103
+ v-model="${vModel}">
1104
+ </u-select>
1105
+ `;
1106
+ }
1107
+ else
1108
+ return '';
1109
+ }
1110
+ else
1111
+ return '';
1112
+ }
1113
+ else if (propertyTypeName === 'Boolean') {
1114
+ formItem += `
1115
+ <u-select clearable v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}>
1116
+ <u-select-item :value="true" text="是"><u-text text="是"></u-text></u-select-item>
1117
+ <u-select-item :value="false" text="否"><u-text text="否"></u-text></u-select-item>
1118
+ </u-select>`;
1119
+ }
1120
+ else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
1121
+ formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-number-input>`;
1122
+ }
1123
+ else if (propertyTypeName === 'Double') {
1124
+ formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-number-input>`;
1125
+ }
1126
+ else if (propertyTypeName === 'Decimal') {
1127
+ formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-number-input>`;
1128
+ }
1129
+ else if (propertyTypeName === 'String' && propertyTypeMaxLength > 256) {
1130
+ formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-textarea>`;
1131
+ }
1132
+ else if (propertyTypeName === 'Date') {
1133
+ formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-date-picker>`;
1134
+ }
1135
+ else if (propertyTypeName === 'Time') {
1136
+ formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-time-picker>`;
1137
+ }
1138
+ else if (propertyTypeName === 'DateTime') {
1139
+ formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-date-time-picker>`;
1140
+ }
1141
+ else {
1142
+ const namespaceArr = propertyTypeNamespace.split('.');
1143
+ const type = namespaceArr.pop();
1144
+ if (type === 'enums') {
1145
+ const Enum = dataSource.app.findNodeByCompleteName(`${propertyTypeNamespace}.${propertyTypeName}`);
1146
+ formItem += (0, _1.genEnumSelectBlock)(Enum, `${vModel}`, '', `请选择${label}`, true);
1147
+ }
1148
+ else {
1149
+ formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-input>`;
1150
+ }
1151
+ }
1152
+ formItem += `</u-form-item>\n`;
1153
+ return formItem;
1154
+ })
1155
+ .join('')}
1156
+ </u-form>`;
1157
+ if (SaveModalFormTemplate) {
1158
+ SaveModalFormTemplate = SaveModalFormTemplate.replace('<u-form', `<u-form ref="${nameGroup.viewElementSaveModalForm}" :preview="${nameGroup.viewVariablePreview}" `);
1159
+ }
1160
+ return `
1161
+ <u-modal ref="${nameGroup.viewElementSaveModal}" @close="${nameGroup.viewLogicCloseModal}" size="huge" :show-foot="!${nameGroup.viewVariablePreview}">
1162
+ <template #title>
1163
+ <div v-if="${nameGroup.viewVariablePreview}">
1164
+ <u-text>详情</u-text>
1165
+ </div>
1166
+ <div v-if="!${nameGroup.viewVariablePreview}">
1167
+ <div v-if="${nameGroup.viewVariableIsUpdate}"><u-text>修改</u-text></div>
1168
+ <div v-if="!${nameGroup.viewVariableIsUpdate}"><u-text>新增</u-text></div>
1169
+ </template>
1170
+ <template #body>
1171
+ ${SaveModalFormTemplate || formStr}
1172
+ </template>
1173
+ <template #foot>
1174
+ <u-linear-layout>
1175
+ <u-button color="primary" @click="${nameGroup.viewLogicUpdateSubmit}()" v-if="${nameGroup.viewVariableIsUpdate}">提交修改</u-button>
1176
+ <u-button color="primary" @click="${nameGroup.viewLogicSubmit}()" v-if="!${nameGroup.viewVariableIsUpdate}">立即新增</u-button>
1177
+ </u-linear-layout>
1178
+ </template>
1179
+ </u-modal>`;
1180
+ }
1181
+ const genDelModalTemplate = (nameGroup) => {
1182
+ return `
1183
+ <u-modal
1184
+ ref="${nameGroup.viewElementDelModal}"
1185
+ style="
1186
+ border-top-left-radius: 4px;
1187
+ border-top-right-radius: 4px;
1188
+ border-bottom-right-radius: 4px;
1189
+ border-bottom-left-radius: 4px;
1190
+ --update-key: d9hj;
1191
+ "
1192
+ icon="warning"
1193
+ >
1194
+ <template #foot>
1195
+ <u-linear-layout style="text-align: right" :vusion-disabled-cut="true" justify="center">
1196
+ <u-button text="取 消" @click="${nameGroup.viewLogicCloseDelModal}"></u-button>
1197
+ <u-button color="primary" text="确 定" @click="${nameGroup.viewLogicDelModalSubmit}"></u-button>
1198
+ </u-linear-layout>
1199
+ </template>
1200
+ <template #body>
1201
+ <u-text style="font-weight: bold; font-size: 18px" text="请确认是否删除?"></u-text>
1202
+ <u-linear-layout style="--custom-start: auto" direction="horizontal">
1203
+ <u-text
1204
+ style="--custom-start: auto"
1205
+ color="secondary"
1206
+ text="删除后将无法恢复,请谨慎操作"
1207
+ ></u-text>
1208
+ </u-linear-layout>
1209
+ </template>
1210
+ <template #title> <u-text></u-text> </template
1211
+ ></u-modal>
1212
+ `;
1213
+ };
1214
+ exports.genDelModalTemplate = genDelModalTemplate;
1215
+ // composedBy 节点组合属性
1216
+ function genCurdMultipleKeyBlockForTableDesigner(entity, oldNode, SaveModalFormTemplate, optionsMap, composedBy) {
1217
+ const { view } = oldNode;
1218
+ const dataSource = entity.parentNode;
1219
+ const module = dataSource.app;
1220
+ const composedByOptionStr = composedBy && composedBy.length > 0 ? `"composedBy":${JSON.stringify(composedBy)},` : '';
1221
+ const patchLogic = (logic) => {
1222
+ if (composedBy && composedBy.length > 0) {
1223
+ return {
1224
+ ...logic,
1225
+ composedBy,
1226
+ };
1227
+ }
1228
+ else
1229
+ return logic;
1230
+ };
1231
+ const viewElementMainView = view.getViewElementUniqueName('tableView');
1232
+ const nameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementMainView);
1233
+ nameGroup.viewElementMainView = viewElementMainView;
1234
+ nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
1235
+ nameGroup.viewElementDelModal = view.getViewElementUniqueName('delModal');
1236
+ nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
1237
+ nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
1238
+ nameGroup.viewLogicInit = view.getLogicUniqueName('init');
1239
+ nameGroup.viewLogicCreate = view.getLogicUniqueName('create');
1240
+ nameGroup.viewLogicModify = view.getLogicUniqueName('modify');
1241
+ nameGroup.viewLogicSubmit = view.getLogicUniqueName('submit');
1242
+ nameGroup.viewLogicUpdateSubmit = view.getLogicUniqueName('updateSubmit');
1243
+ nameGroup.viewLogicReload = view.getLogicUniqueName('reload');
1244
+ nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
1245
+ nameGroup.viewVariableInput = view.getVariableUniqueName('input');
1246
+ nameGroup.viewVariableFilter = view.getVariableUniqueName('filter');
1247
+ nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
1248
+ nameGroup.viewLogicReset = view.getLogicUniqueName('reset');
1249
+ nameGroup.viewLogicExportData = view.getLogicUniqueName('exportData');
1250
+ nameGroup.viewVariablePreview = view.getVariableUniqueName('preview');
1251
+ nameGroup.viewLogicPreview = view.getLogicUniqueName('preview');
1252
+ nameGroup.viewLogicCloseModal = view.getLogicUniqueName('closeModal');
1253
+ nameGroup.viewLogicOpenDelModal = view.getLogicUniqueName('openDelModal');
1254
+ nameGroup.viewLogicCloseDelModal = view.getLogicUniqueName('closeDelModal');
1255
+ nameGroup.viewLogicDelModalSubmit = view.getLogicUniqueName('delModalSubmit');
1256
+ // 收集所有和本实体关联的实体
1257
+ const entitySet = new Set();
1258
+ entitySet.add(entity);
1259
+ const selectNameGroupMap = new Map();
1260
+ const newLogics = [];
1261
+ const newLoadSelectLogics = [];
1262
+ entity.properties.forEach((property) => {
1263
+ // 有外键关联
1264
+ if (property.relationEntity) {
1265
+ const relationEntity = dataSource?.findEntityByName(property.relationEntity);
1266
+ if (relationEntity) {
1267
+ const displayedProperty = (0, _1.getFirstDisplayedProperty)(relationEntity);
1268
+ if (displayedProperty) {
1269
+ entitySet.add(relationEntity);
1270
+ const viewElementSelect = view.getViewElementUniqueName('select');
1271
+ const selectNameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementSelect, false, relationEntity.name);
1272
+ selectNameGroup.viewElementSelect = viewElementSelect;
1273
+ // 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
1274
+ const key = [property.name, relationEntity.name].join('-');
1275
+ selectNameGroupMap.set(key, selectNameGroup);
1276
+ const newLogic = (0, _1.genQueryLogic)([relationEntity], selectNameGroup, false, false, module);
1277
+ newLogics.push(newLogic);
1278
+ newLoadSelectLogics.push((0, _1.genLoadSelectLogic)(relationEntity, selectNameGroup, newLogic));
1279
+ }
1280
+ }
1281
+ }
1282
+ });
1283
+ const allEntities = [...entitySet];
1284
+ const entityLogic = (0, _1.genQueryLogic)(allEntities, nameGroup, true, true, module);
1285
+ newLogics.push(patchLogic(entityLogic));
1286
+ const code = `<template>
1287
+ <u-linear-layout direction="vertical" :bindEntity="" :TableDesignerLocked="true" style="background: #F7F8FA;">
1288
+ ${genFilterTemplateTableDesigner(entity, nameGroup, selectNameGroupMap, optionsMap)}
1289
+ ${(0, _1.genTableTemplateTableDesigner)(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock', optionsMap)}
1290
+ ${genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate)}
1291
+ ${(0, exports.genDelModalTemplate)(nameGroup)}
1292
+ </u-linear-layout>
1293
+ </template>
1294
+
1295
+ <definition>
1296
+ {
1297
+ "viewVariables": [
1298
+ {
1299
+ "concept": "Variable",
1300
+ ${composedByOptionStr}
1301
+ "name": "${nameGroup.viewVariableEntity}",
1302
+ "typeAnnotation": ${JSON.stringify(utils_1.NaslTypeAnnotation.Reference({
1303
+ typeNamespace: entity.getNamespace(),
1304
+ typeName: entity.name,
1305
+ }))}
1306
+ },
1307
+ {
1308
+ "concept": "Variable",
1309
+ ${composedByOptionStr}
1310
+ "name": "${nameGroup.viewVariableInput}",
1311
+ "typeAnnotation": ${JSON.stringify(utils_1.NaslTypeAnnotation.Reference({
1312
+ typeNamespace: entity.getNamespace(),
1313
+ typeName: entity.name,
1314
+ }))}
1315
+ },
1316
+ {
1317
+ "concept": "Variable",
1318
+ ${composedByOptionStr}
1319
+ "name": "${nameGroup.viewVariableFilter}",
1320
+ "typeAnnotation": ${JSON.stringify(utils_1.NaslTypeAnnotation.Reference({
1321
+ typeNamespace: entity.getNamespace(),
1322
+ typeName: entity.name,
1323
+ }))}
1324
+ },
1325
+ {
1326
+ "concept": "Variable",
1327
+ ${composedByOptionStr}
1328
+ "name": "${nameGroup.viewVariableIsUpdate}",
1329
+ "typeAnnotation": ${JSON.stringify(utils_1.NaslCoreTypeAnnotation.Boolean)}
1330
+ },
1331
+ {
1332
+ "concept": "Variable",
1333
+ ${composedByOptionStr}
1334
+ "name": "${nameGroup.viewVariablePreview}",
1335
+ "typeAnnotation": ${JSON.stringify(utils_1.NaslCoreTypeAnnotation.Boolean)}
1336
+ }
1337
+ ],
1338
+ "viewLogics": [
1339
+ ${JSON.stringify(patchLogic((0, _1.genTableLoadLogic)(entity, nameGroup, entityLogic, true)))},
1340
+ ${JSON.stringify(patchLogic((0, _1.genTableRemoveLogic)(entity, nameGroup)))},
1341
+ ${JSON.stringify(patchLogic(genInitLogic(nameGroup)))},
1342
+ ${JSON.stringify(patchLogic(genCreateLogic(nameGroup)))},
1343
+ ${JSON.stringify(patchLogic(genModifyLogic(entity, nameGroup)))},
1344
+ ${JSON.stringify(patchLogic(genSubmitLogic(entity, nameGroup)))},
1345
+ ${JSON.stringify(patchLogic(genDetailLogic(entity, nameGroup)))},
1346
+ ${JSON.stringify(patchLogic(genCloseModalLogic(nameGroup)))},
1347
+ ${JSON.stringify(patchLogic(genDelModalSubmitLogic(entity, nameGroup)))},
1348
+ ${JSON.stringify(patchLogic(genOpenDelModalLogic(entity, nameGroup)))},
1349
+ ${JSON.stringify(patchLogic(genCloseDelModalLogic(nameGroup)))},
1350
+ ${JSON.stringify(patchLogic(genUpdateSubmitLogic(entity, nameGroup)))},
1351
+ ${JSON.stringify(patchLogic(genReloadLogic(nameGroup)))},
1352
+ ${JSON.stringify(patchLogic(genResetLogic(nameGroup)))},
1353
+ ${JSON.stringify(patchLogic(genExportExcelLogic(nameGroup)))}
1354
+ ${newLoadSelectLogics.map((logic) => `,${JSON.stringify(patchLogic(logic))}`).join('\n')}
1355
+ ],
1356
+ "viewBindEvents": [
1357
+ {
1358
+ "concept": "BindEvent",
1359
+ ${composedByOptionStr}
1360
+ "arguments": [],
1361
+ "name": "created",
1362
+ "calleeNamespace": "",
1363
+ "calleeName": "${nameGroup.viewLogicInit}"
1364
+ }
1365
+ ],
1366
+
1367
+ "logics": ${JSON.stringify(newLogics)}
1368
+ }
1369
+ </definition>
1370
+ `;
1371
+ return {
1372
+ code,
1373
+ nameGroup,
1374
+ saveFormTemp: `${genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate)}`,
1375
+ };
1376
+ }
1377
+ exports.genCurdMultipleKeyBlockForTableDesigner = genCurdMultipleKeyBlockForTableDesigner;
706
1378
  //# sourceMappingURL=genCurdMultipleKeyBlock.js.map