vue2-client 1.8.205 → 1.8.207

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 CHANGED
@@ -1,161 +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
- ```
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2-client",
3
- "version": "1.8.205",
3
+ "version": "1.8.207",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
package/src/App.vue CHANGED
@@ -114,12 +114,15 @@ export default {
114
114
  }
115
115
  },
116
116
  setMicroAppTheme (themeStore) {
117
- let themeScheme = 'dark'
118
- if (themeStore && themeStore.themeColor && themeStore.themeScheme) {
119
- if (themeStore.themeScheme === 'dark') {
120
- themeScheme = 'night'
117
+ try {
118
+ let themeScheme = 'dark'
119
+ if (themeStore && themeStore.themeColor && themeStore.themeScheme) {
120
+ if (themeStore.themeScheme === 'dark') {
121
+ themeScheme = 'night'
122
+ }
123
+ themeUtil.changeThemeColor(themeStore.themeColor, themeScheme)
121
124
  }
122
- themeUtil.changeThemeColor(themeStore.themeColor, themeScheme)
125
+ }catch (e){
123
126
  }
124
127
  },
125
128
  setLanguage (lang) {
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  <div style="height: auto; width: 1%;" class="dragDiv" @mousedown="dragStart($event, item.id, page.body)"></div>
33
33
  </div>
34
- <div :class=" editMode ? 'componentInEditor' : '' " v-else>
34
+ <div :class=" editMode ? 'componentInEditor' : '' " v-else-if="editMode || (page.type !== 'modal' && page.type !== 'draw')">
35
35
  <component
36
36
  :is="resolveComponentType(item.type, item.id)"
37
37
  :propsData="{...item.props}"
@@ -44,6 +44,48 @@
44
44
  </template>
45
45
  </a-row>
46
46
  </template>
47
+ <template v-for="(modal, modalIndex) in pageConfig.filter(page => page.type === 'modal')">
48
+ <a-modal
49
+ :key="'modalIndex_' + modalIndex"
50
+ :title="modal.title"
51
+ :width="modal.width"
52
+ :dialog-style="{ top: '5rem' }"
53
+ :visible="modalVisible"
54
+ :z-index="1003"
55
+ :maskClosable="false"
56
+ @cancel="() => { modalVisible = false }"
57
+ :destroyOnClose="true">
58
+ <template v-for="(item, itemIndex) in modal.body">
59
+ <component
60
+ :key="'modalItem_' + itemIndex"
61
+ :is="resolveComponentType(item.type)"
62
+ :propsData="{...item.props, showModalOrDraw: false}"
63
+ @componentDidMounted="componentDidMounted"
64
+ @onEvent="handleEvent"
65
+ :mixinComponentId="item.id"/>
66
+ </template>
67
+ </a-modal>
68
+ </template>
69
+ <template v-for="(draw, drawIndex) in pageConfig.filter(page => page.type === 'draw')">
70
+ <a-drawer
71
+ :key="'drawIndex_' + drawIndex"
72
+ :title="draw.title"
73
+ :width="draw.width"
74
+ :visible="drawVisible"
75
+ :z-index="1003"
76
+ @close="() => { drawVisible = false }"
77
+ :destroyOnClose="true">
78
+ <template v-for="(item, itemIndex) in draw.body">
79
+ <component
80
+ :key="'drawItem_' + itemIndex"
81
+ :is="resolveComponentType(item.type)"
82
+ :propsData="{...item.props, showModalOrDraw: false}"
83
+ @componentDidMounted="componentDidMounted"
84
+ @onEvent="handleEvent"
85
+ :mixinComponentId="item.id"/>
86
+ </template>
87
+ </a-drawer>
88
+ </template>
47
89
  </div>
48
90
  </template>
49
91
 
@@ -63,6 +105,14 @@ export default {
63
105
  editMode: {
64
106
  type: Boolean,
65
107
  default: true
108
+ },
109
+ showModal: {
110
+ type: Boolean,
111
+ default: false
112
+ },
113
+ showDraw: {
114
+ type: Boolean,
115
+ default: false
66
116
  }
67
117
  },
68
118
  data () {
@@ -73,6 +123,8 @@ export default {
73
123
  beforeSpanThrough: -1,
74
124
  originalSpan: -1,
75
125
  nextOriginalSpan: -1,
126
+ modalVisible: false,
127
+ drawVisible: false
76
128
  }
77
129
  },
78
130
  inject: [
@@ -166,13 +218,6 @@ export default {
166
218
  document.addEventListener('mouseup', dragEnd)
167
219
  document.addEventListener('mousemove', onDrag)
168
220
  },
169
- calcRowSpanTotal (page) {
170
- let result = 0
171
- page.body.forEach(item => {
172
- result += item.span
173
- })
174
- return result
175
- },
176
221
  resolveComponentType (type, componentId) {
177
222
  switch (type) {
178
223
  case 'XFormTable':
@@ -181,6 +226,12 @@ export default {
181
226
  // return XTree
182
227
  case 'XTreeOne':
183
228
  return allComponents.XTreeOne
229
+ case 'XAddNativeFormForLowcode':
230
+ return allComponents.XAddNativeFormModal
231
+ case 'XAddNativeForm':
232
+ return allComponents.XAddNativeForm
233
+ case 'XDescriptions':
234
+ return allComponents.XDescriptions
184
235
  }
185
236
  },
186
237
  componentDidMounted (vm, id) {
@@ -192,7 +243,9 @@ export default {
192
243
  if (item.id === id) {
193
244
  const keys = Object.keys(item.props)
194
245
  keys.forEach(key => {
195
- Vue.set(vm, key, item.props[key])
246
+ if (item.props[key] !== undefined && item.props[key] !== '') {
247
+ Vue.set(vm, key, item.props[key])
248
+ }
196
249
  })
197
250
  }
198
251
  })
@@ -226,33 +279,75 @@ export default {
226
279
  let targetComponentId = ''
227
280
 
228
281
  eventConfigs.forEach(eachEvent => {
229
- // 寻找target
230
- targetComponentId = eachEvent.target
231
- const targetVM = this.componentsMap[targetComponentId]
232
282
  lowcodeLog(
233
283
  ` 事件数据:${data} \n 目标组件: ${targetComponentId}`,
234
284
  '开始遍历执行事件',
235
285
  eachEvent.eventName,
236
286
  false
237
287
  )
238
- // 执行
239
- // 是否存在js函数
240
- if (eachEvent.JSFunction !== undefined && eachEvent.JSFunction !== '') {
288
+ if (eachEvent.eventType === 'showDraw') {
289
+ this.drawVisible = true
241
290
  lowcodeLog(
242
- '发现自定义JS函数,开始执行',
243
- '自定义函数',
244
291
  undefined,
245
- false
292
+ '打开抽屉',
293
+ '',
294
+ false,
295
+ true
246
296
  )
247
- // eslint-disable-next-line no-eval
248
- const customFunction = eval('(' + eachEvent.JSFunction + ')')
249
- const returnValue = customFunction(eachEvent.eventName, data, eachEvent.targetKey, vm, targetVM)
250
- targetVM.handleComponentCommunication(returnValue.eventType, returnValue.data, returnValue.targetKey, vm)
251
- } else {
252
- targetVM.handleComponentCommunication(eachEvent.eventName, data, eachEvent.targetKey, vm)
297
+ } else if (eachEvent.eventType === 'showModal') {
298
+ this.modalVisible = true
299
+ lowcodeLog(
300
+ undefined,
301
+ '打开弹窗',
302
+ '',
303
+ false,
304
+ true
305
+ )
306
+ } else if (eachEvent.eventType === 'changeProps') {
307
+ const targetConfig = lowcodeUtils.getComponentConfig(eachEvent.target, this.pageConfig)
308
+ targetConfig.props[eachEvent.targetKey] = data
309
+ lowcodeLog(
310
+ `目标key:${eachEvent.targetKey},新的值:${data.toString()}`,
311
+ '修改Props',
312
+ targetConfig.id,
313
+ false,
314
+ true
315
+ )
316
+ } else if (eachEvent.eventType === 'changeValue') {
317
+ // 寻找target
318
+ targetComponentId = eachEvent.target
319
+ const targetVM = this.componentsMap[targetComponentId]
320
+ // 执行
321
+ // 是否存在js函数
322
+ if (eachEvent.JSFunction !== undefined && eachEvent.JSFunction !== '') {
323
+ lowcodeLog(
324
+ '发现自定义JS函数,开始执行',
325
+ '自定义函数',
326
+ undefined,
327
+ false
328
+ )
329
+ // eslint-disable-next-line no-eval
330
+ const customFunction = eval('(' + eachEvent.JSFunction + ')')
331
+ const returnValue = customFunction(eachEvent.eventName, data, eachEvent.targetKey, vm, targetVM)
332
+ targetVM.handleComponentCommunication(returnValue.eventType, returnValue.data, returnValue.targetKey, vm)
333
+ } else {
334
+ targetVM.handleComponentCommunication(eachEvent.eventName, data, eachEvent.targetKey, vm)
335
+ }
253
336
  }
254
337
  })
255
338
  }
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
+ },
256
351
  }
257
352
  }
258
353
  </script>
@@ -72,14 +72,25 @@
72
72
  import XFormItem from '@vue2-client/base-client/components/common/XForm/XFormItem'
73
73
  import { formatDate } from '@vue2-client/utils/util'
74
74
  import { mapState } from 'vuex'
75
- import { addOrModify, runLogic } from '@vue2-client/services/api/common'
75
+ import { addOrModify, getConfigByName, runLogic } from '@vue2-client/services/api/common'
76
+ import lowcodeComponentMixin from '@vue2-client/utils/lowcode/lowcodeComponentMixin'
76
77
 
77
78
  export default {
78
79
  name: 'XAddNativeForm',
79
80
  components: {
80
81
  XFormItem
81
82
  },
82
- props: {},
83
+ props: {
84
+ configNameForLowCode: {
85
+ type: String,
86
+ default: undefined
87
+ },
88
+ systemNameForLowCode: {
89
+ type: String,
90
+ default: undefined
91
+ }
92
+ },
93
+ mixins: [lowcodeComponentMixin],
83
94
  data () {
84
95
  return {
85
96
  // 预览模式
@@ -182,6 +193,19 @@ export default {
182
193
  },
183
194
  ...mapState('account', { currUser: 'user' })
184
195
  },
196
+ mounted () {
197
+ if (this.configNameForLowCode !== undefined) {
198
+ getConfigByName(this.configNameForLowCode, this.systemNameForLowCode, (res) => {
199
+ this.init({
200
+ formItems: res.formJson,
201
+ title: this.modalTitle,
202
+ businessType: this.businessType,
203
+ layout: res.xAddFormLayout,
204
+ isKeyHandle: res.isKeyHandle
205
+ })
206
+ })
207
+ }
208
+ },
185
209
  methods: {
186
210
  init (params) {
187
211
  const {
@@ -536,6 +560,18 @@ export default {
536
560
  }
537
561
  }
538
562
  }
563
+ },
564
+ watch: {
565
+ configNameForLowCode: {
566
+ handler () {
567
+ this.init()
568
+ }
569
+ },
570
+ systemNameForLowCode: {
571
+ handler () {
572
+ this.init()
573
+ }
574
+ },
539
575
  }
540
576
  }
541
577
  </script>
@@ -0,0 +1,12 @@
1
+ export const XAddNativeFormConfig = {
2
+ type: 'XAddNativeForm',
3
+ properties: {
4
+ configNameForLowCode: {
5
+ type: 'string'
6
+ },
7
+ systemNameForLowCode: {
8
+ type: 'string'
9
+ }
10
+ },
11
+ selfEvent: ['onSubmit']
12
+ }