vue2-client 1.8.195 → 1.8.197
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/docs/lowcode.md +161 -0
- package/package.json +1 -1
- package/src/base-client/components/common/LowCodePageRender/LowCodePageRender.vue +1 -1
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +17 -3
- package/src/base-client/components/common/XForm/XFormItem.vue +45 -29
- package/src/base-client/components/common/XFormTable/XFormTable.vue +3 -0
- package/src/base-client/components/common/XFormTable/lowcodeEditorRegister.js +1 -1
- package/src/base-client/components/common/XTreeOne/XTreeOne.vue +1 -1
- package/src/pages/lowCode/lowCodeEditor.vue +47 -12
- package/src/utils/lowcode/lowcodeComponentMixin.js +14 -2
- package/src/utils/lowcode/lowcodeUtils.js +8 -0
- package/src/base-client/plugins/lowcodeUtils/lowcodeComponentMixin.js +0 -49
- package/src/base-client/plugins/lowcodeUtils/lowcodeLog.js +0 -29
- package/src/base-client/plugins/lowcodeUtils/lowcodeUtils.js +0 -43
- package/src/base-client/plugins/lowcodeUtils/registerComponentForEditor.js +0 -7
- package/src/base-client/plugins/lowcodeUtils/registerComponentForRender.js +0 -7
package/docs/lowcode.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# 奥枫低代码平台
|
|
2
|
+
|
|
3
|
+
> 低代码平台在使用时分为两个大部分
|
|
4
|
+
>
|
|
5
|
+
> 1. 插件
|
|
6
|
+
> 2. 渲染器
|
|
7
|
+
>
|
|
8
|
+
> 所以在使用时要将这两个配置好,才可以正确的在编辑器中显示并编辑
|
|
9
|
+
|
|
10
|
+
> ---------------- **注意** ----------------
|
|
11
|
+
>
|
|
12
|
+
> 所有文件中引用其他文件,请使用@vue2-client,而不是@。
|
|
13
|
+
> 不然琉璃中会将@符解析到自己的src下
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## 组件注册使用
|
|
17
|
+
|
|
18
|
+
> 组件要想在低代码平台中展示,并可编辑需要完成一下几点
|
|
19
|
+
|
|
20
|
+
### 插件
|
|
21
|
+
|
|
22
|
+
> 插件的用途是,在编辑器中定义该组件有哪些**事件**,哪些可以编辑的**属性**
|
|
23
|
+
|
|
24
|
+
#### 插件定义
|
|
25
|
+
|
|
26
|
+
> 以下是一个简单的插件声明示例
|
|
27
|
+
```js
|
|
28
|
+
export const XFormTableConfig = {
|
|
29
|
+
type: 'XFormTable',
|
|
30
|
+
properties: {
|
|
31
|
+
queryParamsName: {
|
|
32
|
+
type: 'string'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
selfEvent: ['action']
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> `type`
|
|
40
|
+
>
|
|
41
|
+
> 该字段用于描述本组件使用渲染器的类型,如type: '111'
|
|
42
|
+
> 这个组件就会去找名称为'111'的渲染器,来将配置渲染为页面
|
|
43
|
+
|
|
44
|
+
> `properties`
|
|
45
|
+
>
|
|
46
|
+
> 该字段用于描述本组件右侧属性编辑栏中,可以展示哪些属性供编辑,
|
|
47
|
+
> 通常所有的props都需要在这里声明
|
|
48
|
+
|
|
49
|
+
> `selfEvent`
|
|
50
|
+
>
|
|
51
|
+
> 该字段用于描述该组件中有哪些事件会交给编辑器统一调用
|
|
52
|
+
|
|
53
|
+
#### 插件注册
|
|
54
|
+
|
|
55
|
+
> 定义完成后的插件,需要注册,才会被低代码平台识别
|
|
56
|
+
>
|
|
57
|
+
> 在src/utils/lowcode/registerComponentForEditor.js文件中注册插件
|
|
58
|
+
>
|
|
59
|
+
> 以下是一个简单的实例,导入刚刚定义好的插件js文件,并将其暴露
|
|
60
|
+
>
|
|
61
|
+
> 低代码平台会自动来扫描该文件中的定义
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
```js
|
|
65
|
+
import { XFormTableConfig } from '@vue2-client/base-client/components/common/XFormTable/lowcodeEditorRegister'
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
XFormTableConfig
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 渲染器
|
|
73
|
+
|
|
74
|
+
> 渲染器决定了配置中的每一个组件,该用哪个VUE对象来渲染
|
|
75
|
+
>
|
|
76
|
+
> 渲染器不需要配置文件,只需要注册
|
|
77
|
+
>
|
|
78
|
+
> 在src/utils/lowcode/registerComponentForRender.js文件中
|
|
79
|
+
>
|
|
80
|
+
> 导入vue对象,并将其暴露即可
|
|
81
|
+
>
|
|
82
|
+
> vue组件名,就是插件中的type类型
|
|
83
|
+
```js
|
|
84
|
+
import XFormTable from '@vue2-client/base-client/components/common/XFormTable/XFormTable.vue'
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
XFormTable
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 组件本身修改
|
|
92
|
+
|
|
93
|
+
> 在组件中有些内容需要做出修改以适配低代码平台
|
|
94
|
+
>
|
|
95
|
+
> 1. mixin
|
|
96
|
+
> 2. 事件emit
|
|
97
|
+
> 3. props的定义
|
|
98
|
+
|
|
99
|
+
#### mixin
|
|
100
|
+
|
|
101
|
+
> 在低代码平台中,所有组件注册,组件通信都要依赖于mixin。
|
|
102
|
+
>
|
|
103
|
+
> 在渲染器中,必须引入mixin
|
|
104
|
+
>
|
|
105
|
+
> mixin所在位置为:src/utils/lowcode/lowcodeComponentMixin.js
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
import lowcodeComponentMixin from '@vue2-client/utils/lowcode/lowcodeComponentMixin'
|
|
109
|
+
|
|
110
|
+
export default {
|
|
111
|
+
...
|
|
112
|
+
mixins: [lowcodeComponentMixin],
|
|
113
|
+
...
|
|
114
|
+
```
|
|
115
|
+
#### 事件emit
|
|
116
|
+
|
|
117
|
+
> 在低代码平台中,如果需要与其他组件进行通信,
|
|
118
|
+
> 则必须使用低代码平台指定的传递事件的方式
|
|
119
|
+
>
|
|
120
|
+
> 该方法已在mixin中定义,只需要调用即可
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
action (record, id, actionType, fun = 'action') {
|
|
124
|
+
this.$emit(fun, record, id, actionType)
|
|
125
|
+
this.$lowCodeEmit('action', record)
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
#### props
|
|
130
|
+
|
|
131
|
+
> require不能为true
|
|
132
|
+
>
|
|
133
|
+
> 如果require为true会导致组件无法正确初始化,要么给props一个默认值,
|
|
134
|
+
> 要么从propsData中取值
|
|
135
|
+
>
|
|
136
|
+
> 所有在插件中定义的properties,都会通过propsData传递,其格式为
|
|
137
|
+
> { a: aValue, b: bValue}
|
|
138
|
+
|
|
139
|
+
## 功能新增
|
|
140
|
+
|
|
141
|
+
### 事件处理新增
|
|
142
|
+
> 在mixin中,handleComponentCommunication函数新增新的case
|
|
143
|
+
```js
|
|
144
|
+
handleComponentCommunication (actionType, data, targetKey = undefined, eventOriginalVM = undefined) {
|
|
145
|
+
...
|
|
146
|
+
switch (actionType) {
|
|
147
|
+
case ...
|
|
148
|
+
case 'log':
|
|
149
|
+
this.handleComponentLog(data)
|
|
150
|
+
break
|
|
151
|
+
}
|
|
152
|
+
...
|
|
153
|
+
}
|
|
154
|
+
> ```
|
|
155
|
+
> 将新增的处理方法,声明在supportedEventType数组中
|
|
156
|
+
```js
|
|
157
|
+
supportedEventType: [
|
|
158
|
+
...
|
|
159
|
+
'log'
|
|
160
|
+
]
|
|
161
|
+
```
|
package/package.json
CHANGED
|
@@ -164,12 +164,20 @@ export default {
|
|
|
164
164
|
})
|
|
165
165
|
},
|
|
166
166
|
formItemLayout () {
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
if (this.layout === 'horizontal') {
|
|
168
|
+
return {
|
|
169
169
|
labelCol: { span: 4, offset: 2 },
|
|
170
170
|
wrapperCol: { span: 14 },
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
}
|
|
173
|
+
if (this.layout === 'vertical') {
|
|
174
|
+
return {
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
labelCol: { span: 8 },
|
|
179
|
+
wrapperCol: { span: 16 },
|
|
180
|
+
}
|
|
173
181
|
},
|
|
174
182
|
...mapState('account', { currUser: 'user' })
|
|
175
183
|
},
|
|
@@ -521,3 +529,9 @@ export default {
|
|
|
521
529
|
}
|
|
522
530
|
}
|
|
523
531
|
</script>
|
|
532
|
+
|
|
533
|
+
<style scoped>
|
|
534
|
+
:deep(.ant-form-inline .ant-form-item ){
|
|
535
|
+
display: block !important;
|
|
536
|
+
}
|
|
537
|
+
</style>
|
|
@@ -246,38 +246,41 @@
|
|
|
246
246
|
</a-form-model-item>
|
|
247
247
|
</x-form-col>
|
|
248
248
|
<!-- 文本域 -->
|
|
249
|
-
<
|
|
249
|
+
<a-col
|
|
250
250
|
v-else-if="attr.type === 'textarea'"
|
|
251
|
-
:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}">
|
|
251
|
+
:style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"
|
|
252
|
+
:xs="24"
|
|
253
|
+
:sm="24"
|
|
254
|
+
:md="24"
|
|
255
|
+
:lg="24"
|
|
256
|
+
:xl="24"
|
|
257
|
+
:xxl="24">
|
|
259
258
|
<a-form-model-item
|
|
259
|
+
:labelCol="layout === 'inline'?{span:2}:undefined"
|
|
260
260
|
:ref="attr.model"
|
|
261
261
|
:label="attr.name"
|
|
262
262
|
:prop="attr.prop ? attr.prop : attr.model">
|
|
263
263
|
<a-textarea v-model="form[attr.model]" :disabled="disabled" :placeholder="attr.placeholder ? attr.placeholder : '请输入'+attr.name.replace(/\s*/g, '')" :rows="4"/>
|
|
264
264
|
</a-form-model-item>
|
|
265
|
-
</
|
|
265
|
+
</a-col>
|
|
266
266
|
<!-- 文件上传 -->
|
|
267
|
-
<
|
|
267
|
+
<a-col
|
|
268
268
|
v-else-if="attr.type === 'file' || attr.type === 'image'"
|
|
269
|
-
:
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
269
|
+
:style="layout === 'inline'?{width:'calc(100% - 60px)'}:{}"
|
|
270
|
+
:xs="24"
|
|
271
|
+
:sm="24"
|
|
272
|
+
:md="24"
|
|
273
|
+
:lg="24"
|
|
274
|
+
:xl="24"
|
|
275
|
+
:xxl="24">
|
|
276
|
+
<a-form-model-item
|
|
277
|
+
:labelCol="layout === 'inline'?{span:2}:undefined"
|
|
278
|
+
:ref="attr.model"
|
|
279
|
+
:label="attr.name"
|
|
280
|
+
:prop="attr.prop ? attr.prop : attr.model">
|
|
278
281
|
<upload :files="files" :images="images" :model="attr" :service-name="serviceName" @setFiles="setFiles"></upload>
|
|
279
282
|
</a-form-model-item>
|
|
280
|
-
</
|
|
283
|
+
</a-col>
|
|
281
284
|
<!-- 省市区选择框 -->
|
|
282
285
|
<x-form-col
|
|
283
286
|
v-else-if="attr.type === 'citySelect'"
|
|
@@ -442,14 +445,27 @@ export default {
|
|
|
442
445
|
},
|
|
443
446
|
methods: {
|
|
444
447
|
init () {
|
|
445
|
-
if (this.mode === '新增/修改' && !this.attr.flex
|
|
446
|
-
this.
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
448
|
+
if (this.mode === '新增/修改' && !this.attr.flex) {
|
|
449
|
+
if (['horizontal', 'vertical'].includes(this.layout)) {
|
|
450
|
+
// 新增修改表单 horizontal 模式下默认为一行
|
|
451
|
+
this.attr.flex = {
|
|
452
|
+
xs: 24,
|
|
453
|
+
sm: 24,
|
|
454
|
+
md: 24,
|
|
455
|
+
lg: 24,
|
|
456
|
+
xl: 24,
|
|
457
|
+
xxl: 24
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
// 新增修改表单 vertical 模式下默认为1列
|
|
461
|
+
this.attr.flex = {
|
|
462
|
+
xs: 24,
|
|
463
|
+
sm: 24,
|
|
464
|
+
md: 24,
|
|
465
|
+
lg: 12,
|
|
466
|
+
xl: 8,
|
|
467
|
+
xxl: 8
|
|
468
|
+
}
|
|
453
469
|
}
|
|
454
470
|
}
|
|
455
471
|
if (this.attr.keyName && this.attr.keyName.indexOf('logic@') !== -1) {
|
|
@@ -338,6 +338,7 @@ export default {
|
|
|
338
338
|
*/
|
|
339
339
|
action (record, id, actionType, fun = 'action') {
|
|
340
340
|
this.$emit(fun, record, id, actionType)
|
|
341
|
+
this.$lowCodeEmit('action', record)
|
|
341
342
|
},
|
|
342
343
|
treeOnChecked (checkedKeys, deepNodes, deepKeys) {
|
|
343
344
|
this.$emit('treeOnChecked', checkedKeys, deepNodes, deepKeys)
|
|
@@ -359,6 +360,7 @@ export default {
|
|
|
359
360
|
serviceName: this.serviceName,
|
|
360
361
|
fixedAddForm: this.fixedAddForm,
|
|
361
362
|
getDataParams: this.getDataParams,
|
|
363
|
+
layout: res.xAddFormLayout || 'horizontal',
|
|
362
364
|
env: this.env
|
|
363
365
|
})
|
|
364
366
|
},
|
|
@@ -381,6 +383,7 @@ export default {
|
|
|
381
383
|
fixedAddForm: this.fixedAddForm,
|
|
382
384
|
getDataParams: this.getDataParams,
|
|
383
385
|
modifyModelData: modifyModelData,
|
|
386
|
+
layout: res.xAddFormLayout || 'horizontal',
|
|
384
387
|
env: this.env
|
|
385
388
|
})
|
|
386
389
|
},
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
组件容器
|
|
39
39
|
</a-card-grid>
|
|
40
40
|
<template v-for="(item, index) in getRegisteredComponents()">
|
|
41
|
-
<a-card-grid style="width: 50%;text-align: center" :key="index" class="ui-item" @click="addComponentToContainer(item)">
|
|
41
|
+
<a-card-grid style="width: 50%;text-align: center;overflow-wrap: break-word;padding: 7%" :key="index" class="ui-item" @click="addComponentToContainer(item)">
|
|
42
42
|
{{ item }}
|
|
43
43
|
</a-card-grid>
|
|
44
44
|
</template>
|
|
@@ -58,11 +58,14 @@
|
|
|
58
58
|
</a-col>
|
|
59
59
|
<!-- 右侧属性面板 -->
|
|
60
60
|
<a-col :span="5">
|
|
61
|
-
<a-card
|
|
61
|
+
<a-card>
|
|
62
62
|
<template v-if="editorPropertiesConfig === 'unregistered'">
|
|
63
63
|
<p>所选组件并未注册</p>
|
|
64
64
|
</template>
|
|
65
65
|
<template v-else>
|
|
66
|
+
<div v-if="editorPropertiesConfig.id">
|
|
67
|
+
<a-statistic title="组件ID" :value="editorPropertiesConfig.id" valueStyle="font-size: 1.2em"/>
|
|
68
|
+
</div>
|
|
66
69
|
<!-- 切换 -->
|
|
67
70
|
<a-menu v-model="editorPanelCurrent" mode="horizontal" @click="handelEditorPanelTitleClick">
|
|
68
71
|
<a-menu-item key="properties">属性</a-menu-item>
|
|
@@ -108,6 +111,9 @@
|
|
|
108
111
|
<a-button v-if="editorPropertiesConfig.id !== undefined" @click="addEvent">添加事件</a-button>
|
|
109
112
|
<p v-else>您未选择任何组件</p>
|
|
110
113
|
</div>
|
|
114
|
+
<div style="margin-top: 5%" v-if="editorPropertiesConfig.id !== undefined">
|
|
115
|
+
<a-button type="danger" @click="deleteComponent">删除组件</a-button>
|
|
116
|
+
</div>
|
|
111
117
|
</template>
|
|
112
118
|
</a-card>
|
|
113
119
|
</a-col>
|
|
@@ -149,13 +155,13 @@
|
|
|
149
155
|
<!-- 目标组件执行事件名 -->
|
|
150
156
|
<a-form-item label="目标组件执行事件名">
|
|
151
157
|
<a-select @change="handleEventEditorTargetEventTypeChange" :default-value="eventEditorContent.eventName">
|
|
152
|
-
<a-select-option value="
|
|
153
|
-
|
|
158
|
+
<a-select-option :value="eventType" v-for="(eventType,eventTypeIndex) in supportedEventType" :key="'eventType_' + eventTypeIndex">
|
|
159
|
+
{{ eventType }}
|
|
154
160
|
</a-select-option>
|
|
155
161
|
</a-select>
|
|
156
162
|
</a-form-item>
|
|
157
163
|
<!-- 目标组件修改值对应的key -->
|
|
158
|
-
<a-form-item label="目标组件修改值对应的key">
|
|
164
|
+
<a-form-item label="目标组件修改值对应的key" v-if="eventEditorContent.eventName === 'changeValue'">
|
|
159
165
|
<a-input v-model="eventEditorContent.targetKey"/>
|
|
160
166
|
</a-form-item>
|
|
161
167
|
<!-- 自定义JS方法 -->
|
|
@@ -211,6 +217,9 @@ import * as registeredRender from '@vue2-client/utils/lowcode/registerComponentF
|
|
|
211
217
|
import * as lowcodeUtils from '@vue2-client/utils/lowcode/lowcodeUtils'
|
|
212
218
|
import codeMirror from '@vue2-client/components/CodeMirror/inedx.vue'
|
|
213
219
|
import { nanoid } from 'nanoid'
|
|
220
|
+
import lowcodeComponentMixin from '@vue2-client/utils/lowcode/lowcodeComponentMixin'
|
|
221
|
+
// eslint-disable-next-line no-unused-vars
|
|
222
|
+
import lowcodeLog from '@vue2-client/utils/lowcode/lowcodeLog'
|
|
214
223
|
|
|
215
224
|
export default {
|
|
216
225
|
components: {
|
|
@@ -269,7 +278,8 @@ export default {
|
|
|
269
278
|
renderPreview: true,
|
|
270
279
|
editorPanelCurrent: ['properties'],
|
|
271
280
|
eventEditorContent: {},
|
|
272
|
-
eventEditorCurrent: undefined
|
|
281
|
+
eventEditorCurrent: undefined,
|
|
282
|
+
supportedEventType: undefined
|
|
273
283
|
}
|
|
274
284
|
},
|
|
275
285
|
provide () {
|
|
@@ -278,6 +288,24 @@ export default {
|
|
|
278
288
|
}
|
|
279
289
|
},
|
|
280
290
|
methods: {
|
|
291
|
+
deleteComponent () {
|
|
292
|
+
this.config.forEach(page => {
|
|
293
|
+
for (let i = 0; i < page.body.length; i++) {
|
|
294
|
+
if (page.body[i].id === this.editorPropertiesConfig.id) {
|
|
295
|
+
const deletedSpan = page.body[i].span
|
|
296
|
+
page.body.splice(i, 1)
|
|
297
|
+
if (i !== 0) {
|
|
298
|
+
page.body[i - 1].span += deletedSpan
|
|
299
|
+
}
|
|
300
|
+
delete this.$children[0]._provided.componentsMap[this.editorPropertiesConfig.id]
|
|
301
|
+
this.targetContainer = undefined
|
|
302
|
+
this.editorPropertiesConfig = {}
|
|
303
|
+
lowcodeUtils.configPageRemoveIfIsNull(this.config)
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
})
|
|
308
|
+
},
|
|
281
309
|
openEventJSEditor () {
|
|
282
310
|
if (!this.eventEditorContent.JSFunction) {
|
|
283
311
|
this.eventEditorContent.JSFunction = 'function(eventType, data, targetKey, sourceVM, targetVM) {\n \n return {\n "eventType": eventType,\n "data": data,\n "targetKey": targetKey\n }\n}'
|
|
@@ -333,11 +361,13 @@ export default {
|
|
|
333
361
|
}
|
|
334
362
|
}
|
|
335
363
|
target.body.splice(targetIndex, 1)
|
|
364
|
+
this.targetContainer = undefined
|
|
336
365
|
if (target.body.length === 0) {
|
|
337
366
|
this.config.splice(pageIndex, 1)
|
|
338
367
|
} else if (target.body.length === 1) {
|
|
339
368
|
target.body[0].span = 24
|
|
340
369
|
}
|
|
370
|
+
lowcodeUtils.configPageRemoveIfIsNull(this.config)
|
|
341
371
|
},
|
|
342
372
|
handleEventEditorOk () {
|
|
343
373
|
if (this.eventEditorCurrent) {
|
|
@@ -383,6 +413,7 @@ export default {
|
|
|
383
413
|
},
|
|
384
414
|
handleEventEditorTargetEventTypeChange (type) {
|
|
385
415
|
this.eventEditorContent.eventName = type
|
|
416
|
+
this.$forceUpdate()
|
|
386
417
|
},
|
|
387
418
|
handleJSEventEditorOk () {
|
|
388
419
|
this.showJSEventEditor = false
|
|
@@ -399,16 +430,18 @@ export default {
|
|
|
399
430
|
{
|
|
400
431
|
span: 24,
|
|
401
432
|
type: type,
|
|
402
|
-
id: type + '_' + nanoid(),
|
|
433
|
+
id: type + '_' + nanoid(6),
|
|
403
434
|
}
|
|
404
435
|
]
|
|
405
436
|
})
|
|
437
|
+
} else {
|
|
438
|
+
this.$message.error('单组件页面只可以存在一个组件,如需多个组件请先添加组件容器!')
|
|
406
439
|
}
|
|
407
440
|
return
|
|
408
441
|
}
|
|
409
442
|
const target = lowcodeUtils.getComponentConfig(this.targetContainer.id, this.config)
|
|
410
443
|
target.type = type
|
|
411
|
-
target.id = target.type + '_' + nanoid()
|
|
444
|
+
target.id = target.type + '_' + nanoid(6)
|
|
412
445
|
},
|
|
413
446
|
handleWidthChange (id, type, pageIndex) {
|
|
414
447
|
const target = lowcodeUtils.getComponentConfig(id, this.config)
|
|
@@ -430,12 +463,12 @@ export default {
|
|
|
430
463
|
{
|
|
431
464
|
type: 'container',
|
|
432
465
|
span: 12,
|
|
433
|
-
id: 'container_' + nanoid()
|
|
466
|
+
id: 'container_' + nanoid(6)
|
|
434
467
|
},
|
|
435
468
|
{
|
|
436
469
|
type: 'container',
|
|
437
470
|
span: 12,
|
|
438
|
-
id: 'container_' + nanoid()
|
|
471
|
+
id: 'container_' + nanoid(6)
|
|
439
472
|
}
|
|
440
473
|
]
|
|
441
474
|
})
|
|
@@ -456,11 +489,11 @@ export default {
|
|
|
456
489
|
this.config[targetPageIndex].body.splice(targetIndex, 1, {
|
|
457
490
|
type: 'container',
|
|
458
491
|
span: Math.floor(maxWidth / 2),
|
|
459
|
-
id: 'container_' + nanoid()
|
|
492
|
+
id: 'container_' + nanoid(6)
|
|
460
493
|
}, {
|
|
461
494
|
type: 'container',
|
|
462
495
|
span: Math.ceil(maxWidth / 2),
|
|
463
|
-
id: 'container_' + nanoid()
|
|
496
|
+
id: 'container_' + nanoid(6)
|
|
464
497
|
})
|
|
465
498
|
}
|
|
466
499
|
},
|
|
@@ -551,10 +584,12 @@ export default {
|
|
|
551
584
|
console.warn('map', this.$children[0]._provided.componentsMap)
|
|
552
585
|
},
|
|
553
586
|
exportConfig () {
|
|
587
|
+
console.warn('导出', this.config)
|
|
554
588
|
this.$emit('exportConfig', this.config)
|
|
555
589
|
}
|
|
556
590
|
},
|
|
557
591
|
mounted () {
|
|
592
|
+
this.supportedEventType = [...lowcodeComponentMixin.supportedEventType]
|
|
558
593
|
this.config = JSON.parse(JSON.stringify(this.originalConfig))
|
|
559
594
|
}
|
|
560
595
|
}
|
|
@@ -25,8 +25,16 @@ export default {
|
|
|
25
25
|
switch (actionType) {
|
|
26
26
|
case 'changeValue':
|
|
27
27
|
this.handleComponentChangeValue(data, targetKey)
|
|
28
|
+
break
|
|
29
|
+
case 'log':
|
|
30
|
+
this.handleComponentLog(data)
|
|
31
|
+
break
|
|
28
32
|
}
|
|
29
33
|
},
|
|
34
|
+
handleComponentLog (data) {
|
|
35
|
+
console.warn('vm', this)
|
|
36
|
+
console.warn('data', data)
|
|
37
|
+
},
|
|
30
38
|
handleComponentChangeValue (data, targetKey = undefined) {
|
|
31
39
|
if (targetKey) {
|
|
32
40
|
this[targetKey] = data
|
|
@@ -39,11 +47,15 @@ export default {
|
|
|
39
47
|
})
|
|
40
48
|
},
|
|
41
49
|
// 处理本组件发出的事件
|
|
42
|
-
|
|
50
|
+
$lowCodeEmit (eventType, data) {
|
|
43
51
|
this.$emit('onEvent', data, eventType, this.mixinComponentId)
|
|
44
52
|
}
|
|
45
53
|
},
|
|
46
54
|
mounted () {
|
|
47
55
|
this.$emit('componentDidMounted', this, this.mixinComponentId)
|
|
48
|
-
}
|
|
56
|
+
},
|
|
57
|
+
supportedEventType: [
|
|
58
|
+
'changeValue',
|
|
59
|
+
'log'
|
|
60
|
+
],
|
|
49
61
|
}
|
|
@@ -41,3 +41,11 @@ export function getComponentConfigPageIndex (componentId, config) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
export function configPageRemoveIfIsNull (config) {
|
|
46
|
+
for (let i = 0; i < config.length; i++) {
|
|
47
|
+
if (config[i].body.length === 0) {
|
|
48
|
+
config.splice(i, 1)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import Vue from 'vue'
|
|
3
|
-
import lowcodeLog from '@/utils/lowcode/lowcodeLog'
|
|
4
|
-
export default {
|
|
5
|
-
props: {
|
|
6
|
-
mixinComponentId: {
|
|
7
|
-
type: String,
|
|
8
|
-
required: true
|
|
9
|
-
},
|
|
10
|
-
propsData: {
|
|
11
|
-
type: Object,
|
|
12
|
-
default: {}
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
methods: {
|
|
16
|
-
// 处理目标为本组件的通信
|
|
17
|
-
handleComponentCommunication (actionType, data, targetKey = undefined, eventOriginalVM = undefined) {
|
|
18
|
-
lowcodeLog(
|
|
19
|
-
` 事件数据:${data},\n 目标key:${targetKey}`,
|
|
20
|
-
'响应组件接收到事件',
|
|
21
|
-
actionType,
|
|
22
|
-
false,
|
|
23
|
-
true
|
|
24
|
-
)
|
|
25
|
-
switch (actionType) {
|
|
26
|
-
case 'changeValue':
|
|
27
|
-
this.handleComponentChangeValue(data, targetKey)
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
handleComponentChangeValue (data, targetKey = undefined) {
|
|
31
|
-
if (targetKey) {
|
|
32
|
-
this[targetKey] = data
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const keys = Object.keys(data)
|
|
37
|
-
keys.forEach(key => {
|
|
38
|
-
this[key] = data[key]
|
|
39
|
-
})
|
|
40
|
-
},
|
|
41
|
-
// 处理本组件发出的事件
|
|
42
|
-
handleComponentEmit (eventType, data) {
|
|
43
|
-
this.$emit('onEvent', data, eventType, this.mixinComponentId)
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
mounted () {
|
|
47
|
-
this.$emit('componentDidMounted', this, this.mixinComponentId)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const banner = `
|
|
2
|
-
_____ .__ .___
|
|
3
|
-
_____ _/ ____\\ | | ______ _ __ ____ ____ __| _/____
|
|
4
|
-
\\__ \\\\ __\\ ______ | | / _ \\ \\/ \\/ // ___\\/ _ \\ / __ |/ __ \\
|
|
5
|
-
/ __ \\| | /_____/ | |_( <_> ) /\\ \\__( <_> ) /_/ \\ ___/
|
|
6
|
-
(____ /__| |____/\\____/ \\/\\_/ \\___ >____/\\____ |\\___ >
|
|
7
|
-
\\/ \\/ \\/ \\/
|
|
8
|
-
`
|
|
9
|
-
|
|
10
|
-
const end = '========事件处理结束========'
|
|
11
|
-
|
|
12
|
-
const styleTitle1 = ` font-size: 20px; font-weight: 600; color: rgb(244,167,89); `
|
|
13
|
-
const styleTitle2 = ` font-style: oblique; font-size:14px; color: rgb(244,167,89); font-weight: 400; `
|
|
14
|
-
const styleContent = ` color:rgb(30,152,255);margin-top:15px `
|
|
15
|
-
|
|
16
|
-
export default function lowcodeLog (content, title1 = '', title2 = '', withBanner = false, withEnd = false) {
|
|
17
|
-
if (withBanner) {
|
|
18
|
-
console.log(banner)
|
|
19
|
-
}
|
|
20
|
-
console.log(
|
|
21
|
-
`%c${title1} %c${title2} %c${content}`,
|
|
22
|
-
styleTitle1,
|
|
23
|
-
styleTitle2,
|
|
24
|
-
styleContent
|
|
25
|
-
)
|
|
26
|
-
if (withEnd) {
|
|
27
|
-
console.log(`%c${end}`, styleTitle1)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as registeredConfig from './registerComponentForEditor'
|
|
3
|
-
export function getEditorConfigById (componentId, config) {
|
|
4
|
-
for (let i = 0; i < config.length; i++) {
|
|
5
|
-
for (let j = 0; j < config[i].body.length; j++) {
|
|
6
|
-
if (config[i].body[j].id === componentId) {
|
|
7
|
-
return getEditorConfigByType(config[i].body[j].type)
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return undefined
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getEditorConfigByType (componentType) {
|
|
15
|
-
let result
|
|
16
|
-
const registeredConfigKeys = Object.keys(registeredConfig)
|
|
17
|
-
registeredConfigKeys.forEach(key => {
|
|
18
|
-
if (registeredConfig[key].type === componentType) {
|
|
19
|
-
result = registeredConfig[key]
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
return result
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function getComponentConfig (componentId, config) {
|
|
26
|
-
for (let i = 0; i < config.length; i++) {
|
|
27
|
-
for (let j = 0; j < config[i].body.length; j++) {
|
|
28
|
-
if (config[i].body[j].id === componentId) {
|
|
29
|
-
return config[i].body[j]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function getComponentConfigPageIndex (componentId, config) {
|
|
36
|
-
for (let i = 0; i < config.length; i++) {
|
|
37
|
-
for (let j = 0; j < config[i].body.length; j++) {
|
|
38
|
-
if (config[i].body[j].id === componentId) {
|
|
39
|
-
return i
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|