web-component-gallery 2.3.3 → 2.3.5
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/dist/js.umd.js +1 -1
- package/lib/amap-draw/index.jsx +191 -92
- package/lib/form-comp/ASelectCustom.vue +386 -130
- package/lib/form-comp/ATagsInput.vue +1 -1
- package/lib/model/Model.js +16 -15
- package/lib/model/utils/render.js +33 -20
- package/lib/transfer-table/style/index.less +1 -0
- package/package.json +4 -3
- package/utils/Utils.js +59 -29
package/lib/model/Model.js
CHANGED
|
@@ -48,14 +48,22 @@ export default {
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
formAttrs() {
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
const baseAttrs = {
|
|
52
|
+
// 是否禁用表单,默认否
|
|
53
|
+
disabled: false,
|
|
54
|
+
...this.$attrs
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 如果不是垂直布局,则添加标签列和包装列的配置
|
|
58
|
+
if (this.layout !== 'vertical') {
|
|
59
|
+
return {
|
|
60
|
+
labelCol: { span: 4 },
|
|
61
|
+
wrapperCol: { span: 20 },
|
|
62
|
+
...baseAttrs
|
|
57
63
|
}
|
|
58
|
-
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return baseAttrs
|
|
59
67
|
},
|
|
60
68
|
dynamicFormRules() {
|
|
61
69
|
const formRules = {}
|
|
@@ -82,13 +90,6 @@ export default {
|
|
|
82
90
|
this.$emit('update:refForm', this.$refs.FormModel)
|
|
83
91
|
},
|
|
84
92
|
methods: {
|
|
85
|
-
getDefaultFormAttrs() {
|
|
86
|
-
return {
|
|
87
|
-
labelCol: { span: 4 },
|
|
88
|
-
wrapperCol: { span: 20 }
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
|
|
92
93
|
renderSingleFormItem(h, props) {
|
|
93
94
|
return setFormItem.call(this, h, this.form, props)
|
|
94
95
|
},
|
|
@@ -108,7 +109,7 @@ export default {
|
|
|
108
109
|
return setFormItem.call(this, h, modelItem, configItem, childAttrs)
|
|
109
110
|
})
|
|
110
111
|
})
|
|
111
|
-
},
|
|
112
|
+
},
|
|
112
113
|
|
|
113
114
|
setModelRender(h, props) {
|
|
114
115
|
const dynamicModel = this.form[props.model]
|
|
@@ -9,10 +9,12 @@ const FormModelItem = FormModel.Item
|
|
|
9
9
|
* @param {number} layoutSize - 一行显示的表单项数量
|
|
10
10
|
* @param {number} [gap=24] - 表单项间距
|
|
11
11
|
* @returns {string} - 计算后的CSS样式
|
|
12
|
-
*/
|
|
12
|
+
*/
|
|
13
13
|
export function getFormWidth(child, layoutSize, gap = 24) {
|
|
14
14
|
const width = (100 / layoutSize) * (child.size ?? 1)
|
|
15
|
-
if (this.layout === 'vertical')
|
|
15
|
+
if (this.layout === 'vertical') {
|
|
16
|
+
return `flex: 0 1 calc(${width}% - ${gap}px); margin-right: ${gap}px;`
|
|
17
|
+
}
|
|
16
18
|
return `flex: 0 1 ${width}%;`
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -32,24 +34,26 @@ export function setFormItemRule(node, nodeParent = {}) {
|
|
|
32
34
|
(node.label || '')
|
|
33
35
|
|
|
34
36
|
// 基础规则
|
|
35
|
-
const baseRules = [
|
|
36
|
-
|
|
37
|
+
const baseRules = []
|
|
38
|
+
|
|
39
|
+
if (required) {
|
|
40
|
+
baseRules.push({
|
|
37
41
|
required,
|
|
38
42
|
message,
|
|
39
43
|
trigger: ['change', 'blur']
|
|
40
|
-
}
|
|
41
|
-
|
|
44
|
+
})
|
|
45
|
+
}
|
|
42
46
|
|
|
43
47
|
// 合并自定义规则
|
|
44
|
-
const customRules = (node.rules || []).
|
|
45
|
-
if (rule.pattern) {
|
|
46
|
-
rule
|
|
48
|
+
const customRules = (node.rules || []).map(rule => {
|
|
49
|
+
if (rule.pattern && typeof rule.pattern === 'string') {
|
|
50
|
+
return { ...rule, pattern: new RegExp(rule.pattern) }
|
|
47
51
|
}
|
|
48
52
|
return rule
|
|
49
53
|
})
|
|
50
54
|
|
|
51
55
|
return [...baseRules, ...customRules]
|
|
52
|
-
}
|
|
56
|
+
}
|
|
53
57
|
|
|
54
58
|
/**
|
|
55
59
|
* 动态渲染表单项
|
|
@@ -60,13 +64,14 @@ export function setFormItemRule(node, nodeParent = {}) {
|
|
|
60
64
|
* @returns {VNode} - 渲染结果
|
|
61
65
|
*/
|
|
62
66
|
export function setFormItem(h, vModel, child, childAttrs) {
|
|
63
|
-
const {layout, layoutSize, $scopedSlots} = this
|
|
67
|
+
const { layout, layoutSize, formAttrs, $scopedSlots } = this
|
|
64
68
|
|
|
65
69
|
// 设置表单项属性
|
|
66
|
-
const formItemAttrs =
|
|
70
|
+
const formItemAttrs = {
|
|
67
71
|
key: child.model,
|
|
68
72
|
prop: child.model,
|
|
69
|
-
colon: !(layout === 'inline')
|
|
73
|
+
colon: !(layout === 'inline'),
|
|
74
|
+
...childAttrs
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
// 生成插槽名称
|
|
@@ -78,22 +83,30 @@ export function setFormItem(h, vModel, child, childAttrs) {
|
|
|
78
83
|
|
|
79
84
|
// 渲染表单项内容
|
|
80
85
|
const renderContent = () => {
|
|
81
|
-
if ($scopedSlots[child.model])
|
|
86
|
+
if ($scopedSlots[child.model]) {
|
|
87
|
+
return $scopedSlots[child.model](child)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const contentAttrs = {
|
|
91
|
+
disabled: childAttrs?.disabled ?? formAttrs.disabled ?? false,
|
|
92
|
+
...child.attrs
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
return (
|
|
83
96
|
<RenderComp
|
|
84
97
|
v-model={vModel[child.model]}
|
|
85
98
|
component={child.is}
|
|
86
|
-
{...{ on: child.event, attrs:
|
|
99
|
+
{...{ on: child.event, attrs: contentAttrs }}
|
|
87
100
|
/>
|
|
88
101
|
)
|
|
89
102
|
}
|
|
90
103
|
|
|
91
104
|
return (
|
|
92
105
|
<FormModelItem
|
|
93
|
-
class={
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
class={{
|
|
107
|
+
'FormLineVertical': child.size === layoutSize && layout === 'vertical',
|
|
108
|
+
'FormLine': child.size === layoutSize
|
|
109
|
+
}}
|
|
97
110
|
{...{ attrs: formItemAttrs }}
|
|
98
111
|
>
|
|
99
112
|
<template slot="label">
|
|
@@ -105,4 +118,4 @@ export function setFormItem(h, vModel, child, childAttrs) {
|
|
|
105
118
|
{$scopedSlots[`${slotsName}Handle`] && $scopedSlots[`${slotsName}Handle`](formItemAttrs)}
|
|
106
119
|
</FormModelItem>
|
|
107
120
|
)
|
|
108
|
-
}
|
|
121
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-component-gallery",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"description": "基础vue、antdvue、less实现的私有组件库",
|
|
5
5
|
"main": "dist/index.umd.js",
|
|
6
6
|
"files": [
|
|
@@ -23,14 +23,15 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@amap/amap-jsapi-loader": "^1.0.1",
|
|
26
|
-
"@babel/core": "^7.28.
|
|
26
|
+
"@babel/core": "^7.28.6",
|
|
27
27
|
"@babel/eslint-parser": "^7.12.16",
|
|
28
|
-
"@babel/preset-env": "^7.28.
|
|
28
|
+
"@babel/preset-env": "^7.28.6",
|
|
29
29
|
"@vue/babel-preset-jsx": "^1.4.0",
|
|
30
30
|
"@vue/cli-plugin-babel": "~5.0.0",
|
|
31
31
|
"@vue/cli-plugin-eslint": "~5.0.0",
|
|
32
32
|
"@vue/cli-service": "~5.0.0",
|
|
33
33
|
"ant-design-vue": "1.7.8",
|
|
34
|
+
"babel-eslint": "^10.1.0",
|
|
34
35
|
"babel-loader": "^9.1.3",
|
|
35
36
|
"clean-webpack-plugin": "^4.0.0",
|
|
36
37
|
"eslint": "^7.32.0",
|
package/utils/Utils.js
CHANGED
|
@@ -134,22 +134,33 @@ export function handleEnvURL(url, processType = 'url') {
|
|
|
134
134
|
return isDev ? strategy.dev() : strategy.prod()
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
|
|
137
138
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @param {Array}
|
|
140
|
-
* @param {string} key -
|
|
141
|
-
* @param {*} data -
|
|
142
|
-
* @returns {Array}
|
|
139
|
+
* 根据属性路径更新对象或数组中的数据,支持条件匹配和批量设置
|
|
140
|
+
* @param {Object|Array} target - 目标对象或数组
|
|
141
|
+
* @param {string|Object} key - 属性路径字符串 或 批量设置配置对象
|
|
142
|
+
* @param {*} data - 要设置的数据(当key为字符串时使用)
|
|
143
|
+
* @returns {Object|Array} 更新后的对象或数组
|
|
143
144
|
*/
|
|
144
|
-
export function setOptionsData(
|
|
145
|
-
if (!
|
|
145
|
+
export function setOptionsData(target, key, data) {
|
|
146
|
+
if (!target || (typeof target !== 'object' && !Array.isArray(target))) return target
|
|
147
|
+
|
|
148
|
+
// 批量设置模式:key 是对象,data 为 undefined
|
|
149
|
+
if (typeof key === 'object' && data === undefined) {
|
|
150
|
+
return Object.entries(key).reduce((acc, [path, value]) => {
|
|
151
|
+
return setOptionsData(acc, path, value)
|
|
152
|
+
}, target)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 单个设置模式
|
|
156
|
+
if (!key || typeof key !== 'string') return target
|
|
146
157
|
|
|
147
158
|
// 解析条件匹配格式
|
|
148
159
|
const hasCondition = key.includes(':')
|
|
149
160
|
let conditionModel = null
|
|
150
161
|
let conditionValue = null
|
|
151
162
|
let actualPath = key
|
|
152
|
-
|
|
163
|
+
|
|
153
164
|
if (hasCondition) {
|
|
154
165
|
const [prefix, path] = key.split(':').map(s => s.trim())
|
|
155
166
|
conditionModel = prefix
|
|
@@ -159,38 +170,57 @@ export function setOptionsData(arr, key, data) {
|
|
|
159
170
|
|
|
160
171
|
// 分割属性路径
|
|
161
172
|
const pathParts = actualPath.split('.')
|
|
162
|
-
|
|
163
|
-
// 更新数组中的每个对象
|
|
164
|
-
return arr.map(item => {
|
|
165
|
-
// 检查条件匹配
|
|
166
|
-
if (hasCondition && conditionModel) {
|
|
167
|
-
if (item[conditionModel] !== conditionValue) {
|
|
168
|
-
return item
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
173
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
+
// 设置属性值的辅助函数
|
|
175
|
+
const setProp = (obj) => {
|
|
176
|
+
let current = obj
|
|
174
177
|
|
|
175
178
|
// 遍历路径(除最后一部分)
|
|
176
179
|
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
177
|
-
if (!current[pathParts[i]])
|
|
180
|
+
if (!current[pathParts[i]]) {
|
|
181
|
+
current[pathParts[i]] = {}
|
|
182
|
+
}
|
|
178
183
|
current = current[pathParts[i]]
|
|
179
184
|
}
|
|
180
|
-
|
|
185
|
+
|
|
181
186
|
// 设置最终属性值
|
|
182
187
|
const lastPart = pathParts[pathParts.length - 1]
|
|
183
|
-
// 是对象则进行属性合并
|
|
184
|
-
const isObj = data instanceof Object && !Array.isArray(data)
|
|
185
|
-
|
|
186
|
-
pathParts.length > 1 ?
|
|
187
|
-
current[lastPart] = isObj ? { ...current[lastPart], ...data } : data :
|
|
188
|
-
current[pathParts[0]] = isObj ? { ...current[pathParts[0]], ...data } : data
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
// 合并对象或直接赋值
|
|
190
|
+
if (typeof data === 'object' && data !== null && !Array.isArray(data)) {
|
|
191
|
+
current[lastPart] = { ...current[lastPart], ...data }
|
|
192
|
+
} else {
|
|
193
|
+
current[lastPart] = data
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// 处理数组
|
|
198
|
+
if (Array.isArray(target)) {
|
|
199
|
+
return target.map(item => {
|
|
200
|
+
// 检查条件匹配
|
|
201
|
+
if (hasCondition && item[conditionModel] !== conditionValue) {
|
|
202
|
+
return item
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const newItem = { ...item }
|
|
206
|
+
setProp(newItem)
|
|
207
|
+
return newItem
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 处理对象
|
|
212
|
+
const updatedTarget = { ...target }
|
|
213
|
+
|
|
214
|
+
// 检查条件匹配
|
|
215
|
+
if (hasCondition && updatedTarget[conditionModel] !== conditionValue) {
|
|
216
|
+
return updatedTarget
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
setProp(updatedTarget)
|
|
220
|
+
return updatedTarget
|
|
192
221
|
}
|
|
193
222
|
|
|
223
|
+
|
|
194
224
|
/**
|
|
195
225
|
* 异步获取搜索数据并更新配置
|
|
196
226
|
* @param {Object} searchSetting - 需要更新的搜索配置对象
|