vue2-client 1.8.214 → 1.8.216
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/package.json +1 -1
- package/src/base-client/components/common/LowCodeComponent/LowCodeGlobalVariable.vue +65 -0
- package/src/base-client/components/common/LowCodeComponent/LowCodePageOrganization.vue +138 -0
- package/src/base-client/components/common/LowCodePageRender/editorPageRender.vue +142 -58
- package/src/base-client/components/common/Upload/Upload.vue +22 -26
- package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +37 -1
- package/src/base-client/components/common/XDescriptions/XDescriptions.vue +0 -5
- package/src/base-client/components/common/XForm/XFormItem.vue +31 -8
- package/src/base-client/components/common/XForm/XTreeSelect.vue +1 -1
- package/src/base-client/components/common/XTable/XTable.vue +0 -2
- package/src/pages/lowCode/lowCodeEditor.vue +436 -256
package/package.json
CHANGED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<!-- 实时预览 -->
|
|
4
|
+
<json-viewer
|
|
5
|
+
:copyable="{copyText: '复制', copiedText: '已复制'}"
|
|
6
|
+
:expand-depth="parseInt('100')"
|
|
7
|
+
:value="globalVariable"
|
|
8
|
+
style="overflow: auto;max-height: 440px"></json-viewer>
|
|
9
|
+
<a-button @click="addVariable">添加变量</a-button>
|
|
10
|
+
<!-- 添加变量弹框 -->
|
|
11
|
+
<a-modal
|
|
12
|
+
title="添加全局变量"
|
|
13
|
+
width="60%"
|
|
14
|
+
:z-index="1001"
|
|
15
|
+
:destroyOnClose="true"
|
|
16
|
+
@ok="handleModalOk"
|
|
17
|
+
@cancel="() => { showModal = false }"
|
|
18
|
+
:visible="showModal">
|
|
19
|
+
<a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
|
|
20
|
+
<!-- key -->
|
|
21
|
+
<a-form-item label="定义Key">
|
|
22
|
+
<a-input v-model="defineKey"/>
|
|
23
|
+
</a-form-item>
|
|
24
|
+
</a-form>
|
|
25
|
+
</a-modal>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import JsonViewer from 'vue-json-viewer'
|
|
31
|
+
export default {
|
|
32
|
+
components: {
|
|
33
|
+
JsonViewer
|
|
34
|
+
},
|
|
35
|
+
props: {
|
|
36
|
+
globalVariable: {
|
|
37
|
+
type: Object,
|
|
38
|
+
default: () => {
|
|
39
|
+
return {}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
data () {
|
|
44
|
+
return {
|
|
45
|
+
showModal: false,
|
|
46
|
+
defineKey: ''
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
methods: {
|
|
50
|
+
addVariable () {
|
|
51
|
+
this.defineKey = ''
|
|
52
|
+
this.showModal = true
|
|
53
|
+
},
|
|
54
|
+
handleModalOk () {
|
|
55
|
+
this.$emit('addVariable', this.defineKey)
|
|
56
|
+
this.defineKey = ''
|
|
57
|
+
this.showModal = false
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<style scoped lang="less">
|
|
64
|
+
|
|
65
|
+
</style>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<a-button @click="addComponent">添加组件</a-button>
|
|
4
|
+
<a-tree
|
|
5
|
+
@select="handleTreeSelect"
|
|
6
|
+
:tree-data="treeData"/>
|
|
7
|
+
<!-- 新增组件弹框 -->
|
|
8
|
+
<a-modal
|
|
9
|
+
title="新增组件"
|
|
10
|
+
width="60%"
|
|
11
|
+
:z-index="1001"
|
|
12
|
+
:destroyOnClose="true"
|
|
13
|
+
@ok="handleModalOk"
|
|
14
|
+
@cancel="() => { showModal = false }"
|
|
15
|
+
:visible="showModal">
|
|
16
|
+
<a-form :label-col="{ span: 7 }" :wrapper-col="{ span: 12 }">
|
|
17
|
+
<!-- 容器类型 -->
|
|
18
|
+
<a-form-item label="容器类型">
|
|
19
|
+
<a-select v-model="addComponentTemp.type" @change="componentTypeChange">
|
|
20
|
+
<a-select-option value="page">
|
|
21
|
+
页面
|
|
22
|
+
</a-select-option>
|
|
23
|
+
<a-select-option value="modal">
|
|
24
|
+
弹框
|
|
25
|
+
</a-select-option>
|
|
26
|
+
<a-select-option value="draw">
|
|
27
|
+
抽屉
|
|
28
|
+
</a-select-option>
|
|
29
|
+
</a-select>
|
|
30
|
+
</a-form-item>
|
|
31
|
+
<template v-if="addComponentTemp.type !== 'page'">
|
|
32
|
+
<!-- 标题 -->
|
|
33
|
+
<a-form-item label="标题">
|
|
34
|
+
<a-input v-model="addComponentTemp.title"/>
|
|
35
|
+
</a-form-item>
|
|
36
|
+
<!-- 宽度 -->
|
|
37
|
+
<a-form-item label="宽度">
|
|
38
|
+
<a-input v-model="addComponentTemp.width"/>
|
|
39
|
+
</a-form-item>
|
|
40
|
+
</template>
|
|
41
|
+
</a-form>
|
|
42
|
+
</a-modal>
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
import { nanoid } from 'nanoid'
|
|
48
|
+
export default {
|
|
49
|
+
props: {
|
|
50
|
+
config: {
|
|
51
|
+
type: Object,
|
|
52
|
+
required: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
methods: {
|
|
56
|
+
// 处理架构树点击事件
|
|
57
|
+
handleTreeSelect (value) {
|
|
58
|
+
// 如果类型为string,证明点到的是组件
|
|
59
|
+
if (typeof value[0] === 'string') {
|
|
60
|
+
this.config.page.forEach(page => {
|
|
61
|
+
page.body.forEach(item => {
|
|
62
|
+
if (item.id === value[0]) {
|
|
63
|
+
this.$emit('treeOrganizationClick', item.id, 'component')
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
// 如果类型为number,证明点到的是容器
|
|
68
|
+
} else if (typeof value[0] === 'number') {
|
|
69
|
+
const target = this.treeData[value].title
|
|
70
|
+
const pageId = target.slice(target.length - 3, target.length - 1)
|
|
71
|
+
this.$emit('treeOrganizationClick', pageId, 'page')
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
addComponent () {
|
|
75
|
+
this.addComponentTemp = { type: 'page' }
|
|
76
|
+
this.showModal = true
|
|
77
|
+
},
|
|
78
|
+
handleModalOk () {
|
|
79
|
+
const result = {
|
|
80
|
+
id: nanoid(2),
|
|
81
|
+
type: this.addComponentTemp.type,
|
|
82
|
+
title: this.addComponentTemp.title,
|
|
83
|
+
width: this.addComponentTemp.width,
|
|
84
|
+
body: []
|
|
85
|
+
}
|
|
86
|
+
this.addComponentTemp = { type: 'page' }
|
|
87
|
+
this.$emit('addComponent', result)
|
|
88
|
+
},
|
|
89
|
+
componentTypeChange (value) {
|
|
90
|
+
if (value !== 'page') {
|
|
91
|
+
this.addComponentTemp = { width: '70%', type: value }
|
|
92
|
+
} else {
|
|
93
|
+
this.addComponentTemp = { type: value }
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
determinePageType (type) {
|
|
97
|
+
switch (type) {
|
|
98
|
+
case 'page':
|
|
99
|
+
return '页面'
|
|
100
|
+
case 'modal':
|
|
101
|
+
return '弹框'
|
|
102
|
+
case 'draw':
|
|
103
|
+
return '抽屉'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
mounted () {
|
|
108
|
+
// 从配置中,抽取组件,初始化成树的格式
|
|
109
|
+
for (let i = 0; i < this.config.page.length; i++) {
|
|
110
|
+
const page = this.config.page[i]
|
|
111
|
+
this.treeData.push({
|
|
112
|
+
title: this.determinePageType(page.type) + '[' + page.id + ']',
|
|
113
|
+
key: i,
|
|
114
|
+
children: []
|
|
115
|
+
})
|
|
116
|
+
for (let j = 0; j < page.body.length; j++) {
|
|
117
|
+
const item = page.body[j]
|
|
118
|
+
this.treeData[i].children.push({
|
|
119
|
+
title: item.id,
|
|
120
|
+
key: item.id,
|
|
121
|
+
children: []
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
data () {
|
|
127
|
+
return {
|
|
128
|
+
treeData: [],
|
|
129
|
+
showModal: false,
|
|
130
|
+
addComponentTemp: { type: 'page' }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style scoped lang="less">
|
|
137
|
+
|
|
138
|
+
</style>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<template v-for="(page,pageIndex) in pageConfig">
|
|
3
|
+
<template v-for="(page,pageIndex) in pageConfig.page">
|
|
4
4
|
<a-row :key="pageIndex">
|
|
5
|
+
<!-- 拖拽时显示宽度 -->
|
|
5
6
|
<template v-if="showDragSpan">
|
|
6
7
|
<div style="display: flex">
|
|
7
8
|
<template v-for="item in dragConfig">
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
<template v-else>
|
|
15
16
|
<template v-for="item in page.body">
|
|
16
17
|
<a-col :span="item.span" :key="item.id" @click="clickComponentInEditor(item)">
|
|
18
|
+
<!-- 显示容器 -->
|
|
17
19
|
<div v-if="item.type === 'container' && editMode" style="display: flex">
|
|
18
20
|
<div :class="item.selected ? 'selected_container' : 'container'">
|
|
19
21
|
<div>
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
</div>
|
|
32
34
|
<div style="height: auto; width: 1%;" class="dragDiv" @mousedown="dragStart($event, item.id, page.body)"></div>
|
|
33
35
|
</div>
|
|
36
|
+
<!-- 页面渲染 / 编辑模式中,将弹框或抽屉中的内容渲染为页面 -->
|
|
34
37
|
<div :class=" editMode ? 'componentInEditor' : '' " v-else-if="editMode || (page.type !== 'modal' && page.type !== 'draw')">
|
|
35
38
|
<component
|
|
36
39
|
:is="resolveComponentType(item.type, item.id)"
|
|
@@ -44,16 +47,17 @@
|
|
|
44
47
|
</template>
|
|
45
48
|
</a-row>
|
|
46
49
|
</template>
|
|
47
|
-
|
|
50
|
+
<!-- 弹框渲染 -->
|
|
51
|
+
<template v-for="(modal, modalIndex) in pageConfig.page.filter(page => page.type === 'modal')">
|
|
48
52
|
<a-modal
|
|
49
53
|
:key="'modalIndex_' + modalIndex"
|
|
50
54
|
:title="modal.title"
|
|
51
55
|
:width="modal.width"
|
|
52
56
|
:dialog-style="{ top: '5rem' }"
|
|
53
|
-
:visible="modalVisible"
|
|
57
|
+
:visible="modalVisible[modal.id]"
|
|
54
58
|
:z-index="1003"
|
|
55
59
|
:maskClosable="false"
|
|
56
|
-
@cancel="()
|
|
60
|
+
@cancel="closeModalOrDraw(modal.id, 'modal')"
|
|
57
61
|
:destroyOnClose="true">
|
|
58
62
|
<template v-for="(item, itemIndex) in modal.body">
|
|
59
63
|
<component
|
|
@@ -66,14 +70,15 @@
|
|
|
66
70
|
</template>
|
|
67
71
|
</a-modal>
|
|
68
72
|
</template>
|
|
69
|
-
|
|
73
|
+
<!-- 抽屉渲染 -->
|
|
74
|
+
<template v-for="(draw, drawIndex) in pageConfig.page.filter(page => page.type === 'draw')">
|
|
70
75
|
<a-drawer
|
|
71
76
|
:key="'drawIndex_' + drawIndex"
|
|
72
77
|
:title="draw.title"
|
|
73
78
|
:width="draw.width"
|
|
74
|
-
:visible="drawVisible"
|
|
79
|
+
:visible="drawVisible[draw.id]"
|
|
75
80
|
:z-index="1003"
|
|
76
|
-
@close="()
|
|
81
|
+
@close="closeModalOrDraw(draw.id, 'draw')"
|
|
77
82
|
:destroyOnClose="true">
|
|
78
83
|
<template v-for="(item, itemIndex) in draw.body">
|
|
79
84
|
<component
|
|
@@ -95,55 +100,90 @@ import Vue from 'vue'
|
|
|
95
100
|
import * as allComponents from '@vue2-client/utils/lowcode/registerComponentForRender'
|
|
96
101
|
import lowcodeLog from '@vue2-client/utils/lowcode/lowcodeLog'
|
|
97
102
|
import * as lowcodeUtils from '@vue2-client/utils/lowcode/lowcodeUtils'
|
|
103
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
98
104
|
|
|
99
105
|
export default {
|
|
100
106
|
props: {
|
|
107
|
+
// 页面配置
|
|
101
108
|
pageConfig: {
|
|
102
|
-
type:
|
|
109
|
+
type: Object,
|
|
103
110
|
required: true
|
|
104
111
|
},
|
|
112
|
+
// 是否为编辑模式
|
|
105
113
|
editMode: {
|
|
106
114
|
type: Boolean,
|
|
107
115
|
default: true
|
|
108
|
-
},
|
|
109
|
-
showModal: {
|
|
110
|
-
type: Boolean,
|
|
111
|
-
default: false
|
|
112
|
-
},
|
|
113
|
-
showDraw: {
|
|
114
|
-
type: Boolean,
|
|
115
|
-
default: false
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
data () {
|
|
119
119
|
return {
|
|
120
|
+
// 全局变量
|
|
121
|
+
globalVariable: {},
|
|
122
|
+
// 传递给组件的Props合集
|
|
120
123
|
propsData: {},
|
|
124
|
+
// 是否为拖拽模式
|
|
121
125
|
showDragSpan: false,
|
|
126
|
+
// 拖拽的缓存
|
|
122
127
|
dragConfig: [],
|
|
128
|
+
// 记录拖拽位移单位量
|
|
123
129
|
beforeSpanThrough: -1,
|
|
130
|
+
// 记录拖拽之前的span
|
|
124
131
|
originalSpan: -1,
|
|
132
|
+
// 记录拖拽目标下一个元素的原始span
|
|
125
133
|
nextOriginalSpan: -1,
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
// 弹框显示集合
|
|
135
|
+
modalVisible: {},
|
|
136
|
+
// 抽屉显示集合
|
|
137
|
+
drawVisible: {}
|
|
128
138
|
}
|
|
129
139
|
},
|
|
130
140
|
inject: [
|
|
131
141
|
'componentsMap'
|
|
132
142
|
],
|
|
143
|
+
mounted () {
|
|
144
|
+
// 如果有全局变量,则将全局变量初始化
|
|
145
|
+
if (this.pageConfig.data) {
|
|
146
|
+
this.globalVariable = { ...this.pageConfig.data }
|
|
147
|
+
}
|
|
148
|
+
// 初始化控制弹框和抽屉的变量合集
|
|
149
|
+
this.pageConfig.page.forEach(page => {
|
|
150
|
+
if (page.type === 'modal') {
|
|
151
|
+
this.modalVisible[page.id] = false
|
|
152
|
+
} else if (page.type === 'draw') {
|
|
153
|
+
this.drawVisible[page.id] = false
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
},
|
|
133
157
|
methods: {
|
|
158
|
+
// 关闭弹窗或抽屉
|
|
159
|
+
closeModalOrDraw (id, type) {
|
|
160
|
+
if (type === 'modal') {
|
|
161
|
+
this.modalVisible[id] = false
|
|
162
|
+
} else if (type === 'draw') {
|
|
163
|
+
this.drawVisible[id] = false
|
|
164
|
+
}
|
|
165
|
+
this.$forceUpdate()
|
|
166
|
+
},
|
|
167
|
+
// 开始拖拽
|
|
134
168
|
dragStart (event, id, page) {
|
|
169
|
+
// 获取目标html元素
|
|
135
170
|
const targetElement = event.srcElement
|
|
171
|
+
// 获取外层元素用于计算总宽度
|
|
136
172
|
const outerElement = targetElement.parentNode.parentNode.parentNode
|
|
137
173
|
const outerWidth = outerElement.offsetWidth
|
|
174
|
+
// 计算每一个span对应的像素
|
|
138
175
|
const outerSpanWidth = outerWidth / 24
|
|
139
176
|
|
|
177
|
+
// 记录初始X
|
|
140
178
|
const startX = event.clientX
|
|
141
179
|
|
|
180
|
+
// 记录兄弟元素
|
|
142
181
|
const targetElementBros = outerElement.childNodes
|
|
143
182
|
|
|
144
183
|
let targetComponent
|
|
145
184
|
let targetNextComponent
|
|
146
185
|
|
|
186
|
+
// 缓存拖拽组件,用于显示拖拽时的实时Span,拖拽完成后再统一赋值
|
|
147
187
|
this.dragConfig = []
|
|
148
188
|
for (let i = 0; i < page.length; i++) {
|
|
149
189
|
this.dragConfig.push({
|
|
@@ -155,40 +195,49 @@ export default {
|
|
|
155
195
|
|
|
156
196
|
this.showDragSpan = true
|
|
157
197
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
198
|
+
// 保存目标容器,和目标的下一个容器,用于改变宽度
|
|
199
|
+
for (let i = 0; i < this.pageConfig.page.length; i++) {
|
|
200
|
+
for (let j = 0; j < this.pageConfig.page[i].body.length; j++) {
|
|
201
|
+
if (id === this.pageConfig.page[i].body[j].id) {
|
|
161
202
|
targetComponent = this.dragConfig[j]
|
|
162
203
|
targetNextComponent = this.dragConfig[j + 1]
|
|
163
204
|
}
|
|
164
205
|
}
|
|
165
206
|
}
|
|
166
207
|
|
|
208
|
+
// 如果鼠标之后没有组件,禁止移动
|
|
167
209
|
if (!targetComponent || !targetNextComponent) {
|
|
168
210
|
this.$message.error('单个组件无法移动!')
|
|
169
211
|
this.showDragSpan = false
|
|
170
212
|
return
|
|
171
213
|
}
|
|
172
214
|
|
|
215
|
+
// 保存原始的像素宽度
|
|
173
216
|
const orignalTargetWidth = targetComponent.width
|
|
174
217
|
const orignalTargetNextWidth = targetNextComponent.width
|
|
175
218
|
|
|
219
|
+
// 保存原始的span
|
|
176
220
|
this.originalSpan = targetComponent.span
|
|
177
221
|
this.nextOriginalSpan = targetNextComponent.span
|
|
178
222
|
|
|
223
|
+
// 拖拽事件
|
|
179
224
|
const onDrag = (e) => {
|
|
225
|
+
// 计算出移动的像素数
|
|
180
226
|
let deltaX = e.clientX - startX
|
|
227
|
+
// 判断移动方向
|
|
181
228
|
let direction = 1
|
|
182
229
|
if (deltaX < 0) {
|
|
183
230
|
direction = -1
|
|
184
231
|
deltaX = 0 - deltaX
|
|
185
232
|
}
|
|
186
233
|
|
|
234
|
+
// 根据移动像素数计算出移动了多少个span
|
|
187
235
|
const throughSpanNum = Math.floor(deltaX / outerSpanWidth)
|
|
188
236
|
if (this.beforeSpanThrough === -1) {
|
|
189
237
|
this.beforeSpanThrough = throughSpanNum
|
|
190
238
|
}
|
|
191
239
|
|
|
240
|
+
// 将移动的距离更新到临时显示的span中
|
|
192
241
|
if (direction > 0) {
|
|
193
242
|
targetComponent.width = orignalTargetWidth + deltaX
|
|
194
243
|
targetNextComponent.width = orignalTargetNextWidth - deltaX
|
|
@@ -208,37 +257,38 @@ export default {
|
|
|
208
257
|
}
|
|
209
258
|
}
|
|
210
259
|
|
|
260
|
+
// 拖拽结束
|
|
211
261
|
const dragEnd = (e) => {
|
|
262
|
+
// 解绑事件,更新数据
|
|
212
263
|
this.showDragSpan = false
|
|
213
264
|
document.removeEventListener('mouseup', dragEnd)
|
|
214
265
|
document.removeEventListener('mousemove', onDrag)
|
|
215
266
|
this.$emit('spanDrag', targetComponent, targetNextComponent)
|
|
216
267
|
}
|
|
217
268
|
|
|
269
|
+
// 绑定拖拽事件和结束事件
|
|
218
270
|
document.addEventListener('mouseup', dragEnd)
|
|
219
271
|
document.addEventListener('mousemove', onDrag)
|
|
220
272
|
},
|
|
273
|
+
// 解析配置中的type,找出对应的渲染器
|
|
221
274
|
resolveComponentType (type, componentId) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
case 'XAddNativeFormForLowcode':
|
|
230
|
-
return allComponents.XAddNativeFormModal
|
|
231
|
-
case 'XAddNativeForm':
|
|
232
|
-
return allComponents.XAddNativeForm
|
|
233
|
-
case 'XDescriptions':
|
|
234
|
-
return allComponents.XDescriptions
|
|
275
|
+
// 从组件注册中拿到所有注册的组件
|
|
276
|
+
const allComponentKeys = Object.keys(allComponents)
|
|
277
|
+
for (let i = 0; i < allComponentKeys.length; i++) {
|
|
278
|
+
const keyStr = allComponentKeys[i].toString()
|
|
279
|
+
if (type === keyStr) {
|
|
280
|
+
return allComponents[keyStr]
|
|
281
|
+
}
|
|
235
282
|
}
|
|
236
283
|
},
|
|
284
|
+
// mixin中组件mounted后的回调
|
|
237
285
|
componentDidMounted (vm, id) {
|
|
286
|
+
// 将组件注册到全局的Map中
|
|
238
287
|
if (vm && id) {
|
|
239
288
|
this.componentsMap[id] = vm
|
|
240
289
|
}
|
|
241
|
-
|
|
290
|
+
// 如果组件中有props,将其挨个set到vm中
|
|
291
|
+
this.pageConfig.page.forEach(page => {
|
|
242
292
|
page.body.forEach(item => {
|
|
243
293
|
if (item.id === id) {
|
|
244
294
|
const keys = Object.keys(item.props)
|
|
@@ -260,8 +310,11 @@ export default {
|
|
|
260
310
|
handelContainerDelete (id, pageIndex) {
|
|
261
311
|
this.$emit('containerDelete', id, pageIndex)
|
|
262
312
|
},
|
|
313
|
+
// 处理组件的事件
|
|
263
314
|
handleEvent (data, eventTiggerType, id) {
|
|
264
|
-
|
|
315
|
+
// 找到目标对象的配置
|
|
316
|
+
const targetConfig = lowcodeUtils.getComponentConfig(id, this.pageConfig.page)
|
|
317
|
+
// 找到目标对象对应触发事件的配置
|
|
265
318
|
const eventConfigs = targetConfig.onEvent[eventTiggerType]
|
|
266
319
|
|
|
267
320
|
if (!eventConfigs) {
|
|
@@ -278,41 +331,84 @@ export default {
|
|
|
278
331
|
|
|
279
332
|
let targetComponentId = ''
|
|
280
333
|
|
|
334
|
+
// 遍历该类型触发事件,挨个执行
|
|
281
335
|
eventConfigs.forEach(eachEvent => {
|
|
282
336
|
lowcodeLog(
|
|
283
337
|
` 事件数据:${data} \n 目标组件: ${targetComponentId}`,
|
|
284
338
|
'开始遍历执行事件',
|
|
285
|
-
eachEvent.
|
|
339
|
+
eachEvent.eventType,
|
|
286
340
|
false
|
|
287
341
|
)
|
|
342
|
+
// 修改弹窗显隐
|
|
288
343
|
if (eachEvent.eventType === 'showDraw') {
|
|
289
|
-
this.drawVisible =
|
|
344
|
+
this.drawVisible[eachEvent.containerId] = eachEvent.visible === 'open'
|
|
345
|
+
this.$forceUpdate()
|
|
290
346
|
lowcodeLog(
|
|
291
|
-
|
|
292
|
-
'
|
|
293
|
-
'',
|
|
347
|
+
eachEvent.containerId,
|
|
348
|
+
'修改抽屉可见性',
|
|
349
|
+
eachEvent.visible === 'open' ? '可见' : '隐藏',
|
|
294
350
|
false,
|
|
295
351
|
true
|
|
296
352
|
)
|
|
353
|
+
// 修改抽屉显隐
|
|
297
354
|
} else if (eachEvent.eventType === 'showModal') {
|
|
298
|
-
this.modalVisible =
|
|
355
|
+
this.modalVisible[eachEvent.containerId] = eachEvent.visible === 'open'
|
|
356
|
+
this.$forceUpdate()
|
|
357
|
+
lowcodeLog(
|
|
358
|
+
eachEvent.containerId,
|
|
359
|
+
'修改弹窗可见性',
|
|
360
|
+
eachEvent.visible === 'open' ? '可见' : '隐藏',
|
|
361
|
+
false,
|
|
362
|
+
true
|
|
363
|
+
)
|
|
364
|
+
// 运行Logic
|
|
365
|
+
} else if (eachEvent.eventType === 'runLogic') {
|
|
366
|
+
// eslint-disable-next-line no-eval
|
|
367
|
+
const logicCallBackFunction = eval('(' + eachEvent.logicCallBackFunction + ')')
|
|
368
|
+
// eslint-disable-next-line no-eval
|
|
369
|
+
const logicParamFunction = eval('(' + eachEvent.logicParamFunction + ')')
|
|
370
|
+
const param = logicParamFunction(this.globalVariable, data)
|
|
371
|
+
lowcodeLog(
|
|
372
|
+
JSON.stringify(param),
|
|
373
|
+
'执行Logic',
|
|
374
|
+
eachEvent.logicName,
|
|
375
|
+
false,
|
|
376
|
+
true
|
|
377
|
+
)
|
|
378
|
+
runLogic(eachEvent.logicName, param, eachEvent.serviceName).then(logicCallBackFunction(this.componentsMap))
|
|
379
|
+
// 为全局组件赋值
|
|
380
|
+
} else if (eachEvent.eventType === 'changeGlobalVariable') {
|
|
381
|
+
this.globalVariable[eachEvent.globalVariableKey] = data
|
|
299
382
|
lowcodeLog(
|
|
300
|
-
undefined,
|
|
301
|
-
'打开弹窗',
|
|
302
383
|
'',
|
|
384
|
+
'修改全局变量',
|
|
385
|
+
eachEvent.globalVariableKey,
|
|
303
386
|
false,
|
|
304
387
|
true
|
|
305
388
|
)
|
|
389
|
+
// 通知外侧编辑器修改全局组件的值,在编辑模式中,可以实时掌握全局变量的值
|
|
390
|
+
this.$emit('changeGlobalVariable', eachEvent.globalVariableKey, data)
|
|
391
|
+
// 修改组件的props
|
|
306
392
|
} else if (eachEvent.eventType === 'changeProps') {
|
|
307
|
-
const targetConfig = lowcodeUtils.getComponentConfig(eachEvent.target, this.pageConfig)
|
|
393
|
+
const targetConfig = lowcodeUtils.getComponentConfig(eachEvent.target, this.pageConfig.page)
|
|
308
394
|
targetConfig.props[eachEvent.targetKey] = data
|
|
309
395
|
lowcodeLog(
|
|
310
|
-
`目标key:${eachEvent.targetKey},新的值:${
|
|
396
|
+
`目标key:${eachEvent.targetKey},新的值:${JSON.stringify(data)}`,
|
|
311
397
|
'修改Props',
|
|
312
398
|
targetConfig.id,
|
|
313
399
|
false,
|
|
314
400
|
true
|
|
315
401
|
)
|
|
402
|
+
// 打印日志
|
|
403
|
+
} else if (eachEvent.eventType === 'log') {
|
|
404
|
+
lowcodeLog(
|
|
405
|
+
JSON.stringify(data),
|
|
406
|
+
'打印日志',
|
|
407
|
+
targetConfig.id,
|
|
408
|
+
false,
|
|
409
|
+
true
|
|
410
|
+
)
|
|
411
|
+
// 修改组件的值
|
|
316
412
|
} else if (eachEvent.eventType === 'changeValue') {
|
|
317
413
|
// 寻找target
|
|
318
414
|
targetComponentId = eachEvent.target
|
|
@@ -336,18 +432,6 @@ export default {
|
|
|
336
432
|
}
|
|
337
433
|
})
|
|
338
434
|
}
|
|
339
|
-
},
|
|
340
|
-
watch: {
|
|
341
|
-
showModal: {
|
|
342
|
-
handler () {
|
|
343
|
-
this.modalVisible = !this.modalVisible
|
|
344
|
-
}
|
|
345
|
-
},
|
|
346
|
-
showDraw: {
|
|
347
|
-
handler () {
|
|
348
|
-
this.drawVisible = !this.drawVisible
|
|
349
|
-
}
|
|
350
|
-
},
|
|
351
435
|
}
|
|
352
436
|
}
|
|
353
437
|
</script>
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
+
<a-upload
|
|
4
|
+
v-if="uploadStyle === 'simple'"
|
|
5
|
+
:accept="model.accept?.join('')"
|
|
6
|
+
:customRequest="uploadFiles"
|
|
7
|
+
:file-list="uploadedFileList"
|
|
8
|
+
:remove="deleteFileItem">
|
|
9
|
+
<a-button style="margin-top: 2%"> <a-icon type="upload" /> 上传 </a-button>
|
|
10
|
+
</a-upload>
|
|
3
11
|
<a-upload-dragger
|
|
4
|
-
v-if="model.type === 'file'"
|
|
5
|
-
:accept="model.accept
|
|
12
|
+
v-else-if="model.type === 'file'"
|
|
13
|
+
:accept="model.accept?.join('')"
|
|
6
14
|
:customRequest="uploadFiles"
|
|
7
15
|
:file-list="uploadedFileList"
|
|
8
16
|
:multiple="true"
|
|
@@ -18,30 +26,18 @@
|
|
|
18
26
|
支持单个或多个文件
|
|
19
27
|
</p>
|
|
20
28
|
</a-upload-dragger>
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
v-if=" model.type === 'image'"
|
|
34
|
-
:accept="model.accept.join('')"
|
|
35
|
-
:customRequest="uploadFiles"
|
|
36
|
-
:file-list="uploadedFileList"
|
|
37
|
-
:remove="deleteFileItem"
|
|
38
|
-
list-type="picture-card">
|
|
39
|
-
<a-icon type="plus"/>
|
|
40
|
-
<div class="ant-upload-text">
|
|
41
|
-
Upload
|
|
42
|
-
</div>
|
|
43
|
-
</a-upload>
|
|
44
|
-
</template>
|
|
29
|
+
<a-upload
|
|
30
|
+
v-else
|
|
31
|
+
:accept="model.accept?.join('')"
|
|
32
|
+
:customRequest="uploadFiles"
|
|
33
|
+
:file-list="uploadedFileList"
|
|
34
|
+
:remove="deleteFileItem"
|
|
35
|
+
list-type="picture-card">
|
|
36
|
+
<a-icon type="plus"/>
|
|
37
|
+
<div class="ant-upload-text">
|
|
38
|
+
Upload
|
|
39
|
+
</div>
|
|
40
|
+
</a-upload>
|
|
45
41
|
</div>
|
|
46
42
|
</template>
|
|
47
43
|
|