@lcap/nasl 1.0.1 → 2.12.0-beta.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/automate/engine/index.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +108 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +6 -1
- package/out/common/BaseNode.js +37 -6
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +52 -49
- package/out/concepts/App__.js +89 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/Assignee__.d.ts +11 -0
- package/out/concepts/Assignee__.js +34 -0
- package/out/concepts/Assignee__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +9 -4
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +34 -4
- package/out/concepts/CallQueryComponent__.js +340 -95
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/Constant__.js +6 -6
- package/out/concepts/Constant__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +22 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +10 -2
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +22 -7
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +6 -0
- package/out/concepts/Entity__.js +27 -11
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.d.ts +1 -0
- package/out/concepts/Enum__.js +14 -4
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +5 -14
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/InterfaceParam__.js +9 -4
- package/out/concepts/InterfaceParam__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +3 -2
- package/out/concepts/Param__.js +15 -8
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +38 -12
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryAggregateExpression__.js +1 -1
- package/out/concepts/QueryAggregateExpression__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.d.ts +1 -0
- package/out/concepts/QueryFieldExpression__.js +11 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryGroupByExpression__.d.ts +3 -0
- package/out/concepts/QueryGroupByExpression__.js +20 -0
- package/out/concepts/QueryGroupByExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.d.ts +1 -1
- package/out/concepts/Return__.js +16 -11
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +2 -9
- package/out/concepts/StringLiteral__.js.map +1 -1
- package/out/concepts/StructureProperty__.js +11 -10
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +53 -3
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.d.ts +1 -1
- package/out/concepts/Variable__.js +16 -11
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +1 -3
- package/out/concepts/View__.js +42 -36
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js +1 -1
- package/out/concepts/basics/stdlib/nasl.configuration.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.interface.d.ts +2 -0
- package/out/concepts/basics/stdlib/nasl.interface.js +4 -4
- package/out/concepts/basics/stdlib/nasl.interface.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +270 -8
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js +1 -1
- package/out/concepts/basics/stdlib/reference2TypeAnnotationList.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +2 -0
- package/out/concepts/basics/types/index.js +6 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/enums/KEYWORDS.js +0 -7
- package/out/enums/KEYWORDS.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/manager/diagnostic.d.ts +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/{test/integration/connect-file copy.d.ts → server/extendBaseNode.d.ts} +0 -0
- package/out/server/extendBaseNode.js +323 -0
- package/out/server/extendBaseNode.js.map +1 -0
- package/out/server/getLogics.js +49 -2
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +52 -2
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +8 -2
- package/out/server/getProcesses.js +228 -20
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/getScope.d.ts +1 -0
- package/out/server/getScope.js +4 -0
- package/out/server/getScope.js.map +1 -1
- package/out/server/index.d.ts +1 -0
- package/out/server/index.js +1 -0
- package/out/server/index.js.map +1 -1
- package/out/server/naslServer.d.ts +8 -5
- package/out/server/naslServer.js +314 -383
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.d.ts +1 -1
- package/out/server/translator.js +40 -2
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +113 -94
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +1 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +31 -29
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +13 -22
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +35 -25
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +5 -3
- package/out/templator/utils.js +2 -1
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -2
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +110 -69
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +35 -7
- package/src/concepts/App__.ts +132 -131
- package/src/concepts/Assignee__.ts +30 -0
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +7 -4
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +352 -101
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/Constant__.ts +6 -6
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +22 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +11 -2
- package/src/concepts/EntityProperty__.ts +23 -7
- package/src/concepts/Entity__.ts +38 -14
- package/src/concepts/Enum__.ts +15 -4
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +5 -14
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/InterfaceParam__.ts +9 -4
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +17 -9
- package/src/concepts/ProcessElement__.ts +42 -15
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryAggregateExpression__.ts +1 -1
- package/src/concepts/QueryFieldExpression__.ts +13 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryGroupByExpression__.ts +23 -0
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +16 -11
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +2 -9
- package/src/concepts/StructureProperty__.ts +11 -14
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +52 -3
- package/src/concepts/Variable__.ts +16 -11
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +45 -38
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.configuration.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.interface.ts +1 -1
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +271 -8
- package/src/concepts/basics/stdlib/reference2TypeAnnotationList.ts +1 -1
- package/src/concepts/basics/types/index.ts +2 -0
- package/src/concepts/index__.ts +1 -0
- package/src/enums/KEYWORDS.ts +0 -7
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/manager/diagnostic.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/extendBaseNode.ts +318 -0
- package/src/server/getLogics.ts +51 -5
- package/src/server/getMemberIdentifier.ts +53 -2
- package/src/server/getProcesses.ts +238 -21
- package/src/server/getScope.ts +5 -0
- package/src/server/index.ts +1 -0
- package/src/server/naslServer.ts +322 -380
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +42 -2
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +115 -97
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGetBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +34 -30
- package/src/templator/genSelectBlock.ts +14 -23
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +36 -26
- package/src/templator/utils.ts +5 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
- package/out/concepts/basics/stdlib/nasl.browser copy.d.ts +0 -3
- package/out/concepts/basics/stdlib/nasl.browser copy.js +0 -70
- package/out/concepts/basics/stdlib/nasl.browser copy.js.map +0 -1
- package/out/terms/LEVEL_NAME_MAP.d.ts +0 -26
- package/out/terms/LEVEL_NAME_MAP.js +0 -30
- package/out/terms/LEVEL_NAME_MAP.js.map +0 -1
- package/out/test/integration/connect-file copy.js +0 -50
- package/out/test/integration/connect-file copy.js.map +0 -1
- package/out/test/integration/node-nasl-server.d.ts +0 -1
- package/out/test/integration/node-nasl-server.js +0 -41
- package/out/test/integration/node-nasl-server.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '../config';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
|
-
import { App, Namespace, Entity, Logic, View, Enum } from '../concepts';
|
|
3
|
+
import { App, Module, Namespace, Entity, Logic, View, Enum, DataSource } from '../concepts';
|
|
4
4
|
import { NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
|
|
5
5
|
import {
|
|
6
6
|
NameGroup,
|
|
@@ -16,7 +16,8 @@ import {
|
|
|
16
16
|
} from '.';
|
|
17
17
|
|
|
18
18
|
export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
19
|
-
const
|
|
19
|
+
const dataSource = entity.parentNode as DataSource;
|
|
20
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
20
21
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
21
22
|
|
|
22
23
|
return `<u-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -39,13 +40,15 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
39
40
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
40
41
|
if (property.relationEntity) {
|
|
41
42
|
// 有外键关联
|
|
42
|
-
const relationEntity =
|
|
43
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
43
44
|
if (relationEntity) {
|
|
44
45
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
45
46
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
46
47
|
if (displayedProperty) {
|
|
47
48
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
48
|
-
|
|
49
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
50
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
51
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
49
52
|
formItem += `
|
|
50
53
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
51
54
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -73,7 +76,7 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
73
76
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
74
77
|
const type = namespaceArr.pop();
|
|
75
78
|
if (type === 'enums') {
|
|
76
|
-
formItem += genEnumSelectBlock(
|
|
79
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
77
80
|
} else {
|
|
78
81
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
79
82
|
}
|
|
@@ -89,7 +92,8 @@ export function genCreateFormTemplate(entity: Entity, nameGroup: NameGroup, sele
|
|
|
89
92
|
}
|
|
90
93
|
|
|
91
94
|
export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
92
|
-
const
|
|
95
|
+
const dataSource = entity.parentNode as DataSource;
|
|
96
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
93
97
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
94
98
|
|
|
95
99
|
return `<van-form ref="${nameGroup.viewElementMainView}">
|
|
@@ -106,53 +110,55 @@ export function genH5CreateFormTemplate(entity: Entity, nameGroup: NameGroup, se
|
|
|
106
110
|
rules.push('required');
|
|
107
111
|
const rulesStr = rules.join(' | ');
|
|
108
112
|
|
|
109
|
-
let formItem = ` <van-field drole="other"
|
|
113
|
+
let formItem = ` <van-field drole="other" ${required ? ' required' : ''}${rulesStr.length ? ` rules="${rulesStr}"` : ''}>\n`;
|
|
110
114
|
const { typeAnnotation } = property || {};
|
|
111
115
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
112
116
|
if (property.relationEntity) {
|
|
113
117
|
// 有外键关联
|
|
114
|
-
const relationEntity =
|
|
118
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
115
119
|
if (relationEntity) {
|
|
116
120
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
117
121
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
118
122
|
if (displayedProperty) {
|
|
119
123
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
120
|
-
|
|
124
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
125
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
126
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
121
127
|
formItem += `
|
|
122
|
-
<template #input><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
128
|
+
<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-cascader title="请选择${label}" placeholder="请选择${label}"
|
|
123
129
|
v-model="${vModel}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
124
130
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}"
|
|
125
131
|
:notitleblock="true"
|
|
126
|
-
:pageable="true" :remote-paging="true"></van-cascader></template>
|
|
132
|
+
:pageable="true" input-align="left" :remote-paging="true"></van-cascader></van-linear-layout></template>
|
|
127
133
|
`;
|
|
128
134
|
} else
|
|
129
135
|
return '';
|
|
130
136
|
} else
|
|
131
137
|
return '';
|
|
132
138
|
} else if (propertyTypeName === 'Boolean') {
|
|
133
|
-
formItem += `<template #input><van-switch v-model="${vModel}"></van-switch></template>`;
|
|
139
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-switch v-model="${vModel}"></van-switch></van-linear-layout></template>`;
|
|
134
140
|
} else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
|
|
135
|
-
formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-stepper></template>`;
|
|
141
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${property.label || property.name}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
|
|
136
142
|
} else if (propertyTypeName === 'Double') {
|
|
137
|
-
formItem += `<template #input><van-stepper v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-stepper></template>`;
|
|
143
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-stepper-new v-model="${vModel}" placeholder="请输入${property.label || property.name}" :showPlus="false" :showMinus="false" align="left"></van-stepper-new></van-linear-layout></template>`;
|
|
138
144
|
} else if (propertyTypeName === 'Text') {
|
|
139
|
-
formItem += `<template #input><van-fieldtextarea v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldtextarea></template>`;
|
|
145
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldtextarea v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldtextarea></van-linear-layout></template>`;
|
|
140
146
|
} else if (propertyTypeName === 'Date') {
|
|
141
|
-
formItem += `<template #input><van-calendar :default-date.sync="${vModel}" title="选择日期"></van-calendar></template>`;
|
|
147
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-calendar :default-date.sync="${vModel}" title="选择日期" input-align="left"></van-calendar></van-linear-layout></template>`;
|
|
142
148
|
} else if (propertyTypeName === 'Time') {
|
|
143
|
-
formItem += `<template #input><van-datetime-picker type="time" v-model="${vModel}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
|
|
149
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="time" v-model="${vModel}" title="请选择${property.label || property.name}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
|
|
144
150
|
} else if (propertyTypeName === 'DateTime') {
|
|
145
|
-
formItem += `<template #input><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${property.label || property.name}" label-field=""></van-datetime-picker></template>`;
|
|
151
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-datetime-picker type="datetime" v-model="${vModel}" title="请选择${property.label || property.name}" label-field="" input-align="left"></van-datetime-picker></van-linear-layout></template>`;
|
|
146
152
|
} else {
|
|
147
153
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
148
154
|
const type = namespaceArr.pop();
|
|
149
155
|
if (type === 'enums') {
|
|
150
|
-
formItem += '<template #input>' + genEnumSelectBlock(
|
|
156
|
+
formItem += '<template #input><van-linear-layout style="width:100%;" direction="horizontal">' + genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true) + '</van-linear-layout></template>';
|
|
151
157
|
} else {
|
|
152
|
-
formItem += `<template #input><van-fieldinput v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldinput></template>`;
|
|
158
|
+
formItem += `<template #input><van-linear-layout style="width:100%;" direction="horizontal"><van-fieldinput v-model="${vModel}" placeholder="请输入${property.label || property.name}"></van-fieldinput></van-linear-layout></template>`;
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
|
-
|
|
161
|
+
formItem += `<template #title><van-text text="${property.label || property.name}"><van-text></template>`;
|
|
156
162
|
formItem += ` </van-field>\n`;
|
|
157
163
|
|
|
158
164
|
formItem = formItem.replace(/>\n<van-input|<\/van-input>/g, '');
|
|
@@ -227,7 +233,8 @@ function genSubmitLogic(createLogic: Logic, nameGroup: NameGroup) {
|
|
|
227
233
|
* @param resolver 实体创建 Action
|
|
228
234
|
*/
|
|
229
235
|
export function genCreateBlock(entity: Entity, view: View) {
|
|
230
|
-
const
|
|
236
|
+
const dataSource = entity.parentNode as DataSource;
|
|
237
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
231
238
|
const ns = entity.ns;
|
|
232
239
|
const createLogic = ns?.logics?.find((logic) => logic.name === `create`);
|
|
233
240
|
|
|
@@ -244,16 +251,18 @@ export function genCreateBlock(entity: Entity, view: View) {
|
|
|
244
251
|
entity.properties.forEach((property) => {
|
|
245
252
|
// 有外键关联
|
|
246
253
|
if (property.relationEntity) {
|
|
247
|
-
const relationEntity =
|
|
254
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
248
255
|
if (relationEntity) {
|
|
249
256
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
250
257
|
if (displayedProperty) {
|
|
251
258
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
252
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
259
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
253
260
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
254
|
-
|
|
261
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
262
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
263
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
255
264
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
256
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
265
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
257
266
|
newStructures.push(newStructure);
|
|
258
267
|
newLogics.push(newLogic);
|
|
259
268
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 3. 先简单做后续在看如何优化
|
|
5
5
|
*/
|
|
6
6
|
import * as utils from '../utils';
|
|
7
|
-
import { App, Namespace, Entity, View, Enum } from '../concepts';
|
|
7
|
+
import { App, Module, Namespace, Entity, View, Enum, DataSource } from '../concepts';
|
|
8
8
|
import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslTypeAnnotation, NaslLogicItem, NaslNode } from './utils';
|
|
9
9
|
import {
|
|
10
10
|
filterProperty,
|
|
@@ -25,7 +25,8 @@ import {
|
|
|
25
25
|
} from '.';
|
|
26
26
|
|
|
27
27
|
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
28
|
-
const
|
|
28
|
+
const dataSource = entity.parentNode as DataSource;
|
|
29
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
29
30
|
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
30
31
|
|
|
31
32
|
return `
|
|
@@ -41,13 +42,15 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
41
42
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
42
43
|
if (property.relationEntity) {
|
|
43
44
|
// 有外键关联
|
|
44
|
-
const relationEntity =
|
|
45
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
45
46
|
if (relationEntity) {
|
|
46
47
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
47
48
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
48
49
|
if (displayedProperty) {
|
|
49
50
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
50
|
-
|
|
51
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
52
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
53
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
51
54
|
formItem += `
|
|
52
55
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
53
56
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -80,7 +83,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
80
83
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
81
84
|
const type = namespaceArr.pop();
|
|
82
85
|
if (type === 'enums') {
|
|
83
|
-
formItem += genEnumSelectBlock(
|
|
86
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
84
87
|
} else {
|
|
85
88
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
86
89
|
}
|
|
@@ -102,7 +105,8 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
105
|
-
const
|
|
108
|
+
const dataSource = entity.parentNode as DataSource;
|
|
109
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
106
110
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
107
111
|
|
|
108
112
|
return `
|
|
@@ -136,13 +140,15 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
136
140
|
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
137
141
|
if (property.relationEntity) {
|
|
138
142
|
// 有外键关联
|
|
139
|
-
const relationEntity =
|
|
143
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
140
144
|
if (relationEntity) {
|
|
141
145
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
142
146
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
143
147
|
if (displayedProperty) {
|
|
144
148
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
145
|
-
|
|
149
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
150
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
151
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
146
152
|
formItem += `
|
|
147
153
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.load}"
|
|
148
154
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -174,7 +180,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
174
180
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
175
181
|
const type = namespaceArr.pop();
|
|
176
182
|
if (type === 'enums') {
|
|
177
|
-
formItem += genEnumSelectBlock(
|
|
183
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
178
184
|
} else {
|
|
179
185
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
180
186
|
}
|
|
@@ -332,10 +338,11 @@ function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
332
338
|
}
|
|
333
339
|
|
|
334
340
|
export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
335
|
-
const
|
|
341
|
+
const dataSource = entity.parentNode as DataSource;
|
|
342
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
336
343
|
|
|
337
344
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
338
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
345
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
339
346
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
340
347
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
341
348
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -350,7 +357,8 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
350
357
|
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
351
358
|
|
|
352
359
|
// 收集所有和本实体关联的实体
|
|
353
|
-
const
|
|
360
|
+
const entitySet: Set<Entity> = new Set();
|
|
361
|
+
entitySet.add(entity);
|
|
354
362
|
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
355
363
|
const newStructures: any[] = [];
|
|
356
364
|
const newLogics: any[] = [];
|
|
@@ -358,17 +366,19 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
358
366
|
entity.properties.forEach((property) => {
|
|
359
367
|
// 有外键关联
|
|
360
368
|
if (property.relationEntity) {
|
|
361
|
-
const relationEntity =
|
|
369
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
362
370
|
if (relationEntity) {
|
|
363
371
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
364
372
|
if (displayedProperty) {
|
|
365
|
-
|
|
373
|
+
entitySet.add(relationEntity);
|
|
366
374
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
367
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
375
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
368
376
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
369
|
-
|
|
377
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
378
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
379
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
370
380
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
371
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
381
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
372
382
|
newStructures.push(newStructure);
|
|
373
383
|
newLogics.push(newLogic);
|
|
374
384
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -376,13 +386,11 @@ export function genCurdEditMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
388
|
});
|
|
389
|
+
const allEntities = [...entitySet];
|
|
379
390
|
const entityStructure = genEditQueryStructure(allEntities, nameGroup);
|
|
380
391
|
newStructures.push(entityStructure);
|
|
381
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
392
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
382
393
|
newLogics.push(entityLogic);
|
|
383
|
-
|
|
384
|
-
// console.log(entityStructure);
|
|
385
|
-
|
|
386
394
|
return `<template>
|
|
387
395
|
<u-linear-layout direction="vertical">
|
|
388
396
|
${genFilterTemplate(entity, nameGroup, selectNameGroupMap)}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 4. 主键目前支持 Long String Double 类型接口所以只禁用了对应的三个类型
|
|
6
6
|
*/
|
|
7
7
|
import * as utils from '../utils';
|
|
8
|
-
import { App, Namespace, Entity, View, Enum } from '../concepts';
|
|
8
|
+
import { App, Module, Namespace, Entity, View, Enum, DataSource } from '../concepts';
|
|
9
9
|
import {
|
|
10
10
|
NaslCoreTypeAnnotation, NaslUITypeAnnotation,
|
|
11
11
|
NaslTypeAnnotation, NaslLogicItem, NaslNode,
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
} from '.';
|
|
19
19
|
|
|
20
20
|
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
21
|
-
const
|
|
21
|
+
const dataSource = entity.parentNode as DataSource;
|
|
22
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
22
23
|
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
23
24
|
return `
|
|
24
25
|
<u-linear-layout justify="space-between">
|
|
@@ -36,13 +37,15 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
36
37
|
} = typeAnnotation || {};
|
|
37
38
|
if (property.relationEntity) {
|
|
38
39
|
// 有外键关联
|
|
39
|
-
const relationEntity =
|
|
40
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
40
41
|
if (relationEntity) {
|
|
41
42
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
42
43
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
43
44
|
if (displayedProperty) {
|
|
44
45
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
45
|
-
|
|
46
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
47
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
48
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
46
49
|
formItem += `
|
|
47
50
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
48
51
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -75,7 +78,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
75
78
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
76
79
|
const type = namespaceArr.pop();
|
|
77
80
|
if (type === 'enums') {
|
|
78
|
-
formItem += genEnumSelectBlock(
|
|
81
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
79
82
|
} else {
|
|
80
83
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
81
84
|
}
|
|
@@ -97,7 +100,8 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
100
|
-
const
|
|
103
|
+
const dataSource = entity.parentNode as DataSource;
|
|
104
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
101
105
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
102
106
|
|
|
103
107
|
return `
|
|
@@ -129,13 +133,15 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
129
133
|
} = typeAnnotation || {};
|
|
130
134
|
if (property.relationEntity) {
|
|
131
135
|
// 有外键关联
|
|
132
|
-
const relationEntity =
|
|
136
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
133
137
|
if (relationEntity) {
|
|
134
138
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
135
139
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
136
140
|
if (displayedProperty) {
|
|
137
141
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
138
|
-
|
|
142
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
143
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
144
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
139
145
|
formItem += `
|
|
140
146
|
<u-select clearable placeholder="请选择${label}"
|
|
141
147
|
text-field="${lowerEntityName}.${displayedProperty.name}"
|
|
@@ -175,7 +181,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
175
181
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
176
182
|
const type = namespaceArr.pop();
|
|
177
183
|
if (type === 'enums') {
|
|
178
|
-
formItem += genEnumSelectBlock(
|
|
184
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
179
185
|
} else {
|
|
180
186
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-input>`;
|
|
181
187
|
}
|
|
@@ -338,8 +344,8 @@ function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
338
344
|
|
|
339
345
|
function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
340
346
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
341
|
-
const
|
|
342
|
-
const
|
|
347
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
348
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
343
349
|
|
|
344
350
|
return NaslNode.Logic({
|
|
345
351
|
name: nameGroup.viewLogicModify,
|
|
@@ -353,7 +359,7 @@ function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
353
359
|
name: 'scope',
|
|
354
360
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
355
361
|
NaslTypeAnnotation.Reference({
|
|
356
|
-
typeNamespace: `${
|
|
362
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
357
363
|
typeName: nameGroup.structure,
|
|
358
364
|
}),
|
|
359
365
|
]),
|
|
@@ -406,10 +412,11 @@ function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
406
412
|
|
|
407
413
|
// 列表(全)
|
|
408
414
|
export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
409
|
-
const
|
|
415
|
+
const dataSource = entity.parentNode as DataSource;
|
|
416
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
410
417
|
|
|
411
418
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
412
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
419
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
413
420
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
414
421
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
415
422
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -424,7 +431,8 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
424
431
|
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
425
432
|
|
|
426
433
|
// 收集所有和本实体关联的实体
|
|
427
|
-
const
|
|
434
|
+
const entitySet: Set<Entity> = new Set();
|
|
435
|
+
entitySet.add(entity);
|
|
428
436
|
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
429
437
|
const newStructures: any[] = [];
|
|
430
438
|
const newLogics: any[] = [];
|
|
@@ -432,17 +440,19 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
432
440
|
entity.properties.forEach((property) => {
|
|
433
441
|
// 有外键关联
|
|
434
442
|
if (property.relationEntity) {
|
|
435
|
-
const relationEntity =
|
|
443
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
436
444
|
if (relationEntity) {
|
|
437
445
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
438
446
|
if (displayedProperty) {
|
|
439
|
-
|
|
447
|
+
entitySet.add(relationEntity);
|
|
440
448
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
441
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
449
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
442
450
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
443
|
-
|
|
451
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
452
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
453
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
444
454
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
445
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
455
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
446
456
|
newStructures.push(newStructure);
|
|
447
457
|
newLogics.push(newLogic);
|
|
448
458
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -450,10 +460,10 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
450
460
|
}
|
|
451
461
|
}
|
|
452
462
|
});
|
|
453
|
-
|
|
463
|
+
const allEntities = [...entitySet];
|
|
454
464
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
455
465
|
newStructures.push(entityStructure);
|
|
456
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
466
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
457
467
|
newLogics.push(entityLogic);
|
|
458
468
|
|
|
459
469
|
return `<template>
|
|
@@ -525,10 +535,11 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
525
535
|
|
|
526
536
|
// 数据网格(全)
|
|
527
537
|
export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
528
|
-
const
|
|
538
|
+
const dataSource = entity.parentNode as DataSource;
|
|
539
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
529
540
|
|
|
530
541
|
const viewElementMainView = view.getViewElementUniqueName('gridView');
|
|
531
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
542
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
532
543
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
533
544
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
534
545
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -543,7 +554,8 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
543
554
|
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
544
555
|
|
|
545
556
|
// 收集所有和本实体关联的实体
|
|
546
|
-
const
|
|
557
|
+
const entitySet: Set<Entity> = new Set();
|
|
558
|
+
entitySet.add(entity);
|
|
547
559
|
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
548
560
|
const newStructures: any[] = [];
|
|
549
561
|
const newLogics: any[] = [];
|
|
@@ -551,21 +563,23 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
551
563
|
entity.properties.forEach((property) => {
|
|
552
564
|
// 有外键关联
|
|
553
565
|
if (property.relationEntity) {
|
|
554
|
-
const relationEntity =
|
|
566
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
555
567
|
if (relationEntity) {
|
|
556
568
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
557
569
|
if (displayedProperty) {
|
|
558
|
-
|
|
570
|
+
entitySet.add(relationEntity);
|
|
559
571
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
560
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
572
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
561
573
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
562
|
-
|
|
574
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
575
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
576
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
563
577
|
const newStructure = genQueryStructure([
|
|
564
578
|
relationEntity,
|
|
565
579
|
], selectNameGroup);
|
|
566
580
|
const newLogic = genQueryLogic([
|
|
567
581
|
relationEntity,
|
|
568
|
-
], selectNameGroup, false, false,
|
|
582
|
+
], selectNameGroup, false, false, module);
|
|
569
583
|
newStructures.push(newStructure);
|
|
570
584
|
newLogics.push(newLogic);
|
|
571
585
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -573,9 +587,10 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
573
587
|
}
|
|
574
588
|
}
|
|
575
589
|
});
|
|
590
|
+
const allEntities = [...entitySet];
|
|
576
591
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
577
592
|
newStructures.push(entityStructure);
|
|
578
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
593
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
579
594
|
newLogics.push(entityLogic);
|
|
580
595
|
|
|
581
596
|
return `<template>
|