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