@lcap/nasl 0.3.9-beta → 0.3.10-beta.10
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 +3 -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 +4 -0
- package/out/types/app/App.js +31 -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 +38 -5
- 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 +40 -0
- 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/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 +48 -31
- 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 +27 -0
- package/out/types/page/Element.js +229 -131
- 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 +78 -37
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +18 -1
- package/out/types/page/View.js +119 -42
- 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 +2 -3
- package/src/service/app/api.js +8 -17
- package/src/service/create/errHandles.js +18 -2
- package/src/service/create/index.js +4 -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 +37 -2
- package/src/types/app/History.ts +3 -2
- package/src/types/app/Service.ts +44 -6
- package/src/types/cache.ts +50 -0
- package/src/types/cacheData.ts +7 -7
- package/src/types/common/Vertex.ts +30 -0
- 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/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 +54 -37
- 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 +250 -135
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +93 -49
- package/src/types/page/View.ts +123 -42
- 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
package/src/types/page/Page.ts
CHANGED
|
@@ -3,6 +3,23 @@ import { config, history, LEVEL_ENUM, Vertex, Entity, Enum, PackageJSON, App, We
|
|
|
3
3
|
import pageService from '../../service/page';
|
|
4
4
|
import { traverse } from '../utils';
|
|
5
5
|
import { postServiceType } from '../../service/common/preprocess';
|
|
6
|
+
import { refreshPages } from '../cache';
|
|
7
|
+
import { BusinessCode } from '../enum';
|
|
8
|
+
|
|
9
|
+
export function catchFn() {
|
|
10
|
+
return async (err: any) => {
|
|
11
|
+
const code = err?.code;
|
|
12
|
+
// 节点已存在; 节点不存在; 父节点不存在
|
|
13
|
+
if ([BusinessCode.ElementExist, BusinessCode.ElementNotExist, BusinessCode.ParentElementNotExist].includes(code)) {
|
|
14
|
+
await refreshPages();
|
|
15
|
+
} else
|
|
16
|
+
config.defaultApp?.emit('saved', err);
|
|
17
|
+
|
|
18
|
+
config.defaultApp?.history.load();
|
|
19
|
+
|
|
20
|
+
throw err;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
6
23
|
|
|
7
24
|
/**
|
|
8
25
|
* 页面(入口页)类,后端路由控制
|
|
@@ -39,6 +56,13 @@ export class Page extends Vertex {
|
|
|
39
56
|
*/
|
|
40
57
|
@immutable()
|
|
41
58
|
public readonly isIndex: boolean = undefined;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 描述信息
|
|
62
|
+
*/
|
|
63
|
+
@immutable()
|
|
64
|
+
public readonly description: string = undefined;
|
|
65
|
+
|
|
42
66
|
/**
|
|
43
67
|
* 根页面视图
|
|
44
68
|
*/
|
|
@@ -95,22 +119,12 @@ export class Page extends Vertex {
|
|
|
95
119
|
}, { node: this.rootView });
|
|
96
120
|
const rootView = new View(this.rootView);
|
|
97
121
|
rootView.assign({ page: this });
|
|
98
|
-
|
|
122
|
+
|
|
99
123
|
this.assign({ rootView });
|
|
100
124
|
}
|
|
101
125
|
|
|
102
126
|
addData(res: any) {
|
|
103
127
|
const microService = this.service.app.firstMicroService;
|
|
104
|
-
const interfaces = res.interfaces as Array<Interface>;
|
|
105
|
-
if (interfaces && interfaces.length) {
|
|
106
|
-
interfaces.forEach((item, index) => {
|
|
107
|
-
const itface = interfaces[index] = Interface.from(item, microService);
|
|
108
|
-
postServiceType(itface);
|
|
109
|
-
});
|
|
110
|
-
microService.interfaces.unshift(...interfaces);
|
|
111
|
-
microService.globalLogic.globalLogics.unshift(...interfaces);
|
|
112
|
-
microService.emit('interfacesChange');
|
|
113
|
-
}
|
|
114
128
|
|
|
115
129
|
const enums = res.enums as Array<Enum>;
|
|
116
130
|
if (enums && enums.length) {
|
|
@@ -132,6 +146,19 @@ export class Page extends Vertex {
|
|
|
132
146
|
microService.data.structures.unshift(...structures);
|
|
133
147
|
updateDataTypeList();
|
|
134
148
|
}
|
|
149
|
+
|
|
150
|
+
const interfaces = res.interfaces as Array<Interface>;
|
|
151
|
+
if (interfaces && interfaces.length) {
|
|
152
|
+
interfaces.forEach((item, index) => {
|
|
153
|
+
const itface = interfaces[index] = Interface.from(item, microService);
|
|
154
|
+
postServiceType(itface);
|
|
155
|
+
});
|
|
156
|
+
microService.interfaces.unshift(...interfaces);
|
|
157
|
+
microService.globalLogic.globalLogics.unshift(...interfaces);
|
|
158
|
+
microService.mountResolverOnEntity();
|
|
159
|
+
microService.mountResolverOnInterface();
|
|
160
|
+
microService.emit('interfacesChange');
|
|
161
|
+
}
|
|
135
162
|
}
|
|
136
163
|
|
|
137
164
|
/**
|
|
@@ -149,8 +176,8 @@ export class Page extends Vertex {
|
|
|
149
176
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
150
177
|
},
|
|
151
178
|
body,
|
|
152
|
-
});
|
|
153
|
-
|
|
179
|
+
}).catch(catchFn());
|
|
180
|
+
|
|
154
181
|
this.deepPick(result.page, ['id']);
|
|
155
182
|
// 添加数据和接口
|
|
156
183
|
this.addData(result);
|
|
@@ -166,8 +193,8 @@ export class Page extends Vertex {
|
|
|
166
193
|
tempPath: `/${rootView.name}`,
|
|
167
194
|
code: `/ID_${rootView.id}`,
|
|
168
195
|
});
|
|
169
|
-
|
|
170
|
-
if(result.page.isIndex) {
|
|
196
|
+
this.rootView.attachNodePath();
|
|
197
|
+
if (result.page.isIndex) {
|
|
171
198
|
const tasks = this.service.pages.filter((page) => page.isIndex && page.id !== result.page.id)
|
|
172
199
|
.map((page) => {
|
|
173
200
|
page.assign({ isIndex: false });
|
|
@@ -175,7 +202,7 @@ export class Page extends Vertex {
|
|
|
175
202
|
});
|
|
176
203
|
Promise.all(tasks);
|
|
177
204
|
}
|
|
178
|
-
|
|
205
|
+
|
|
179
206
|
await then?.();
|
|
180
207
|
this.service.emit('pageTreeChange');
|
|
181
208
|
|
|
@@ -183,10 +210,10 @@ export class Page extends Vertex {
|
|
|
183
210
|
microService.emit('dataTypesChange');
|
|
184
211
|
microService.emit('enumsChange');
|
|
185
212
|
microService.emit('vertexIdToNameChange');
|
|
186
|
-
|
|
213
|
+
|
|
187
214
|
this.rootView.emit('change');
|
|
188
215
|
// this.assign(Page.from(this, this.service));
|
|
189
|
-
|
|
216
|
+
|
|
190
217
|
await config.defaultApp?.history.load();
|
|
191
218
|
config.defaultApp?.emit('saved');
|
|
192
219
|
return this;
|
|
@@ -211,7 +238,7 @@ export class Page extends Vertex {
|
|
|
211
238
|
});
|
|
212
239
|
this.deepPick(result, ['id']);
|
|
213
240
|
this.rootView.attachNodePath();
|
|
214
|
-
if(result.isIndex) {
|
|
241
|
+
if (result.isIndex) {
|
|
215
242
|
const tasks = this.service.pages.filter((page) => page.isIndex && page.id !== result.id)
|
|
216
243
|
.map((page) => {
|
|
217
244
|
page.assign({ isIndex: false });
|
|
@@ -219,12 +246,12 @@ export class Page extends Vertex {
|
|
|
219
246
|
});
|
|
220
247
|
Promise.all(tasks);
|
|
221
248
|
}
|
|
222
|
-
|
|
249
|
+
|
|
223
250
|
await then?.();
|
|
224
251
|
this.service.emit('pageTreeChange');
|
|
225
252
|
this.rootView.emit('change');
|
|
226
253
|
// this.assign(Page.from(this, this.service));
|
|
227
|
-
|
|
254
|
+
|
|
228
255
|
await config.defaultApp?.history.load();
|
|
229
256
|
config.defaultApp?.emit('saved');
|
|
230
257
|
return this;
|
|
@@ -236,21 +263,16 @@ export class Page extends Vertex {
|
|
|
236
263
|
async delete(none?: void, actionOptions?: ActionOptions) {
|
|
237
264
|
config.defaultApp?.emit('saving');
|
|
238
265
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
});
|
|
250
|
-
} catch(err) {
|
|
251
|
-
await config.defaultApp?.history.load();
|
|
252
|
-
throw err;
|
|
253
|
-
}
|
|
266
|
+
await pageService.removePage({
|
|
267
|
+
headers: {
|
|
268
|
+
appId: config.defaultApp?.id,
|
|
269
|
+
operationAction: actionOptions?.actionName || 'Page.delete',
|
|
270
|
+
operationDesc: actionOptions?.actionDesc || `删除页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
271
|
+
},
|
|
272
|
+
path: {
|
|
273
|
+
id: this.id,
|
|
274
|
+
},
|
|
275
|
+
}).catch(catchFn());
|
|
254
276
|
|
|
255
277
|
const index = this.service.pages.indexOf(this);
|
|
256
278
|
~index && this.service.pages.splice(index, 1);
|
|
@@ -275,7 +297,7 @@ export class Page extends Vertex {
|
|
|
275
297
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
276
298
|
},
|
|
277
299
|
body,
|
|
278
|
-
});
|
|
300
|
+
}).catch(catchFn());
|
|
279
301
|
|
|
280
302
|
await config.defaultApp?.history.load();
|
|
281
303
|
config.defaultApp?.emit('saved');
|
|
@@ -288,19 +310,41 @@ export class Page extends Vertex {
|
|
|
288
310
|
async setAsIndex() {
|
|
289
311
|
config.defaultApp?.emit('saving');
|
|
290
312
|
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
313
|
+
const oldIndexPages: Array<Page> = this.service.pages.filter((page) => page.isIndex);
|
|
314
|
+
const rejectedPages: Array<Page> = [];
|
|
315
|
+
const tasks = oldIndexPages.map((page) => {
|
|
316
|
+
page.assign({ isIndex: false });
|
|
317
|
+
return page.update().catch((e) => {
|
|
318
|
+
rejectedPages.push(page);
|
|
319
|
+
return Promise.reject(e);
|
|
295
320
|
});
|
|
296
|
-
|
|
297
|
-
tasks.push(this.update(undefined, {
|
|
298
|
-
actionDesc: `设置页面"${this.name}"为首页`,
|
|
299
|
-
}));
|
|
300
|
-
await Promise.all(tasks);
|
|
321
|
+
});
|
|
301
322
|
|
|
302
|
-
|
|
323
|
+
// 去掉旧首页
|
|
324
|
+
try {
|
|
325
|
+
await Promise.all(tasks);
|
|
326
|
+
} catch (e) {
|
|
327
|
+
// 恢复状态
|
|
328
|
+
rejectedPages.forEach((page) => page.assign({ isIndex: true }));
|
|
303
329
|
|
|
330
|
+
this.service.emit('pageTreeChange');
|
|
331
|
+
await config.defaultApp?.history.load();
|
|
332
|
+
config.defaultApp?.emit('saved');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// 设置新首页
|
|
337
|
+
try {
|
|
338
|
+
this.assign({ isIndex: true });
|
|
339
|
+
await this.update(undefined, {
|
|
340
|
+
actionDesc: `设置页面"${this.name}"为首页`,
|
|
341
|
+
});
|
|
342
|
+
} catch (e) {
|
|
343
|
+
// 恢复状态
|
|
344
|
+
this.assign({ isIndex: false });
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.service.emit('pageTreeChange');
|
|
304
348
|
await config.defaultApp?.history.load();
|
|
305
349
|
config.defaultApp?.emit('saved');
|
|
306
350
|
}
|
|
@@ -352,8 +396,8 @@ export class Page extends Vertex {
|
|
|
352
396
|
page.assign({
|
|
353
397
|
rootView: View.from(page.rootView, null, page),
|
|
354
398
|
service,
|
|
355
|
-
tempPath: page.rootView? `/${page.rootView.name}
|
|
356
|
-
code: page.rootView
|
|
399
|
+
tempPath: page.rootView ? `/${page.rootView.name}` : '',
|
|
400
|
+
code: page.rootView ? `/ID_${page.rootView.id}` : '',
|
|
357
401
|
});
|
|
358
402
|
|
|
359
403
|
return page;
|
package/src/types/page/View.ts
CHANGED
|
@@ -16,6 +16,7 @@ import * as babel from '@babel/core';
|
|
|
16
16
|
import view from '@/service/page/view';
|
|
17
17
|
import Entity from '../data/Entity';
|
|
18
18
|
import { postServiceType } from '../../service/common/preprocess';
|
|
19
|
+
import { catchFn } from './Page';
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* 子页面类,前端路由控制
|
|
@@ -58,6 +59,12 @@ export class View extends Block {
|
|
|
58
59
|
*/
|
|
59
60
|
@immutable()
|
|
60
61
|
public readonly title: string = undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 标题
|
|
65
|
+
*/
|
|
66
|
+
@immutable()
|
|
67
|
+
public readonly description: string = undefined;
|
|
61
68
|
/**
|
|
62
69
|
* 面包屑
|
|
63
70
|
*/
|
|
@@ -127,6 +134,12 @@ export class View extends Block {
|
|
|
127
134
|
*/
|
|
128
135
|
@immutable()
|
|
129
136
|
public readonly moreChildrenFields: Array<string> = ['$def.params', '$def.variables', '$def.logics'];
|
|
137
|
+
/**
|
|
138
|
+
* 当前View中所有组件名的缓存
|
|
139
|
+
*/
|
|
140
|
+
@immutable()
|
|
141
|
+
public readonly elementNameSet: Set<string> = new Set();
|
|
142
|
+
|
|
130
143
|
/**
|
|
131
144
|
* @param source 需要合并的部分参数
|
|
132
145
|
*/
|
|
@@ -199,26 +212,40 @@ export class View extends Block {
|
|
|
199
212
|
} catch (err) { }
|
|
200
213
|
})().finally(() => this.contentPromise = undefined);
|
|
201
214
|
}
|
|
202
|
-
loadAll() {
|
|
215
|
+
loadAll(enableCache = true) {
|
|
216
|
+
const isGONGHANG = utils.getGlobalEnv() === 'gonghang';
|
|
217
|
+
if (isGONGHANG) {
|
|
218
|
+
enableCache = false;
|
|
219
|
+
}
|
|
203
220
|
// 如果有正在进行的 Promise,则直接返回它
|
|
204
221
|
if (this.contentPromise)
|
|
205
222
|
return this.contentPromise;
|
|
206
223
|
|
|
207
224
|
return this.contentPromise = (async () => {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
225
|
+
const result: View = await viewService.load({
|
|
226
|
+
path: {
|
|
227
|
+
id: this.id,
|
|
228
|
+
},
|
|
229
|
+
query: {
|
|
230
|
+
enableCache,
|
|
231
|
+
},
|
|
232
|
+
config: { noErrorTip: true },
|
|
233
|
+
});
|
|
234
|
+
const oldLogics = this.$def.logics;
|
|
235
|
+
Object.assign(result, {
|
|
236
|
+
children: this.children,
|
|
237
|
+
});
|
|
238
|
+
const temp = View.from(result, this.parent, this.page, this);
|
|
239
|
+
const newLogics = temp.$def.logics;
|
|
240
|
+
oldLogics.forEach((logic) => {
|
|
241
|
+
if (!newLogics.find((item) => item.id === logic.id))
|
|
242
|
+
logic.destroy();
|
|
243
|
+
});
|
|
244
|
+
this.assign(temp);
|
|
245
|
+
utils.traverse((current) => {
|
|
246
|
+
current.node.attachNodePath(true);
|
|
247
|
+
}, { node: this });
|
|
248
|
+
return this;
|
|
222
249
|
})().finally(() => this.contentPromise = undefined);
|
|
223
250
|
}
|
|
224
251
|
isContentLoaded() {
|
|
@@ -277,16 +304,6 @@ export class View extends Block {
|
|
|
277
304
|
/* 绑定数据结构和接口 */
|
|
278
305
|
addData(res: any) {
|
|
279
306
|
const microService = this.parent.page.service.app.firstMicroService;
|
|
280
|
-
const interfaces = res.interfaces as Array<Interface>;
|
|
281
|
-
if (interfaces && interfaces.length) {
|
|
282
|
-
interfaces.forEach((item, index) => {
|
|
283
|
-
const itface = interfaces[index] = Interface.from(item, microService);
|
|
284
|
-
postServiceType(itface);
|
|
285
|
-
});
|
|
286
|
-
microService.interfaces.unshift(...interfaces);
|
|
287
|
-
microService.emit('interfacesChange');
|
|
288
|
-
}
|
|
289
|
-
|
|
290
307
|
const enums = res.enums as Array<Enum>;
|
|
291
308
|
if (enums && enums.length) {
|
|
292
309
|
enums.forEach((item, index) => enums[index] = Enum.from(item, microService));
|
|
@@ -307,6 +324,19 @@ export class View extends Block {
|
|
|
307
324
|
microService.data.structures.unshift(...structures);
|
|
308
325
|
updateDataTypeList();
|
|
309
326
|
}
|
|
327
|
+
|
|
328
|
+
const interfaces = res.interfaces as Array<Interface>;
|
|
329
|
+
if (interfaces && interfaces.length) {
|
|
330
|
+
interfaces.forEach((item, index) => {
|
|
331
|
+
const itface = interfaces[index] = Interface.from(item, microService);
|
|
332
|
+
postServiceType(itface);
|
|
333
|
+
});
|
|
334
|
+
microService.interfaces.unshift(...interfaces);
|
|
335
|
+
microService.globalLogic.globalLogics.unshift(...interfaces);
|
|
336
|
+
microService.mountResolverOnEntity();
|
|
337
|
+
microService.mountResolverOnInterface();
|
|
338
|
+
microService.emit('interfacesChange');
|
|
339
|
+
}
|
|
310
340
|
}
|
|
311
341
|
|
|
312
342
|
@action('添加子页面')
|
|
@@ -322,7 +352,7 @@ export class View extends Block {
|
|
|
322
352
|
operationDesc: actionOptions?.actionDesc || `添加子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
323
353
|
},
|
|
324
354
|
body,
|
|
325
|
-
});
|
|
355
|
+
}).catch(catchFn());
|
|
326
356
|
this.deepPick(result.view, ['id']);
|
|
327
357
|
// 添加数据
|
|
328
358
|
this.addData(result);
|
|
@@ -403,21 +433,16 @@ export class View extends Block {
|
|
|
403
433
|
if (!this.parent)
|
|
404
434
|
throw Error('该子页面为根节点!');
|
|
405
435
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
});
|
|
417
|
-
} catch (err) {
|
|
418
|
-
await config.defaultApp?.history.load();
|
|
419
|
-
throw err;
|
|
420
|
-
}
|
|
436
|
+
await viewService.delete({
|
|
437
|
+
headers: {
|
|
438
|
+
appId: config.defaultApp?.id,
|
|
439
|
+
operationAction: actionOptions?.actionName || 'View.delete',
|
|
440
|
+
operationDesc: actionOptions?.actionDesc || `删除子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
441
|
+
},
|
|
442
|
+
path: {
|
|
443
|
+
id: this.id,
|
|
444
|
+
},
|
|
445
|
+
}).catch(catchFn());
|
|
421
446
|
|
|
422
447
|
const index = this.parent.children.indexOf(this);
|
|
423
448
|
~index && this.parent.children.splice(index, 1);
|
|
@@ -449,7 +474,7 @@ export class View extends Block {
|
|
|
449
474
|
operationDesc: actionOptions?.actionDesc || `修改子页面"${this.name}${this.title ? `(${this.title})` : ''}"`,
|
|
450
475
|
},
|
|
451
476
|
body,
|
|
452
|
-
});
|
|
477
|
+
}).catch(catchFn());
|
|
453
478
|
|
|
454
479
|
await then?.();
|
|
455
480
|
await config.defaultApp?.history.load();
|
|
@@ -519,6 +544,28 @@ export class View extends Block {
|
|
|
519
544
|
this.page.service.emit('pageTreeChange');
|
|
520
545
|
this.emit('change');
|
|
521
546
|
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* 描述信息
|
|
550
|
+
* @param description 描述信息
|
|
551
|
+
*/
|
|
552
|
+
@action('设置子页面面包屑')
|
|
553
|
+
async setDescription(description: string) {
|
|
554
|
+
const oldDescription = this.description;
|
|
555
|
+
this.assign({ description });
|
|
556
|
+
console.info('description abc', description);
|
|
557
|
+
await this.update(undefined, {
|
|
558
|
+
actionDesc: `设置页面"${oldDescription}"的描述为"${description}"`,
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
if (this.page.rootView === this) {
|
|
562
|
+
this.page.assign({ description });
|
|
563
|
+
await this.page.update();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
this.page.service.emit('pageTreeChange');
|
|
567
|
+
this.emit('change');
|
|
568
|
+
}
|
|
522
569
|
/**
|
|
523
570
|
* 设置该子页面为默认跳转页
|
|
524
571
|
*/
|
|
@@ -898,6 +945,40 @@ export class View extends Block {
|
|
|
898
945
|
// config.defaultApp?.emit('saved');
|
|
899
946
|
}
|
|
900
947
|
|
|
948
|
+
// 遍历页面缓存所有组件名
|
|
949
|
+
traverseAllElementName(): void {
|
|
950
|
+
this.elementNameSet.clear();
|
|
951
|
+
utils.traverse(({ node }) => {
|
|
952
|
+
node && this.elementNameSet.add(node.name);
|
|
953
|
+
}, { node: this.$html });
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
// 组件名是否有效
|
|
957
|
+
isValidElementName(name: string): boolean {
|
|
958
|
+
if (name) {
|
|
959
|
+
return !this.elementNameSet.has(name);
|
|
960
|
+
}
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// 保存组件名至缓存
|
|
965
|
+
addElementName(nameOrElement: string | Element) {
|
|
966
|
+
let name: string = nameOrElement as string;
|
|
967
|
+
if (nameOrElement instanceof Element) {
|
|
968
|
+
name = nameOrElement.name;
|
|
969
|
+
}
|
|
970
|
+
return this.elementNameSet.add(name);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// 在缓存中移除组件名
|
|
974
|
+
removeElementName(nameOrElement: string | Element): void {
|
|
975
|
+
let name: string = nameOrElement as string;
|
|
976
|
+
if (nameOrElement instanceof Element) {
|
|
977
|
+
name = nameOrElement.name;
|
|
978
|
+
}
|
|
979
|
+
this.elementNameSet.delete(name);
|
|
980
|
+
}
|
|
981
|
+
|
|
901
982
|
_removeDef($def: View['$def']) {
|
|
902
983
|
const removedParams = this.$def.params.filter((param) => $def.params?.find((item) => param.id === item.id));
|
|
903
984
|
this.$def.params = this.$def.params.filter((param) => !$def.params?.find((item) => param.id === item.id));
|
|
@@ -5,6 +5,25 @@ import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
|
5
5
|
import { viewService } from '../../service/page';
|
|
6
6
|
import { View } from './View';
|
|
7
7
|
import { schemaService } from '../../service/common';
|
|
8
|
+
import { refreshPages, refreshView } from '../cache';
|
|
9
|
+
import { BusinessCode } from '../enum';
|
|
10
|
+
|
|
11
|
+
export function catchFn(view: View) {
|
|
12
|
+
return async (err: any) => {
|
|
13
|
+
const code = err?.code;
|
|
14
|
+
// 节点已存在; 节点不存在
|
|
15
|
+
if([BusinessCode.ElementExist, BusinessCode.ElementNotExist].includes(code)) {
|
|
16
|
+
await refreshView(view);
|
|
17
|
+
} else if(code === BusinessCode.ParentElementNotExist) { // 父节点不存在。视图添加变量,发现视图不存在
|
|
18
|
+
await refreshPages();
|
|
19
|
+
} else
|
|
20
|
+
config.defaultApp?.emit('saved', err);
|
|
21
|
+
|
|
22
|
+
config.defaultApp?.history.load();
|
|
23
|
+
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
8
27
|
|
|
9
28
|
/**
|
|
10
29
|
* 页面输入参数
|
|
@@ -56,7 +75,7 @@ export class ViewParam extends Param {
|
|
|
56
75
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"输入参数"${this.name}"`,
|
|
57
76
|
},
|
|
58
77
|
body,
|
|
59
|
-
});
|
|
78
|
+
}).catch(catchFn(this.view));
|
|
60
79
|
// convert2RefType(result.schema);
|
|
61
80
|
this.deepPick(result, ['id']);
|
|
62
81
|
this.assign({ code: this.genCode() });
|
|
@@ -88,7 +107,7 @@ export class ViewParam extends Param {
|
|
|
88
107
|
query: {
|
|
89
108
|
id: this.id,
|
|
90
109
|
},
|
|
91
|
-
});
|
|
110
|
+
}).catch(catchFn(this.view));
|
|
92
111
|
} catch(err) {
|
|
93
112
|
await config.defaultApp?.history.load();
|
|
94
113
|
throw err;
|
|
@@ -129,7 +148,7 @@ export class ViewParam extends Param {
|
|
|
129
148
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"输入参数"${this.name}"`,
|
|
130
149
|
},
|
|
131
150
|
body,
|
|
132
|
-
});
|
|
151
|
+
}).catch(catchFn(this.view));
|
|
133
152
|
// convert2RefType(result.schema);
|
|
134
153
|
// this.plainAssign(result);
|
|
135
154
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { immutable, excludedInJSON, action } from '../decorators';
|
|
2
|
-
import { config,
|
|
3
|
-
import { paramService } from '../../service/logic';
|
|
2
|
+
import { config, utils, Logic, Variable, View, Schema, ActionOptions } from '..';
|
|
4
3
|
import { viewService } from '../../service/page';
|
|
5
|
-
import { convert2RefType
|
|
4
|
+
import { convert2RefType } from '../data/dataTypeUtils';
|
|
6
5
|
import { getBasicTypeDefaultValue } from '../data/basicTypes';
|
|
7
6
|
import { schemaService } from '../../service/common';
|
|
7
|
+
import { catchFn } from './ViewParam';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* 页面局部变量
|
|
@@ -42,7 +42,7 @@ export class ViewVariable extends Variable {
|
|
|
42
42
|
|
|
43
43
|
const body = this.toJSON('', ['ideVersion', 'editable']);
|
|
44
44
|
body.viewId = this.view.id;
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
utils.logger.debug('添加页面局部变量', body);
|
|
47
47
|
const result: ViewVariable = await viewService.createViewVariable({
|
|
48
48
|
headers: {
|
|
@@ -51,8 +51,7 @@ export class ViewVariable extends Variable {
|
|
|
51
51
|
operationDesc: actionOptions?.actionDesc || `添加页面"${this.view.name}"局部变量"${this.name}"`,
|
|
52
52
|
},
|
|
53
53
|
body,
|
|
54
|
-
});
|
|
55
|
-
// convert2RefType(result.schema);
|
|
54
|
+
}).catch(catchFn(this.view));
|
|
56
55
|
this.deepPick(result, ['id']);
|
|
57
56
|
this.assign({ code: this.genCode() });
|
|
58
57
|
|
|
@@ -73,21 +72,16 @@ export class ViewVariable extends Variable {
|
|
|
73
72
|
config.defaultApp?.emit('saving');
|
|
74
73
|
|
|
75
74
|
if (this.id) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
} catch (err) {
|
|
88
|
-
await config.defaultApp?.history.load();
|
|
89
|
-
throw err;
|
|
90
|
-
}
|
|
75
|
+
await viewService.deleteViewVariable({
|
|
76
|
+
headers: {
|
|
77
|
+
appId: config.defaultApp?.id,
|
|
78
|
+
operationAction: actionOptions?.actionName || 'ViewVariable.delete',
|
|
79
|
+
operationDesc: actionOptions?.actionDesc || `删除页面"${this.view.name}"局部变量"${this.name}"`,
|
|
80
|
+
},
|
|
81
|
+
query: {
|
|
82
|
+
id: this.id,
|
|
83
|
+
},
|
|
84
|
+
}).catch(catchFn(this.view));
|
|
91
85
|
}
|
|
92
86
|
|
|
93
87
|
const { variables } = this.view.$def;
|
|
@@ -113,7 +107,6 @@ export class ViewVariable extends Variable {
|
|
|
113
107
|
delete body.ideVersion;
|
|
114
108
|
delete body.editable;
|
|
115
109
|
body.viewId = this.view.id;
|
|
116
|
-
// convert2SchemaType(body.schema);
|
|
117
110
|
utils.logger.debug('修改页面局部变量', body);
|
|
118
111
|
const result = await viewService.updateViewVariable({
|
|
119
112
|
headers: {
|
|
@@ -122,9 +115,7 @@ export class ViewVariable extends Variable {
|
|
|
122
115
|
operationDesc: actionOptions?.actionDesc || `修改页面"${this.view.name}"局部变量"${this.name}"`,
|
|
123
116
|
},
|
|
124
117
|
body,
|
|
125
|
-
});
|
|
126
|
-
// convert2RefType(result.schema);
|
|
127
|
-
// this.plainAssign(result);
|
|
118
|
+
}).catch(catchFn(this.view));
|
|
128
119
|
|
|
129
120
|
await config.defaultApp?.history.load();
|
|
130
121
|
config.defaultApp?.emit('saved');
|
|
@@ -190,7 +181,6 @@ export class ViewVariable extends Variable {
|
|
|
190
181
|
typeInstantiation: undefined,
|
|
191
182
|
});
|
|
192
183
|
Object.assign(this.schema, schema);
|
|
193
|
-
// if (this.defaultValue)
|
|
194
184
|
this.assign({ defaultValue: getBasicTypeDefaultValue() });
|
|
195
185
|
try {
|
|
196
186
|
await this.update(undefined, {
|