@lcap/nasl 3.5.0-beta.4 → 3.6.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/breakpoint/shared/utils.js +1 -19
- package/out/breakpoint/shared/utils.js.map +1 -1
- package/out/breakpoint/store/core.js +1 -1
- package/out/breakpoint/store/core.js.map +1 -1
- package/out/common/BaseNode.d.ts +9 -0
- package/out/common/BaseNode.js +15 -0
- 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/AnonymousFunction__.d.ts +6 -1
- package/out/concepts/AnonymousFunction__.js +34 -16
- package/out/concepts/AnonymousFunction__.js.map +1 -1
- package/out/concepts/App__.d.ts +29 -0
- package/out/concepts/App__.js +120 -21
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindEvent__.js +2 -2
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BusinessComponent__.d.ts +1 -1
- package/out/concepts/BusinessComponent__.js +107 -87
- package/out/concepts/BusinessComponent__.js.map +1 -1
- package/out/concepts/CallEvent__.d.ts +4 -0
- package/out/concepts/CallEvent__.js +18 -1
- package/out/concepts/CallEvent__.js.map +1 -1
- package/out/concepts/CallFunction__.d.ts +0 -1
- package/out/concepts/CallFunction__.js +0 -8
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/Destination__.js +3 -3
- package/out/concepts/Destination__.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/Logic__.js +15 -8
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Match__.d.ts +1 -1
- package/out/concepts/ValidationRule__.js +2 -1
- package/out/concepts/ValidationRule__.js.map +1 -1
- package/out/concepts/ViewElement__.d.ts +1 -0
- package/out/concepts/ViewElement__.js +20 -3
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.js +19 -18
- package/out/concepts/View__.js.map +1 -1
- package/out/server/extendBaseNode.js +18 -0
- package/out/server/extendBaseNode.js.map +1 -1
- package/out/server/getProcesses.js +3 -3
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.js +16 -12
- package/out/server/naslServer.js.map +1 -1
- package/out/service/storage/init.js +24 -1
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.d.ts +27 -0
- package/out/templator/genCurdMultipleKeyBlock.js +673 -1
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genGetBlock.js +2 -1
- package/out/templator/genGetBlock.js.map +1 -1
- package/out/templator/genTableBlock.d.ts +2 -0
- package/out/templator/genTableBlock.js +114 -1
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +2 -1
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/translator/utils.js +30 -1
- package/out/translator/utils.js.map +1 -1
- package/out/utils/index.d.ts +17 -0
- package/out/utils/index.js +184 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/breakpoint/shared/utils.ts +2 -24
- package/src/breakpoint/store/core.ts +1 -1
- package/src/common/BaseNode.ts +19 -0
- package/src/common/Command.ts +1 -0
- package/src/common/EventEmitter.ts +1 -6
- package/src/concepts/AnonymousFunction__.ts +36 -18
- package/src/concepts/App__.ts +132 -21
- package/src/concepts/BindAttribute__.ts +0 -1
- package/src/concepts/BindEvent__.ts +2 -2
- package/src/concepts/BusinessComponent__.ts +122 -98
- package/src/concepts/CallEvent__.ts +19 -2
- package/src/concepts/CallFunction__.ts +0 -11
- package/src/concepts/Destination__.ts +3 -3
- package/src/concepts/Entity__.ts +3 -1
- package/src/concepts/Logic__.ts +15 -9
- package/src/concepts/ValidationRule__.ts +6 -1
- package/src/concepts/ViewElement__.ts +26 -3
- package/src/concepts/View__.ts +19 -18
- package/src/server/extendBaseNode.ts +21 -0
- package/src/server/getProcesses.ts +3 -3
- package/src/server/naslServer.ts +17 -11
- package/src/service/storage/init.ts +31 -1
- package/src/templator/genCurdMultipleKeyBlock.ts +781 -57
- package/src/templator/genGetBlock.ts +2 -1
- package/src/templator/genTableBlock.ts +127 -2
- package/src/templator/genUpdateBlock.ts +2 -1
- package/src/translator/utils.ts +32 -1
- package/src/utils/index.ts +211 -1
- package/ts-worker/src/index.js +1 -0
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
* 4. 主键目前支持 Long String Double 类型接口所以只禁用了对应的三个类型
|
|
6
6
|
*/
|
|
7
7
|
import * as utils from '../utils';
|
|
8
|
-
import { App, Module, Namespace, Entity, View, Enum, DataSource, ViewElement } from '../concepts';
|
|
9
|
-
import {
|
|
8
|
+
import { App, Module, Namespace, Entity, View, Enum, DataSource, ViewElement, NumericLiteral, Logic } from '../concepts';
|
|
9
|
+
import {
|
|
10
|
+
NaslCoreTypeAnnotation,
|
|
11
|
+
NaslUITypeAnnotation,
|
|
12
|
+
NaslTypeAnnotation,
|
|
13
|
+
NaslLogicItem,
|
|
14
|
+
NaslNode,
|
|
15
|
+
getDecimalInfo,
|
|
16
|
+
transEntityMetadataTypes,
|
|
17
|
+
} from './utils';
|
|
10
18
|
import {
|
|
11
19
|
filterProperty,
|
|
12
20
|
NameGroup,
|
|
@@ -23,6 +31,7 @@ import {
|
|
|
23
31
|
genGridViewLoadLogic,
|
|
24
32
|
genGridViewRemoveLogic,
|
|
25
33
|
genLogicParam,
|
|
34
|
+
genTableTemplateTableDesigner,
|
|
26
35
|
} from '.';
|
|
27
36
|
|
|
28
37
|
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
@@ -58,7 +67,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
58
67
|
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
59
68
|
const key = [property.name, relationEntity.name].join('-');
|
|
60
69
|
const selectNameGroup = selectNameGroupMap.get(key);
|
|
61
|
-
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)
|
|
70
|
+
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
|
|
62
71
|
formItem += `
|
|
63
72
|
<u-select clearable placeholder="请选择${label}" :data-source="${dataSourceValue}" :page-size="50"
|
|
64
73
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pagination="true" v-model="${vModel}">
|
|
@@ -109,11 +118,12 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
109
118
|
</u-form>
|
|
110
119
|
</u-linear-layout>
|
|
111
120
|
|
|
112
|
-
<u-linear-layout mode="flex" alignment="start" justify="end"><u-button color="primary" @click="${
|
|
121
|
+
<u-linear-layout mode="flex" alignment="start" justify="end"><u-button color="primary" @click="${
|
|
122
|
+
nameGroup.viewLogicCreate
|
|
123
|
+
}">创 建</u-button></u-linear-layout>
|
|
113
124
|
`;
|
|
114
125
|
}
|
|
115
126
|
|
|
116
|
-
|
|
117
127
|
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
118
128
|
const dataSource = entity.parentNode as DataSource;
|
|
119
129
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
@@ -137,8 +147,9 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
137
147
|
}
|
|
138
148
|
if (required) rules.push('required');
|
|
139
149
|
const rulesStr = rules.join(' | ');
|
|
140
|
-
let formItem = `<u-form-item ${required ? 'required' : ''} ${
|
|
141
|
-
|
|
150
|
+
let formItem = `<u-form-item ${required ? 'required' : ''} ${
|
|
151
|
+
rulesStr.length ? `rules="${rulesStr}"` : ''
|
|
152
|
+
} layout="center"><template #label><u-text text="${label}"></u-text></template>`;
|
|
142
153
|
|
|
143
154
|
const { typeAnnotation } = property || {};
|
|
144
155
|
const { typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
@@ -161,7 +172,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
161
172
|
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
162
173
|
const key = [property.name, relationEntity.name].join('-');
|
|
163
174
|
const selectNameGroup = selectNameGroupMap.get(key);
|
|
164
|
-
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)
|
|
175
|
+
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
|
|
165
176
|
formItem += `
|
|
166
177
|
<u-select clearable placeholder="请选择${label}"
|
|
167
178
|
text-field="${lowerEntityName}.${displayedProperty.name}"
|
|
@@ -176,32 +187,40 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
176
187
|
} else return '';
|
|
177
188
|
} else if (propertyTypeName === 'Boolean') {
|
|
178
189
|
formItem += `
|
|
179
|
-
<u-select clearable v-model="${vModel}" placeholder="请输入${label}" ${
|
|
180
|
-
|
|
190
|
+
<u-select clearable v-model="${vModel}" placeholder="请输入${label}" ${
|
|
191
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
192
|
+
}>
|
|
181
193
|
<u-select-item :value="true" text="是"><u-text text="是"></u-text></u-select-item>
|
|
182
194
|
<u-select-item :value="false" text="否"><u-text text="否"></u-text></u-select-item>
|
|
183
195
|
</u-select>`;
|
|
184
196
|
} else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
|
|
185
|
-
formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
186
|
-
}
|
|
197
|
+
formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
198
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
199
|
+
}></u-number-input>`;
|
|
187
200
|
} else if (propertyTypeName === 'Double') {
|
|
188
|
-
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
189
|
-
}
|
|
201
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
202
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
203
|
+
}></u-number-input>`;
|
|
190
204
|
} else if (propertyTypeName === 'Decimal') {
|
|
191
|
-
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
192
|
-
}
|
|
205
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
206
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
207
|
+
}></u-number-input>`;
|
|
193
208
|
} else if (propertyTypeName === 'String' && propertyTypeMaxLength > 256) {
|
|
194
|
-
formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}" ${
|
|
195
|
-
}
|
|
209
|
+
formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}" ${
|
|
210
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
211
|
+
}></u-textarea>`;
|
|
196
212
|
} else if (propertyTypeName === 'Date') {
|
|
197
|
-
formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
198
|
-
}
|
|
213
|
+
formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
214
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
215
|
+
}></u-date-picker>`;
|
|
199
216
|
} else if (propertyTypeName === 'Time') {
|
|
200
|
-
formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
201
|
-
}
|
|
217
|
+
formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
218
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
219
|
+
}></u-time-picker>`;
|
|
202
220
|
} else if (propertyTypeName === 'DateTime') {
|
|
203
|
-
formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
204
|
-
}
|
|
221
|
+
formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
222
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
223
|
+
}></u-date-time-picker>`;
|
|
205
224
|
} else {
|
|
206
225
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
207
226
|
const type = namespaceArr.pop();
|
|
@@ -209,8 +228,9 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
209
228
|
const Enum = dataSource.app.findNodeByCompleteName(`${propertyTypeNamespace}.${propertyTypeName}`) as Enum;
|
|
210
229
|
formItem += genEnumSelectBlock(Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
211
230
|
} else {
|
|
212
|
-
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
213
|
-
}
|
|
231
|
+
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
232
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
233
|
+
}></u-input>`;
|
|
214
234
|
}
|
|
215
235
|
}
|
|
216
236
|
|
|
@@ -230,7 +250,6 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
230
250
|
</u-modal>`;
|
|
231
251
|
}
|
|
232
252
|
|
|
233
|
-
|
|
234
253
|
function genInitLogic(nameGroup: NameGroup) {
|
|
235
254
|
return NaslNode.Logic({
|
|
236
255
|
name: nameGroup.viewLogicInit,
|
|
@@ -445,6 +464,58 @@ function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
445
464
|
});
|
|
446
465
|
}
|
|
447
466
|
|
|
467
|
+
function genDetailLogic(entity: Entity, nameGroup: NameGroup) {
|
|
468
|
+
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
469
|
+
|
|
470
|
+
return NaslNode.Logic({
|
|
471
|
+
name: nameGroup.viewLogicPreview,
|
|
472
|
+
description: '',
|
|
473
|
+
params: [],
|
|
474
|
+
returns: [] as any[],
|
|
475
|
+
variables: [] as any[],
|
|
476
|
+
body: [
|
|
477
|
+
NaslLogicItem.Start,
|
|
478
|
+
NaslLogicItem.Assignment({
|
|
479
|
+
left: NaslLogicItem.Identifier({
|
|
480
|
+
name: nameGroup.viewVariablePreview,
|
|
481
|
+
}),
|
|
482
|
+
right: NaslLogicItem.Identifier({
|
|
483
|
+
name: 'true',
|
|
484
|
+
}),
|
|
485
|
+
}),
|
|
486
|
+
NaslLogicItem.Assignment({
|
|
487
|
+
left: NaslLogicItem.Identifier({
|
|
488
|
+
name: nameGroup.viewVariableInput,
|
|
489
|
+
}),
|
|
490
|
+
right: NaslLogicItem.CallFunction({
|
|
491
|
+
calleeName: 'Clone',
|
|
492
|
+
arguments: [
|
|
493
|
+
NaslLogicItem.Argument({
|
|
494
|
+
keyword: 'obj',
|
|
495
|
+
expression: NaslLogicItem.MemberExpression({
|
|
496
|
+
object: NaslLogicItem.MemberExpression({
|
|
497
|
+
object: NaslLogicItem.Identifier({
|
|
498
|
+
name: 'current',
|
|
499
|
+
}),
|
|
500
|
+
property: NaslLogicItem.Identifier({
|
|
501
|
+
name: 'item',
|
|
502
|
+
}),
|
|
503
|
+
}),
|
|
504
|
+
property: NaslLogicItem.Identifier({
|
|
505
|
+
name: lowerEntityName,
|
|
506
|
+
}),
|
|
507
|
+
}),
|
|
508
|
+
}),
|
|
509
|
+
],
|
|
510
|
+
}),
|
|
511
|
+
}),
|
|
512
|
+
genCallComponentLogic(nameGroup.viewElementSaveModal, 'open'),
|
|
513
|
+
NaslLogicItem.End,
|
|
514
|
+
],
|
|
515
|
+
playground: [] as any[],
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
|
|
448
519
|
// 列表(全)
|
|
449
520
|
export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
|
|
450
521
|
const likeComponent = oldNode?.likeComponent;
|
|
@@ -514,31 +585,31 @@ export function genCurdMultipleKeyBlock(entity: Entity, oldNode: ViewElement) {
|
|
|
514
585
|
"concept": "Variable",
|
|
515
586
|
"name": "${nameGroup.viewVariableEntity}",
|
|
516
587
|
"typeAnnotation": ${JSON.stringify(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
588
|
+
NaslTypeAnnotation.Reference({
|
|
589
|
+
typeNamespace: entity.getNamespace(),
|
|
590
|
+
typeName: entity.name,
|
|
591
|
+
})
|
|
592
|
+
)}
|
|
522
593
|
},
|
|
523
594
|
{
|
|
524
595
|
"concept": "Variable",
|
|
525
596
|
"name": "${nameGroup.viewVariableInput}",
|
|
526
597
|
"typeAnnotation": ${JSON.stringify(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
598
|
+
NaslTypeAnnotation.Reference({
|
|
599
|
+
typeNamespace: entity.getNamespace(),
|
|
600
|
+
typeName: entity.name,
|
|
601
|
+
})
|
|
602
|
+
)}
|
|
532
603
|
},
|
|
533
604
|
{
|
|
534
605
|
"concept": "Variable",
|
|
535
606
|
"name": "${nameGroup.viewVariableFilter}",
|
|
536
607
|
"typeAnnotation": ${JSON.stringify(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
608
|
+
NaslTypeAnnotation.Reference({
|
|
609
|
+
typeNamespace: entity.getNamespace(),
|
|
610
|
+
typeName: entity.name,
|
|
611
|
+
})
|
|
612
|
+
)}
|
|
542
613
|
},
|
|
543
614
|
{
|
|
544
615
|
"concept": "Variable",
|
|
@@ -642,31 +713,31 @@ export function genGridViewMultipleKeyBlock(entity: Entity, oldNode: ViewElement
|
|
|
642
713
|
"concept": "Variable",
|
|
643
714
|
"name": "${nameGroup.viewVariableEntity}",
|
|
644
715
|
"typeAnnotation": ${JSON.stringify(
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
716
|
+
NaslTypeAnnotation.Reference({
|
|
717
|
+
typeNamespace: entity.getNamespace(),
|
|
718
|
+
typeName: entity.name,
|
|
719
|
+
})
|
|
720
|
+
)}
|
|
650
721
|
},
|
|
651
722
|
{
|
|
652
723
|
"concept": "Variable",
|
|
653
724
|
"name": "${nameGroup.viewVariableInput}",
|
|
654
725
|
"typeAnnotation": ${JSON.stringify(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
726
|
+
NaslTypeAnnotation.Reference({
|
|
727
|
+
typeNamespace: entity.getNamespace(),
|
|
728
|
+
typeName: entity.name,
|
|
729
|
+
})
|
|
730
|
+
)}
|
|
660
731
|
},
|
|
661
732
|
{
|
|
662
733
|
"concept": "Variable",
|
|
663
734
|
"name": "${nameGroup.viewVariableFilter}",
|
|
664
735
|
"typeAnnotation": ${JSON.stringify(
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
736
|
+
NaslTypeAnnotation.Reference({
|
|
737
|
+
typeNamespace: entity.getNamespace(),
|
|
738
|
+
typeName: entity.name,
|
|
739
|
+
})
|
|
740
|
+
)}
|
|
670
741
|
},
|
|
671
742
|
{
|
|
672
743
|
"concept": "Variable",
|
|
@@ -715,3 +786,656 @@ export function genReloadLogic(nameGroup: NameGroup) {
|
|
|
715
786
|
playground: [],
|
|
716
787
|
});
|
|
717
788
|
}
|
|
789
|
+
|
|
790
|
+
export function genResetLogic(nameGroup: NameGroup) {
|
|
791
|
+
return NaslNode.Logic({
|
|
792
|
+
name: nameGroup.viewLogicReset,
|
|
793
|
+
params: [] as any[],
|
|
794
|
+
returns: [] as any[],
|
|
795
|
+
variables: [
|
|
796
|
+
NaslNode.Variable({
|
|
797
|
+
name: 'validateResult',
|
|
798
|
+
typeAnnotation: NaslUITypeAnnotation.ValidateEvent,
|
|
799
|
+
}),
|
|
800
|
+
],
|
|
801
|
+
body: [
|
|
802
|
+
NaslLogicItem.Start,
|
|
803
|
+
NaslLogicItem.CallFunction({
|
|
804
|
+
calleeName: 'Clear',
|
|
805
|
+
arguments: [
|
|
806
|
+
NaslLogicItem.Argument({
|
|
807
|
+
keyword: 'struct',
|
|
808
|
+
expression: NaslLogicItem.Identifier({
|
|
809
|
+
name: nameGroup.viewVariableFilter,
|
|
810
|
+
}),
|
|
811
|
+
}),
|
|
812
|
+
],
|
|
813
|
+
}),
|
|
814
|
+
genCallComponentLogic(nameGroup.viewElementMainView, 'reload'),
|
|
815
|
+
NaslLogicItem.End,
|
|
816
|
+
],
|
|
817
|
+
playground: [],
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
export function genExportExcelLogic(nameGroup: NameGroup) {
|
|
822
|
+
return NaslNode.Logic({
|
|
823
|
+
name: nameGroup.viewLogicExportData,
|
|
824
|
+
params: [] as any[],
|
|
825
|
+
returns: [] as any[],
|
|
826
|
+
variables: [],
|
|
827
|
+
body: [
|
|
828
|
+
NaslLogicItem.Start,
|
|
829
|
+
NaslLogicItem.CallLogic({
|
|
830
|
+
calleeNamespace: `elements.${nameGroup.viewElementMainView}.logics`,
|
|
831
|
+
calleeName: 'exportExcel',
|
|
832
|
+
arguments: [
|
|
833
|
+
NaslLogicItem.Argument({
|
|
834
|
+
keyword: 'page',
|
|
835
|
+
expression: {
|
|
836
|
+
concept: 'NumericLiteral',
|
|
837
|
+
value: '1',
|
|
838
|
+
typeAnnotation: {
|
|
839
|
+
concept: 'TypeAnnotation',
|
|
840
|
+
typeKind: 'primitive',
|
|
841
|
+
typeNamespace: 'nasl.core',
|
|
842
|
+
typeName: 'Long',
|
|
843
|
+
},
|
|
844
|
+
},
|
|
845
|
+
}),
|
|
846
|
+
NaslLogicItem.Argument({
|
|
847
|
+
keyword: 'size',
|
|
848
|
+
expression: {
|
|
849
|
+
concept: 'NumericLiteral',
|
|
850
|
+
value: '9999',
|
|
851
|
+
typeAnnotation: {
|
|
852
|
+
concept: 'TypeAnnotation',
|
|
853
|
+
typeKind: 'primitive',
|
|
854
|
+
typeNamespace: 'nasl.core',
|
|
855
|
+
typeName: 'Long',
|
|
856
|
+
},
|
|
857
|
+
},
|
|
858
|
+
}),
|
|
859
|
+
NaslLogicItem.Argument({
|
|
860
|
+
keyword: 'filename',
|
|
861
|
+
expression: null,
|
|
862
|
+
}),
|
|
863
|
+
NaslLogicItem.Argument({
|
|
864
|
+
keyword: 'sort',
|
|
865
|
+
expression: null,
|
|
866
|
+
}),
|
|
867
|
+
NaslLogicItem.Argument({
|
|
868
|
+
keyword: 'order',
|
|
869
|
+
expression: null,
|
|
870
|
+
}),
|
|
871
|
+
NaslLogicItem.Argument({
|
|
872
|
+
keyword: 'excludeColumns',
|
|
873
|
+
expression: null,
|
|
874
|
+
}),
|
|
875
|
+
],
|
|
876
|
+
}),
|
|
877
|
+
NaslLogicItem.End,
|
|
878
|
+
],
|
|
879
|
+
playground: [],
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
function genCloseModalLogic(nameGroup: NameGroup) {
|
|
884
|
+
return NaslNode.Logic({
|
|
885
|
+
name: nameGroup.viewLogicCloseModal,
|
|
886
|
+
description: '',
|
|
887
|
+
params: [],
|
|
888
|
+
returns: [] as any[],
|
|
889
|
+
variables: [] as any[],
|
|
890
|
+
body: [
|
|
891
|
+
NaslLogicItem.Start,
|
|
892
|
+
NaslLogicItem.Assignment({
|
|
893
|
+
left: NaslLogicItem.Identifier({
|
|
894
|
+
name: nameGroup.viewVariablePreview,
|
|
895
|
+
}),
|
|
896
|
+
right: NaslLogicItem.Identifier({
|
|
897
|
+
name: 'false',
|
|
898
|
+
}),
|
|
899
|
+
}),
|
|
900
|
+
NaslLogicItem.End,
|
|
901
|
+
],
|
|
902
|
+
playground: [] as any[],
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
function genOpenDelModalLogic(entity: Entity, nameGroup: NameGroup) {
|
|
907
|
+
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
908
|
+
return NaslNode.Logic({
|
|
909
|
+
name: nameGroup.viewLogicOpenDelModal,
|
|
910
|
+
description: '',
|
|
911
|
+
params: [],
|
|
912
|
+
returns: [] as any[],
|
|
913
|
+
variables: [] as any[],
|
|
914
|
+
body: [
|
|
915
|
+
NaslLogicItem.Start,
|
|
916
|
+
NaslLogicItem.Assignment({
|
|
917
|
+
left: NaslLogicItem.Identifier({
|
|
918
|
+
name: nameGroup.viewVariableInput,
|
|
919
|
+
}),
|
|
920
|
+
right: NaslLogicItem.CallFunction({
|
|
921
|
+
calleeName: 'Clone',
|
|
922
|
+
arguments: [
|
|
923
|
+
NaslLogicItem.Argument({
|
|
924
|
+
keyword: 'obj',
|
|
925
|
+
expression: NaslLogicItem.MemberExpression({
|
|
926
|
+
object: NaslLogicItem.MemberExpression({
|
|
927
|
+
object: NaslLogicItem.Identifier({
|
|
928
|
+
name: 'current',
|
|
929
|
+
}),
|
|
930
|
+
property: NaslLogicItem.Identifier({
|
|
931
|
+
name: 'item',
|
|
932
|
+
}),
|
|
933
|
+
}),
|
|
934
|
+
property: NaslLogicItem.Identifier({
|
|
935
|
+
name: lowerEntityName,
|
|
936
|
+
}),
|
|
937
|
+
}),
|
|
938
|
+
}),
|
|
939
|
+
],
|
|
940
|
+
}),
|
|
941
|
+
}),
|
|
942
|
+
genCallComponentLogic(nameGroup.viewElementDelModal, 'open'),
|
|
943
|
+
NaslLogicItem.End,
|
|
944
|
+
],
|
|
945
|
+
playground: [] as any[],
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function genCloseDelModalLogic(nameGroup: NameGroup) {
|
|
949
|
+
return NaslNode.Logic({
|
|
950
|
+
name: nameGroup.viewLogicCloseDelModal,
|
|
951
|
+
body: [NaslLogicItem.Start, genCallComponentLogic(nameGroup.viewElementDelModal, 'close'), NaslLogicItem.End],
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
function genDelModalSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
956
|
+
const { ns } = entity;
|
|
957
|
+
const deleteLogic = ns?.logics?.find((logic) => logic.name === 'delete');
|
|
958
|
+
return NaslNode.Logic({
|
|
959
|
+
name: nameGroup.viewLogicDelModalSubmit,
|
|
960
|
+
params: [],
|
|
961
|
+
returns: [] as any[],
|
|
962
|
+
variables: [] as any[],
|
|
963
|
+
body: [
|
|
964
|
+
NaslLogicItem.Start,
|
|
965
|
+
NaslLogicItem.CallLogic({
|
|
966
|
+
calleeNamespace: deleteLogic.getNamespace(),
|
|
967
|
+
calleeName: deleteLogic.name,
|
|
968
|
+
arguments: [
|
|
969
|
+
{
|
|
970
|
+
concept: 'Argument',
|
|
971
|
+
keyword: 'id',
|
|
972
|
+
expression: {
|
|
973
|
+
concept: 'MemberExpression',
|
|
974
|
+
object: {
|
|
975
|
+
concept: 'Identifier',
|
|
976
|
+
name: 'input',
|
|
977
|
+
},
|
|
978
|
+
property: {
|
|
979
|
+
concept: 'Identifier',
|
|
980
|
+
name: 'id',
|
|
981
|
+
},
|
|
982
|
+
},
|
|
983
|
+
},
|
|
984
|
+
],
|
|
985
|
+
}),
|
|
986
|
+
genCallComponentLogic(nameGroup.viewElementDelModal, 'close'),
|
|
987
|
+
genCallComponentLogic(nameGroup.viewElementMainView, 'reload'),
|
|
988
|
+
NaslLogicItem.End,
|
|
989
|
+
],
|
|
990
|
+
});
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
export function genFilterTemplateTableDesigner(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, optionsMap?: any) {
|
|
994
|
+
const dataSource = entity.parentNode as DataSource;
|
|
995
|
+
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
996
|
+
const getCol = (code: string) => `<u-grid-layout-column span="6" style="padding: 10px 0;">${code}</u-grid-layout-column>`;
|
|
997
|
+
return `<u-form style="margin-bottom: 6px;padding: 15px 15px 5px 15px;background: #fff;">
|
|
998
|
+
<u-grid-layout>
|
|
999
|
+
<u-grid-layout-row repeat="24">
|
|
1000
|
+
${properties
|
|
1001
|
+
.map((property) => {
|
|
1002
|
+
const vModel = `${nameGroup.viewVariableFilter}.${property.name}`;
|
|
1003
|
+
const label = (property.label || property.name).replace(/"/g, '"');
|
|
1004
|
+
let formItem = `<u-form-item layout="center"><template #label><u-text text="${label}"></u-text></template>`;
|
|
1005
|
+
|
|
1006
|
+
const { typeAnnotation } = property || {};
|
|
1007
|
+
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
1008
|
+
const propertyTypeMaxLength: number =
|
|
1009
|
+
Number(
|
|
1010
|
+
property.rules
|
|
1011
|
+
.find((item) => item.indexOf('max') > -1)
|
|
1012
|
+
?.split('(')[1]
|
|
1013
|
+
.slice(0, -1)
|
|
1014
|
+
) || 0;
|
|
1015
|
+
if (optionsMap?.[property.name]) {
|
|
1016
|
+
const options = optionsMap?.[property.name];
|
|
1017
|
+
const multiple = property?.typeAnnotation?.typeName === 'List';
|
|
1018
|
+
formItem += `
|
|
1019
|
+
<u-select clearable v-model="${vModel}" placeholder="请选择" ${multiple ? 'multiple' : ''}>
|
|
1020
|
+
${options.map((option: any) => `<u-select-item value="${option.value}">${option.label}</u-select-item>`).join('')}
|
|
1021
|
+
</u-select>
|
|
1022
|
+
`;
|
|
1023
|
+
} else if (property.relationEntity) {
|
|
1024
|
+
// 有外键关联
|
|
1025
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
1026
|
+
if (relationEntity) {
|
|
1027
|
+
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
1028
|
+
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
1029
|
+
if (displayedProperty) {
|
|
1030
|
+
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
1031
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
1032
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
1033
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
1034
|
+
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
|
|
1035
|
+
formItem += `
|
|
1036
|
+
<u-select clearable placeholder="请选择${label}" :data-source="${dataSourceValue}" :page-size="50"
|
|
1037
|
+
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pagination="true" v-model="${vModel}">
|
|
1038
|
+
</u-select>
|
|
1039
|
+
`;
|
|
1040
|
+
} else return '';
|
|
1041
|
+
} else return '';
|
|
1042
|
+
} else if (propertyTypeName === 'Boolean') {
|
|
1043
|
+
formItem += `
|
|
1044
|
+
<u-select clearable v-model="${vModel}" placeholder="请输入${label}">
|
|
1045
|
+
<u-select-item :value="true" text="是">是</u-select-item>
|
|
1046
|
+
<u-select-item :value="false" text="否">否</u-select-item>
|
|
1047
|
+
</u-select>
|
|
1048
|
+
`;
|
|
1049
|
+
} else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
|
|
1050
|
+
formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}"></u-number-input>`;
|
|
1051
|
+
} else if (propertyTypeName === 'Double') {
|
|
1052
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
|
|
1053
|
+
} else if (propertyTypeName === 'Decimal') {
|
|
1054
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
|
|
1055
|
+
} else if (propertyTypeName === 'String' && propertyTypeMaxLength > 256) {
|
|
1056
|
+
formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}"></u-textarea>`;
|
|
1057
|
+
} else if (propertyTypeName === 'Date') {
|
|
1058
|
+
formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}"></u-date-picker>`;
|
|
1059
|
+
} else if (propertyTypeName === 'Time') {
|
|
1060
|
+
formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}"></u-time-picker>`;
|
|
1061
|
+
} else if (propertyTypeName === 'DateTime') {
|
|
1062
|
+
formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
1063
|
+
} else {
|
|
1064
|
+
const namespaceArr = propertyTypeNamespace.split('.');
|
|
1065
|
+
const type = namespaceArr.pop();
|
|
1066
|
+
if (type === 'enums') {
|
|
1067
|
+
const Enum = dataSource.app.findNodeByCompleteName(`${propertyTypeNamespace}.${propertyTypeName}`) as Enum;
|
|
1068
|
+
formItem += genEnumSelectBlock(Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
1069
|
+
} else {
|
|
1070
|
+
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
formItem += `</u-form-item>`;
|
|
1075
|
+
return getCol(formItem);
|
|
1076
|
+
})
|
|
1077
|
+
.join('')}
|
|
1078
|
+
${getCol(`<u-form-item layout="center" label-size="auto">
|
|
1079
|
+
<u-button color="primary" style="margin-right: 5px" @click="${nameGroup.viewLogicReload}">查 询</u-button>
|
|
1080
|
+
<u-button @click="${nameGroup.viewLogicReset}">重 置</u-button>
|
|
1081
|
+
</u-form-item>`)}
|
|
1082
|
+
</u-grid-layout-row>
|
|
1083
|
+
</u-grid-layout>
|
|
1084
|
+
</u-form>
|
|
1085
|
+
`;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
function genSaveModalTemplateDesigner(
|
|
1089
|
+
entity: Entity,
|
|
1090
|
+
nameGroup: NameGroup,
|
|
1091
|
+
selectNameGroupMap: Map<string, NameGroup>,
|
|
1092
|
+
SaveModalFormTemplate?: string
|
|
1093
|
+
) {
|
|
1094
|
+
const dataSource = entity.parentNode as DataSource;
|
|
1095
|
+
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
1096
|
+
|
|
1097
|
+
const formStr = ` <u-form ref="${nameGroup.viewElementSaveModalForm}" :preview="${nameGroup.viewVariablePreview}">
|
|
1098
|
+
${properties
|
|
1099
|
+
.map((property) => {
|
|
1100
|
+
const vModel = `${nameGroup.viewVariableInput}.${property.name}`;
|
|
1101
|
+
const label = (property.label || property.name).replace(/"/g, '"');
|
|
1102
|
+
const required = !!property.required;
|
|
1103
|
+
const rules = [];
|
|
1104
|
+
if (property.rules && property.rules.length) {
|
|
1105
|
+
property.rules.forEach((rule) => rules.push(rule));
|
|
1106
|
+
}
|
|
1107
|
+
if (required) rules.push('required');
|
|
1108
|
+
const rulesStr = rules.join(' | ');
|
|
1109
|
+
let formItem = `<u-form-item ${required ? 'required' : ''} ${
|
|
1110
|
+
rulesStr.length ? `rules="${rulesStr}"` : ''
|
|
1111
|
+
} layout="center"><template #label><u-text text="${label}"></u-text></template>`;
|
|
1112
|
+
|
|
1113
|
+
const { typeAnnotation } = property || {};
|
|
1114
|
+
const { typeName: propertyTypeName, typeNamespace: propertyTypeNamespace } = typeAnnotation || {};
|
|
1115
|
+
const propertyTypeMaxLength: number =
|
|
1116
|
+
Number(
|
|
1117
|
+
property.rules
|
|
1118
|
+
.find((item) => item.indexOf('max') > -1)
|
|
1119
|
+
?.split('(')[1]
|
|
1120
|
+
.slice(0, -1)
|
|
1121
|
+
) || 0;
|
|
1122
|
+
if (property.relationEntity) {
|
|
1123
|
+
// 有外键关联
|
|
1124
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
1125
|
+
if (relationEntity) {
|
|
1126
|
+
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
1127
|
+
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
1128
|
+
if (displayedProperty) {
|
|
1129
|
+
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
1130
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
1131
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
1132
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
1133
|
+
let dataSourceValue = `(params) => ${selectNameGroup.logic}(elements.$ce.page, elements.$ce.size)`;
|
|
1134
|
+
formItem += `
|
|
1135
|
+
<u-select clearable placeholder="请选择${label}"
|
|
1136
|
+
text-field="${lowerEntityName}.${displayedProperty.name}"
|
|
1137
|
+
value-field="${lowerEntityName}.${relationProperty.name}"
|
|
1138
|
+
:data-source="${dataSourceValue}" :page-size="50"
|
|
1139
|
+
:pagination="true"
|
|
1140
|
+
${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}
|
|
1141
|
+
v-model="${vModel}">
|
|
1142
|
+
</u-select>
|
|
1143
|
+
`;
|
|
1144
|
+
} else return '';
|
|
1145
|
+
} else return '';
|
|
1146
|
+
} else if (propertyTypeName === 'Boolean') {
|
|
1147
|
+
formItem += `
|
|
1148
|
+
<u-select clearable v-model="${vModel}" placeholder="请输入${label}" ${
|
|
1149
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1150
|
+
}>
|
|
1151
|
+
<u-select-item :value="true" text="是"><u-text text="是"></u-text></u-select-item>
|
|
1152
|
+
<u-select-item :value="false" text="否"><u-text text="否"></u-text></u-select-item>
|
|
1153
|
+
</u-select>`;
|
|
1154
|
+
} else if (propertyTypeName === 'Integer' || propertyTypeName === 'Long') {
|
|
1155
|
+
formItem += `<u-number-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
1156
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1157
|
+
}></u-number-input>`;
|
|
1158
|
+
} else if (propertyTypeName === 'Double') {
|
|
1159
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
1160
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1161
|
+
}></u-number-input>`;
|
|
1162
|
+
} else if (propertyTypeName === 'Decimal') {
|
|
1163
|
+
formItem += `<u-number-input v-model="${vModel}" :precision="0" :step="0" placeholder="请输入${label}" ${
|
|
1164
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1165
|
+
}></u-number-input>`;
|
|
1166
|
+
} else if (propertyTypeName === 'String' && propertyTypeMaxLength > 256) {
|
|
1167
|
+
formItem += `<u-textarea v-model="${vModel}" placeholder="请输入${label}" ${
|
|
1168
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1169
|
+
}></u-textarea>`;
|
|
1170
|
+
} else if (propertyTypeName === 'Date') {
|
|
1171
|
+
formItem += `<u-date-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
1172
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1173
|
+
}></u-date-picker>`;
|
|
1174
|
+
} else if (propertyTypeName === 'Time') {
|
|
1175
|
+
formItem += `<u-time-picker :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
1176
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1177
|
+
}></u-time-picker>`;
|
|
1178
|
+
} else if (propertyTypeName === 'DateTime') {
|
|
1179
|
+
formItem += `<u-date-time-picker clearable :value.sync="${vModel}" placeholder="请输入${label}" ${
|
|
1180
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1181
|
+
}></u-date-time-picker>`;
|
|
1182
|
+
} else {
|
|
1183
|
+
const namespaceArr = propertyTypeNamespace.split('.');
|
|
1184
|
+
const type = namespaceArr.pop();
|
|
1185
|
+
if (type === 'enums') {
|
|
1186
|
+
const Enum = dataSource.app.findNodeByCompleteName(`${propertyTypeNamespace}.${propertyTypeName}`) as Enum;
|
|
1187
|
+
formItem += genEnumSelectBlock(Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
1188
|
+
} else {
|
|
1189
|
+
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${
|
|
1190
|
+
property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''
|
|
1191
|
+
}></u-input>`;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
formItem += `</u-form-item>\n`;
|
|
1196
|
+
|
|
1197
|
+
return formItem;
|
|
1198
|
+
})
|
|
1199
|
+
.join('')}
|
|
1200
|
+
</u-form>`;
|
|
1201
|
+
if (SaveModalFormTemplate) {
|
|
1202
|
+
SaveModalFormTemplate = SaveModalFormTemplate.replace(
|
|
1203
|
+
'<u-form',
|
|
1204
|
+
`<u-form ref="${nameGroup.viewElementSaveModalForm}" :preview="${nameGroup.viewVariablePreview}" `
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
return `
|
|
1209
|
+
<u-modal ref="${nameGroup.viewElementSaveModal}" @close="${nameGroup.viewLogicCloseModal}" size="huge" :show-foot="!${
|
|
1210
|
+
nameGroup.viewVariablePreview
|
|
1211
|
+
}">
|
|
1212
|
+
<template #title>
|
|
1213
|
+
<div v-if="${nameGroup.viewVariablePreview}">
|
|
1214
|
+
<u-text>详情</u-text>
|
|
1215
|
+
</div>
|
|
1216
|
+
<div v-if="!${nameGroup.viewVariablePreview}">
|
|
1217
|
+
<div v-if="${nameGroup.viewVariableIsUpdate}"><u-text>修改</u-text></div>
|
|
1218
|
+
<div v-if="!${nameGroup.viewVariableIsUpdate}"><u-text>新增</u-text></div>
|
|
1219
|
+
</template>
|
|
1220
|
+
<template #body>
|
|
1221
|
+
${SaveModalFormTemplate || formStr}
|
|
1222
|
+
</template>
|
|
1223
|
+
<template #foot>
|
|
1224
|
+
<u-linear-layout>
|
|
1225
|
+
<u-button color="primary" @click="${nameGroup.viewLogicUpdateSubmit}()" v-if="${nameGroup.viewVariableIsUpdate}">提交修改</u-button>
|
|
1226
|
+
<u-button color="primary" @click="${nameGroup.viewLogicSubmit}()" v-if="!${nameGroup.viewVariableIsUpdate}">立即新增</u-button>
|
|
1227
|
+
</u-linear-layout>
|
|
1228
|
+
</template>
|
|
1229
|
+
</u-modal>`;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
export const genDelModalTemplate = (nameGroup: NameGroup) => {
|
|
1233
|
+
return `
|
|
1234
|
+
<u-modal
|
|
1235
|
+
ref="${nameGroup.viewElementDelModal}"
|
|
1236
|
+
style="
|
|
1237
|
+
border-top-left-radius: 4px;
|
|
1238
|
+
border-top-right-radius: 4px;
|
|
1239
|
+
border-bottom-right-radius: 4px;
|
|
1240
|
+
border-bottom-left-radius: 4px;
|
|
1241
|
+
--update-key: d9hj;
|
|
1242
|
+
"
|
|
1243
|
+
icon="warning"
|
|
1244
|
+
>
|
|
1245
|
+
<template #foot>
|
|
1246
|
+
<u-linear-layout style="text-align: right" :vusion-disabled-cut="true" justify="center">
|
|
1247
|
+
<u-button text="取 消" @click="${nameGroup.viewLogicCloseDelModal}"></u-button>
|
|
1248
|
+
<u-button color="primary" text="确 定" @click="${nameGroup.viewLogicDelModalSubmit}"></u-button>
|
|
1249
|
+
</u-linear-layout>
|
|
1250
|
+
</template>
|
|
1251
|
+
<template #body>
|
|
1252
|
+
<u-text style="font-weight: bold; font-size: 18px" text="请确认是否删除?"></u-text>
|
|
1253
|
+
<u-linear-layout style="--custom-start: auto" direction="horizontal">
|
|
1254
|
+
<u-text
|
|
1255
|
+
style="--custom-start: auto"
|
|
1256
|
+
color="secondary"
|
|
1257
|
+
text="删除后将无法恢复,请谨慎操作"
|
|
1258
|
+
></u-text>
|
|
1259
|
+
</u-linear-layout>
|
|
1260
|
+
</template>
|
|
1261
|
+
<template #title> <u-text></u-text> </template
|
|
1262
|
+
></u-modal>
|
|
1263
|
+
`;
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
// composedBy 节点组合属性
|
|
1267
|
+
export function genCurdMultipleKeyBlockForTableDesigner(
|
|
1268
|
+
entity: Entity,
|
|
1269
|
+
oldNode: ViewElement,
|
|
1270
|
+
SaveModalFormTemplate?: string,
|
|
1271
|
+
optionsMap?: any,
|
|
1272
|
+
composedBy?: string
|
|
1273
|
+
) {
|
|
1274
|
+
const { view } = oldNode;
|
|
1275
|
+
const dataSource = entity.parentNode as DataSource;
|
|
1276
|
+
const module = dataSource.app;
|
|
1277
|
+
const composedByOptionStr = composedBy && composedBy.length > 0 ? `"composedBy":${JSON.stringify(composedBy)},` : '';
|
|
1278
|
+
const patchLogic = (logic: any) => {
|
|
1279
|
+
if (composedBy && composedBy.length > 0) {
|
|
1280
|
+
return {
|
|
1281
|
+
...logic,
|
|
1282
|
+
composedBy,
|
|
1283
|
+
};
|
|
1284
|
+
} else return logic;
|
|
1285
|
+
};
|
|
1286
|
+
|
|
1287
|
+
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
1288
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
1289
|
+
nameGroup.viewElementMainView = viewElementMainView;
|
|
1290
|
+
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
1291
|
+
nameGroup.viewElementDelModal = view.getViewElementUniqueName('delModal');
|
|
1292
|
+
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
1293
|
+
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
1294
|
+
nameGroup.viewLogicInit = view.getLogicUniqueName('init');
|
|
1295
|
+
nameGroup.viewLogicCreate = view.getLogicUniqueName('create');
|
|
1296
|
+
nameGroup.viewLogicModify = view.getLogicUniqueName('modify');
|
|
1297
|
+
nameGroup.viewLogicSubmit = view.getLogicUniqueName('submit');
|
|
1298
|
+
nameGroup.viewLogicUpdateSubmit = view.getLogicUniqueName('updateSubmit');
|
|
1299
|
+
nameGroup.viewLogicReload = view.getLogicUniqueName('reload');
|
|
1300
|
+
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
1301
|
+
nameGroup.viewVariableInput = view.getVariableUniqueName('input');
|
|
1302
|
+
nameGroup.viewVariableFilter = view.getVariableUniqueName('filter');
|
|
1303
|
+
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
1304
|
+
nameGroup.viewLogicReset = view.getLogicUniqueName('reset');
|
|
1305
|
+
nameGroup.viewLogicExportData = view.getLogicUniqueName('exportData');
|
|
1306
|
+
nameGroup.viewVariablePreview = view.getVariableUniqueName('preview');
|
|
1307
|
+
nameGroup.viewLogicPreview = view.getLogicUniqueName('preview');
|
|
1308
|
+
nameGroup.viewLogicCloseModal = view.getLogicUniqueName('closeModal');
|
|
1309
|
+
nameGroup.viewLogicOpenDelModal = view.getLogicUniqueName('openDelModal');
|
|
1310
|
+
nameGroup.viewLogicCloseDelModal = view.getLogicUniqueName('closeDelModal');
|
|
1311
|
+
nameGroup.viewLogicDelModalSubmit = view.getLogicUniqueName('delModalSubmit');
|
|
1312
|
+
|
|
1313
|
+
// 收集所有和本实体关联的实体
|
|
1314
|
+
const entitySet: Set<Entity> = new Set();
|
|
1315
|
+
entitySet.add(entity);
|
|
1316
|
+
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
1317
|
+
const newLogics: any[] = [];
|
|
1318
|
+
const newLoadSelectLogics: any[] = [];
|
|
1319
|
+
entity.properties.forEach((property) => {
|
|
1320
|
+
// 有外键关联
|
|
1321
|
+
if (property.relationEntity) {
|
|
1322
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
1323
|
+
if (relationEntity) {
|
|
1324
|
+
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
1325
|
+
if (displayedProperty) {
|
|
1326
|
+
entitySet.add(relationEntity);
|
|
1327
|
+
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
1328
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
1329
|
+
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
1330
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
1331
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
1332
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
1333
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
1334
|
+
newLogics.push(newLogic);
|
|
1335
|
+
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
const allEntities = [...entitySet];
|
|
1341
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
1342
|
+
newLogics.push(patchLogic(entityLogic));
|
|
1343
|
+
|
|
1344
|
+
const code = `<template>
|
|
1345
|
+
<u-linear-layout direction="vertical" :bindEntity="" :TableDesignerLocked="true" style="background: #F7F8FA;">
|
|
1346
|
+
${genFilterTemplateTableDesigner(entity, nameGroup, selectNameGroupMap, optionsMap)}
|
|
1347
|
+
${genTableTemplateTableDesigner(entity, nameGroup, entityLogic, true, 'genCurdMultipleKeyBlock', optionsMap)}
|
|
1348
|
+
${genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate)}
|
|
1349
|
+
${genDelModalTemplate(nameGroup)}
|
|
1350
|
+
</u-linear-layout>
|
|
1351
|
+
</template>
|
|
1352
|
+
|
|
1353
|
+
<definition>
|
|
1354
|
+
{
|
|
1355
|
+
"viewVariables": [
|
|
1356
|
+
{
|
|
1357
|
+
"concept": "Variable",
|
|
1358
|
+
${composedByOptionStr}
|
|
1359
|
+
"name": "${nameGroup.viewVariableEntity}",
|
|
1360
|
+
"typeAnnotation": ${JSON.stringify(
|
|
1361
|
+
NaslTypeAnnotation.Reference({
|
|
1362
|
+
typeNamespace: entity.getNamespace(),
|
|
1363
|
+
typeName: entity.name,
|
|
1364
|
+
})
|
|
1365
|
+
)}
|
|
1366
|
+
},
|
|
1367
|
+
{
|
|
1368
|
+
"concept": "Variable",
|
|
1369
|
+
${composedByOptionStr}
|
|
1370
|
+
"name": "${nameGroup.viewVariableInput}",
|
|
1371
|
+
"typeAnnotation": ${JSON.stringify(
|
|
1372
|
+
NaslTypeAnnotation.Reference({
|
|
1373
|
+
typeNamespace: entity.getNamespace(),
|
|
1374
|
+
typeName: entity.name,
|
|
1375
|
+
})
|
|
1376
|
+
)}
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
"concept": "Variable",
|
|
1380
|
+
${composedByOptionStr}
|
|
1381
|
+
"name": "${nameGroup.viewVariableFilter}",
|
|
1382
|
+
"typeAnnotation": ${JSON.stringify(
|
|
1383
|
+
NaslTypeAnnotation.Reference({
|
|
1384
|
+
typeNamespace: entity.getNamespace(),
|
|
1385
|
+
typeName: entity.name,
|
|
1386
|
+
})
|
|
1387
|
+
)}
|
|
1388
|
+
},
|
|
1389
|
+
{
|
|
1390
|
+
"concept": "Variable",
|
|
1391
|
+
${composedByOptionStr}
|
|
1392
|
+
"name": "${nameGroup.viewVariableIsUpdate}",
|
|
1393
|
+
"typeAnnotation": ${JSON.stringify(NaslCoreTypeAnnotation.Boolean)}
|
|
1394
|
+
},
|
|
1395
|
+
{
|
|
1396
|
+
"concept": "Variable",
|
|
1397
|
+
${composedByOptionStr}
|
|
1398
|
+
"name": "${nameGroup.viewVariablePreview}",
|
|
1399
|
+
"typeAnnotation": ${JSON.stringify(NaslCoreTypeAnnotation.Boolean)}
|
|
1400
|
+
}
|
|
1401
|
+
],
|
|
1402
|
+
"viewLogics": [
|
|
1403
|
+
${JSON.stringify(patchLogic(genTableLoadLogic(entity, nameGroup, entityLogic, true)))},
|
|
1404
|
+
${JSON.stringify(patchLogic(genTableRemoveLogic(entity, nameGroup)))},
|
|
1405
|
+
${JSON.stringify(patchLogic(genInitLogic(nameGroup)))},
|
|
1406
|
+
${JSON.stringify(patchLogic(genCreateLogic(nameGroup)))},
|
|
1407
|
+
${JSON.stringify(patchLogic(genModifyLogic(entity, nameGroup)))},
|
|
1408
|
+
${JSON.stringify(patchLogic(genSubmitLogic(entity, nameGroup)))},
|
|
1409
|
+
${JSON.stringify(patchLogic(genDetailLogic(entity, nameGroup)))},
|
|
1410
|
+
${JSON.stringify(patchLogic(genCloseModalLogic(nameGroup)))},
|
|
1411
|
+
${JSON.stringify(patchLogic(genDelModalSubmitLogic(entity, nameGroup)))},
|
|
1412
|
+
${JSON.stringify(patchLogic(genOpenDelModalLogic(entity, nameGroup)))},
|
|
1413
|
+
${JSON.stringify(patchLogic(genCloseDelModalLogic(nameGroup)))},
|
|
1414
|
+
${JSON.stringify(patchLogic(genUpdateSubmitLogic(entity, nameGroup)))},
|
|
1415
|
+
${JSON.stringify(patchLogic(genReloadLogic(nameGroup)))},
|
|
1416
|
+
${JSON.stringify(patchLogic(genResetLogic(nameGroup)))},
|
|
1417
|
+
${JSON.stringify(patchLogic(genExportExcelLogic(nameGroup)))}
|
|
1418
|
+
${newLoadSelectLogics.map((logic) => `,${JSON.stringify(patchLogic(logic))}`).join('\n')}
|
|
1419
|
+
],
|
|
1420
|
+
"viewBindEvents": [
|
|
1421
|
+
{
|
|
1422
|
+
"concept": "BindEvent",
|
|
1423
|
+
${composedByOptionStr}
|
|
1424
|
+
"arguments": [],
|
|
1425
|
+
"name": "created",
|
|
1426
|
+
"calleeNamespace": "",
|
|
1427
|
+
"calleeName": "${nameGroup.viewLogicInit}"
|
|
1428
|
+
}
|
|
1429
|
+
],
|
|
1430
|
+
|
|
1431
|
+
"logics": ${JSON.stringify(newLogics)}
|
|
1432
|
+
}
|
|
1433
|
+
</definition>
|
|
1434
|
+
`;
|
|
1435
|
+
|
|
1436
|
+
return {
|
|
1437
|
+
code,
|
|
1438
|
+
nameGroup,
|
|
1439
|
+
saveFormTemp: `${genSaveModalTemplateDesigner(entity, nameGroup, selectNameGroupMap, SaveModalFormTemplate)}`,
|
|
1440
|
+
};
|
|
1441
|
+
}
|