vue2-client 1.8.229 → 1.8.231
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/public/index.html +1 -1
- package/src/base-client/components/common/XDescriptions/XDescriptionsGroup.vue +299 -0
- package/src/base-client/components/common/XDescriptions/demo.vue +50 -0
- package/src/base-client/components/common/XFormGroup/XFormGroup.vue +69 -48
- package/src/pages/Example/index.vue +3 -1
- package/vue.config.js +2 -2
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<noscript>
|
|
16
16
|
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
17
17
|
</noscript>
|
|
18
|
-
<div id="popContainer" class="beauty-scroll" style="height:
|
|
18
|
+
<div id="popContainer" class="beauty-scroll" style="height: 100%; overflow-y: auto">
|
|
19
19
|
<div id="app"></div>
|
|
20
20
|
</div>
|
|
21
21
|
<!-- require cdn assets js -->
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<a-row id="XDescriptionGroup" :gutter="24">
|
|
3
|
+
<a-col :span="4" v-if="showLeftTab && realData.length">
|
|
4
|
+
<a-tabs tab-position="left" v-model="activeTab" @change="scrollToGroup">
|
|
5
|
+
<template v-for="(item,index) in realData">
|
|
6
|
+
<a-tab-pane
|
|
7
|
+
:tab="item.title"
|
|
8
|
+
:key="index"
|
|
9
|
+
v-if="item.title">
|
|
10
|
+
</a-tab-pane>
|
|
11
|
+
</template>
|
|
12
|
+
</a-tabs>
|
|
13
|
+
</a-col>
|
|
14
|
+
<a-col :span="showLeftTab ? 20 : 24" ref="descriptionsGroupContext" class="descriptionsGroupContext">
|
|
15
|
+
<div
|
|
16
|
+
class="descriptions-item"
|
|
17
|
+
:ref="`descriptions-item-${index}`"
|
|
18
|
+
:key="index"
|
|
19
|
+
v-for="(realDataItem, index) in realData">
|
|
20
|
+
<template v-if="!loadError">
|
|
21
|
+
<!-- 带有子的详情 -->
|
|
22
|
+
<template
|
|
23
|
+
v-if="realDataItem.title && groups[realDataItem.title]?.type ==='array'"
|
|
24
|
+
>
|
|
25
|
+
<div class="ant-descriptions-title">{{ realDataItem.title }}</div>
|
|
26
|
+
<div class="descriptions-array-item">
|
|
27
|
+
<a-descriptions
|
|
28
|
+
v-for="(arrayItem,arrayIndex) in realDataItem.column"
|
|
29
|
+
:column="isMobile ? 1 : column"
|
|
30
|
+
size="small"
|
|
31
|
+
:key="arrayIndex"
|
|
32
|
+
:title="arrayItem.title">
|
|
33
|
+
{{ arrayItem }}
|
|
34
|
+
<template v-for="(item, index) in arrayItem.column">
|
|
35
|
+
<!-- 大多数情况 循环下 空值省略不展示,todo 后期可能加配置处理 -->
|
|
36
|
+
<a-descriptions-item
|
|
37
|
+
:key="index"
|
|
38
|
+
v-if="item.value"
|
|
39
|
+
:label="item.key">
|
|
40
|
+
{{ formatText(item.value) }}
|
|
41
|
+
</a-descriptions-item>
|
|
42
|
+
</template>
|
|
43
|
+
</a-descriptions>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
<a-descriptions
|
|
47
|
+
v-else-if="realDataItem.title"
|
|
48
|
+
:column="isMobile ? 1 : column"
|
|
49
|
+
size="small"
|
|
50
|
+
:title="realDataItem.title">
|
|
51
|
+
<a-descriptions-item
|
|
52
|
+
v-for="(item, index) in realDataItem.column"
|
|
53
|
+
:key="index"
|
|
54
|
+
:label="item.key">
|
|
55
|
+
{{ formatText(item.value) }}
|
|
56
|
+
</a-descriptions-item>
|
|
57
|
+
</a-descriptions>
|
|
58
|
+
</template>
|
|
59
|
+
</div>
|
|
60
|
+
</a-col>
|
|
61
|
+
</a-row>
|
|
62
|
+
</template>
|
|
63
|
+
<script>
|
|
64
|
+
|
|
65
|
+
import { mapState } from 'vuex'
|
|
66
|
+
import { getRealKeyData } from '@vue2-client/utils/formatter'
|
|
67
|
+
import { getConfigByName } from '@vue2-client/services/api/common'
|
|
68
|
+
import lowcodeComponentMixin from '@vue2-client/utils/lowcode/lowcodeComponentMixin'
|
|
69
|
+
import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
name: 'XDescriptionsGroup',
|
|
73
|
+
components: {
|
|
74
|
+
XAddNativeForm
|
|
75
|
+
},
|
|
76
|
+
mixins: [lowcodeComponentMixin],
|
|
77
|
+
props: {
|
|
78
|
+
// 内容
|
|
79
|
+
data: {
|
|
80
|
+
type: Object,
|
|
81
|
+
required: true,
|
|
82
|
+
default: undefined
|
|
83
|
+
},
|
|
84
|
+
// 展示列配置 格式 {title:[{key,name}]} {描述列表标题:[{字段名,字段中文名}]}
|
|
85
|
+
// {
|
|
86
|
+
// "groups": {
|
|
87
|
+
// "表具信息": {
|
|
88
|
+
// "f_gasbrand": "气表品牌"
|
|
89
|
+
// },
|
|
90
|
+
// "客户信息": {
|
|
91
|
+
// "f_userinfo_code": "用户编号"
|
|
92
|
+
// },
|
|
93
|
+
// "设备信息":{
|
|
94
|
+
// "type": "array",
|
|
95
|
+
// "value": {
|
|
96
|
+
// "f_devices_num": "设备数量",
|
|
97
|
+
// "f_devices_type": "设备类型",
|
|
98
|
+
// },
|
|
99
|
+
// "key": "devices"
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
103
|
+
configName: {
|
|
104
|
+
type: String,
|
|
105
|
+
required: true,
|
|
106
|
+
default: ''
|
|
107
|
+
},
|
|
108
|
+
// 配置所属命名空间
|
|
109
|
+
serviceName: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: process.env.VUE_APP_SYSTEM_NAME
|
|
112
|
+
},
|
|
113
|
+
// 每列显示数量
|
|
114
|
+
column: {
|
|
115
|
+
type: Number,
|
|
116
|
+
default: 3
|
|
117
|
+
},
|
|
118
|
+
// 处理 key tuf_f_userinfo_id -> f_userinfo_id
|
|
119
|
+
getRealData: {
|
|
120
|
+
type: Boolean,
|
|
121
|
+
default: false
|
|
122
|
+
},
|
|
123
|
+
// 是否展示左侧tab
|
|
124
|
+
showLeftTab: {
|
|
125
|
+
type: Boolean,
|
|
126
|
+
default: false
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
mounted () {
|
|
130
|
+
},
|
|
131
|
+
beforeDestroy () {
|
|
132
|
+
const formGroupContext = this.$refs.formGroupContext?.$el
|
|
133
|
+
if (formGroupContext && formGroupContext.removeEventListener) {
|
|
134
|
+
formGroupContext.removeEventListener('scroll', this.onScroll)
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
created () {
|
|
138
|
+
this.initConfig()
|
|
139
|
+
},
|
|
140
|
+
data () {
|
|
141
|
+
return {
|
|
142
|
+
// 加载状态
|
|
143
|
+
loading: false,
|
|
144
|
+
loadError: false,
|
|
145
|
+
realData: [],
|
|
146
|
+
// 获取到的配置组
|
|
147
|
+
groups: {},
|
|
148
|
+
activeTab: 0
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
computed: {
|
|
152
|
+
...mapState('setting', { isMobile: 'isMobile' })
|
|
153
|
+
},
|
|
154
|
+
methods: {
|
|
155
|
+
initConfig () {
|
|
156
|
+
this.loading = true
|
|
157
|
+
if (this.configName) {
|
|
158
|
+
this.getConfig()
|
|
159
|
+
this.$nextTick(() => {
|
|
160
|
+
const formGroupContext = this.$refs.descriptionsGroupContext?.$el
|
|
161
|
+
if (formGroupContext && formGroupContext.addEventListener) {
|
|
162
|
+
formGroupContext.addEventListener('scroll', this.onScroll)
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
} else {
|
|
166
|
+
this.loading = false
|
|
167
|
+
this.loadError = true
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
scrollToGroup (index) {
|
|
171
|
+
const groupElement = this.$refs[`descriptions-item-${index}`][0]
|
|
172
|
+
if (groupElement) {
|
|
173
|
+
groupElement.scrollIntoView({ behavior: 'smooth' })
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
getConfig () {
|
|
177
|
+
getConfigByName(this.configName, this.serviceName, (res) => {
|
|
178
|
+
if (res.groups) {
|
|
179
|
+
this.groups = res.groups
|
|
180
|
+
this.realData = Object.keys(res.groups).map((h) => {
|
|
181
|
+
const hObj = res.groups[h]
|
|
182
|
+
const dataItem = {}
|
|
183
|
+
dataItem.title = h
|
|
184
|
+
dataItem.column = []
|
|
185
|
+
if (hObj.type && hObj.type === 'array') {
|
|
186
|
+
// 从data 取出数组
|
|
187
|
+
const arrayData = this.data[hObj.key]
|
|
188
|
+
const arrayDataItem = arrayData.map((item, index) => {
|
|
189
|
+
const arrayItem = {
|
|
190
|
+
title: `${h} ${index + 1}`,
|
|
191
|
+
column: Object.keys(hObj.value).map((key) => {
|
|
192
|
+
return {
|
|
193
|
+
key: hObj.value[key],
|
|
194
|
+
value: item[key]
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
}
|
|
198
|
+
// 如果所有 value 都是空的 return null todo 后期可能做成配置
|
|
199
|
+
const isAllNull = arrayItem.column.every((item) => {
|
|
200
|
+
return item.value === null || item.value === ''
|
|
201
|
+
})
|
|
202
|
+
return isAllNull ? null : arrayItem
|
|
203
|
+
}).filter((item) => item)
|
|
204
|
+
if (arrayDataItem.length) {
|
|
205
|
+
dataItem.column = arrayDataItem
|
|
206
|
+
return dataItem
|
|
207
|
+
} else {
|
|
208
|
+
return null
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
const tempData = Object.keys(hObj).map((key) => {
|
|
212
|
+
// 如果是数组形态
|
|
213
|
+
return { key: hObj[key], value: this.getRealKeyData(this.data, key) }
|
|
214
|
+
})
|
|
215
|
+
// 如果所有 value 都是空的 return null todo 后期可能做成配置
|
|
216
|
+
const isAllNull = tempData.every((item) => {
|
|
217
|
+
return item.value === null || item.value === ''
|
|
218
|
+
})
|
|
219
|
+
if (isAllNull) {
|
|
220
|
+
return null
|
|
221
|
+
} else {
|
|
222
|
+
dataItem.column = tempData
|
|
223
|
+
return dataItem
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}).filter((item) => item)
|
|
227
|
+
} else {
|
|
228
|
+
this.loading = false
|
|
229
|
+
this.loadError = true
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
},
|
|
233
|
+
// 文字格式化
|
|
234
|
+
formatText (value) {
|
|
235
|
+
return value || '--'
|
|
236
|
+
},
|
|
237
|
+
getRealKeyData (data, key) {
|
|
238
|
+
if (this.getRealData) {
|
|
239
|
+
return getRealKeyData(data)[key] || ''
|
|
240
|
+
} else {
|
|
241
|
+
return this.data[key] || ''
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
onScroll () {
|
|
245
|
+
const formGroupContext = this.$refs.descriptionsGroupContext.$el
|
|
246
|
+
let groupItems = []
|
|
247
|
+
if (formGroupContext && formGroupContext.querySelectorAll) {
|
|
248
|
+
groupItems = formGroupContext.querySelectorAll('.descriptions-item')
|
|
249
|
+
}
|
|
250
|
+
let activeIndex = this.activeTab
|
|
251
|
+
|
|
252
|
+
groupItems.forEach((item, index) => {
|
|
253
|
+
const rect = item.getBoundingClientRect()
|
|
254
|
+
if (rect.top <= 205 && rect.bottom > 200) {
|
|
255
|
+
activeIndex = index
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
this.activeTab = activeIndex
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
watch: {
|
|
262
|
+
content: {
|
|
263
|
+
handler () {
|
|
264
|
+
this.initConfig()
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
configName: {
|
|
268
|
+
handler () {
|
|
269
|
+
this.initConfig()
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
serviceName: {
|
|
273
|
+
handler () {
|
|
274
|
+
this.initConfig()
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
</script>
|
|
280
|
+
|
|
281
|
+
<style lang="less" scoped>
|
|
282
|
+
#XDescriptionGroup {
|
|
283
|
+
height: 100%;
|
|
284
|
+
:deep(.ant-descriptions-title) {
|
|
285
|
+
color: @primary-color;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.descriptions-item {
|
|
289
|
+
margin-bottom: 8px;
|
|
290
|
+
}
|
|
291
|
+
.descriptions-array-item{
|
|
292
|
+
padding-left: 1rem;
|
|
293
|
+
}
|
|
294
|
+
.descriptionsGroupContext {
|
|
295
|
+
height: 100%;
|
|
296
|
+
overflow-y: scroll;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import XDescriptionsGroup from '@vue2-client/base-client/components/common/XDescriptions/XDescriptionsGroup.vue'
|
|
3
|
+
import { runLogic } from '@vue2-client/services/api/common'
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
name: 'Demo',
|
|
7
|
+
components: { XDescriptionsGroup },
|
|
8
|
+
data () {
|
|
9
|
+
return {
|
|
10
|
+
visible: false,
|
|
11
|
+
userinfo: {
|
|
12
|
+
f_userinfo_code: '143400000003',
|
|
13
|
+
f_gasbrand: '测试表品牌'
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
open () {
|
|
19
|
+
runLogic('querySingleUserDetail', {
|
|
20
|
+
f_userinfo_code: '143400000003'
|
|
21
|
+
}, 'af-revenue').then(res => {
|
|
22
|
+
this.userinfo = res
|
|
23
|
+
this.visible = true
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<div>
|
|
32
|
+
<a-button @click="open">
|
|
33
|
+
展开详情
|
|
34
|
+
</a-button>
|
|
35
|
+
<a-drawer
|
|
36
|
+
title="描述列表详情"
|
|
37
|
+
placement="right"
|
|
38
|
+
width="65vw"
|
|
39
|
+
:body-style="{height:'92%'}"
|
|
40
|
+
:visible="visible"
|
|
41
|
+
@close="()=>{visible = false}"
|
|
42
|
+
>
|
|
43
|
+
<x-descriptions-group config-name="用户详情描述列表" :showLeftTab="true" :data="userinfo" service-name="af-revenue"/>
|
|
44
|
+
</a-drawer>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped lang="less">
|
|
49
|
+
|
|
50
|
+
</style>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="groups.length ? 'XFormGroupClass' : ''">
|
|
3
3
|
<a-empty v-if="loadingErr" description="配置走丢了"/>
|
|
4
|
-
<a-spin v-else tip="
|
|
5
|
-
<a-row :gutter="24" style="height:100%">
|
|
4
|
+
<a-spin v-else tip="正在努力加载..." :spinning="spinning" wrapperClassName="heigth100">
|
|
5
|
+
<a-row :gutter="24" style="height: 100%">
|
|
6
6
|
<a-col :span="3" v-if="showLeftTab && groups.length">
|
|
7
|
-
<a-tabs tab-position="left" @change="scrollToGroup">
|
|
8
|
-
<template v-for="(item,index) in groups">
|
|
7
|
+
<a-tabs tab-position="left" v-model="activeTab" @change="scrollToGroup">
|
|
8
|
+
<template v-for="(item, index) in groups">
|
|
9
9
|
<a-tab-pane
|
|
10
10
|
:tab="item.describe"
|
|
11
11
|
:key="index"
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
</a-tabs>
|
|
16
16
|
</a-col>
|
|
17
|
-
<a-col :span="showLeftTab ? 21 : 24" class="formGroupContext">
|
|
17
|
+
<a-col :span="showLeftTab ? 21 : 24" class="formGroupContext" ref="formGroupContext">
|
|
18
18
|
<div class="group-item" :ref="`group-${index}`" :key="index" v-for="(item, index) in groups">
|
|
19
|
-
<a-row :style="{marginTop: index === 0 ? '':'8px'}">
|
|
19
|
+
<a-row :style="{ marginTop: index === 0 ? '' : '8px' }">
|
|
20
20
|
<a-col :span="5">
|
|
21
21
|
<span class="xFormGroupTitle">{{ item.describe }}</span>
|
|
22
22
|
</a-col>
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
|
|
37
37
|
<script>
|
|
38
38
|
import XAddNativeForm from '@vue2-client/base-client/components/common/XAddNativeForm/XAddNativeForm.vue'
|
|
39
|
-
import { parseConfig } from '@vue2-client/services/api/common'
|
|
40
39
|
|
|
41
40
|
export default {
|
|
42
41
|
name: 'XFormGroup',
|
|
@@ -58,14 +57,18 @@ export default {
|
|
|
58
57
|
businessType: {},
|
|
59
58
|
env: 'prod',
|
|
60
59
|
spinning: true,
|
|
61
|
-
loadingErr: false
|
|
60
|
+
loadingErr: false,
|
|
61
|
+
activeTab: 0
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
mounted () {
|
|
65
65
|
},
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
beforeDestroy () {
|
|
67
|
+
const formGroupContext = this.$refs.formGroupContext?.$el
|
|
68
|
+
if (formGroupContext && formGroupContext.removeEventListener) {
|
|
69
|
+
formGroupContext.removeEventListener('scroll', this.onScroll)
|
|
70
|
+
}
|
|
71
|
+
},
|
|
69
72
|
methods: {
|
|
70
73
|
setRef (refName, refValue) {
|
|
71
74
|
if (!this.$refs[refName]) {
|
|
@@ -82,15 +85,21 @@ export default {
|
|
|
82
85
|
* @param businessType 新增还是修改
|
|
83
86
|
*/
|
|
84
87
|
init ({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
groups,
|
|
89
|
+
modifyModelData = {},
|
|
90
|
+
serviceName = process.env.VUE_APP_SYSTEM_NAME,
|
|
91
|
+
env = 'prod',
|
|
92
|
+
showLeftTab = false,
|
|
93
|
+
businessType = '新增'
|
|
94
|
+
}) {
|
|
92
95
|
Object.assign(this, { groups, modifyModelData, serviceName, env, showLeftTab, businessType })
|
|
93
96
|
this.initView()
|
|
97
|
+
this.$nextTick(() => {
|
|
98
|
+
const formGroupContext = this.$refs.formGroupContext?.$el
|
|
99
|
+
if (formGroupContext && formGroupContext.addEventListener) {
|
|
100
|
+
formGroupContext.addEventListener('scroll', this.onScroll)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
94
103
|
},
|
|
95
104
|
// 初始化组件
|
|
96
105
|
initView () {
|
|
@@ -108,7 +117,7 @@ export default {
|
|
|
108
117
|
},
|
|
109
118
|
getNativeFormRef (group) {
|
|
110
119
|
return this.groups.map((item, index) => {
|
|
111
|
-
if (item.
|
|
120
|
+
if (item.groupName === group) {
|
|
112
121
|
return this.$refs[`nativeForm-${index}`][0]
|
|
113
122
|
} else {
|
|
114
123
|
return null
|
|
@@ -116,35 +125,34 @@ export default {
|
|
|
116
125
|
}).filter(ref => ref !== null)
|
|
117
126
|
},
|
|
118
127
|
initData (index) {
|
|
128
|
+
// 定义当前表单配置
|
|
129
|
+
const res = this.groups[index]
|
|
119
130
|
// 如果是插槽组件
|
|
120
|
-
|
|
121
|
-
if (this.groups[index]?.formGroupType === 'slot') {
|
|
131
|
+
if (res?.formGroupType === 'slot') {
|
|
122
132
|
// 组织插槽表单的结果
|
|
123
|
-
this.allFormData[
|
|
133
|
+
this.allFormData[res.slotName] = {}
|
|
124
134
|
return
|
|
125
135
|
}
|
|
126
136
|
// 组织native表单存储的结果
|
|
127
|
-
this.allFormData[
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
this.$
|
|
146
|
-
this.$refs[`nativeForm-${index}`][0].init(params)
|
|
147
|
-
})
|
|
137
|
+
this.allFormData[res.groupName] = {}
|
|
138
|
+
this.formList.push(res)
|
|
139
|
+
let modifyModelData = {}
|
|
140
|
+
if (this.modifyModelData[res.groupName]) {
|
|
141
|
+
modifyModelData = { data: this.modifyModelData[res.groupName] }
|
|
142
|
+
}
|
|
143
|
+
const params = {
|
|
144
|
+
layout: res.xAddFormLayout,
|
|
145
|
+
formItems: res.formJson,
|
|
146
|
+
showSubmitBtn: false,
|
|
147
|
+
serviceName: this.serviceName,
|
|
148
|
+
modifyModelData: modifyModelData,
|
|
149
|
+
fixedAddForm: modifyModelData.data,
|
|
150
|
+
businessType: this.businessType,
|
|
151
|
+
...res
|
|
152
|
+
}
|
|
153
|
+
params.showSubmitBtn = false
|
|
154
|
+
this.$nextTick(() => {
|
|
155
|
+
this.$refs[`nativeForm-${index}`][0].init(params)
|
|
148
156
|
})
|
|
149
157
|
},
|
|
150
158
|
scrollToGroup (index) {
|
|
@@ -153,9 +161,6 @@ export default {
|
|
|
153
161
|
groupElement.scrollIntoView({ behavior: 'smooth' })
|
|
154
162
|
}
|
|
155
163
|
},
|
|
156
|
-
onClose () {
|
|
157
|
-
this.$emit('update:visible', false)
|
|
158
|
-
},
|
|
159
164
|
// xfromitem 一路传递上来的事件
|
|
160
165
|
emitFunc (func, data) {
|
|
161
166
|
this.$emit('x-form-item-emit-func', func, data)
|
|
@@ -164,10 +169,10 @@ export default {
|
|
|
164
169
|
let pass = true
|
|
165
170
|
const promises = this.groups.map((item, index) => {
|
|
166
171
|
const nativeFormRef = this.$refs[`nativeForm-${index}`] ? this.$refs[`nativeForm-${index}`][0] : undefined
|
|
167
|
-
if ((item.
|
|
172
|
+
if ((item.groupName || item.slotName) && nativeFormRef && typeof nativeFormRef.asyncSubmit === 'function') {
|
|
168
173
|
// 如果 ref 存在 asyncSubmit 方法,则调用 asyncSubmit 方法
|
|
169
174
|
return nativeFormRef.asyncSubmit().then(res => {
|
|
170
|
-
this.allFormData[item.slotName || item.
|
|
175
|
+
this.allFormData[item.slotName || item.groupName] = res.realForm
|
|
171
176
|
}).catch(_err => {
|
|
172
177
|
pass = false
|
|
173
178
|
this.scrollToGroup(index)
|
|
@@ -191,6 +196,22 @@ export default {
|
|
|
191
196
|
} catch (error) {
|
|
192
197
|
return Promise.reject(new Error('An unexpected error occurred'))
|
|
193
198
|
}
|
|
199
|
+
},
|
|
200
|
+
onScroll () {
|
|
201
|
+
const formGroupContext = this.$refs.formGroupContext.$el
|
|
202
|
+
let groupItems = []
|
|
203
|
+
if (formGroupContext && formGroupContext.querySelectorAll) {
|
|
204
|
+
groupItems = formGroupContext.querySelectorAll('.group-item')
|
|
205
|
+
}
|
|
206
|
+
let activeIndex = this.activeTab
|
|
207
|
+
|
|
208
|
+
groupItems.forEach((item, index) => {
|
|
209
|
+
const rect = item.getBoundingClientRect()
|
|
210
|
+
if (rect.top <= 205 && rect.bottom > 200) {
|
|
211
|
+
activeIndex = index
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
this.activeTab = activeIndex
|
|
194
215
|
}
|
|
195
216
|
}
|
|
196
217
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div id="test">
|
|
3
|
+
<!-- 修改 import 路径展示不同的组件 Demo -->
|
|
3
4
|
<demo></demo>
|
|
4
5
|
</div>
|
|
5
6
|
</template>
|
|
6
7
|
|
|
7
8
|
<script>
|
|
8
9
|
import XReport from '@vue2-client/base-client/components/common/XReport'
|
|
9
|
-
import Demo from '@vue2-client/base-client/components/common/XFormGroup/demo.vue'
|
|
10
|
+
// import Demo from '@vue2-client/base-client/components/common/XFormGroup/demo.vue'
|
|
11
|
+
import Demo from '@vue2-client/base-client/components/common/XDescriptions/demo.vue'
|
|
10
12
|
|
|
11
13
|
export default {
|
|
12
14
|
name: 'Example',
|
package/vue.config.js
CHANGED
|
@@ -44,8 +44,8 @@ module.exports = {
|
|
|
44
44
|
// changeOrigin: true
|
|
45
45
|
// },
|
|
46
46
|
'/api/af-revenue/logic/openapi/': {
|
|
47
|
-
|
|
48
|
-
target:
|
|
47
|
+
pathRewrite: { '^/api/af-revenue/logic/openapi/': '/logic/' },
|
|
48
|
+
target: 'http://127.0.0.1:9026',
|
|
49
49
|
changeOrigin: true
|
|
50
50
|
},
|
|
51
51
|
'/api/af-revenue': {
|