@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
|
@@ -25,8 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.Element = void 0;
|
|
29
|
-
// import stringify = require('json-stringify-safe');
|
|
28
|
+
exports.Element = exports.catchFn = void 0;
|
|
30
29
|
const decorators_1 = require("../decorators");
|
|
31
30
|
const __1 = require("..");
|
|
32
31
|
const compiler = __importStar(require("vue-template-compiler"));
|
|
@@ -34,8 +33,20 @@ const json5 = __importStar(require("json5"));
|
|
|
34
33
|
const page_1 = require("../../service/page");
|
|
35
34
|
const cacheData_1 = require("../cacheData");
|
|
36
35
|
const babelParser = __importStar(require("@babel/parser"));
|
|
37
|
-
const utils_1 = require("../utils");
|
|
38
36
|
const lodash_1 = require("lodash");
|
|
37
|
+
const cache_1 = require("../cache");
|
|
38
|
+
const enum_1 = require("../enum");
|
|
39
|
+
function catchFn(view) {
|
|
40
|
+
return async (err) => {
|
|
41
|
+
if (err.code !== enum_1.BusinessCode.HasReferenced) // 节点被引用,不用刷新数据
|
|
42
|
+
await cache_1.refreshHtml(view);
|
|
43
|
+
else
|
|
44
|
+
__1.config.defaultApp?.emit('saved', err);
|
|
45
|
+
__1.config.defaultApp?.history.load();
|
|
46
|
+
throw err;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
exports.catchFn = catchFn;
|
|
39
50
|
/**
|
|
40
51
|
* 前端页面元素
|
|
41
52
|
* @example
|
|
@@ -70,6 +81,10 @@ class Element extends __1.Vertex {
|
|
|
70
81
|
* Vue 中的 ref
|
|
71
82
|
*/
|
|
72
83
|
this.name = undefined;
|
|
84
|
+
/*
|
|
85
|
+
* 描述信息
|
|
86
|
+
*/
|
|
87
|
+
this.description = undefined;
|
|
73
88
|
/**
|
|
74
89
|
* 属性列表
|
|
75
90
|
* 和原来的 attrsList 不同,注意区分
|
|
@@ -134,9 +149,6 @@ class Element extends __1.Vertex {
|
|
|
134
149
|
*/
|
|
135
150
|
this.children = [];
|
|
136
151
|
source && this.assign(source);
|
|
137
|
-
// 为了给生成的节点使用
|
|
138
|
-
// !this.id && this.assign({ id: uuidv4() });
|
|
139
|
-
// this.assign({ id: 'temp-' + uuidv4() });
|
|
140
152
|
}
|
|
141
153
|
assign(source) {
|
|
142
154
|
['attrList', 'eventList', 'directiveList', 'children'].forEach((key) => {
|
|
@@ -154,59 +166,42 @@ class Element extends __1.Vertex {
|
|
|
154
166
|
return this;
|
|
155
167
|
}
|
|
156
168
|
__1.config.defaultApp?.emit('saving');
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
appId: __1.config.defaultApp?.id,
|
|
166
|
-
operationAction: 'Element.create',
|
|
167
|
-
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
168
|
-
},
|
|
169
|
-
body,
|
|
170
|
-
});
|
|
171
|
-
// Nuims createResource
|
|
172
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
173
|
-
// 暂时只增不减
|
|
174
|
-
// new Nuims({
|
|
175
|
-
// domainName: this.view.page.service.app.name,
|
|
176
|
-
// element: this,
|
|
177
|
-
// }).createResource();
|
|
178
|
-
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
179
|
-
// attr,directive,event的id,exprssion需要合并
|
|
180
|
-
this.attrList.forEach((attr, index) => {
|
|
181
|
-
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
182
|
-
});
|
|
183
|
-
this.directiveList.forEach((directive, index) => {
|
|
184
|
-
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
185
|
-
});
|
|
186
|
-
this.eventList.forEach((event, index) => {
|
|
187
|
-
event.deepPick(result.eventList[index], ['id']);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
this.view && this.view.emit('change');
|
|
191
|
-
if (actionOptions?.loadHistory !== false) {
|
|
192
|
-
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
169
|
+
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
170
|
+
const body = this.toJSON();
|
|
171
|
+
body.parentId = this.parent && this.parent.id;
|
|
172
|
+
body._posIndex = this.parent && this.parent.children.indexOf(this);
|
|
173
|
+
__1.utils.logger.debug('添加元素', body);
|
|
174
|
+
const result = await page_1.elementService.create({
|
|
175
|
+
headers: {
|
|
176
|
+
appId: __1.config.defaultApp?.id,
|
|
193
177
|
operationAction: 'Element.create',
|
|
194
|
-
operationBeforeImage: null,
|
|
195
|
-
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
196
178
|
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
|
|
179
|
+
},
|
|
180
|
+
body,
|
|
181
|
+
}).catch(catchFn(this.view));
|
|
182
|
+
this.deepPick(result, ['id', 'parentId', 'elementId']);
|
|
183
|
+
// attr,directive,event的id,expression需要合并
|
|
184
|
+
this.attrList.forEach((attr, index) => {
|
|
185
|
+
attr.deepPick(result.attrList[index], ['id', 'expression']);
|
|
186
|
+
});
|
|
187
|
+
this.directiveList.forEach((directive, index) => {
|
|
188
|
+
directive.deepPick(result.directiveList[index], ['id', 'expression']);
|
|
189
|
+
});
|
|
190
|
+
this.eventList.forEach((event, index) => {
|
|
191
|
+
event.deepPick(result.eventList[index], ['id']);
|
|
192
|
+
});
|
|
201
193
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
194
|
+
this.view && this.view.emit('change');
|
|
195
|
+
if (actionOptions?.loadHistory !== false) {
|
|
196
|
+
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
197
|
+
operationAction: 'Element.create',
|
|
198
|
+
operationBeforeImage: null,
|
|
199
|
+
operationAfterImage: JSON.parse(JSON.stringify(this)),
|
|
200
|
+
operationDesc: `添加组件"${this.getElementTitle()}"`,
|
|
201
|
+
});
|
|
202
|
+
__1.config.defaultApp?.emit('saved');
|
|
209
203
|
}
|
|
204
|
+
return this;
|
|
210
205
|
}
|
|
211
206
|
/**
|
|
212
207
|
* 删除元素
|
|
@@ -215,6 +210,7 @@ class Element extends __1.Vertex {
|
|
|
215
210
|
if (actionOptions?.actionMode === __1.ACTION_MODE.local) {
|
|
216
211
|
const index = this.parent.children.indexOf(this);
|
|
217
212
|
~index && this.parent.children.splice(index, 1);
|
|
213
|
+
this.deepRemoveElementsName();
|
|
218
214
|
this.view && this.view.emit('local-change');
|
|
219
215
|
return this;
|
|
220
216
|
}
|
|
@@ -223,33 +219,22 @@ class Element extends __1.Vertex {
|
|
|
223
219
|
throw Error('该元素为根节点!');
|
|
224
220
|
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
225
221
|
if (this.id) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
catch (err) {
|
|
239
|
-
await __1.config.defaultApp?.history.load();
|
|
240
|
-
throw err;
|
|
241
|
-
}
|
|
242
|
-
// Nuims deleteResource
|
|
243
|
-
// Element 对应资源增删在 undo/redo 情况下可能存在权限丢失的情况
|
|
244
|
-
// 暂时只增不减
|
|
245
|
-
// new Nuims({
|
|
246
|
-
// domainName: this.view.page.service.app.name,
|
|
247
|
-
// element: this,
|
|
248
|
-
// }).deleteResources();
|
|
222
|
+
await page_1.elementService.delete({
|
|
223
|
+
headers: {
|
|
224
|
+
appId: __1.config.defaultApp?.id,
|
|
225
|
+
operationAction: 'Element.delete',
|
|
226
|
+
operationDesc: `删除组件"${this.getElementTitle()}"`,
|
|
227
|
+
},
|
|
228
|
+
query: {
|
|
229
|
+
id: this.id,
|
|
230
|
+
},
|
|
231
|
+
}).catch(catchFn(this.view));
|
|
249
232
|
}
|
|
250
233
|
}
|
|
251
234
|
const index = this.parent.children.indexOf(this);
|
|
252
235
|
~index && this.parent.children.splice(index, 1);
|
|
236
|
+
// 递归删除组件名的缓存
|
|
237
|
+
this.deepRemoveElementsName();
|
|
253
238
|
this.destroy();
|
|
254
239
|
this.view && this.view.emit('change');
|
|
255
240
|
if (actionOptions?.loadHistory !== false) {
|
|
@@ -268,37 +253,45 @@ class Element extends __1.Vertex {
|
|
|
268
253
|
async update(source, actionOptions) {
|
|
269
254
|
__1.config.defaultApp?.emit('saving');
|
|
270
255
|
source && this.assign(source);
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
this.view && this.view.emit('change');
|
|
285
|
-
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
286
|
-
operationAction: 'Element.update',
|
|
287
|
-
operationBeforeImage: null,
|
|
288
|
-
operationAfterImage: null,
|
|
289
|
-
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
290
|
-
});
|
|
291
|
-
__1.config.defaultApp?.emit('saved');
|
|
292
|
-
return this;
|
|
293
|
-
}
|
|
294
|
-
catch (err) {
|
|
295
|
-
if (this.view) {
|
|
296
|
-
await this.view.load();
|
|
297
|
-
this.view.emit('change');
|
|
298
|
-
__1.config.defaultApp?.emit('saved');
|
|
299
|
-
}
|
|
300
|
-
throw err;
|
|
256
|
+
if (actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo) {
|
|
257
|
+
const body = this.toPlainJSON();
|
|
258
|
+
__1.utils.logger.debug('修改组件', body);
|
|
259
|
+
await page_1.elementService.update({
|
|
260
|
+
headers: {
|
|
261
|
+
appId: __1.config.defaultApp?.id,
|
|
262
|
+
operationAction: actionOptions?.actionName || 'Element.update',
|
|
263
|
+
operationDesc: actionOptions?.actionDesc || `修改组件"${this.getElementTitle()}"`,
|
|
264
|
+
},
|
|
265
|
+
body,
|
|
266
|
+
}).catch(catchFn(this.view));
|
|
301
267
|
}
|
|
268
|
+
this.view && this.view.emit('change');
|
|
269
|
+
await __1.config.defaultApp?.history.load(actionOptions?.actionMode !== __1.ACTION_MODE.undoRedo && {
|
|
270
|
+
operationAction: 'Element.update',
|
|
271
|
+
operationBeforeImage: null,
|
|
272
|
+
operationAfterImage: null,
|
|
273
|
+
operationDesc: `修改组件"${this.getElementTitle()}"`,
|
|
274
|
+
});
|
|
275
|
+
__1.config.defaultApp?.emit('saved');
|
|
276
|
+
return this;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* 按当前 id 加载逻辑数据
|
|
280
|
+
*/
|
|
281
|
+
async load() {
|
|
282
|
+
if (!this.id)
|
|
283
|
+
return;
|
|
284
|
+
const result = await page_1.elementService.load({
|
|
285
|
+
headers: {
|
|
286
|
+
appId: __1.config.defaultApp?.id,
|
|
287
|
+
},
|
|
288
|
+
query: {
|
|
289
|
+
id: this.id,
|
|
290
|
+
},
|
|
291
|
+
config: { noErrorTip: true },
|
|
292
|
+
});
|
|
293
|
+
const newElement = Element.from(result, this.parent, this.view);
|
|
294
|
+
this.assign(newElement);
|
|
302
295
|
}
|
|
303
296
|
async move(options, actionOptions) {
|
|
304
297
|
try {
|
|
@@ -327,12 +320,17 @@ class Element extends __1.Vertex {
|
|
|
327
320
|
await __1.config.defaultApp?.history.load();
|
|
328
321
|
}
|
|
329
322
|
__1.config.defaultApp?.emit('element.moved');
|
|
323
|
+
__1.config.defaultApp?.emit('saved');
|
|
330
324
|
}
|
|
331
325
|
catch (err) {
|
|
332
326
|
if (this.view) {
|
|
333
327
|
await this.view.load();
|
|
334
328
|
this.view.emit('change');
|
|
335
329
|
}
|
|
330
|
+
__1.config.defaultApp?.emit('saved', {
|
|
331
|
+
action: 'move',
|
|
332
|
+
err,
|
|
333
|
+
});
|
|
336
334
|
throw err;
|
|
337
335
|
}
|
|
338
336
|
}
|
|
@@ -344,6 +342,8 @@ class Element extends __1.Vertex {
|
|
|
344
342
|
const code = this.toVue();
|
|
345
343
|
const index = this.parent.children.indexOf(this);
|
|
346
344
|
const newNode = Element.fromHTML(code, this.parent, this.view);
|
|
345
|
+
// 复制的元素需重新命名
|
|
346
|
+
newNode.deepRenameElements();
|
|
347
347
|
const mergeExpression = (originList, newList) => {
|
|
348
348
|
newList.forEach((item) => {
|
|
349
349
|
const originItem = originList.find((originItem) => originItem.name === item.name);
|
|
@@ -394,11 +394,11 @@ class Element extends __1.Vertex {
|
|
|
394
394
|
}
|
|
395
395
|
};
|
|
396
396
|
const arrayComp = this.findElementsByTag('u-modal');
|
|
397
|
-
const existingNames = Object.values(lodash_1.mapValues(arrayComp,
|
|
397
|
+
const existingNames = Object.values(lodash_1.mapValues(arrayComp, (o) => o.name));
|
|
398
398
|
// 处理弹窗组件的命名问题
|
|
399
399
|
if (newNode.tag === 'u-modal') {
|
|
400
400
|
Object.assign(newNode, {
|
|
401
|
-
name:
|
|
401
|
+
name: __1.utils.unique('saveModal1', existingNames),
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
traverseMergeNode(this, newNode);
|
|
@@ -456,11 +456,27 @@ class Element extends __1.Vertex {
|
|
|
456
456
|
await this.update(undefined, {
|
|
457
457
|
actionDesc: `设置组件"${this.getElementTitle()}"的名称为"${name}"`,
|
|
458
458
|
});
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
459
|
+
if (!window.globalData.hasUserCenter) {
|
|
460
|
+
// 同步权限
|
|
461
|
+
new __1.Nuims({
|
|
462
|
+
domainName: this.view.page.service.app.name,
|
|
463
|
+
element: this,
|
|
464
|
+
}).editResourceFromResourceValue(oldName ? `${this.view.tempPath}/${oldName}` : null);
|
|
465
|
+
}
|
|
466
|
+
this.view && this.view.emit('change');
|
|
467
|
+
if (this.view && this.view.page && this.view.page.service) {
|
|
468
|
+
this.view.page.service.emit('vertexIdToNameChange', this.id, this.name);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* 更新描述信息
|
|
473
|
+
* @param description
|
|
474
|
+
*/
|
|
475
|
+
async setDescription(description) {
|
|
476
|
+
this.assign({ description });
|
|
477
|
+
await this.update(undefined, {
|
|
478
|
+
actionDesc: `设置组件"${this.getElementTitle()}"的描述为"${description}"`,
|
|
479
|
+
});
|
|
464
480
|
this.view && this.view.emit('change');
|
|
465
481
|
if (this.view && this.view.page && this.view.page.service) {
|
|
466
482
|
this.view.page.service.emit('vertexIdToNameChange', this.id, this.name);
|
|
@@ -503,9 +519,7 @@ class Element extends __1.Vertex {
|
|
|
503
519
|
async setAttr(name, type, value) {
|
|
504
520
|
let attr = this.getAttr(name);
|
|
505
521
|
//
|
|
506
|
-
if (value
|
|
507
|
-
}
|
|
508
|
-
else {
|
|
522
|
+
if (value !== undefined) {
|
|
509
523
|
if (typeof value !== 'string')
|
|
510
524
|
value = JSON.stringify(value);
|
|
511
525
|
if (attr) {
|
|
@@ -515,7 +529,7 @@ class Element extends __1.Vertex {
|
|
|
515
529
|
});
|
|
516
530
|
await attr.update(undefined, {
|
|
517
531
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
518
|
-
});
|
|
532
|
+
}).catch(catchFn(this.view));
|
|
519
533
|
}
|
|
520
534
|
else {
|
|
521
535
|
attr = __1.Attr.from({
|
|
@@ -526,7 +540,7 @@ class Element extends __1.Vertex {
|
|
|
526
540
|
}, this);
|
|
527
541
|
await attr.create(undefined, {
|
|
528
542
|
actionDesc: `设置组件"${this.getElementTitle()}"属性"${attr.name}"的值为"${attr.value}"`,
|
|
529
|
-
});
|
|
543
|
+
}).catch(catchFn(this.view));
|
|
530
544
|
this.attrList.push(attr);
|
|
531
545
|
}
|
|
532
546
|
}
|
|
@@ -540,7 +554,7 @@ class Element extends __1.Vertex {
|
|
|
540
554
|
let event = new __1.Event(data);
|
|
541
555
|
await event.create(undefined, Object.assign({
|
|
542
556
|
actionDesc: `添加组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
543
|
-
}, actionOptions));
|
|
557
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
544
558
|
event = __1.Event.from(event, this);
|
|
545
559
|
this.eventList.push(event);
|
|
546
560
|
this.view && this.view.emit('change');
|
|
@@ -558,7 +572,7 @@ class Element extends __1.Vertex {
|
|
|
558
572
|
event = this.eventList.find((item) => item.id === event.id);
|
|
559
573
|
await event.delete(undefined, Object.assign({
|
|
560
574
|
actionDesc: `删除组件"${this.getElementTitle()}"事件"${event.name}"`,
|
|
561
|
-
}, actionOptions));
|
|
575
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
562
576
|
const index = this.eventList.indexOf(event);
|
|
563
577
|
~index && this.eventList.splice(index, 1);
|
|
564
578
|
this.view && this.view.emit('change');
|
|
@@ -573,7 +587,7 @@ class Element extends __1.Vertex {
|
|
|
573
587
|
const directive = new __1.Directive(data);
|
|
574
588
|
await directive.create(undefined, Object.assign({
|
|
575
589
|
actionDesc: `添加组件"${this.getElementTitle()}"指令"${directive.name}"`,
|
|
576
|
-
}, actionOptions));
|
|
590
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
577
591
|
this.directiveList.push(__1.Directive.from(directive, this));
|
|
578
592
|
this.view && this.view.emit('change');
|
|
579
593
|
}
|
|
@@ -587,7 +601,7 @@ class Element extends __1.Vertex {
|
|
|
587
601
|
directive = this.directiveList.find((item) => item.id === directive.id);
|
|
588
602
|
await directive.delete(undefined, Object.assign({
|
|
589
603
|
actionDesc: `删除组件"${this.getElementTitle()}"属性"${directive.name}"`,
|
|
590
|
-
}, actionOptions));
|
|
604
|
+
}, actionOptions)).catch(catchFn(this.view));
|
|
591
605
|
const index = this.directiveList.indexOf(directive);
|
|
592
606
|
~index && this.directiveList.splice(index, 1);
|
|
593
607
|
this.view && this.view.emit('change');
|
|
@@ -661,8 +675,11 @@ class Element extends __1.Vertex {
|
|
|
661
675
|
if (attr.level === __1.LEVEL_ENUM.attr) {
|
|
662
676
|
const api = __1.config.allNodesAPI[el.tag];
|
|
663
677
|
const apiOfAttr = api && api.attrs && api.attrs.find((_attr) => _attr.name === attr.name);
|
|
664
|
-
if (apiOfAttr && apiOfAttr['designer-value']) {
|
|
665
|
-
|
|
678
|
+
if (apiOfAttr && apiOfAttr['designer-value'] !== undefined) {
|
|
679
|
+
let designerValue = apiOfAttr['designer-value'];
|
|
680
|
+
if (typeof designerValue === 'string') {
|
|
681
|
+
designerValue = designerValue.replace(/"/g, '\'');
|
|
682
|
+
}
|
|
666
683
|
try {
|
|
667
684
|
json5.parse(designerValue);
|
|
668
685
|
return `:${attr.name}="${designerValue}"`;
|
|
@@ -771,6 +788,40 @@ class Element extends __1.Vertex {
|
|
|
771
788
|
}
|
|
772
789
|
}
|
|
773
790
|
}
|
|
791
|
+
// 初始化组件名
|
|
792
|
+
initElementName() {
|
|
793
|
+
if (Element.ignoreTag.includes(this.tag)) {
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
const name = this.genElementName();
|
|
797
|
+
this.assign({ name });
|
|
798
|
+
this.view.addElementName(name);
|
|
799
|
+
}
|
|
800
|
+
// 生成新的组件名
|
|
801
|
+
genElementName() {
|
|
802
|
+
const compNameSet = this.view.elementNameSet;
|
|
803
|
+
const tagName = this.tag.replace(Element.TAG_NAME_PREFIX_REG, '').replace(/-/g, '_');
|
|
804
|
+
const componentName = __1.utils.unique(tagName + '1', compNameSet);
|
|
805
|
+
return componentName;
|
|
806
|
+
}
|
|
807
|
+
// 递归生成组件名
|
|
808
|
+
deepRenameElements() {
|
|
809
|
+
return this.traverseChildren((ele) => {
|
|
810
|
+
ele.initElementName();
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
// 递归删除组件名的缓存
|
|
814
|
+
deepRemoveElementsName() {
|
|
815
|
+
return this.traverseChildren((ele) => {
|
|
816
|
+
this.view.removeElementName(ele.name);
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
// 递归遍历组件
|
|
820
|
+
traverseChildren(cb) {
|
|
821
|
+
__1.utils.traverse((current) => {
|
|
822
|
+
cb(current.node);
|
|
823
|
+
}, { node: this });
|
|
824
|
+
}
|
|
774
825
|
/**
|
|
775
826
|
* 从 Vue 的 ASTNode 转换成 ASL 元素
|
|
776
827
|
* @param astNode Vue 的 ASTNode
|
|
@@ -812,8 +863,6 @@ class Element extends __1.Vertex {
|
|
|
812
863
|
astNode.tag = 'u-router-view';
|
|
813
864
|
}
|
|
814
865
|
}
|
|
815
|
-
// if (astNode.tag === 'template')
|
|
816
|
-
// astNode.tag = 'div';
|
|
817
866
|
element = new Element({
|
|
818
867
|
tag: astNode.tag,
|
|
819
868
|
name: astNode.attrsMap.ref,
|
|
@@ -855,7 +904,6 @@ class Element extends __1.Vertex {
|
|
|
855
904
|
}
|
|
856
905
|
}
|
|
857
906
|
element.attrList.push(attr);
|
|
858
|
-
// element.attrMap[attr.name] = attr;
|
|
859
907
|
});
|
|
860
908
|
// compiler 处理:value.sync 时会加上update:value事件,需要过滤
|
|
861
909
|
astNode.events && Object.keys(astNode.events).filter((name) => !name.startsWith('update:')).forEach((name) => {
|
|
@@ -866,10 +914,6 @@ class Element extends __1.Vertex {
|
|
|
866
914
|
value,
|
|
867
915
|
logicId: value[0] === '$' ? undefined : value,
|
|
868
916
|
}, element));
|
|
869
|
-
// element.eventMap[name] = new Event({
|
|
870
|
-
// name,
|
|
871
|
-
// value: oldEvent.value,
|
|
872
|
-
// });
|
|
873
917
|
});
|
|
874
918
|
astNode.directives && astNode.directives.forEach((directive) => {
|
|
875
919
|
if (directive.name === 'model') {
|
|
@@ -896,7 +940,6 @@ class Element extends __1.Vertex {
|
|
|
896
940
|
arg: directive.arg,
|
|
897
941
|
modifiers: directive.modifiers,
|
|
898
942
|
}, element));
|
|
899
|
-
// element.directiveMap[directive.name] = );
|
|
900
943
|
}
|
|
901
944
|
});
|
|
902
945
|
if (astNode.if) {
|
|
@@ -1237,6 +1280,10 @@ class Element extends __1.Vertex {
|
|
|
1237
1280
|
const element = this.parse(html, context);
|
|
1238
1281
|
__1.utils.traverse((current) => {
|
|
1239
1282
|
current.node.assign({ view, parent: current.parent });
|
|
1283
|
+
// 生成唯一组件名 依赖element.view
|
|
1284
|
+
if (!current.node.name) {
|
|
1285
|
+
current.node.initElementName();
|
|
1286
|
+
}
|
|
1240
1287
|
}, { node: element, parent });
|
|
1241
1288
|
return element;
|
|
1242
1289
|
}
|
|
@@ -1257,6 +1304,14 @@ class Element extends __1.Vertex {
|
|
|
1257
1304
|
return element;
|
|
1258
1305
|
}
|
|
1259
1306
|
}
|
|
1307
|
+
/**
|
|
1308
|
+
* 标签名前缀
|
|
1309
|
+
*/
|
|
1310
|
+
Element.TAG_NAME_PREFIX_REG = /^([lieu]|van)[-_]/;
|
|
1311
|
+
/**
|
|
1312
|
+
* 忽略命名的标签
|
|
1313
|
+
*/
|
|
1314
|
+
Element.ignoreTag = ['div', 'span'];
|
|
1260
1315
|
__decorate([
|
|
1261
1316
|
decorators_1.immutable()
|
|
1262
1317
|
], Element.prototype, "level", void 0);
|
|
@@ -1272,6 +1327,9 @@ __decorate([
|
|
|
1272
1327
|
__decorate([
|
|
1273
1328
|
decorators_1.immutable()
|
|
1274
1329
|
], Element.prototype, "name", void 0);
|
|
1330
|
+
__decorate([
|
|
1331
|
+
decorators_1.immutable()
|
|
1332
|
+
], Element.prototype, "description", void 0);
|
|
1275
1333
|
__decorate([
|
|
1276
1334
|
decorators_1.immutable()
|
|
1277
1335
|
], Element.prototype, "attrList", void 0);
|
|
@@ -1349,6 +1407,12 @@ __decorate([
|
|
|
1349
1407
|
__decorate([
|
|
1350
1408
|
decorators_1.action('删除组件指令')
|
|
1351
1409
|
], Element.prototype, "deleteDirective", null);
|
|
1410
|
+
__decorate([
|
|
1411
|
+
decorators_1.immutable()
|
|
1412
|
+
], Element, "TAG_NAME_PREFIX_REG", void 0);
|
|
1413
|
+
__decorate([
|
|
1414
|
+
decorators_1.immutable()
|
|
1415
|
+
], Element, "ignoreTag", void 0);
|
|
1352
1416
|
exports.Element = Element;
|
|
1353
1417
|
exports.default = Element;
|
|
1354
1418
|
//# sourceMappingURL=Element.js.map
|