eoss 0.1.0-alpha.40 → 0.1.0-alpha.41
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/lib/0.js +1 -1
- package/lib/1.js +1 -1
- package/lib/10.js +1 -1
- package/lib/11.js +1 -1
- package/lib/12.js +1 -1
- package/lib/13.js +1 -1
- package/lib/14.js +1 -1
- package/lib/15.js +1 -1
- package/lib/16.js +1 -1
- package/lib/17.js +1 -1
- package/lib/18.js +1 -1
- package/lib/19.js +1 -1
- package/lib/20.js +1 -1
- package/lib/21.js +1 -1
- package/lib/22.js +1 -1
- package/lib/23.js +1 -1
- package/lib/24.js +1 -1
- package/lib/25.js +1 -1
- package/lib/26.js +1 -1
- package/lib/27.js +1 -1
- package/lib/28.js +1 -1
- package/lib/29.js +1 -1
- package/lib/3.js +1 -1
- package/lib/30.js +1 -1
- package/lib/31.js +1 -1
- package/lib/32.js +1 -1
- package/lib/33.js +1 -1
- package/lib/34.js +1 -1
- package/lib/35.js +1 -1
- package/lib/36.js +1 -1
- package/lib/37.js +1 -1
- package/lib/38.js +1 -1
- package/lib/39.js +1 -1
- package/lib/4.js +1 -1
- package/lib/40.js +1 -1
- package/lib/41.js +1 -1
- package/lib/42.js +1 -1
- package/lib/43.js +1 -1
- package/lib/44.js +1 -1
- package/lib/45.js +1 -1
- package/lib/46.js +1 -1
- package/lib/47.js +1 -1
- package/lib/48.js +1 -1
- package/lib/49.js +1 -1
- package/lib/5.js +1 -1
- package/lib/50.js +1 -1
- package/lib/51.js +1 -1
- package/lib/52.js +1 -1
- package/lib/53.js +1 -1
- package/lib/54.js +1 -1
- package/lib/55.js +1 -1
- package/lib/56.js +1 -1
- package/lib/57.js +1 -1
- package/lib/58.js +1 -1
- package/lib/59.js +1 -1
- package/lib/6.js +1 -1
- package/lib/60.js +1 -1
- package/lib/61.js +1 -1
- package/lib/62.js +1 -1
- package/lib/63.js +1 -1
- package/lib/64.js +1 -1
- package/lib/65.js +1 -1
- package/lib/66.js +1 -1
- package/lib/67.js +1 -1
- package/lib/68.js +1 -1
- package/lib/69.js +1 -1
- package/lib/7.js +1 -1
- package/lib/70.js +1 -1
- package/lib/71.js +1 -1
- package/lib/72.js +1 -1
- package/lib/73.js +1 -1
- package/lib/74.js +1 -1
- package/lib/75.js +1 -1
- package/lib/76.js +1 -1
- package/lib/77.js +1 -1
- package/lib/78.js +1 -1
- package/lib/79.js +1 -1
- package/lib/8.js +1 -1
- package/lib/80.js +1 -1
- package/lib/81.js +1 -1
- package/lib/9.js +1 -1
- package/lib/account-login.js +59 -59
- package/lib/alert.js +2 -2
- package/lib/aside.js +2 -2
- package/lib/audit-trajectory.js +2 -2
- package/lib/autocomplete.js +56 -56
- package/lib/avatar.js +2 -2
- package/lib/backtop.js +6 -6
- package/lib/badge.js +2 -2
- package/lib/breadcrumb-item.js +4 -4
- package/lib/breadcrumb.js +4 -4
- package/lib/button-group.js +4 -4
- package/lib/button.js +2 -2
- package/lib/ca-login.js +37 -37
- package/lib/calendar.js +4 -4
- package/lib/card.js +2 -2
- package/lib/carousel-item.js +36 -36
- package/lib/carousel.js +38 -38
- package/lib/cascader-panel.js +71 -71
- package/lib/cascader.js +220 -220
- package/lib/checkbox-button.js +4 -4
- package/lib/checkbox-group.js +65 -65
- package/lib/checkbox.js +6 -6
- package/lib/code-editor.js +1134 -0
- package/lib/col.js +2 -2
- package/lib/collapse-item.js +76 -76
- package/lib/collapse.js +76 -76
- package/lib/color-picker.js +10 -10
- package/lib/container.js +2 -2
- package/lib/cron.js +20 -20
- package/lib/data-table.js +66 -66
- package/lib/date-picker.js +2419 -2419
- package/lib/descriptions-item.js +4 -4
- package/lib/descriptions.js +4 -4
- package/lib/dialog.js +42 -42
- package/lib/divider.js +2 -2
- package/lib/drawer.js +6 -6
- package/lib/dropdown-item.js +8 -8
- package/lib/dropdown-menu.js +20 -20
- package/lib/dropdown.js +40 -40
- package/lib/email-login.js +64 -64
- package/lib/empty.js +2 -2
- package/lib/eoss.common.js +23730 -5967
- package/lib/flip.js +2 -2
- package/lib/flow-group.js +55 -55
- package/lib/flow.js +171 -171
- package/lib/flows.js +77 -77
- package/lib/footer.js +2 -2
- package/lib/form-editor.js +12534 -0
- package/lib/form-item.js +57 -49
- package/lib/form.js +233 -174
- package/lib/guide.js +2 -2
- package/lib/header.js +2 -2
- package/lib/icon.js +38 -38
- package/lib/icons.js +11 -11
- package/lib/image-viewer.js +38 -38
- package/lib/image.js +6 -6
- package/lib/index.js +1 -1
- package/lib/infinite-scroll.js +4 -4
- package/lib/input-number.js +39 -39
- package/lib/input.js +60 -60
- package/lib/link.js +2 -2
- package/lib/loading.js +6 -6
- package/lib/login.js +193 -193
- package/lib/lowcode-view.js +824 -132
- package/lib/lowcode.js +27278 -16925
- package/lib/main.js +270 -257
- package/lib/marquee.js +38 -38
- package/lib/menu-item-group.js +14 -14
- package/lib/menu-item.js +10 -10
- package/lib/menu.js +129 -129
- package/lib/message-box.js +52 -52
- package/lib/message.js +62 -62
- package/lib/notification.js +40 -40
- package/lib/option-group.js +4 -4
- package/lib/option.js +36 -36
- package/lib/page-header.js +2 -2
- package/lib/pagination.js +37 -37
- package/lib/phone-login.js +58 -58
- package/lib/popconfirm.js +4 -4
- package/lib/popover.js +42 -42
- package/lib/process-config.js +65 -65
- package/lib/process-module.js +62 -62
- package/lib/process-rule.js +66 -66
- package/lib/progress.js +2 -2
- package/lib/qr-code.js +6 -6
- package/lib/qrcode-login.js +57 -57
- package/lib/radio-button.js +4 -4
- package/lib/radio-group.js +63 -63
- package/lib/radio.js +6 -6
- package/lib/rate.js +36 -36
- package/lib/retrial-auth.js +55 -55
- package/lib/row.js +2 -2
- package/lib/scrollbar.js +41 -41
- package/lib/select.js +95 -95
- package/lib/selector-panel.js +92 -91
- package/lib/selector.js +935 -935
- package/lib/slider.js +6 -6
- package/lib/step.js +35 -35
- package/lib/steps.js +82 -82
- package/lib/submenu.js +38 -38
- package/lib/switch.js +38 -38
- package/lib/tab-pane.js +4 -4
- package/lib/table-column.js +39 -39
- package/lib/table.js +653 -653
- package/lib/tabs.js +42 -42
- package/lib/tag.js +2 -2
- package/lib/theme-chalk/code-editor.css +1 -0
- package/lib/theme-chalk/form-editor.css +1 -0
- package/lib/theme-chalk/form.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/theme-chalk/lowcode.css +1 -1
- package/lib/theme-chalk/selector.css +1 -1
- package/lib/time-picker.js +1276 -1276
- package/lib/time-select.js +21 -21
- package/lib/timeline-item.js +2 -2
- package/lib/timeline.js +2 -2
- package/lib/tips.js +59 -59
- package/lib/toolbar.js +6 -6
- package/lib/tooltip.js +44 -44
- package/lib/transfer.js +36 -36
- package/lib/tree-group.js +49 -49
- package/lib/tree.js +432 -432
- package/lib/update-history.js +2 -2
- package/lib/upload.js +942 -942
- package/lib/utils/source-generator.js +586 -0
- package/lib/utils/source-parser.js +581 -0
- package/lib/wujie.js +39 -39
- package/package.json +1 -1
- package/packages/code-editor/index.js +5 -0
- package/packages/{lowcode/src/editor.vue → code-editor/src/code-editor.vue} +14 -17
- package/packages/form/src/form-item-render.vue +25 -0
- package/packages/form/src/form-item.vue +10 -3
- package/packages/form-editor/index.js +5 -0
- package/packages/form-editor/src/components.js +6736 -0
- package/packages/form-editor/src/form-editor.vue +981 -0
- package/packages/form-editor/src/props-panel.vue +168 -0
- package/packages/lowcode/src/attribute/bind.vue +5 -5
- package/packages/lowcode/src/attribute/function.vue +24 -9
- package/packages/lowcode/src/attribute/javascript.vue +4 -4
- package/packages/lowcode/src/attribute/property.vue +1 -1
- package/packages/lowcode/src/attribute/props.vue +44 -29
- package/packages/lowcode/src/attribute/styles.vue +1 -1
- package/packages/lowcode/src/attribute.vue +4 -4
- package/packages/lowcode/src/canvas.vue +45 -100
- package/packages/lowcode/src/form-render.vue +25 -13
- package/packages/lowcode/src/json.vue +4 -4
- package/packages/lowcode/src/lowcode.vue +1 -1
- package/packages/lowcode/src/modules.vue +8 -1
- package/packages/lowcode/src/render.vue +14 -9
- package/packages/lowcode/src/source.vue +6 -6
- package/packages/lowcode/src/util/components.js +15646 -68
- package/packages/lowcode/src/util/form-controls.js +87 -0
- package/packages/lowcode/src/util/props-util.js +9 -8
- package/packages/lowcode-view/src/render.vue +13 -6
- package/packages/lowcode-view/src/view.vue +4 -1
- package/packages/main/src/components/user.vue +2 -0
- package/packages/main/src/components/userinfo.vue +22 -14
- package/packages/selector-panel/src/mixin.js +1 -0
- package/packages/theme-chalk/src/code-editor.scss +59 -0
- package/packages/theme-chalk/src/form-editor.scss +240 -0
- package/packages/theme-chalk/src/form.scss +10 -1
- package/packages/theme-chalk/src/index.scss +2 -0
- package/packages/theme-chalk/src/lowcode.scss +1 -42
- package/packages/theme-chalk/src/selector.scss +2 -0
- package/src/index.js +7 -1
- package/{packages/lowcode/src/util → src/utils}/source-generator.js +24 -15
- package/{packages/lowcode/src/util → src/utils}/source-parser.js +67 -23
- /package/packages/{lowcode → code-editor}/src/util/json-repair.js +0 -0
- /package/packages/{lowcode → code-editor}/src/util/monaco-vue-completions.js +0 -0
package/src/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import CascaderPanel from '../packages/cascader-panel/index.js';
|
|
|
21
21
|
import Checkbox from '../packages/checkbox/index.js';
|
|
22
22
|
import CheckboxButton from '../packages/checkbox-button/index.js';
|
|
23
23
|
import CheckboxGroup from '../packages/checkbox-group/index.js';
|
|
24
|
+
import CodeEditor from '../packages/code-editor/index.js';
|
|
24
25
|
import Col from '../packages/col/index.js';
|
|
25
26
|
import Collapse from '../packages/collapse/index.js';
|
|
26
27
|
import CollapseItem from '../packages/collapse-item/index.js';
|
|
@@ -44,6 +45,7 @@ import Flow from '../packages/flow/index.js';
|
|
|
44
45
|
import Flows from '../packages/flows/index.js';
|
|
45
46
|
import FlowGroup from '../packages/flow-group/index.js';
|
|
46
47
|
import Form from '../packages/form/index.js';
|
|
48
|
+
import FormEditor from '../packages/form-editor/index.js';
|
|
47
49
|
import FormItem from '../packages/form-item/index.js';
|
|
48
50
|
import Footer from '../packages/footer/index.js';
|
|
49
51
|
import Guide from '../packages/guide/index.js';
|
|
@@ -138,6 +140,7 @@ const components = [
|
|
|
138
140
|
Checkbox,
|
|
139
141
|
CheckboxButton,
|
|
140
142
|
CheckboxGroup,
|
|
143
|
+
CodeEditor,
|
|
141
144
|
Col,
|
|
142
145
|
Collapse,
|
|
143
146
|
CollapseItem,
|
|
@@ -161,6 +164,7 @@ const components = [
|
|
|
161
164
|
Flows,
|
|
162
165
|
FlowGroup,
|
|
163
166
|
Form,
|
|
167
|
+
FormEditor,
|
|
164
168
|
FormItem,
|
|
165
169
|
Footer,
|
|
166
170
|
Header,
|
|
@@ -266,7 +270,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
export default {
|
|
269
|
-
version: '0.1.0-alpha.
|
|
273
|
+
version: '0.1.0-alpha.41',
|
|
270
274
|
install,
|
|
271
275
|
CollapseTransition,
|
|
272
276
|
Loading,
|
|
@@ -291,6 +295,7 @@ export default {
|
|
|
291
295
|
Checkbox,
|
|
292
296
|
CheckboxButton,
|
|
293
297
|
CheckboxGroup,
|
|
298
|
+
CodeEditor,
|
|
294
299
|
Col,
|
|
295
300
|
Collapse,
|
|
296
301
|
CollapseItem,
|
|
@@ -314,6 +319,7 @@ export default {
|
|
|
314
319
|
Flows,
|
|
315
320
|
FlowGroup,
|
|
316
321
|
Form,
|
|
322
|
+
FormEditor,
|
|
317
323
|
FormItem,
|
|
318
324
|
Footer,
|
|
319
325
|
Guide,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* 低代码页面 JSON → Vue 单文件源码生成器
|
|
3
3
|
* 将 page 对象(含 children 节点树)转换为可直接运行的 .vue 源码字符串
|
|
4
4
|
*/
|
|
5
|
+
import { isFormControlNode, toPascal } from 'eoss/packages/lowcode/src/util/form-controls.js';
|
|
5
6
|
|
|
6
7
|
const INDENT = ' ';
|
|
7
8
|
|
|
@@ -125,11 +126,16 @@ function genProps(node) {
|
|
|
125
126
|
if (key.startsWith('v-')) {
|
|
126
127
|
return attrs;
|
|
127
128
|
}
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
return attrs + ' :' + key + '="' + val + '"';
|
|
131
|
-
}
|
|
129
|
+
// 字符串:{{var}} 整体匹配输出绑定表达式(与数组形态 genPropAttr 对称);
|
|
130
|
+
// 以 { 或 [ 开头的历史表达式原样绑定;其余按字面量输出
|
|
132
131
|
if (typeof val === 'string') {
|
|
132
|
+
const full = /^\{\{([\s\S]+)\}\}$/.exec(val);
|
|
133
|
+
if (full) {
|
|
134
|
+
return attrs + ' :' + key + '="' + full[1].trim() + '"';
|
|
135
|
+
}
|
|
136
|
+
if (isExpression(val)) {
|
|
137
|
+
return attrs + ' :' + key + '="' + val + '"';
|
|
138
|
+
}
|
|
133
139
|
return attrs + ' ' + key + '="' + val + '"';
|
|
134
140
|
}
|
|
135
141
|
if (typeof val === 'boolean') {
|
|
@@ -260,7 +266,7 @@ export function genNode(node, indent) {
|
|
|
260
266
|
return '';
|
|
261
267
|
}
|
|
262
268
|
const pad = new Array(indent + 1).join(INDENT);
|
|
263
|
-
const tag = tagName(node.
|
|
269
|
+
const tag = tagName(node.nodeName || 'div');
|
|
264
270
|
|
|
265
271
|
// 节点 id 以 data-id 输出,源码编辑后能原样解析回来
|
|
266
272
|
const idAttr = node.id ? ' data-id="' + node.id + '"' : '';
|
|
@@ -286,26 +292,29 @@ export function genNode(node, indent) {
|
|
|
286
292
|
// v-text 属性转换为 {{xxx}} 形式
|
|
287
293
|
lines.push(pad + INDENT + '{{' + vText + '}}');
|
|
288
294
|
}
|
|
289
|
-
//
|
|
290
|
-
//
|
|
295
|
+
// 子节点继续递归下钻;仅 es-form 内的表单控件子节点输出时包 es-form-item
|
|
296
|
+
// (JSON 不存包裹节点,源码与真实应用结构一一对应);es-form 外的控件裸输出
|
|
291
297
|
children.forEach((child) => {
|
|
292
|
-
lines.push(genChildNode(child, indent + 1));
|
|
298
|
+
lines.push(genChildNode(child, indent + 1, node));
|
|
293
299
|
});
|
|
294
300
|
lines.push(pad + '</' + tag + '>');
|
|
295
301
|
return lines.join('\n');
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
/**
|
|
299
|
-
function genChildNode(child, indent) {
|
|
304
|
+
/** 生成子节点:仅 es-form 内的表单控件(form-controls 清单命中)包 es-form-item 包裹层,其余直接生成 */
|
|
305
|
+
function genChildNode(child, indent, parent) {
|
|
300
306
|
if (!child) {
|
|
301
307
|
return '';
|
|
302
308
|
}
|
|
303
|
-
if (
|
|
309
|
+
if (
|
|
310
|
+
!isFormControlNode(child) ||
|
|
311
|
+
toPascal((parent && parent.nodeName) || '') !== 'EsForm'
|
|
312
|
+
) {
|
|
304
313
|
return genNode(child, indent);
|
|
305
314
|
}
|
|
306
315
|
const pad = new Array(indent + 1).join(INDENT);
|
|
307
|
-
const label = child.
|
|
308
|
-
const prop = child.
|
|
316
|
+
const label = child.label || '';
|
|
317
|
+
const prop = child.name || '';
|
|
309
318
|
// 宽度输出在包裹层:form-item 是列布局单元,拖宽占多列才能在真实应用生效;
|
|
310
319
|
// 内层控件不重复携带 width(画布上宽度同样作用于 es-form-item 根)
|
|
311
320
|
const width = child.style && child.style.width;
|
|
@@ -490,13 +499,13 @@ export function generateVueSource(page) {
|
|
|
490
499
|
// 用户编辑的模板,直接使用
|
|
491
500
|
template = page.template + '\n';
|
|
492
501
|
} else {
|
|
493
|
-
// 页面对象本身就是根节点(含 style/children),但它的 name
|
|
502
|
+
// 页面对象本身就是根节点(含 style/children),但它的 name 是页面名不是标签名,
|
|
494
503
|
// 根标签固定为 div;子节点递归下钻,支持 html 元素 / 组件库组件 / 自封装组件
|
|
495
504
|
const root = {};
|
|
496
505
|
Object.keys(page).forEach((key) => {
|
|
497
506
|
root[key] = page[key];
|
|
498
507
|
});
|
|
499
|
-
root.
|
|
508
|
+
root.nodeName = 'div';
|
|
500
509
|
// 子节点
|
|
501
510
|
const children = Array.isArray(page.children) ? page.children : [];
|
|
502
511
|
// 过滤掉旧格式的导入注册数据(含 path 字段的对象)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Vue 单文件源码 → 低代码页面 JSON 解析器
|
|
3
3
|
* generateVueSource 的反向操作:源码解析失败会抛出带中文说明的 Error
|
|
4
4
|
*/
|
|
5
|
+
import { isFormControlNode, buildFieldKey, toPascal } from 'eoss/packages/lowcode/src/util/form-controls.js';
|
|
5
6
|
|
|
6
7
|
const VOID_TAGS = ['img', 'input', 'br', 'hr', 'meta', 'link'];
|
|
7
8
|
|
|
@@ -76,18 +77,20 @@ function parseAttrs(str) {
|
|
|
76
77
|
return attrs;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
/** 写入
|
|
80
|
+
/** 写入 prop 取值(props 为取值对象,同名覆盖);
|
|
81
|
+
* 历史定义数组形态先转为取值对象(仅承继改动条目) */
|
|
80
82
|
function pushProp(node, name, type, value) {
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
+
if (Array.isArray(node.props)) {
|
|
84
|
+
const obj = {};
|
|
85
|
+
node.props.forEach((p) => {
|
|
86
|
+
if (p && p.name && p.value !== undefined) obj[p.name] = p.value;
|
|
87
|
+
});
|
|
88
|
+
node.props = obj;
|
|
83
89
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
found.type = type;
|
|
87
|
-
found.value = value;
|
|
88
|
-
return;
|
|
90
|
+
if (!node.props || typeof node.props !== 'object') {
|
|
91
|
+
node.props = {};
|
|
89
92
|
}
|
|
90
|
-
node.props
|
|
93
|
+
node.props[name] = value;
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/** 属性列表 → 节点字段(attrs / props / directives / events / style) */
|
|
@@ -156,8 +159,11 @@ function applyAttrs(node, attrs) {
|
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
/**
|
|
159
|
-
*
|
|
160
|
-
*
|
|
162
|
+
* 兼容历史数据(原地递归处理整棵节点树):
|
|
163
|
+
* 1. 把节点 props 中残留的 v- 指令迁移到 directives(早期版本曾把指令存入 props),
|
|
164
|
+
* 迁移后键不含 v- 前缀;
|
|
165
|
+
* 2. 把历史定义数组形态 props 转为取值对象(仅承继改动条目),
|
|
166
|
+
* 无改动取值则删除 props 字段,保持 JSON 精简
|
|
161
167
|
* @param {Object} node 节点或页面对象
|
|
162
168
|
* @returns {Object} 同一个节点对象
|
|
163
169
|
*/
|
|
@@ -177,8 +183,42 @@ export function migrateDirectives(node) {
|
|
|
177
183
|
}
|
|
178
184
|
});
|
|
179
185
|
}
|
|
186
|
+
if (Array.isArray(node.props)) {
|
|
187
|
+
const obj = {};
|
|
188
|
+
node.props.forEach((p) => {
|
|
189
|
+
if (p && p.name && p.value !== undefined) obj[p.name] = p.value;
|
|
190
|
+
});
|
|
191
|
+
if (Object.keys(obj).length) {
|
|
192
|
+
node.props = obj;
|
|
193
|
+
} else {
|
|
194
|
+
delete node.props;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// 历史节点结构字段 name(组件/标签名)改名为 nodeName,
|
|
198
|
+
// 避免与组件 name prop 同名冲突;doc 字段不再入库
|
|
199
|
+
if (node.type !== 'page' && node.name && !node.nodeName) {
|
|
200
|
+
node.nodeName = node.name;
|
|
201
|
+
delete node.name;
|
|
202
|
+
}
|
|
203
|
+
delete node.doc;
|
|
204
|
+
// 历史 formItem 包裹对象 → 拍平到节点:label 与字段键 name 直接挂节点
|
|
205
|
+
// (须在 name→nodeName 迁移之后,字段键才能落回 name)
|
|
206
|
+
if (node.formItem) {
|
|
207
|
+
if (node.label === undefined) node.label = node.formItem.label || '';
|
|
208
|
+
if (node.name === undefined) node.name = node.formItem.prop || '';
|
|
209
|
+
delete node.formItem;
|
|
210
|
+
}
|
|
180
211
|
if (node.children && node.children.length) {
|
|
181
212
|
node.children.forEach((child) => migrateDirectives(child));
|
|
213
|
+
// 孤儿表单控件(直接挂 page/div 下、或历史源码里的裸控件子节点):
|
|
214
|
+
// 子节点迁移完成(nodeName 就位)后补 label 与字段键 name,使 form-render
|
|
215
|
+
// 与源码生成统一包 es-form-item(与 canvas 拖入口径一致)
|
|
216
|
+
node.children.forEach((child) => {
|
|
217
|
+
if (child && child.name === undefined && isFormControlNode(child)) {
|
|
218
|
+
if (child.label === undefined) child.label = child.description || '';
|
|
219
|
+
child.name = buildFieldKey(node.children, toPascal(child.nodeName));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
182
222
|
}
|
|
183
223
|
return node;
|
|
184
224
|
}
|
|
@@ -218,15 +258,15 @@ export function parseTemplateNodes(inner) {
|
|
|
218
258
|
// 闭标签
|
|
219
259
|
const closing = match[1];
|
|
220
260
|
const top = stack[stack.length - 1];
|
|
221
|
-
if (!top || top.
|
|
261
|
+
if (!top || top.nodeName !== closing) {
|
|
222
262
|
throw new Error('标签未正确闭合:</' + closing + '>');
|
|
223
263
|
}
|
|
224
264
|
stack.pop();
|
|
225
265
|
continue;
|
|
226
266
|
}
|
|
227
|
-
//
|
|
267
|
+
// 开标签(结构字段 nodeName 存标签/组件名,避免与组件 name prop 冲突)
|
|
228
268
|
const node = {
|
|
229
|
-
|
|
269
|
+
nodeName: match[2],
|
|
230
270
|
id: '',
|
|
231
271
|
description: ''
|
|
232
272
|
};
|
|
@@ -244,15 +284,15 @@ export function parseTemplateNodes(inner) {
|
|
|
244
284
|
}
|
|
245
285
|
}
|
|
246
286
|
if (stack.length) {
|
|
247
|
-
throw new Error('标签未正确闭合:<' + stack[stack.length - 1].
|
|
287
|
+
throw new Error('标签未正确闭合:<' + stack[stack.length - 1].nodeName + '>');
|
|
248
288
|
}
|
|
249
289
|
normalizeFormItems(roots);
|
|
250
290
|
return roots;
|
|
251
291
|
}
|
|
252
292
|
|
|
253
293
|
/**
|
|
254
|
-
* es-form-item 包裹结构 → 控件节点 +
|
|
255
|
-
* JSON 不存包裹节点,label
|
|
294
|
+
* es-form-item 包裹结构 → 控件节点 + label/字段键 name(genChildNode 的逆操作):
|
|
295
|
+
* JSON 不存包裹节点,label 与字段键 name 直接记在控件节点上,
|
|
256
296
|
* 画布由 form-render 渲染时重新生成包裹层;原地递归处理整棵节点树
|
|
257
297
|
* @param {Array} nodes 节点数组
|
|
258
298
|
* @returns {Array} 同一个节点数组
|
|
@@ -264,23 +304,23 @@ export function normalizeFormItems(nodes) {
|
|
|
264
304
|
}
|
|
265
305
|
node.children = node.children.map((child) => {
|
|
266
306
|
if (
|
|
267
|
-
child.
|
|
307
|
+
child.nodeName === 'es-form-item' &&
|
|
268
308
|
child.children &&
|
|
269
309
|
child.children.length === 1
|
|
270
310
|
) {
|
|
271
311
|
const inner = child.children[0];
|
|
272
312
|
const meta = { ...(child.attrs || {}), ...(child.props || {}) };
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
313
|
+
// 解析端属性值可能带前导空格(属性切分产物),回填前 trim
|
|
314
|
+
inner.label =
|
|
315
|
+
meta.label !== undefined ? String(meta.label).trim() : '';
|
|
316
|
+
inner.name = meta.prop !== undefined ? String(meta.prop).trim() : '';
|
|
277
317
|
// 包裹层宽度还原到控件节点 style.width(画布上作用于 es-form-item 根,
|
|
278
318
|
// 与 genChildNode 输出位置互逆)
|
|
279
319
|
if (child.style && child.style.width) {
|
|
280
320
|
inner.style = { ...(inner.style || {}), width: child.style.width };
|
|
281
321
|
}
|
|
282
322
|
if (!inner.description) {
|
|
283
|
-
inner.description = inner.
|
|
323
|
+
inner.description = inner.label;
|
|
284
324
|
}
|
|
285
325
|
return inner;
|
|
286
326
|
}
|
|
@@ -395,6 +435,10 @@ function extractOption(script, name) {
|
|
|
395
435
|
}
|
|
396
436
|
if (next) {
|
|
397
437
|
keyRe.lastIndex = next.index;
|
|
438
|
+
} else {
|
|
439
|
+
// 探到末键后 exec 失败会把 lastIndex 复位 0,外层 while 会从头再匹配
|
|
440
|
+
// 同一批键形成死循环;显式移到末尾让循环正常结束
|
|
441
|
+
keyRe.lastIndex = blockText.length;
|
|
398
442
|
}
|
|
399
443
|
}
|
|
400
444
|
}
|
|
File without changes
|
|
File without changes
|