vue2-client 1.8.229 → 1.8.230
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 +269 -0
- package/src/base-client/components/common/XDescriptions/demo.vue +50 -0
- package/src/base-client/components/common/XFormGroup/XFormGroup.vue +26 -28
- 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,269 @@
|
|
|
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" @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" 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
|
+
created () {
|
|
130
|
+
this.initConfig()
|
|
131
|
+
},
|
|
132
|
+
data () {
|
|
133
|
+
return {
|
|
134
|
+
// 加载状态
|
|
135
|
+
loading: false,
|
|
136
|
+
loadError: false,
|
|
137
|
+
realData: [],
|
|
138
|
+
// 获取到的配置组
|
|
139
|
+
groups: {}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
computed: {
|
|
143
|
+
...mapState('setting', { isMobile: 'isMobile' })
|
|
144
|
+
},
|
|
145
|
+
methods: {
|
|
146
|
+
initConfig () {
|
|
147
|
+
this.loading = true
|
|
148
|
+
if (this.configName) {
|
|
149
|
+
this.getConfig()
|
|
150
|
+
} else {
|
|
151
|
+
this.loading = false
|
|
152
|
+
this.loadError = true
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
scrollToGroup (index) {
|
|
156
|
+
const groupElement = this.$refs[`descriptions-item-${index}`][0]
|
|
157
|
+
if (groupElement) {
|
|
158
|
+
groupElement.scrollIntoView({ behavior: 'smooth' })
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
getConfig () {
|
|
162
|
+
getConfigByName(this.configName, this.serviceName, (res) => {
|
|
163
|
+
if (res.groups) {
|
|
164
|
+
this.groups = res.groups
|
|
165
|
+
this.realData = Object.keys(res.groups).map((h) => {
|
|
166
|
+
const hObj = res.groups[h]
|
|
167
|
+
const dataItem = {}
|
|
168
|
+
dataItem.title = h
|
|
169
|
+
dataItem.column = []
|
|
170
|
+
if (hObj.type && hObj.type === 'array') {
|
|
171
|
+
// 从data 取出数组
|
|
172
|
+
const arrayData = this.data[hObj.key]
|
|
173
|
+
const arrayDataItem = arrayData.map((item, index) => {
|
|
174
|
+
const arrayItem = {
|
|
175
|
+
title: `${h} ${index + 1}`,
|
|
176
|
+
column: Object.keys(hObj.value).map((key) => {
|
|
177
|
+
return {
|
|
178
|
+
key: hObj.value[key],
|
|
179
|
+
value: item[key]
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
// 如果所有 value 都是空的 return null todo 后期可能做成配置
|
|
184
|
+
const isAllNull = arrayItem.column.every((item) => {
|
|
185
|
+
return item.value === null || item.value === ''
|
|
186
|
+
})
|
|
187
|
+
return isAllNull ? null : arrayItem
|
|
188
|
+
}).filter((item) => item)
|
|
189
|
+
if (arrayDataItem.length) {
|
|
190
|
+
dataItem.column = arrayDataItem
|
|
191
|
+
return dataItem
|
|
192
|
+
} else {
|
|
193
|
+
return null
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
const tempData = Object.keys(hObj).map((key) => {
|
|
197
|
+
// 如果是数组形态
|
|
198
|
+
return { key: hObj[key], value: this.getRealKeyData(this.data, key) }
|
|
199
|
+
})
|
|
200
|
+
// 如果所有 value 都是空的 return null todo 后期可能做成配置
|
|
201
|
+
const isAllNull = tempData.every((item) => {
|
|
202
|
+
return item.value === null || item.value === ''
|
|
203
|
+
})
|
|
204
|
+
if (isAllNull) {
|
|
205
|
+
return null
|
|
206
|
+
} else {
|
|
207
|
+
dataItem.column = tempData
|
|
208
|
+
return dataItem
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}).filter((item) => item)
|
|
212
|
+
console.log(this.realData)
|
|
213
|
+
} else {
|
|
214
|
+
this.loading = false
|
|
215
|
+
this.loadError = true
|
|
216
|
+
}
|
|
217
|
+
})
|
|
218
|
+
},
|
|
219
|
+
// 文字格式化
|
|
220
|
+
formatText (value) {
|
|
221
|
+
return value || '--'
|
|
222
|
+
},
|
|
223
|
+
getRealKeyData (data, key) {
|
|
224
|
+
if (this.getRealData) {
|
|
225
|
+
return getRealKeyData(data)[key] || ''
|
|
226
|
+
} else {
|
|
227
|
+
return this.data[key] || ''
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
watch: {
|
|
232
|
+
content: {
|
|
233
|
+
handler () {
|
|
234
|
+
this.initConfig()
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
configName: {
|
|
238
|
+
handler () {
|
|
239
|
+
this.initConfig()
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
serviceName: {
|
|
243
|
+
handler () {
|
|
244
|
+
this.initConfig()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
</script>
|
|
250
|
+
|
|
251
|
+
<style lang="less" scoped>
|
|
252
|
+
#XDescriptionGroup {
|
|
253
|
+
height: 100%;
|
|
254
|
+
:deep(.ant-descriptions-title) {
|
|
255
|
+
color: @primary-color;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.descriptions-item {
|
|
259
|
+
margin-bottom: 8px;
|
|
260
|
+
}
|
|
261
|
+
.descriptions-array-item{
|
|
262
|
+
padding-left: 1rem;
|
|
263
|
+
}
|
|
264
|
+
.descriptionsGroupContext {
|
|
265
|
+
height: 100%;
|
|
266
|
+
overflow-y: scroll;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
</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>
|
|
@@ -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',
|
|
@@ -108,7 +107,7 @@ export default {
|
|
|
108
107
|
},
|
|
109
108
|
getNativeFormRef (group) {
|
|
110
109
|
return this.groups.map((item, index) => {
|
|
111
|
-
if (item.
|
|
110
|
+
if (item.groupName === group) {
|
|
112
111
|
return this.$refs[`nativeForm-${index}`][0]
|
|
113
112
|
} else {
|
|
114
113
|
return null
|
|
@@ -116,35 +115,34 @@ export default {
|
|
|
116
115
|
}).filter(ref => ref !== null)
|
|
117
116
|
},
|
|
118
117
|
initData (index) {
|
|
118
|
+
// 定义当前表单配置
|
|
119
|
+
const res = this.groups[index]
|
|
119
120
|
// 如果是插槽组件
|
|
120
|
-
|
|
121
|
-
if (this.groups[index]?.formGroupType === 'slot') {
|
|
121
|
+
if (res?.formGroupType === 'slot') {
|
|
122
122
|
// 组织插槽表单的结果
|
|
123
|
-
this.allFormData[
|
|
123
|
+
this.allFormData[res.slotName] = {}
|
|
124
124
|
return
|
|
125
125
|
}
|
|
126
126
|
// 组织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
|
-
})
|
|
127
|
+
this.allFormData[res.groupName] = {}
|
|
128
|
+
this.formList.push(res)
|
|
129
|
+
let modifyModelData = {}
|
|
130
|
+
if (this.modifyModelData[res.groupName]) {
|
|
131
|
+
modifyModelData = { data: this.modifyModelData[res.groupName] }
|
|
132
|
+
}
|
|
133
|
+
const params = {
|
|
134
|
+
layout: res.xAddFormLayout,
|
|
135
|
+
formItems: res.formJson,
|
|
136
|
+
showSubmitBtn: false,
|
|
137
|
+
serviceName: this.serviceName,
|
|
138
|
+
modifyModelData: modifyModelData,
|
|
139
|
+
fixedAddForm: modifyModelData.data,
|
|
140
|
+
businessType: this.businessType,
|
|
141
|
+
...res
|
|
142
|
+
}
|
|
143
|
+
params.showSubmitBtn = false
|
|
144
|
+
this.$nextTick(() => {
|
|
145
|
+
this.$refs[`nativeForm-${index}`][0].init(params)
|
|
148
146
|
})
|
|
149
147
|
},
|
|
150
148
|
scrollToGroup (index) {
|
|
@@ -164,10 +162,10 @@ export default {
|
|
|
164
162
|
let pass = true
|
|
165
163
|
const promises = this.groups.map((item, index) => {
|
|
166
164
|
const nativeFormRef = this.$refs[`nativeForm-${index}`] ? this.$refs[`nativeForm-${index}`][0] : undefined
|
|
167
|
-
if ((item.
|
|
165
|
+
if ((item.groupName || item.slotName) && nativeFormRef && typeof nativeFormRef.asyncSubmit === 'function') {
|
|
168
166
|
// 如果 ref 存在 asyncSubmit 方法,则调用 asyncSubmit 方法
|
|
169
167
|
return nativeFormRef.asyncSubmit().then(res => {
|
|
170
|
-
this.allFormData[item.slotName || item.
|
|
168
|
+
this.allFormData[item.slotName || item.groupName] = res.realForm
|
|
171
169
|
}).catch(_err => {
|
|
172
170
|
pass = false
|
|
173
171
|
this.scrollToGroup(index)
|
|
@@ -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': {
|