@lcap/nasl 0.3.9-beta → 0.3.10-beta.5
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/create/errHandles.js +7 -2
- package/out/service/create/errHandles.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 +30 -0
- package/out/types/app/App.js.map +1 -1
- package/out/types/app/Service.d.ts +2 -2
- package/out/types/app/Service.js +28 -3
- 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.js +1 -0
- package/out/types/data/Entity.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/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/genSelectBlock.js +2 -2
- package/out/types/data/genBlock/genTableBlock.js +14 -3
- 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/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 +142 -31
- package/out/types/logic/Logic.js.map +1 -1
- package/out/types/logic/LogicItem.d.ts +1 -0
- package/out/types/logic/LogicItem.js +43 -24
- package/out/types/logic/LogicItem.js.map +1 -1
- package/out/types/logic/Param.d.ts +1 -0
- package/out/types/logic/Param.js +40 -20
- package/out/types/logic/Param.js.map +1 -1
- package/out/types/logic/Return.js +14 -19
- package/out/types/logic/Return.js.map +1 -1
- package/out/types/logic/Variable.js +14 -19
- 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 +16 -0
- package/out/types/page/Element.js +192 -129
- 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 +1 -0
- package/out/types/page/Page.js +71 -37
- package/out/types/page/Page.js.map +1 -1
- package/out/types/page/View.d.ts +9 -1
- package/out/types/page/View.js +86 -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 -18
- 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/package.json +2 -3
- package/src/service/create/errHandles.js +6 -2
- 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 +36 -1
- package/src/types/app/Service.ts +32 -3
- 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 +1 -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/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/genSelectBlock.ts +2 -2
- package/src/types/data/genBlock/genTableBlock.ts +14 -3
- package/src/types/data/genBlock/genUpdateBlock.ts +5 -5
- 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 +138 -28
- package/src/types/logic/LogicItem.ts +48 -28
- package/src/types/logic/Param.ts +39 -18
- package/src/types/logic/Return.ts +4 -9
- package/src/types/logic/Variable.ts +4 -8
- package/src/types/logic/translator.js +41 -13
- package/src/types/logic/translator_backup.js +5 -16
- package/src/types/nuims/Nuims.ts +11 -5
- package/src/types/page/Element.ts +211 -133
- package/src/types/page/Event.ts +0 -3
- package/src/types/page/Page.ts +86 -49
- package/src/types/page/View.ts +90 -42
- package/src/types/page/ViewParam.ts +22 -3
- package/src/types/page/ViewVariable.ts +4 -8
- 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/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
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
// import stringify = require('json-stringify-safe');
|
|
2
1
|
import { action, circular, excludedInJSON, immutable } from '../decorators';
|
|
3
|
-
import { config,
|
|
2
|
+
import { config, utils, LEVEL_ENUM, Vertex, View, Attr, Directive, Event, ExpressionNode, dataTypesMap, LogicItem, ActionOptions, ACTION_MODE, Nuims, Structure } from '..';
|
|
4
3
|
import * as compiler from 'vue-template-compiler';
|
|
5
4
|
import * as json5 from 'json5';
|
|
6
|
-
import { elementService
|
|
5
|
+
import { elementService } from '../../service/page';
|
|
7
6
|
import { vertexsMap } from '../cacheData';
|
|
8
7
|
import Variable from '../logic/Variable';
|
|
9
8
|
import * as babelParser from '@babel/parser';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { isPlainObject, cloneDeep, mapValues } from 'lodash';
|
|
10
|
+
import { refreshHtml } from '../cache';
|
|
11
|
+
import { BusinessCode } from '../enum';
|
|
12
12
|
|
|
13
13
|
export interface ElementToVueOptions {
|
|
14
14
|
indentStyle?: 'space' | 'tab';
|
|
@@ -28,6 +28,18 @@ export interface ParseContext {
|
|
|
28
28
|
[key: string]: any;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
export function catchFn(view: View) {
|
|
32
|
+
return async (err: any) => {
|
|
33
|
+
if (err.code !== BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
34
|
+
await refreshHtml(view);
|
|
35
|
+
else
|
|
36
|
+
config.defaultApp?.emit('saved', err);
|
|
37
|
+
|
|
38
|
+
config.defaultApp?.history.load();
|
|
39
|
+
throw err;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
/**
|
|
32
44
|
* 前端页面元素
|
|
33
45
|
* @example
|
|
@@ -142,15 +154,18 @@ export class Element extends Vertex {
|
|
|
142
154
|
*/
|
|
143
155
|
@immutable()
|
|
144
156
|
public readonly children?: Array<Element> = [];
|
|
157
|
+
/**
|
|
158
|
+
* 标签名前缀
|
|
159
|
+
*/
|
|
160
|
+
@immutable()
|
|
161
|
+
public static readonly TAG_NAME_REG?: RegExp = /^([lieu]|van)[-_]/;
|
|
162
|
+
|
|
145
163
|
/**
|
|
146
164
|
* @param source 需要合并的部分参数
|
|
147
165
|
*/
|
|
148
166
|
constructor(source?: Partial<Element>) {
|
|
149
167
|
super();
|
|
150
168
|
source && this.assign(source);
|
|
151
|
-
// 为了给生成的节点使用
|
|
152
|
-
// !this.id && this.assign({ id: uuidv4() });
|
|
153
|
-
// this.assign({ id: 'temp-' + uuidv4() });
|
|
154
169
|
}
|
|
155
170
|
assign(source?: any) {
|
|
156
171
|
['attrList', 'eventList', 'directiveList', 'children'].forEach((key) => {
|
|
@@ -170,62 +185,45 @@ export class Element extends Vertex {
|
|
|
170
185
|
}
|
|
171
186
|
|
|
172
187
|
config.defaultApp?.emit('saving');
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
appId: config.defaultApp?.id,
|
|
182
|
-
operationAction: 'Element.create',
|
|
183
|
-
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
184
|
-
},
|
|
185
|
-
body,
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// Nuims createResource
|
|
189
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
190
|
-
// 暂时只增不减
|
|
191
|
-
// new Nuims({
|
|
192
|
-
// domainName: this.view.page.service.app.name,
|
|
193
|
-
// element: this,
|
|
194
|
-
// }).createResource();
|
|
195
|
-
|
|
196
|
-
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
197
|
-
// attr,directive,event的id,exprssion需要合并
|
|
198
|
-
this.attrList.forEach((attr, index) => {
|
|
199
|
-
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
200
|
-
});
|
|
201
|
-
this.directiveList.forEach((directive, index) => {
|
|
202
|
-
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
203
|
-
});
|
|
204
|
-
this.eventList.forEach((event, index) => {
|
|
205
|
-
event.deepPick(result.eventList[index], ['id']);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
this.view && this.view.emit('change');
|
|
210
|
-
|
|
211
|
-
if (actionOptions?.loadHistory !== false) {
|
|
212
|
-
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
188
|
+
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
189
|
+
const body = this.toJSON();
|
|
190
|
+
body.parentId = this.parent && this.parent.id;
|
|
191
|
+
body._posIndex = this.parent && this.parent.children.indexOf(this);
|
|
192
|
+
utils.logger.debug('添加元素', body);
|
|
193
|
+
const result = await elementService.create({
|
|
194
|
+
headers: {
|
|
195
|
+
appId: config.defaultApp?.id,
|
|
213
196
|
operationAction: 'Element.create',
|
|
214
|
-
operationBeforeImage: null,
|
|
215
|
-
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
216
197
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
217
|
-
}
|
|
198
|
+
},
|
|
199
|
+
body,
|
|
200
|
+
}).catch(catchFn(this.view));
|
|
201
|
+
|
|
202
|
+
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
203
|
+
// attr,directive,event的id,exprssion需要合并
|
|
204
|
+
this.attrList.forEach((attr, index) => {
|
|
205
|
+
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
206
|
+
});
|
|
207
|
+
this.directiveList.forEach((directive, index) => {
|
|
208
|
+
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
209
|
+
});
|
|
210
|
+
this.eventList.forEach((event, index) => {
|
|
211
|
+
event.deepPick(result.eventList[index], ['id']);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
this.view && this.view.emit('change');
|
|
216
|
+
|
|
217
|
+
if (actionOptions?.loadHistory !== false) {
|
|
218
|
+
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
219
|
+
operationAction: 'Element.create',
|
|
220
|
+
operationBeforeImage: null,
|
|
221
|
+
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
222
|
+
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
223
|
+
});
|
|
218
224
|
config.defaultApp?.emit('saved');
|
|
219
|
-
}
|
|
220
|
-
return this;
|
|
221
|
-
} catch (err) {
|
|
222
|
-
if (this.view) {
|
|
223
|
-
await this.view.load();
|
|
224
|
-
this.view.emit('change');
|
|
225
|
-
config.defaultApp?.emit('saved');
|
|
226
|
-
}
|
|
227
|
-
throw err;
|
|
228
225
|
}
|
|
226
|
+
return this;
|
|
229
227
|
}
|
|
230
228
|
/**
|
|
231
229
|
* 删除元素
|
|
@@ -236,6 +234,7 @@ export class Element extends Vertex {
|
|
|
236
234
|
const index = this.parent.children.indexOf(this);
|
|
237
235
|
~index && this.parent.children.splice(index, 1);
|
|
238
236
|
this.view && this.view.emit('local-change');
|
|
237
|
+
this.view.removeComponentName(this.name);
|
|
239
238
|
return this;
|
|
240
239
|
}
|
|
241
240
|
|
|
@@ -246,29 +245,16 @@ export class Element extends Vertex {
|
|
|
246
245
|
|
|
247
246
|
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
248
247
|
if (this.id) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
});
|
|
260
|
-
} catch (err) {
|
|
261
|
-
await config.defaultApp?.history.load();
|
|
262
|
-
throw err;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// Nuims deleteResource
|
|
266
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
267
|
-
// 暂时只增不减
|
|
268
|
-
// new Nuims({
|
|
269
|
-
// domainName: this.view.page.service.app.name,
|
|
270
|
-
// element: this,
|
|
271
|
-
// }).deleteResources();
|
|
248
|
+
await elementService.delete({
|
|
249
|
+
headers: {
|
|
250
|
+
appId: config.defaultApp?.id,
|
|
251
|
+
operationAction: 'Element.delete',
|
|
252
|
+
operationDesc: `删除组件"${this.getElementTitle()}"`,
|
|
253
|
+
},
|
|
254
|
+
query: {
|
|
255
|
+
id: this.id,
|
|
256
|
+
},
|
|
257
|
+
}).catch(catchFn(this.view));
|
|
272
258
|
}
|
|
273
259
|
}
|
|
274
260
|
|
|
@@ -285,6 +271,8 @@ export class Element extends Vertex {
|
|
|
285
271
|
});
|
|
286
272
|
config.defaultApp?.emit('saved');
|
|
287
273
|
}
|
|
274
|
+
// 递归删除组件名的缓存
|
|
275
|
+
this.deepRemoveComponentName();
|
|
288
276
|
}
|
|
289
277
|
/**
|
|
290
278
|
* 修改元素
|
|
@@ -293,39 +281,51 @@ export class Element extends Vertex {
|
|
|
293
281
|
config.defaultApp?.emit('saving');
|
|
294
282
|
|
|
295
283
|
source && this.assign(source);
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
284
|
+
if (actionOptions?.actionMode !== ACTION_MODE.undoRedo) {
|
|
285
|
+
const body = this.toPlainJSON();
|
|
286
|
+
utils.logger.debug('修改组件', body);
|
|
287
|
+
await elementService.update({
|
|
288
|
+
headers: {
|
|
289
|
+
appId: config.defaultApp?.id,
|
|
290
|
+
operationAction: actionOptions?.actionName || 'Element.update',
|
|
291
|
+
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
292
|
+
},
|
|
293
|
+
body,
|
|
294
|
+
}).catch(catchFn(this.view));
|
|
295
|
+
}
|
|
309
296
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
297
|
+
this.view && this.view.emit('change');
|
|
298
|
+
await config.defaultApp?.history.load(actionOptions?.actionMode !== ACTION_MODE.undoRedo && {
|
|
299
|
+
operationAction: 'Element.update',
|
|
300
|
+
operationBeforeImage: null,
|
|
301
|
+
operationAfterImage: null,
|
|
302
|
+
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
303
|
+
});
|
|
317
304
|
|
|
318
305
|
config.defaultApp?.emit('saved');
|
|
319
306
|
return this;
|
|
320
|
-
} catch (err) {
|
|
321
|
-
if (this.view) {
|
|
322
|
-
await this.view.load();
|
|
323
|
-
this.view.emit('change');
|
|
324
|
-
config.defaultApp?.emit('saved');
|
|
325
|
-
}
|
|
326
|
-
throw err;
|
|
327
|
-
}
|
|
328
307
|
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 按当前 id 加载逻辑数据
|
|
311
|
+
*/
|
|
312
|
+
async load() {
|
|
313
|
+
if (!this.id)
|
|
314
|
+
return;
|
|
315
|
+
|
|
316
|
+
const result = await elementService.load({
|
|
317
|
+
headers: {
|
|
318
|
+
appId: config.defaultApp?.id,
|
|
319
|
+
},
|
|
320
|
+
query: {
|
|
321
|
+
id: this.id,
|
|
322
|
+
},
|
|
323
|
+
config: { noErrorTip: true },
|
|
324
|
+
});
|
|
325
|
+
const newElement = Element.from(result, this.parent, this.view);
|
|
326
|
+
this.assign(newElement);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
329
|
async move(options: {
|
|
330
330
|
parentId?: string,
|
|
331
331
|
_posIndex?: number,
|
|
@@ -363,11 +363,16 @@ export class Element extends Vertex {
|
|
|
363
363
|
}
|
|
364
364
|
|
|
365
365
|
config.defaultApp?.emit('element.moved');
|
|
366
|
+
config.defaultApp?.emit('saved');
|
|
366
367
|
} catch (err) {
|
|
367
368
|
if (this.view) {
|
|
368
369
|
await this.view.load();
|
|
369
370
|
this.view.emit('change');
|
|
370
371
|
}
|
|
372
|
+
config.defaultApp?.emit('saved', {
|
|
373
|
+
action: 'move',
|
|
374
|
+
err,
|
|
375
|
+
});
|
|
371
376
|
throw err;
|
|
372
377
|
}
|
|
373
378
|
}
|
|
@@ -381,6 +386,9 @@ export class Element extends Vertex {
|
|
|
381
386
|
|
|
382
387
|
const index = this.parent.children.indexOf(this);
|
|
383
388
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
389
|
+
// 复制的元素需重新命名
|
|
390
|
+
newNode.initComponentName();
|
|
391
|
+
|
|
384
392
|
const mergeExpression = (originList: Array<Attr|Directive>, newList: Array<Attr|Directive>) => {
|
|
385
393
|
newList.forEach((item) => {
|
|
386
394
|
const originItem = originList.find((originItem) => originItem.name === item.name);
|
|
@@ -432,6 +440,15 @@ export class Element extends Vertex {
|
|
|
432
440
|
}
|
|
433
441
|
};
|
|
434
442
|
|
|
443
|
+
const arrayComp = this.findElementsByTag('u-modal');
|
|
444
|
+
const existingNames = Object.values(mapValues(arrayComp, (o) => o.name));
|
|
445
|
+
// 处理弹窗组件的命名问题
|
|
446
|
+
if (newNode.tag === 'u-modal') {
|
|
447
|
+
Object.assign(newNode, {
|
|
448
|
+
name: utils.unique('saveModal1', existingNames as any),
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
435
452
|
traverseMergeNode(this, newNode);
|
|
436
453
|
~index && this.parent.children.splice(index + 1, 0, newNode);
|
|
437
454
|
this.parent.children.forEach((item, index) => {
|
|
@@ -488,11 +505,14 @@ export class Element extends Vertex {
|
|
|
488
505
|
await this.update(undefined, {
|
|
489
506
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
490
507
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
508
|
+
|
|
509
|
+
if (!(window as any).globalData.hasUserCenter) {
|
|
510
|
+
// 同步权限
|
|
511
|
+
new Nuims({
|
|
512
|
+
domainName: this.view.page.service.app.name,
|
|
513
|
+
element: this,
|
|
514
|
+
}).editResourceFromResourceValue(oldName ? `${this.view.tempPath}/${oldName}` : null);
|
|
515
|
+
}
|
|
496
516
|
|
|
497
517
|
this.view && this.view.emit('change');
|
|
498
518
|
if (this.view && this.view.page && this.view.page.service) {
|
|
@@ -541,9 +561,7 @@ export class Element extends Vertex {
|
|
|
541
561
|
async setAttr(name: string, type: 'string' | 'static' | 'dynamic', value?: any) {
|
|
542
562
|
let attr = this.getAttr(name);
|
|
543
563
|
//
|
|
544
|
-
if (value
|
|
545
|
-
|
|
546
|
-
} else {
|
|
564
|
+
if (value !== undefined) {
|
|
547
565
|
if (typeof value !== 'string')
|
|
548
566
|
value = JSON.stringify(value);
|
|
549
567
|
|
|
@@ -554,7 +572,7 @@ export class Element extends Vertex {
|
|
|
554
572
|
});
|
|
555
573
|
await attr.update(undefined, {
|
|
556
574
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
557
|
-
});
|
|
575
|
+
}).catch(catchFn(this.view));
|
|
558
576
|
} else {
|
|
559
577
|
attr = Attr.from({
|
|
560
578
|
name,
|
|
@@ -564,7 +582,7 @@ export class Element extends Vertex {
|
|
|
564
582
|
}, this);
|
|
565
583
|
await attr.create(undefined, {
|
|
566
584
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
567
|
-
});
|
|
585
|
+
}).catch(catchFn(this.view));
|
|
568
586
|
this.attrList.push(attr);
|
|
569
587
|
}
|
|
570
588
|
}
|
|
@@ -581,7 +599,7 @@ export class Element extends Vertex {
|
|
|
581
599
|
|
|
582
600
|
await event.create(undefined, Object.assign({
|
|
583
601
|
actionDesc: `添加组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
584
|
-
}, actionOptions));
|
|
602
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
585
603
|
event = Event.from(event, this);
|
|
586
604
|
this.eventList.push(event);
|
|
587
605
|
|
|
@@ -604,7 +622,7 @@ export class Element extends Vertex {
|
|
|
604
622
|
|
|
605
623
|
await event.delete(undefined, Object.assign({
|
|
606
624
|
actionDesc: `删除组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
607
|
-
}, actionOptions));
|
|
625
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
608
626
|
const index = this.eventList.indexOf(event);
|
|
609
627
|
~index && this.eventList.splice(index, 1);
|
|
610
628
|
|
|
@@ -622,7 +640,7 @@ export class Element extends Vertex {
|
|
|
622
640
|
const directive = new Directive(data);
|
|
623
641
|
await directive.create(undefined, Object.assign({
|
|
624
642
|
actionDesc: `添加组件"${this.getElementTitle()}"指令"${directive.name}"`,
|
|
625
|
-
}, actionOptions));
|
|
643
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
626
644
|
this.directiveList.push(Directive.from(directive, this));
|
|
627
645
|
|
|
628
646
|
this.view && this.view.emit('change');
|
|
@@ -639,7 +657,7 @@ export class Element extends Vertex {
|
|
|
639
657
|
|
|
640
658
|
await directive.delete(undefined, Object.assign({
|
|
641
659
|
actionDesc: `删除组件"${this.getElementTitle()}"属性"${directive.name}"`,
|
|
642
|
-
}, actionOptions));
|
|
660
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
643
661
|
const index = this.directiveList.indexOf(directive);
|
|
644
662
|
~index && this.directiveList.splice(index, 1);
|
|
645
663
|
|
|
@@ -808,6 +826,66 @@ export class Element extends Vertex {
|
|
|
808
826
|
}
|
|
809
827
|
}
|
|
810
828
|
}
|
|
829
|
+
|
|
830
|
+
findElementsByTag(tag: string): Array<any> {
|
|
831
|
+
let existingNames: Array<any> = [];
|
|
832
|
+
existingNames = this.findElementsByTagCurrent(tag, existingNames);
|
|
833
|
+
this.findElementsByTagInChildren(this.view.$html.children, tag, existingNames);
|
|
834
|
+
return existingNames;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
findElementsByTagCurrent(tag: string, existingNames: Array<any>) {
|
|
838
|
+
if (this.tag === tag) {
|
|
839
|
+
existingNames.push(this);
|
|
840
|
+
}
|
|
841
|
+
return existingNames;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
findElementsByTagInChildren(children: Array<any>, tag: string, existingNames: Array<any>) {
|
|
845
|
+
for (const child of children) {
|
|
846
|
+
const result = child.findElementByTag(tag);
|
|
847
|
+
|
|
848
|
+
if (child.children) {
|
|
849
|
+
this.findElementsByTagInChildren(child.children, tag, existingNames);
|
|
850
|
+
}
|
|
851
|
+
if (result) {
|
|
852
|
+
existingNames.push(result);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// 初始化组件名
|
|
858
|
+
public initComponentName() {
|
|
859
|
+
const name = this.genComponentName();
|
|
860
|
+
this.assign({ name });
|
|
861
|
+
this.view.addComponentName(name);
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
// 生成新的组件名
|
|
865
|
+
public genComponentName(): string {
|
|
866
|
+
const compNameSet = this.view.componentNameSet;
|
|
867
|
+
const tagName = this.tag.replace(Element.TAG_NAME_REG, '').replace(/-/g, '_');
|
|
868
|
+
const componentName = utils.unique(tagName + '1', compNameSet);
|
|
869
|
+
return componentName;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
// 递归删除组件名的缓存
|
|
873
|
+
public deepRemoveComponentName(): void {
|
|
874
|
+
return this.traverseChildren((ele: Element) => {
|
|
875
|
+
this.view.removeComponentName(ele.name);
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// 递归遍历组件
|
|
880
|
+
public traverseChildren(cb: (ele: Element) => void): void {
|
|
881
|
+
return (function loop(item: Element) {
|
|
882
|
+
cb(item);
|
|
883
|
+
if (item.children?.length) {
|
|
884
|
+
item.children.forEach(loop);
|
|
885
|
+
}
|
|
886
|
+
})(this);
|
|
887
|
+
}
|
|
888
|
+
|
|
811
889
|
/**
|
|
812
890
|
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
813
891
|
* @param astNode Vue 的 ASTNode
|
|
@@ -852,8 +930,6 @@ export class Element extends Vertex {
|
|
|
852
930
|
}
|
|
853
931
|
}
|
|
854
932
|
|
|
855
|
-
// if (astNode.tag === 'template')
|
|
856
|
-
// astNode.tag = 'div';
|
|
857
933
|
element = new Element({
|
|
858
934
|
tag: astNode.tag,
|
|
859
935
|
name: astNode.attrsMap.ref,
|
|
@@ -894,7 +970,6 @@ export class Element extends Vertex {
|
|
|
894
970
|
}
|
|
895
971
|
}
|
|
896
972
|
element.attrList.push(attr);
|
|
897
|
-
// element.attrMap[attr.name] = attr;
|
|
898
973
|
});
|
|
899
974
|
|
|
900
975
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
@@ -906,10 +981,6 @@ export class Element extends Vertex {
|
|
|
906
981
|
value,
|
|
907
982
|
logicId: value[0] === '$' ? undefined : value,
|
|
908
983
|
}, element));
|
|
909
|
-
// element.eventMap[name] = new Event({
|
|
910
|
-
// name,
|
|
911
|
-
// value: oldEvent.value,
|
|
912
|
-
// });
|
|
913
984
|
});
|
|
914
985
|
|
|
915
986
|
astNode.directives && astNode.directives.forEach((directive) => {
|
|
@@ -936,7 +1007,6 @@ export class Element extends Vertex {
|
|
|
936
1007
|
arg: directive.arg,
|
|
937
1008
|
modifiers: directive.modifiers,
|
|
938
1009
|
}, element));
|
|
939
|
-
// element.directiveMap[directive.name] = );
|
|
940
1010
|
}
|
|
941
1011
|
});
|
|
942
1012
|
|
|
@@ -1294,6 +1364,10 @@ export class Element extends Vertex {
|
|
|
1294
1364
|
const element = this.parse(html, context);
|
|
1295
1365
|
utils.traverse((current) => {
|
|
1296
1366
|
current.node.assign({ view, parent: current.parent });
|
|
1367
|
+
// 生成唯一组件名 依赖element.view
|
|
1368
|
+
if (!current.node.name) {
|
|
1369
|
+
current.node.initComponentName();
|
|
1370
|
+
}
|
|
1297
1371
|
}, { node: element, parent });
|
|
1298
1372
|
return element;
|
|
1299
1373
|
}
|
|
@@ -1312,6 +1386,10 @@ export class Element extends Vertex {
|
|
|
1312
1386
|
view,
|
|
1313
1387
|
parent,
|
|
1314
1388
|
});
|
|
1389
|
+
// // 生成唯一组件名 依赖element.view
|
|
1390
|
+
// if (!element.name) {
|
|
1391
|
+
// element.initComponentName();
|
|
1392
|
+
// }
|
|
1315
1393
|
|
|
1316
1394
|
return element;
|
|
1317
1395
|
}
|
package/src/types/page/Event.ts
CHANGED
|
@@ -3,10 +3,7 @@ import { action, circular, excludedInJSON, immutable } from '../decorators';
|
|
|
3
3
|
import { config, history, utils, LEVEL_ENUM, Vertex, PackageJSON, App, Page, DataNode, View, Element, ExpressionNode, Logic, genFinalCode, ActionOptions, ACTION_MODE } from '..';
|
|
4
4
|
import { elementService, attributeService, eventService, directiveService } from '../../service/page';
|
|
5
5
|
import * as babel from '@babel/core';
|
|
6
|
-
import { traverse } from '../utils';
|
|
7
|
-
import generate from '@babel/generator';
|
|
8
6
|
import { vertexsMap } from '../cacheData';
|
|
9
|
-
import Variable from '../logic/Variable';
|
|
10
7
|
|
|
11
8
|
/**
|
|
12
9
|
* 前端组件事件
|