@lcap/nasl 0.3.12-beta.1 → 0.3.12
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/service/logic/checktypeSocket.d.ts +5 -0
- package/out/service/logic/checktypeSocket.js +55 -0
- package/out/service/logic/checktypeSocket.js.map +1 -0
- package/out/service/logic/index.d.ts +3 -0
- package/out/service/logic/index.js +4 -1
- package/out/service/logic/index.js.map +1 -1
- package/out/types/app/App.d.ts +3 -1
- package/out/types/app/App.js +17 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +1 -0
- package/out/types/app/Service.js +36 -3
- package/out/types/app/Service.js.map +1 -1
- package/out/types/data/Entity.d.ts +5 -0
- package/out/types/data/Entity.js +13 -0
- package/out/types/data/Entity.js.map +1 -1
- package/out/types/data/Enum.d.ts +4 -0
- package/out/types/data/Enum.js +7 -0
- package/out/types/data/Enum.js.map +1 -1
- package/out/types/data/Module.d.ts +34 -0
- package/out/types/data/Module.js +53 -0
- package/out/types/data/Module.js.map +1 -0
- package/out/types/data/Structure.d.ts +4 -0
- package/out/types/data/Structure.js +7 -0
- package/out/types/data/Structure.js.map +1 -1
- package/out/types/data/genBlock/index.d.ts +0 -2
- package/out/types/data/genBlock/index.js +0 -2
- package/out/types/data/genBlock/index.js.map +1 -1
- package/out/types/index.d.ts +2 -0
- package/out/types/index.js +5 -2
- package/out/types/index.js.map +1 -1
- package/out/types/logic/Logic.d.ts +4 -0
- package/out/types/logic/Logic.js +7 -0
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.js +17 -10
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.js +1 -1
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/translator.js +8 -1
- package/out/types/logic/translator.js.map +1 -1
- package/out/types/process/ProcessParam.js +1 -1
- package/out/types/process/ProcessParam.js.map +1 -1
- package/package.json +2 -1
- package/src/service/logic/checktypeSocket.js +49 -0
- package/src/service/logic/index.js +3 -0
- package/src/service/modules/api.js +20 -0
- package/src/service/modules/index.js +6 -0
- package/src/types/app/App.ts +17 -2
- package/src/types/app/Service.ts +39 -4
- package/src/types/data/Entity.ts +17 -6
- package/src/types/data/Enum.ts +5 -0
- package/src/types/data/Module.ts +51 -0
- package/src/types/data/Structure.ts +5 -0
- package/src/types/data/dataTypes.ts +24 -4
- package/src/types/data/genBlock/index.ts +0 -2
- package/src/types/index.ts +2 -0
- package/src/types/logic/Logic.ts +5 -0
- package/src/types/logic/LogicItem.ts +20 -13
- package/src/types/logic/Param.ts +1 -1
- package/src/types/logic/translator.js +8 -1
- package/src/types/process/ProcessParam.ts +1 -1
- package/src/types/data/genBlock/genCurdBlock.ts +0 -654
- package/src/types/data/genBlock/genCurdEditTableBlock.ts +0 -581
|
@@ -1,654 +0,0 @@
|
|
|
1
|
-
import { dataTypesMap, vertexsMap, utils, Entity, View, EntityProperty, Enum, LEVEL_ENUM } from '../..';
|
|
2
|
-
import {
|
|
3
|
-
filterProperty, NameGroup, genUniqueQueryNameGroup, getFirstDisplayedProperty, getParamFromResolver, genGenericTypeSchema, genVariable, genInterParam, genCallComponentLogic, genCallInterface, genQueryInterface, genQueryStructure,
|
|
4
|
-
genEnumSelectBlock, genTableTemplate, genTableLoadLogic, genTableRemoveLogic, genLoadSelectLogic, genGridViewTemplate, genGridViewLoadLogic, genGridViewRemoveLogic,
|
|
5
|
-
} from '.';
|
|
6
|
-
import builtInFunctions = require('./builtInFunctions.json');
|
|
7
|
-
|
|
8
|
-
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>, tableRefName = 'tableView') {
|
|
9
|
-
const propertyList = entity.propertyList
|
|
10
|
-
.filter(filterProperty('inFilter'));
|
|
11
|
-
|
|
12
|
-
return `
|
|
13
|
-
<u-linear-layout justify="space-between">
|
|
14
|
-
<u-form layout="inline" label-size="auto">
|
|
15
|
-
${propertyList.map((property) => {
|
|
16
|
-
const label = property.label || property.name;
|
|
17
|
-
let formItem = `<u-form-item label="${label}">`;
|
|
18
|
-
|
|
19
|
-
if (property.$relationEntity) { // 有外键关联
|
|
20
|
-
const relationEntity = vertexsMap.get(property.$relationEntity) as Entity;
|
|
21
|
-
if (relationEntity) {
|
|
22
|
-
const relationProperty = vertexsMap.get(property.$relationProperty) as EntityProperty;
|
|
23
|
-
const displayedProperty = getFirstDisplayedProperty(relationEntity, 'inFilter');
|
|
24
|
-
if (displayedProperty) {
|
|
25
|
-
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
26
|
-
formItem += `
|
|
27
|
-
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
28
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="filter.${property.name}">
|
|
29
|
-
</u-select>
|
|
30
|
-
`;
|
|
31
|
-
} else
|
|
32
|
-
return '';
|
|
33
|
-
} else
|
|
34
|
-
return '';
|
|
35
|
-
} else if (property.typeKey === '#/basicTypes/Boolean') {
|
|
36
|
-
formItem += `
|
|
37
|
-
<u-select clearable v-model="filter.${property.name}" placeholder="请输入${label}">
|
|
38
|
-
<u-select-item :value="true">是</u-select-item>
|
|
39
|
-
<u-select-item :value="false">否</u-select-item>
|
|
40
|
-
</u-select>
|
|
41
|
-
`;
|
|
42
|
-
} else if (property.typeKey === '#/basicTypes/Integer' || property.typeKey === '#/basicTypes/Long') {
|
|
43
|
-
formItem += `<u-number-input v-model="filter.${property.name}" placeholder="请输入${label}"></u-number-input>`;
|
|
44
|
-
} else if (property.typeKey === '#/basicTypes/Decimal') {
|
|
45
|
-
formItem += `<u-number-input v-model="filter.${property.name}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
|
|
46
|
-
} else if (property.typeKey === '#/basicTypes/Text') {
|
|
47
|
-
formItem += `<u-textarea v-model="filter.${property.name}" placeholder="请输入${label}"></u-textarea>`;
|
|
48
|
-
} else if (property.typeKey === '#/basicTypes/Date') {
|
|
49
|
-
formItem += `<u-date-picker clearable :date.sync="filter.${property.name}" placeholder="请输入${label}"></u-date-picker>`;
|
|
50
|
-
} else if (property.typeKey === '#/basicTypes/Time') {
|
|
51
|
-
formItem += `<u-time-picker :time.sync="filter.${property.name}" placeholder="请输入${label}"></u-time-picker>`;
|
|
52
|
-
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
53
|
-
formItem += `<u-date-time-picker clearable :date.sync="filter.${property.name}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
54
|
-
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
55
|
-
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `filter.${property.name}`, '', `请选择${label}`);
|
|
56
|
-
} else {
|
|
57
|
-
formItem += `<u-input v-model="filter.${property.name}" placeholder="请输入${label}"></u-input>`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
formItem += `</u-form-item>`;
|
|
61
|
-
return formItem;
|
|
62
|
-
}).join('')}
|
|
63
|
-
|
|
64
|
-
<u-form-item>
|
|
65
|
-
<u-button color="primary" @click="$refs.${tableRefName}.reload()">查询</u-button>
|
|
66
|
-
</u-form-item>
|
|
67
|
-
</u-form>
|
|
68
|
-
|
|
69
|
-
<u-button color="primary" @click="${nameGroup.create}($event)">创建</u-button>
|
|
70
|
-
</u-linear-layout>
|
|
71
|
-
`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
75
|
-
const propertyList = entity.propertyList
|
|
76
|
-
.filter(filterProperty('inForm'));
|
|
77
|
-
|
|
78
|
-
const idProperty = entity.propertyList.find((item) => item.primaryKey || item.name === 'id');
|
|
79
|
-
|
|
80
|
-
return `
|
|
81
|
-
<u-modal ref="saveModal">
|
|
82
|
-
<template #title>
|
|
83
|
-
<div v-if="input.${idProperty.name}">修改</div>
|
|
84
|
-
<div v-if="input.${idProperty.name} == undefined">创建</div>
|
|
85
|
-
</template>
|
|
86
|
-
<template #body>
|
|
87
|
-
<u-form ref="form1">
|
|
88
|
-
${propertyList.map((property) => {
|
|
89
|
-
const label = property.label || property.name;
|
|
90
|
-
const required = !!property.required;
|
|
91
|
-
const rules = [];
|
|
92
|
-
if (property.rules && property.rules.length) {
|
|
93
|
-
property.rules.forEach((rule) => rules.push(rule));
|
|
94
|
-
}
|
|
95
|
-
if (required)
|
|
96
|
-
rules.push('required');
|
|
97
|
-
const rulesStr = rules.join(' | ');
|
|
98
|
-
|
|
99
|
-
let formItem = `<u-form-item
|
|
100
|
-
label="${label}"
|
|
101
|
-
${required ? 'required' : ''}
|
|
102
|
-
${rulesStr.length ? `rules="${rulesStr}"` : ''}
|
|
103
|
-
>`;
|
|
104
|
-
|
|
105
|
-
if (property.$relationEntity) { // 有外键关联
|
|
106
|
-
const relationEntity = vertexsMap.get(property.$relationEntity) as Entity;
|
|
107
|
-
if (relationEntity) {
|
|
108
|
-
const relationProperty = vertexsMap.get(property.$relationProperty) as EntityProperty;
|
|
109
|
-
const displayedProperty = getFirstDisplayedProperty(relationEntity, 'inForm');
|
|
110
|
-
if (displayedProperty) {
|
|
111
|
-
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
112
|
-
formItem += `
|
|
113
|
-
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroupMap.get(relationEntity.id).load}"
|
|
114
|
-
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="input.${property.name}">
|
|
115
|
-
</u-select>
|
|
116
|
-
`;
|
|
117
|
-
} else
|
|
118
|
-
return '';
|
|
119
|
-
} else
|
|
120
|
-
return '';
|
|
121
|
-
} else if (property.typeKey === '#/basicTypes/Boolean') {
|
|
122
|
-
formItem += `
|
|
123
|
-
<u-select clearable v-model="input.${property.name}" placeholder="请输入${label}">
|
|
124
|
-
<u-select-item :value="true">是</u-select-item>
|
|
125
|
-
<u-select-item :value="false">否</u-select-item>
|
|
126
|
-
</u-select>`;
|
|
127
|
-
} else if (property.typeKey === '#/basicTypes/Integer' || property.typeKey === '#/basicTypes/Long') {
|
|
128
|
-
formItem += `<u-number-input v-model="input.${property.name}" placeholder="请输入${label}"></u-number-input>`;
|
|
129
|
-
} else if (property.typeKey === '#/basicTypes/Decimal') {
|
|
130
|
-
formItem += `<u-number-input v-model="input.${property.name}" :precision="0" :step="0" placeholder="请输入${label}"></u-number-input>`;
|
|
131
|
-
} else if (property.typeKey === '#/basicTypes/Text') {
|
|
132
|
-
formItem += `<u-textarea v-model="input.${property.name}" placeholder="请输入${label}"></u-textarea>`;
|
|
133
|
-
} else if (property.typeKey === '#/basicTypes/Date') {
|
|
134
|
-
formItem += `<u-date-picker clearable :date.sync="input.${property.name}" placeholder="请输入${label}"></u-date-picker>`;
|
|
135
|
-
} else if (property.typeKey === '#/basicTypes/Time') {
|
|
136
|
-
formItem += `<u-time-picker :time.sync="input.${property.name}" placeholder="请输入${label}"></u-time-picker>`;
|
|
137
|
-
} else if (property.typeKey === '#/basicTypes/DateTime') {
|
|
138
|
-
formItem += `<u-date-time-picker clearable :date.sync="input.${property.name}" placeholder="请输入${label}"></u-date-time-picker>`;
|
|
139
|
-
} else if (dataTypesMap[property.typeKey].type === 'enum') {
|
|
140
|
-
formItem += genEnumSelectBlock(dataTypesMap[property.typeKey] as Enum, `input.${property.name}`, '', `请选择${label}`, true);
|
|
141
|
-
} else {
|
|
142
|
-
formItem += `<u-input v-model="input.${property.name}" placeholder="请输入${label}"></u-input>`;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
formItem += `</u-form-item>\n`;
|
|
146
|
-
|
|
147
|
-
return formItem;
|
|
148
|
-
}).join('')}
|
|
149
|
-
</u-form>
|
|
150
|
-
</template>
|
|
151
|
-
<template #foot>
|
|
152
|
-
<u-linear-layout>
|
|
153
|
-
<u-button color="primary" @click="${nameGroup.submit}()" v-if="input.${idProperty.name}">提交修改</u-button>
|
|
154
|
-
<u-button color="primary" @click="${nameGroup.submit}()" v-if="input.${idProperty.name} == undefined">立即创建</u-button>
|
|
155
|
-
</u-linear-layout>
|
|
156
|
-
</template>
|
|
157
|
-
</u-modal>`;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function genInitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
161
|
-
return {
|
|
162
|
-
level: 'logic',
|
|
163
|
-
expanded: false,
|
|
164
|
-
name: nameGroup.init,
|
|
165
|
-
description: '',
|
|
166
|
-
params: [] as Array<any>,
|
|
167
|
-
returns: [] as Array<any>,
|
|
168
|
-
variables: [] as Array<any>,
|
|
169
|
-
body: [
|
|
170
|
-
{
|
|
171
|
-
level: 'logicNode',
|
|
172
|
-
type: 'Start',
|
|
173
|
-
label: '开始',
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
level: 'expressionNode',
|
|
177
|
-
type: 'BuiltInFunction',
|
|
178
|
-
label: '内置函数',
|
|
179
|
-
calleeCode: 'Clear',
|
|
180
|
-
builtInFuncParams: [
|
|
181
|
-
{
|
|
182
|
-
parentAttr: 'builtInFuncParams',
|
|
183
|
-
level: 'expressionNode',
|
|
184
|
-
type: 'BuiltInFuncParam',
|
|
185
|
-
name: 'obj',
|
|
186
|
-
builtInFuncParamValue: {
|
|
187
|
-
parentAttr: 'builtInFuncParamValue',
|
|
188
|
-
level: 'expressionNode',
|
|
189
|
-
type: 'Identifier',
|
|
190
|
-
name: 'filter',
|
|
191
|
-
},
|
|
192
|
-
schema: builtInFunctions.Clear.params[0].schema,
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
level: 'logicNode',
|
|
198
|
-
type: 'End',
|
|
199
|
-
label: '结束',
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
playground: [] as Array<any>,
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function genCreateLogic(entity: Entity, nameGroup: NameGroup) {
|
|
207
|
-
return {
|
|
208
|
-
level: 'logic',
|
|
209
|
-
expanded: false,
|
|
210
|
-
name: nameGroup.create,
|
|
211
|
-
description: '',
|
|
212
|
-
params: [] as Array<any>,
|
|
213
|
-
returns: [] as Array<any>,
|
|
214
|
-
variables: [] as Array<any>,
|
|
215
|
-
body: [
|
|
216
|
-
{
|
|
217
|
-
level: 'logicNode',
|
|
218
|
-
type: 'Start',
|
|
219
|
-
label: '开始',
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
level: 'logicNode',
|
|
223
|
-
type: 'AssignmentExpression',
|
|
224
|
-
label: '赋值',
|
|
225
|
-
operator: '=',
|
|
226
|
-
left: {
|
|
227
|
-
level: 'expressionNode',
|
|
228
|
-
type: 'Identifier',
|
|
229
|
-
name: 'input',
|
|
230
|
-
},
|
|
231
|
-
right: {
|
|
232
|
-
parentAttr: 'right',
|
|
233
|
-
level: 'expressionNode',
|
|
234
|
-
type: 'BuiltInFunction',
|
|
235
|
-
label: '内置函数',
|
|
236
|
-
calleeCode: 'Clone',
|
|
237
|
-
builtInFuncParams: [
|
|
238
|
-
{
|
|
239
|
-
parentAttr: 'builtInFuncParams',
|
|
240
|
-
level: 'expressionNode',
|
|
241
|
-
type: 'BuiltInFuncParam',
|
|
242
|
-
name: 'obj',
|
|
243
|
-
builtInFuncParamValue: {
|
|
244
|
-
parentAttr: 'builtInFuncParamValue',
|
|
245
|
-
level: 'expressionNode',
|
|
246
|
-
type: 'Identifier',
|
|
247
|
-
name: nameGroup.lowerEntity,
|
|
248
|
-
},
|
|
249
|
-
schema: builtInFunctions.Clone.params[0].schema,
|
|
250
|
-
},
|
|
251
|
-
],
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
genCallComponentLogic('saveModal', 'open'),
|
|
255
|
-
{
|
|
256
|
-
level: 'logicNode',
|
|
257
|
-
type: 'End',
|
|
258
|
-
label: '结束',
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
playground: [] as Array<any>,
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
266
|
-
const scopeStructureSchema = genGenericTypeSchema('ScopeOf', { T: { $ref: nameGroup.structure } });
|
|
267
|
-
|
|
268
|
-
return {
|
|
269
|
-
level: 'logic',
|
|
270
|
-
expanded: false,
|
|
271
|
-
name: nameGroup.modify,
|
|
272
|
-
description: '',
|
|
273
|
-
params: [
|
|
274
|
-
{
|
|
275
|
-
level: 'param',
|
|
276
|
-
type: 'Identifier',
|
|
277
|
-
name: 'event',
|
|
278
|
-
schema: {
|
|
279
|
-
type: 'string',
|
|
280
|
-
format: '',
|
|
281
|
-
},
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
level: 'param',
|
|
285
|
-
name: 'scope',
|
|
286
|
-
schema: scopeStructureSchema,
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
returns: [] as Array<any>,
|
|
290
|
-
variables: [] as Array<any>,
|
|
291
|
-
body: [
|
|
292
|
-
{
|
|
293
|
-
level: 'logicNode',
|
|
294
|
-
type: 'Start',
|
|
295
|
-
label: '开始',
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
level: 'logicNode',
|
|
299
|
-
type: 'AssignmentExpression',
|
|
300
|
-
label: '赋值',
|
|
301
|
-
operator: '=',
|
|
302
|
-
left: {
|
|
303
|
-
level: 'expressionNode',
|
|
304
|
-
type: 'Identifier',
|
|
305
|
-
name: 'input',
|
|
306
|
-
},
|
|
307
|
-
right: {
|
|
308
|
-
parentAttr: 'right',
|
|
309
|
-
level: 'expressionNode',
|
|
310
|
-
type: 'BuiltInFunction',
|
|
311
|
-
label: '内置函数',
|
|
312
|
-
calleeCode: 'Clone',
|
|
313
|
-
builtInFuncParams: [
|
|
314
|
-
{
|
|
315
|
-
parentAttr: 'builtInFuncParams',
|
|
316
|
-
level: 'expressionNode',
|
|
317
|
-
type: 'BuiltInFuncParam',
|
|
318
|
-
name: 'obj',
|
|
319
|
-
builtInFuncParamValue: {
|
|
320
|
-
parentAttr: 'builtInFuncParamValue',
|
|
321
|
-
level: 'expressionNode',
|
|
322
|
-
type: 'MemberExpression',
|
|
323
|
-
object: {
|
|
324
|
-
parentAttr: 'builtInFuncParamValue',
|
|
325
|
-
level: 'expressionNode',
|
|
326
|
-
type: 'MemberExpression',
|
|
327
|
-
object: {
|
|
328
|
-
parentAttr: 'object',
|
|
329
|
-
level: 'expressionNode',
|
|
330
|
-
type: 'Identifier',
|
|
331
|
-
name: 'scope',
|
|
332
|
-
},
|
|
333
|
-
property: {
|
|
334
|
-
parentAttr: 'property',
|
|
335
|
-
level: 'expressionNode',
|
|
336
|
-
type: 'Identifier',
|
|
337
|
-
name: 'item',
|
|
338
|
-
schemaRef: '',
|
|
339
|
-
code: 'item',
|
|
340
|
-
},
|
|
341
|
-
code: '',
|
|
342
|
-
},
|
|
343
|
-
property: {
|
|
344
|
-
parentAttr: 'property',
|
|
345
|
-
level: 'expressionNode',
|
|
346
|
-
type: 'Identifier',
|
|
347
|
-
name: nameGroup.lowerEntity,
|
|
348
|
-
schemaRef: `${nameGroup.structure}.${nameGroup.lowerEntity}`,
|
|
349
|
-
code: '',
|
|
350
|
-
},
|
|
351
|
-
code: '',
|
|
352
|
-
},
|
|
353
|
-
schema: builtInFunctions.Clone.params[0].schema,
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
genCallComponentLogic('saveModal', 'open'),
|
|
359
|
-
{
|
|
360
|
-
level: 'logicNode',
|
|
361
|
-
type: 'End',
|
|
362
|
-
label: '结束',
|
|
363
|
-
},
|
|
364
|
-
],
|
|
365
|
-
playground: [] as Array<any>,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function genSubmitLogic(entity: Entity, nameGroup: NameGroup, tableRefName = 'tableView') {
|
|
370
|
-
const updateResolver = entity.resolvers.find((item) => item.name === 'update');
|
|
371
|
-
const createResolver = entity.resolvers.find((item) => item.name === 'create');
|
|
372
|
-
const updateBodyParam = getParamFromResolver(updateResolver, 'body');
|
|
373
|
-
const createBodyparam = getParamFromResolver(createResolver, 'body');
|
|
374
|
-
|
|
375
|
-
const idProperty = entity.propertyList.find((item) => item.primaryKey || item.name === 'id');
|
|
376
|
-
|
|
377
|
-
return {
|
|
378
|
-
level: 'logic',
|
|
379
|
-
name: nameGroup.submit,
|
|
380
|
-
params: [] as Array<any>,
|
|
381
|
-
returns: [] as Array<any>,
|
|
382
|
-
variables: [
|
|
383
|
-
genVariable('validateResult', '#/systemTypes/ValidateEvent', LEVEL_ENUM.variable),
|
|
384
|
-
],
|
|
385
|
-
body: [
|
|
386
|
-
{
|
|
387
|
-
level: 'logicNode',
|
|
388
|
-
type: 'Start',
|
|
389
|
-
label: '开始',
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
level: 'logicNode',
|
|
393
|
-
type: 'AssignmentExpression',
|
|
394
|
-
label: '赋值',
|
|
395
|
-
operator: '=',
|
|
396
|
-
left: {
|
|
397
|
-
level: 'expressionNode',
|
|
398
|
-
type: 'Identifier',
|
|
399
|
-
name: 'validateResult',
|
|
400
|
-
},
|
|
401
|
-
right: genCallComponentLogic('form1', 'validate'),
|
|
402
|
-
},
|
|
403
|
-
{
|
|
404
|
-
level: 'logicNode',
|
|
405
|
-
type: 'IfStatement',
|
|
406
|
-
label: '条件分支',
|
|
407
|
-
test: {
|
|
408
|
-
level: 'expressionNode',
|
|
409
|
-
type: 'MemberExpression',
|
|
410
|
-
name: 'name',
|
|
411
|
-
hide: false,
|
|
412
|
-
object: {
|
|
413
|
-
level: 'expressionNode',
|
|
414
|
-
type: 'Identifier',
|
|
415
|
-
name: 'validateResult',
|
|
416
|
-
},
|
|
417
|
-
property: {
|
|
418
|
-
level: 'expressionNode',
|
|
419
|
-
type: 'Identifier',
|
|
420
|
-
name: 'valid',
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
consequent: [
|
|
424
|
-
{
|
|
425
|
-
level: 'logicNode',
|
|
426
|
-
type: 'IfStatement',
|
|
427
|
-
label: '条件分支',
|
|
428
|
-
test: {
|
|
429
|
-
parentAttr: 'test',
|
|
430
|
-
level: 'expressionNode',
|
|
431
|
-
type: 'BuiltInFunction',
|
|
432
|
-
label: '内置函数',
|
|
433
|
-
calleeCode: 'Convert',
|
|
434
|
-
builtInFuncParams: [
|
|
435
|
-
{
|
|
436
|
-
parentAttr: 'builtInFuncParams',
|
|
437
|
-
level: 'expressionNode',
|
|
438
|
-
type: 'BuiltInFuncParam',
|
|
439
|
-
name: 'value',
|
|
440
|
-
builtInFuncParamValue: {
|
|
441
|
-
level: 'expressionNode',
|
|
442
|
-
type: 'MemberExpression',
|
|
443
|
-
object: {
|
|
444
|
-
level: 'expressionNode',
|
|
445
|
-
type: 'Identifier',
|
|
446
|
-
name: 'input',
|
|
447
|
-
},
|
|
448
|
-
property: {
|
|
449
|
-
level: 'expressionNode',
|
|
450
|
-
type: 'Identifier',
|
|
451
|
-
name: 'id',
|
|
452
|
-
schemaRef: idProperty.id,
|
|
453
|
-
code: `ID_${idProperty.id}`,
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
schema: builtInFunctions.Convert.params[0].schema,
|
|
457
|
-
},
|
|
458
|
-
{
|
|
459
|
-
parentAttr: 'builtInFuncParams',
|
|
460
|
-
level: 'expressionNode',
|
|
461
|
-
type: 'BuiltInFuncParam',
|
|
462
|
-
name: 'convertTo',
|
|
463
|
-
builtInFuncParamValue: {
|
|
464
|
-
level: 'expressionNode',
|
|
465
|
-
type: 'TypeNote',
|
|
466
|
-
schema: {
|
|
467
|
-
format: '',
|
|
468
|
-
type: 'boolean',
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
schema: builtInFunctions.Convert.params[1].schema,
|
|
472
|
-
},
|
|
473
|
-
],
|
|
474
|
-
},
|
|
475
|
-
consequent: [
|
|
476
|
-
genCallInterface(updateResolver.interface, [
|
|
477
|
-
genInterParam(updateBodyParam.id, 'input'),
|
|
478
|
-
]),
|
|
479
|
-
],
|
|
480
|
-
alternate: [
|
|
481
|
-
genCallInterface(createResolver.interface, [
|
|
482
|
-
genInterParam(createBodyparam.id, 'input'),
|
|
483
|
-
]),
|
|
484
|
-
],
|
|
485
|
-
},
|
|
486
|
-
genCallComponentLogic('saveModal', 'close'),
|
|
487
|
-
genCallComponentLogic(tableRefName, 'reload'),
|
|
488
|
-
],
|
|
489
|
-
alternate: [] as Array<any>,
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
level: 'logicNode',
|
|
493
|
-
type: 'End',
|
|
494
|
-
label: '结束',
|
|
495
|
-
},
|
|
496
|
-
],
|
|
497
|
-
playground: [] as Array<any>,
|
|
498
|
-
expanded: false,
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
export function genCurdBlock(entity: Entity, view: View) {
|
|
503
|
-
const existingNameSets = {
|
|
504
|
-
viewLogic: new Set(view.$def.logics.map((logic) => logic.name)),
|
|
505
|
-
interface: new Set(entity.dataNode.service.interfaces.map((itface) => itface.name)),
|
|
506
|
-
structure: new Set(entity.dataNode.structures.map((structure) => structure.name)),
|
|
507
|
-
};
|
|
508
|
-
|
|
509
|
-
const nameGroup = genUniqueQueryNameGroup(existingNameSets, view.name, 'tableView');
|
|
510
|
-
nameGroup.remove = utils.unique('remove', existingNameSets.viewLogic);
|
|
511
|
-
nameGroup.init = utils.unique('init', existingNameSets.viewLogic);
|
|
512
|
-
nameGroup.create = utils.unique('create', existingNameSets.viewLogic);
|
|
513
|
-
nameGroup.modify = utils.unique('modify', existingNameSets.viewLogic);
|
|
514
|
-
nameGroup.submit = utils.unique('submit', existingNameSets.viewLogic);
|
|
515
|
-
nameGroup.lowerEntity = utils.firstLowerCase(entity.name);
|
|
516
|
-
|
|
517
|
-
// 收集所有和本实体关联的实体
|
|
518
|
-
const allEntities = [entity];
|
|
519
|
-
entity.propertyList.forEach((property) => {
|
|
520
|
-
if (property.$relationEntity) { // 有外键关联
|
|
521
|
-
const relationEntity = vertexsMap.get(property.$relationEntity) as Entity;
|
|
522
|
-
if (relationEntity) {
|
|
523
|
-
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
524
|
-
if (displayedProperty && !allEntities.includes(relationEntity))
|
|
525
|
-
allEntities.push(relationEntity);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
});
|
|
529
|
-
|
|
530
|
-
const newStructures: Array<any> = [genQueryStructure(allEntities, nameGroup)];
|
|
531
|
-
const newInterfaces: Array<any> = [genQueryInterface(allEntities, nameGroup, true, true)];
|
|
532
|
-
|
|
533
|
-
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
534
|
-
const loadSelectLogics = allEntities.slice(1).map((entity) => {
|
|
535
|
-
const selectNameGroup = genUniqueQueryNameGroup(existingNameSets, view.name, 'select', false, entity.name);
|
|
536
|
-
selectNameGroupMap.set(entity.id, selectNameGroup);
|
|
537
|
-
return genLoadSelectLogic(entity, selectNameGroup, newStructures, newInterfaces);
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
return `<template>
|
|
541
|
-
<u-linear-layout direction="vertical">
|
|
542
|
-
${genFilterTemplate(entity, nameGroup, selectNameGroupMap)}
|
|
543
|
-
${genTableTemplate(entity, nameGroup)}
|
|
544
|
-
${genSaveModalTemplate(entity, nameGroup, selectNameGroupMap)}
|
|
545
|
-
</u-linear-layout>
|
|
546
|
-
</template>
|
|
547
|
-
|
|
548
|
-
<definition>
|
|
549
|
-
{
|
|
550
|
-
"variables": [
|
|
551
|
-
${JSON.stringify(genVariable(utils.firstLowerCase(entity.name), entity.schemaRef, LEVEL_ENUM.variable))},
|
|
552
|
-
${JSON.stringify(genVariable('input', entity.schemaRef, LEVEL_ENUM.variable))},
|
|
553
|
-
${JSON.stringify(genVariable('filter', entity.schemaRef, LEVEL_ENUM.variable))}
|
|
554
|
-
],
|
|
555
|
-
"lifecycles": [
|
|
556
|
-
{
|
|
557
|
-
"level": "lifecycle",
|
|
558
|
-
"name": "created",
|
|
559
|
-
"logicId": "${nameGroup.init}"
|
|
560
|
-
}
|
|
561
|
-
],
|
|
562
|
-
"logics": [
|
|
563
|
-
${JSON.stringify(genTableLoadLogic(entity, nameGroup, newStructures, newInterfaces, true))},
|
|
564
|
-
${JSON.stringify(genTableRemoveLogic(entity, nameGroup))},
|
|
565
|
-
${JSON.stringify(genInitLogic(entity, nameGroup))},
|
|
566
|
-
${JSON.stringify(genCreateLogic(entity, nameGroup))},
|
|
567
|
-
${JSON.stringify(genModifyLogic(entity, nameGroup))},
|
|
568
|
-
${JSON.stringify(genSubmitLogic(entity, nameGroup))}
|
|
569
|
-
${loadSelectLogics.map((logic) => ',' + JSON.stringify(logic)).join('\n')}
|
|
570
|
-
],
|
|
571
|
-
"interfaces": ${JSON.stringify(newInterfaces)},
|
|
572
|
-
"structures": ${JSON.stringify(newStructures)}
|
|
573
|
-
}
|
|
574
|
-
</definition>
|
|
575
|
-
`;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
export function genCurdGridViewBlock(entity: Entity, view: View) {
|
|
579
|
-
const existingNameSets = {
|
|
580
|
-
viewLogic: new Set(view.$def.logics.map((logic) => logic.name)),
|
|
581
|
-
interface: new Set(entity.dataNode.service.interfaces.map((itface) => itface.name)),
|
|
582
|
-
structure: new Set(entity.dataNode.structures.map((structure) => structure.name)),
|
|
583
|
-
};
|
|
584
|
-
|
|
585
|
-
const nameGroup = genUniqueQueryNameGroup(existingNameSets, view.name, 'gridView');
|
|
586
|
-
nameGroup.remove = utils.unique('remove', existingNameSets.viewLogic);
|
|
587
|
-
nameGroup.init = utils.unique('init', existingNameSets.viewLogic);
|
|
588
|
-
nameGroup.create = utils.unique('create', existingNameSets.viewLogic);
|
|
589
|
-
nameGroup.modify = utils.unique('modify', existingNameSets.viewLogic);
|
|
590
|
-
nameGroup.submit = utils.unique('submit', existingNameSets.viewLogic);
|
|
591
|
-
nameGroup.lowerEntity = utils.firstLowerCase(entity.name);
|
|
592
|
-
|
|
593
|
-
// 收集所有和本实体关联的实体
|
|
594
|
-
const allEntities = [entity];
|
|
595
|
-
entity.propertyList.forEach((property) => {
|
|
596
|
-
if (property.$relationEntity) { // 有外键关联
|
|
597
|
-
const relationEntity = vertexsMap.get(property.$relationEntity) as Entity;
|
|
598
|
-
if (relationEntity) {
|
|
599
|
-
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
600
|
-
if (displayedProperty && !allEntities.includes(relationEntity))
|
|
601
|
-
allEntities.push(relationEntity);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
const newStructures: Array<any> = [genQueryStructure(allEntities, nameGroup)];
|
|
607
|
-
const newInterfaces: Array<any> = [genQueryInterface(allEntities, nameGroup, true, true)];
|
|
608
|
-
|
|
609
|
-
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
610
|
-
const loadSelectLogics = allEntities.slice(1).map((entity) => {
|
|
611
|
-
const selectNameGroup = genUniqueQueryNameGroup(existingNameSets, view.name, 'select', false, entity.name);
|
|
612
|
-
selectNameGroupMap.set(entity.id, selectNameGroup);
|
|
613
|
-
return genLoadSelectLogic(entity, selectNameGroup, newStructures, newInterfaces);
|
|
614
|
-
});
|
|
615
|
-
|
|
616
|
-
return `<template>
|
|
617
|
-
<u-linear-layout direction="vertical">
|
|
618
|
-
${genFilterTemplate(entity, nameGroup, selectNameGroupMap, 'gridView')}
|
|
619
|
-
${genGridViewTemplate(entity, nameGroup)}
|
|
620
|
-
${genSaveModalTemplate(entity, nameGroup, selectNameGroupMap)}
|
|
621
|
-
</u-linear-layout>
|
|
622
|
-
</template>
|
|
623
|
-
|
|
624
|
-
<definition>
|
|
625
|
-
{
|
|
626
|
-
"variables": [
|
|
627
|
-
${JSON.stringify(genVariable(utils.firstLowerCase(entity.name), entity.schemaRef, LEVEL_ENUM.variable))},
|
|
628
|
-
${JSON.stringify(genVariable('input', entity.schemaRef, LEVEL_ENUM.variable))},
|
|
629
|
-
${JSON.stringify(genVariable('filter', entity.schemaRef, LEVEL_ENUM.variable))}
|
|
630
|
-
],
|
|
631
|
-
"lifecycles": [
|
|
632
|
-
{
|
|
633
|
-
"level": "lifecycle",
|
|
634
|
-
"name": "created",
|
|
635
|
-
"logicId": "${nameGroup.init}"
|
|
636
|
-
}
|
|
637
|
-
],
|
|
638
|
-
"logics": [
|
|
639
|
-
${JSON.stringify(genGridViewLoadLogic(entity, nameGroup, newStructures, newInterfaces, true))},
|
|
640
|
-
${JSON.stringify(genGridViewRemoveLogic(entity, nameGroup))},
|
|
641
|
-
${JSON.stringify(genInitLogic(entity, nameGroup))},
|
|
642
|
-
${JSON.stringify(genCreateLogic(entity, nameGroup))},
|
|
643
|
-
${JSON.stringify(genModifyLogic(entity, nameGroup))},
|
|
644
|
-
${JSON.stringify(genSubmitLogic(entity, nameGroup, 'gridView'))}
|
|
645
|
-
${loadSelectLogics.map((logic) => ',' + JSON.stringify(logic)).join('\n')}
|
|
646
|
-
],
|
|
647
|
-
"interfaces": ${JSON.stringify(newInterfaces)},
|
|
648
|
-
"structures": ${JSON.stringify(newStructures)}
|
|
649
|
-
}
|
|
650
|
-
</definition>
|
|
651
|
-
`;
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
export default genCurdBlock;
|