vue2-client 1.8.215 → 1.8.217

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.215",
3
+ "version": "1.8.217",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "SET NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve --no-eslint",
@@ -1,138 +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
+ <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,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.join('')"
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
- <template v-if="uploadStyle === 'simple'">
22
- <a-upload
23
- v-if=" model.type === 'image'"
24
- :accept="model.accept.join('')"
25
- :customRequest="uploadFiles"
26
- :file-list="uploadedFileList"
27
- :remove="deleteFileItem">
28
- <a-button style="margin-top: 2%"> <a-icon type="upload" /> 上传 </a-button>
29
- </a-upload>
30
- </template>
31
- <template v-else>
32
- <a-upload
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