@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.1
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/out/bak/translator.js +39 -119
- package/out/bak/translator.js.map +1 -1
- package/out/breakpoint/generator/BreakpointNode.d.ts +0 -3
- package/out/breakpoint/generator/BreakpointNode.js +0 -9
- package/out/breakpoint/generator/BreakpointNode.js.map +1 -1
- package/out/breakpoint/shared/constants.js +0 -1
- package/out/breakpoint/shared/constants.js.map +1 -1
- package/out/breakpoint/shared/utils.js +7 -31
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/common/BaseNode.d.ts +13 -1
- package/out/common/BaseNode.js +52 -23
- package/out/common/BaseNode.js.map +1 -1
- package/out/common/Command.js +1 -0
- package/out/common/Command.js.map +1 -1
- package/out/common/EventEmitter.d.ts +1 -1
- package/out/common/EventEmitter.js +0 -4
- package/out/common/EventEmitter.js.map +1 -1
- package/out/concepts/App__.d.ts +76 -51
- package/out/concepts/App__.js +190 -87
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BackendVariable__.js +2 -10
- package/out/concepts/BackendVariable__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +6 -16
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.d.ts +0 -1
- package/out/concepts/BindDirective__.js +4 -19
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.d.ts +1 -3
- package/out/concepts/BindEvent__.js +13 -38
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.js +2 -10
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.d.ts +0 -2
- package/out/concepts/CallLogic__.js +27 -38
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -7
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/Destination__.d.ts +1 -1
- package/out/concepts/Destination__.js +4 -6
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +1 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +1 -1
- package/out/concepts/Entity__.js +2 -0
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Event__.d.ts +0 -14
- package/out/concepts/Event__.js +0 -61
- package/out/concepts/Event__.js.map +1 -1
- package/out/concepts/Frontend__.d.ts +88 -0
- package/out/concepts/Frontend__.js +143 -1
- package/out/concepts/Frontend__.js.map +1 -1
- package/out/concepts/Identifier__.d.ts +0 -5
- package/out/concepts/Identifier__.js +9 -19
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/LogicItem__.d.ts +1 -1
- package/out/concepts/LogicItem__.js.map +1 -1
- package/out/concepts/Logic__.d.ts +1 -3
- package/out/concepts/Logic__.js +13 -16
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/MemberExpression__.d.ts +1 -1
- package/out/concepts/MemberExpression__.js +3 -3
- package/out/concepts/MemberExpression__.js.map +1 -1
- package/out/concepts/NewComposite__.js.map +1 -1
- package/out/concepts/Param__.js +3 -11
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +1 -9
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Return__.js +9 -17
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Variable__.js +8 -17
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +2 -17
- package/out/concepts/ViewElement__.js +31 -143
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +6 -6
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/index__.d.ts +0 -5
- package/out/concepts/index__.js +0 -5
- package/out/concepts/index__.js.map +1 -1
- package/out/concepts/utils/asserts.d.ts +3 -258
- package/out/concepts/utils/asserts.js +13 -351
- package/out/concepts/utils/asserts.js.map +1 -1
- package/out/concepts/utils/types.d.ts +3 -20
- package/out/generator/genBundleFiles.js +11 -25
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genReleaseBody.js +3 -12
- package/out/generator/genReleaseBody.js.map +1 -1
- package/out/generator/permission.js +3 -3
- package/out/generator/permission.js.map +1 -1
- package/out/natural/transformTSCode.js +1 -1
- package/out/natural/transformTSCode.js.map +1 -1
- package/out/server/extendBaseNode.js +22 -6
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getLogics.js +27 -62
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +1 -6
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/naslServer.js +11 -28
- package/out/server/naslServer.js.map +1 -1
- package/out/server/translator.js +1 -6
- package/out/server/translator.js.map +1 -1
- package/out/service/storage/init.js +26 -2
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +6 -6
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +16 -16
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
- package/out/templator/genCurdMultipleKeyBlock.js +709 -37
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +4 -4
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +12 -12
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +4 -4
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genSelectBlock.js +3 -3
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +2 -0
- package/out/templator/genTableBlock.js +124 -11
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +8 -8
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/translator/utils.js +18 -0
- package/out/translator/utils.js.map +1 -1
- package/out/utils/i18nInfo.js +2 -7
- package/out/utils/i18nInfo.js.map +1 -1
- package/package.json +2 -2
- package/src/bak/translator.js +43 -121
- package/src/breakpoint/generator/BreakpointNode.ts +0 -12
- package/src/breakpoint/shared/constants.ts +0 -1
- package/src/breakpoint/shared/utils.ts +10 -37
- package/src/common/BaseNode.ts +60 -22
- package/src/common/Command.ts +1 -0
- package/src/common/EventEmitter.ts +1 -6
- package/src/concepts/App__.ts +251 -139
- package/src/concepts/BackendVariable__.ts +2 -10
- package/src/concepts/BindAttribute__.ts +6 -15
- package/src/concepts/BindDirective__.ts +4 -19
- package/src/concepts/BindEvent__.ts +12 -40
- package/src/concepts/CallFunction__.ts +2 -10
- package/src/concepts/CallLogic__.ts +32 -45
- package/src/concepts/Constant__.ts +7 -5
- package/src/concepts/Destination__.ts +4 -6
- package/src/concepts/End__.ts +0 -1
- package/src/concepts/Entity__.ts +3 -1
- package/src/concepts/Event__.ts +0 -70
- package/src/concepts/Frontend__.ts +251 -3
- package/src/concepts/Identifier__.ts +13 -29
- package/src/concepts/LogicItem__.ts +0 -1
- package/src/concepts/Logic__.ts +14 -21
- package/src/concepts/MemberExpression__.ts +3 -3
- package/src/concepts/NewComposite__.ts +6 -4
- package/src/concepts/Param__.ts +3 -11
- package/src/concepts/ProcessElement__.ts +1 -8
- package/src/concepts/Return__.ts +12 -15
- package/src/concepts/Variable__.ts +9 -17
- package/src/concepts/ViewElement__.ts +54 -166
- package/src/concepts/View__.ts +6 -8
- package/src/concepts/index__.ts +0 -5
- package/src/concepts/utils/asserts.ts +4 -367
- package/src/concepts/utils/types.ts +0 -28
- package/src/generator/genBundleFiles.ts +15 -33
- package/src/generator/genReleaseBody.ts +3 -14
- package/src/generator/permission.ts +6 -8
- package/src/natural/transformTSCode.ts +1 -1
- package/src/server/extendBaseNode.ts +41 -22
- package/src/server/getLogics.ts +41 -79
- package/src/server/getMemberIdentifier.ts +1 -7
- package/src/server/naslServer.ts +12 -30
- package/src/server/translator.ts +1 -7
- package/src/service/storage/init.ts +33 -2
- package/src/templator/genCreateBlock.ts +6 -6
- package/src/templator/genCurdEditMultipleKeyBlock.ts +16 -16
- package/src/templator/genCurdMultipleKeyBlock.ts +817 -93
- package/src/templator/genGetBlock.ts +4 -4
- package/src/templator/genGridViewBlock.ts +12 -12
- package/src/templator/genListViewBlock.ts +4 -4
- package/src/templator/genSelectBlock.ts +3 -3
- package/src/templator/genTableBlock.ts +137 -12
- package/src/templator/genUpdateBlock.ts +8 -8
- package/src/templator/utils.ts +2 -2
- package/src/translator/utils.ts +20 -0
- package/src/utils/i18nInfo.ts +2 -7
- package/test/concepts/call-function/fixtures/from-string.json +59 -68
- package/test/concepts/call-function/fixtures/to-string-global-tz.json +58 -67
- package/test/concepts/call-function/fixtures/to-string-no-tz.json +48 -57
- package/test/concepts/call-function/fixtures/to-string-user-tz.json +60 -69
- package/test/concepts/call-function/fixtures/to-string-utc-tz.json +60 -69
- package/test/concepts/call-interface/fixtures/only-interface.json +72 -81
- package/test/concepts/call-interface/fixtures/with-body-complex-argument.json +214 -223
- package/test/concepts/call-interface/fixtures/with-body-no-argument.json +76 -85
- package/test/concepts/call-interface/fixtures/with-body-simple-argument.json +91 -100
- package/test/concepts/call-interface/fixtures/with-headers-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-headers.json +81 -90
- package/test/concepts/call-interface/fixtures/with-query-no-argument.json +79 -88
- package/test/concepts/call-interface/fixtures/with-query.json +81 -90
- package/test/concepts/call-logic/__snapshots__/getQuickInfoOffset.spec.ts.snap +2 -4
- package/test/concepts/call-logic/fixtures/entries-get-with-arguments.json +95 -104
- package/test/concepts/call-logic/fixtures/entries-update-with-arguments.json +200 -209
- package/test/concepts/call-logic/fixtures/global-logic-argument-no-expression.json +88 -97
- package/test/concepts/call-logic/fixtures/global-logic-argument-some-expression.json +115 -124
- package/test/concepts/call-logic/fixtures/json-deserialize.json +111 -120
- package/test/concepts/call-logic/fixtures/json-serialize-with-string.json +115 -124
- package/test/concepts/call-logic/fixtures/json-serialize.json +115 -124
- package/test/concepts/call-logic/fixtures/view-buildin-logic-with-argument.json +82 -91
- package/test/concepts/call-logic/fixtures/view-component-logic-no-argument.json +79 -88
- package/test/concepts/call-logic/fixtures/view-component-with-validation.json +135 -144
- package/test/concepts/identifier/fixtures/view-variable.json +136 -145
- package/test/concepts/view-element/__snapshots__/toVue.spec.ts.snap +1 -1
- package/test/concepts/view-element/fixtures/default-login.json +212 -221
- package/test/concepts/view-element/fixtures/default-not-found.json +174 -183
- package/test/concepts/view-element/fixtures/with-role-auth.json +82 -91
- package/test/concepts/view-element/fixtures/with-table.json +1834 -1843
- package/test/concepts/view-element/toVue.spec.ts +0 -1
- package/ts-worker/package.json +1 -1
- package/out/concepts/BusinessComponent__.d.ts +0 -641
- package/out/concepts/BusinessComponent__.js +0 -1901
- package/out/concepts/BusinessComponent__.js.map +0 -1
- package/out/concepts/BusinessLogic__.d.ts +0 -38
- package/out/concepts/BusinessLogic__.js +0 -358
- package/out/concepts/BusinessLogic__.js.map +0 -1
- package/out/concepts/CallEvent__.d.ts +0 -97
- package/out/concepts/CallEvent__.js +0 -263
- package/out/concepts/CallEvent__.js.map +0 -1
- package/out/concepts/FrontendType__.d.ts +0 -308
- package/out/concepts/FrontendType__.js +0 -605
- package/out/concepts/FrontendType__.js.map +0 -1
- package/out/concepts/ParamWithGroup__.d.ts +0 -39
- package/out/concepts/ParamWithGroup__.js +0 -85
- package/out/concepts/ParamWithGroup__.js.map +0 -1
- package/src/concepts/BusinessComponent__.ts +0 -2669
- package/src/concepts/BusinessLogic__.ts +0 -376
- package/src/concepts/CallEvent__.ts +0 -334
- package/src/concepts/FrontendType__.ts +0 -919
- package/src/concepts/ParamWithGroup__.ts +0 -101
|
@@ -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,27 +450,77 @@ 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
|
-
const
|
|
505
|
+
const { view } = oldNode;
|
|
456
506
|
const dataSource = entity.parentNode;
|
|
457
507
|
const module = dataSource.app;
|
|
458
|
-
const viewElementMainView =
|
|
459
|
-
const nameGroup = (0, _1.genUniqueQueryNameGroup)(module,
|
|
508
|
+
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
509
|
+
const nameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementMainView);
|
|
460
510
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
461
|
-
nameGroup.viewElementSaveModal =
|
|
462
|
-
nameGroup.viewElementSaveModalForm =
|
|
463
|
-
nameGroup.viewLogicRemove =
|
|
464
|
-
nameGroup.viewLogicInit =
|
|
465
|
-
nameGroup.viewLogicCreate =
|
|
466
|
-
nameGroup.viewLogicModify =
|
|
467
|
-
nameGroup.viewLogicSubmit =
|
|
468
|
-
nameGroup.viewLogicUpdateSubmit =
|
|
469
|
-
nameGroup.viewLogicReload =
|
|
470
|
-
nameGroup.viewVariableEntity =
|
|
471
|
-
nameGroup.viewVariableInput =
|
|
472
|
-
nameGroup.viewVariableFilter =
|
|
473
|
-
nameGroup.viewVariableIsUpdate =
|
|
511
|
+
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
512
|
+
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
513
|
+
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
514
|
+
nameGroup.viewLogicInit = view.getLogicUniqueName('init');
|
|
515
|
+
nameGroup.viewLogicCreate = view.getLogicUniqueName('create');
|
|
516
|
+
nameGroup.viewLogicModify = view.getLogicUniqueName('modify');
|
|
517
|
+
nameGroup.viewLogicSubmit = view.getLogicUniqueName('submit');
|
|
518
|
+
nameGroup.viewLogicUpdateSubmit = view.getLogicUniqueName('updateSubmit');
|
|
519
|
+
nameGroup.viewLogicReload = view.getLogicUniqueName('reload');
|
|
520
|
+
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
521
|
+
nameGroup.viewVariableInput = view.getVariableUniqueName('input');
|
|
522
|
+
nameGroup.viewVariableFilter = view.getVariableUniqueName('filter');
|
|
523
|
+
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
474
524
|
// 收集所有和本实体关联的实体
|
|
475
525
|
const entitySet = new Set();
|
|
476
526
|
entitySet.add(entity);
|
|
@@ -485,8 +535,8 @@ function genCurdMultipleKeyBlock(entity, oldNode) {
|
|
|
485
535
|
const displayedProperty = (0, _1.getFirstDisplayedProperty)(relationEntity);
|
|
486
536
|
if (displayedProperty) {
|
|
487
537
|
entitySet.add(relationEntity);
|
|
488
|
-
const viewElementSelect =
|
|
489
|
-
const selectNameGroup = (0, _1.genUniqueQueryNameGroup)(module,
|
|
538
|
+
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
539
|
+
const selectNameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementSelect, false, relationEntity.name);
|
|
490
540
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
491
541
|
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
492
542
|
const key = [property.name, relationEntity.name].join('-');
|
|
@@ -571,25 +621,25 @@ function genCurdMultipleKeyBlock(entity, oldNode) {
|
|
|
571
621
|
exports.genCurdMultipleKeyBlock = genCurdMultipleKeyBlock;
|
|
572
622
|
// 数据网格(全)
|
|
573
623
|
function genGridViewMultipleKeyBlock(entity, oldNode) {
|
|
574
|
-
const
|
|
624
|
+
const { view } = oldNode;
|
|
575
625
|
const dataSource = entity.parentNode;
|
|
576
626
|
const module = dataSource.app;
|
|
577
|
-
const viewElementMainView =
|
|
578
|
-
const nameGroup = (0, _1.genUniqueQueryNameGroup)(module,
|
|
627
|
+
const viewElementMainView = view.getViewElementUniqueName('gridView');
|
|
628
|
+
const nameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementMainView);
|
|
579
629
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
580
|
-
nameGroup.viewElementSaveModal =
|
|
581
|
-
nameGroup.viewElementSaveModalForm =
|
|
582
|
-
nameGroup.viewLogicRemove =
|
|
583
|
-
nameGroup.viewLogicInit =
|
|
584
|
-
nameGroup.viewLogicCreate =
|
|
585
|
-
nameGroup.viewLogicModify =
|
|
586
|
-
nameGroup.viewLogicSubmit =
|
|
587
|
-
nameGroup.viewLogicUpdateSubmit =
|
|
588
|
-
nameGroup.viewLogicReload =
|
|
589
|
-
nameGroup.viewVariableEntity =
|
|
590
|
-
nameGroup.viewVariableInput =
|
|
591
|
-
nameGroup.viewVariableFilter =
|
|
592
|
-
nameGroup.viewVariableIsUpdate =
|
|
630
|
+
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
631
|
+
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
632
|
+
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
633
|
+
nameGroup.viewLogicInit = view.getLogicUniqueName('init');
|
|
634
|
+
nameGroup.viewLogicCreate = view.getLogicUniqueName('create');
|
|
635
|
+
nameGroup.viewLogicModify = view.getLogicUniqueName('modify');
|
|
636
|
+
nameGroup.viewLogicSubmit = view.getLogicUniqueName('submit');
|
|
637
|
+
nameGroup.viewLogicUpdateSubmit = view.getLogicUniqueName('updateSubmit');
|
|
638
|
+
nameGroup.viewLogicReload = view.getLogicUniqueName('reload');
|
|
639
|
+
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
640
|
+
nameGroup.viewVariableInput = view.getVariableUniqueName('input');
|
|
641
|
+
nameGroup.viewVariableFilter = view.getVariableUniqueName('filter');
|
|
642
|
+
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
593
643
|
// 收集所有和本实体关联的实体
|
|
594
644
|
const entitySet = new Set();
|
|
595
645
|
entitySet.add(entity);
|
|
@@ -604,8 +654,8 @@ function genGridViewMultipleKeyBlock(entity, oldNode) {
|
|
|
604
654
|
const displayedProperty = (0, _1.getFirstDisplayedProperty)(relationEntity);
|
|
605
655
|
if (displayedProperty) {
|
|
606
656
|
entitySet.add(relationEntity);
|
|
607
|
-
const viewElementSelect =
|
|
608
|
-
const selectNameGroup = (0, _1.genUniqueQueryNameGroup)(module,
|
|
657
|
+
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
658
|
+
const selectNameGroup = (0, _1.genUniqueQueryNameGroup)(module, view, viewElementSelect, false, relationEntity.name);
|
|
609
659
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
610
660
|
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
611
661
|
const key = [property.name, relationEntity.name].join('-');
|
|
@@ -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, '"');
|
|
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, '"');
|
|
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
|