Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
basic-vue-admin
概览
概览
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Basic
basic-vue-admin
Commits
47a448b8
提交
47a448b8
authored
8月 17, 2021
作者:
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(form): add `Divider` for schema component type
新增Divider用于较长表单的区域分割
上级
5138e447
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
65 行增加
和
12 行删除
+65
-12
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+8
-0
BasicForm.vue
src/components/Form/src/BasicForm.vue
+5
-1
componentMap.ts
src/components/Form/src/componentMap.ts
+2
-0
FormItem.vue
src/components/Form/src/components/FormItem.vue
+20
-6
useFormEvents.ts
src/components/Form/src/hooks/useFormEvents.ts
+6
-2
index.ts
src/components/Form/src/types/index.ts
+2
-1
AdvancedForm.vue
src/views/demo/form/AdvancedForm.vue
+7
-2
index.vue
src/views/demo/form/index.vue
+15
-0
没有找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
47a448b8
### ✨ Features
-
**BasicForm**
表单组件新增
`Divider`
,用于较长表单的区域分割
### 🐛 Bug Fixes
-
**其它**
修复部分封装组件在使用插槽时报错的问题
## 2.7.1(2021-08-16)
## 2.7.1(2021-08-16)
-
升级 vue 3.2,如果运行失败,删除 node_modules 后重装即可
-
升级 vue 3.2,如果运行失败,删除 node_modules 后重装即可
...
...
src/components/Form/src/BasicForm.vue
浏览文件 @
47a448b8
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#[
item
]="
data
"
#[
item
]="
data
"
v-for=
"item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']"
v-for=
"item in ['resetBefore', 'submitBefore', 'advanceBefore', 'advanceAfter']"
>
>
<slot
:name=
"item"
v-bind=
"data"
></slot>
<slot
:name=
"item"
v-bind=
"data
||
{}
">
</slot>
</
template
>
</
template
>
</FormAction>
</FormAction>
<slot
name=
"formFooter"
></slot>
<slot
name=
"formFooter"
></slot>
...
@@ -132,7 +132,11 @@
...
@@ -132,7 +132,11 @@
}
}
}
}
}
}
if
(
unref
(
getProps
).
showAdvancedButton
)
{
return
schemas
.
filter
((
schema
)
=>
schema
.
component
!==
'Divider'
)
as
FormSchema
[];
}
else
{
return
schemas
as
FormSchema
[];
return
schemas
as
FormSchema
[];
}
});
});
const
{
handleToggleAdvanced
}
=
useAdvanced
({
const
{
handleToggleAdvanced
}
=
useAdvanced
({
...
...
src/components/Form/src/componentMap.ts
浏览文件 @
47a448b8
...
@@ -18,6 +18,7 @@ import {
...
@@ -18,6 +18,7 @@ import {
TreeSelect
,
TreeSelect
,
Slider
,
Slider
,
Rate
,
Rate
,
Divider
,
}
from
'ant-design-vue'
;
}
from
'ant-design-vue'
;
import
RadioButtonGroup
from
'./components/RadioButtonGroup.vue'
;
import
RadioButtonGroup
from
'./components/RadioButtonGroup.vue'
;
...
@@ -61,6 +62,7 @@ componentMap.set('IconPicker', IconPicker);
...
@@ -61,6 +62,7 @@ componentMap.set('IconPicker', IconPicker);
componentMap
.
set
(
'InputCountDown'
,
CountdownInput
);
componentMap
.
set
(
'InputCountDown'
,
CountdownInput
);
componentMap
.
set
(
'Upload'
,
BasicUpload
);
componentMap
.
set
(
'Upload'
,
BasicUpload
);
componentMap
.
set
(
'Divider'
,
Divider
);
export
function
add
(
compName
:
ComponentType
,
component
:
Component
)
{
export
function
add
(
compName
:
ComponentType
,
component
:
Component
)
{
componentMap
.
set
(
compName
,
component
);
componentMap
.
set
(
compName
,
component
);
...
...
src/components/Form/src/components/FormItem.vue
浏览文件 @
47a448b8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
type
{
ValidationRule
}
from
'ant-design-vue/lib/form/Form'
;
import
type
{
ValidationRule
}
from
'ant-design-vue/lib/form/Form'
;
import
type
{
TableActionType
}
from
'/@/components/Table'
;
import
type
{
TableActionType
}
from
'/@/components/Table'
;
import
{
defineComponent
,
computed
,
unref
,
toRefs
}
from
'vue'
;
import
{
defineComponent
,
computed
,
unref
,
toRefs
}
from
'vue'
;
import
{
Form
,
Col
}
from
'ant-design-vue'
;
import
{
Form
,
Col
,
Divider
}
from
'ant-design-vue'
;
import
{
componentMap
}
from
'../componentMap'
;
import
{
componentMap
}
from
'../componentMap'
;
import
{
BasicHelp
}
from
'/@/components/Basic'
;
import
{
BasicHelp
}
from
'/@/components/Basic'
;
import
{
isBoolean
,
isFunction
,
isNull
}
from
'/@/utils/is'
;
import
{
isBoolean
,
isFunction
,
isNull
}
from
'/@/utils/is'
;
...
@@ -73,11 +73,17 @@
...
@@ -73,11 +73,17 @@
const
getComponentsProps
=
computed
(()
=>
{
const
getComponentsProps
=
computed
(()
=>
{
const
{
schema
,
tableAction
,
formModel
,
formActionType
}
=
props
;
const
{
schema
,
tableAction
,
formModel
,
formActionType
}
=
props
;
const
{
componentProps
=
{}
}
=
schema
;
let
{
componentProps
=
{}
}
=
schema
;
if
(
!
isFunction
(
componentProps
))
{
if
(
isFunction
(
componentProps
))
{
return
componentProps
;
componentProps
=
componentProps
({
schema
,
tableAction
,
formModel
,
formActionType
})
??
{};
}
if
(
schema
.
component
===
'Divider'
)
{
componentProps
=
Object
.
assign
({
type
:
'horizontal'
},
componentProps
,
{
orientation
:
'left'
,
plain
:
true
,
});
}
}
return
componentProps
({
schema
,
tableAction
,
formModel
,
formActionType
})
??
{}
;
return
componentProps
;
});
});
const
getDisable
=
computed
(()
=>
{
const
getDisable
=
computed
(()
=>
{
...
@@ -300,10 +306,17 @@
...
@@ -300,10 +306,17 @@
}
}
function
renderItem
()
{
function
renderItem
()
{
const
{
itemProps
,
slot
,
render
,
field
,
suffix
}
=
props
.
schema
;
const
{
itemProps
,
slot
,
render
,
field
,
suffix
,
component
,
label
}
=
props
.
schema
;
const
{
labelCol
,
wrapperCol
}
=
unref
(
itemLabelWidthProp
);
const
{
labelCol
,
wrapperCol
}
=
unref
(
itemLabelWidthProp
);
const
{
colon
}
=
props
.
formProps
;
const
{
colon
}
=
props
.
formProps
;
if
(
component
===
'Divider'
)
{
return
(
<
Col
span
=
{
24
}
>
<
Divider
{...
unref
(
getComponentsProps
)}
>
{
label
}
<
/Divider
>
<
/Col
>
);
}
else
{
const
getContent
=
()
=>
{
const
getContent
=
()
=>
{
return
slot
return
slot
?
getSlot
(
slots
,
slot
,
unref
(
getValues
))
?
getSlot
(
slots
,
slot
,
unref
(
getValues
))
...
@@ -333,6 +346,7 @@
...
@@ -333,6 +346,7 @@
<
/Form.Item
>
<
/Form.Item
>
);
);
}
}
}
return
()
=>
{
return
()
=>
{
const
{
colProps
=
{},
colSlot
,
renderColContent
,
component
}
=
props
.
schema
;
const
{
colProps
=
{},
colSlot
,
renderColContent
,
component
}
=
props
.
schema
;
...
...
src/components/Form/src/hooks/useFormEvents.ts
浏览文件 @
47a448b8
...
@@ -149,7 +149,9 @@ export function useFormEvents({
...
@@ -149,7 +149,9 @@ export function useFormEvents({
updateData
=
[...
data
];
updateData
=
[...
data
];
}
}
const
hasField
=
updateData
.
every
((
item
)
=>
Reflect
.
has
(
item
,
'field'
)
&&
item
.
field
);
const
hasField
=
updateData
.
every
(
(
item
)
=>
item
.
component
===
'Divider'
||
(
Reflect
.
has
(
item
,
'field'
)
&&
item
.
field
)
);
if
(
!
hasField
)
{
if
(
!
hasField
)
{
error
(
error
(
...
@@ -169,7 +171,9 @@ export function useFormEvents({
...
@@ -169,7 +171,9 @@ export function useFormEvents({
updateData
=
[...
data
];
updateData
=
[...
data
];
}
}
const
hasField
=
updateData
.
every
((
item
)
=>
Reflect
.
has
(
item
,
'field'
)
&&
item
.
field
);
const
hasField
=
updateData
.
every
(
(
item
)
=>
item
.
component
===
'Divider'
||
(
Reflect
.
has
(
item
,
'field'
)
&&
item
.
field
)
);
if
(
!
hasField
)
{
if
(
!
hasField
)
{
error
(
error
(
...
...
src/components/Form/src/types/index.ts
浏览文件 @
47a448b8
...
@@ -109,4 +109,5 @@ export type ComponentType =
...
@@ -109,4 +109,5 @@ export type ComponentType =
|
'IconPicker'
|
'IconPicker'
|
'Render'
|
'Render'
|
'Slider'
|
'Slider'
|
'Rate'
;
|
'Rate'
|
'Divider'
;
src/views/demo/form/AdvancedForm.vue
浏览文件 @
47a448b8
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
defineComponent
}
from
'vue'
;
import
{
defineComponent
}
from
'vue'
;
import
{
BasicForm
,
FormSchema
,
useForm
}
from
'/@/components/Form/index'
;
import
{
BasicForm
,
FormSchema
,
useForm
}
from
'/@/components/Form/index'
;
import
{
CollapseContainer
}
from
'/@/components/Container
/index
'
;
import
{
CollapseContainer
}
from
'/@/components/Container'
;
import
{
PageWrapper
}
from
'/@/components/Page'
;
import
{
PageWrapper
}
from
'/@/components/Page'
;
const
getSchamas
=
():
FormSchema
[]
=>
{
const
getSchamas
=
():
FormSchema
[]
=>
{
...
@@ -173,7 +173,12 @@
...
@@ -173,7 +173,12 @@
}
}
const
[
register1
]
=
useForm
({
const
[
register1
]
=
useForm
({
labelWidth
:
120
,
labelWidth
:
120
,
schemas
:
[...
getSchamas
(),
...
getAppendSchemas
(),
...
extraSchemas
],
schemas
:
[
...
getSchamas
(),
...
getAppendSchemas
(),
{
field
:
''
,
component
:
'Divider'
,
label
:
'更多字段'
},
...
extraSchemas
,
],
actionColOptions
:
{
actionColOptions
:
{
span
:
24
,
span
:
24
,
},
},
...
...
src/views/demo/form/index.vue
浏览文件 @
47a448b8
...
@@ -101,6 +101,11 @@
...
@@ -101,6 +101,11 @@
const
schemas
:
FormSchema
[]
=
[
const
schemas
:
FormSchema
[]
=
[
{
{
field
:
''
,
component
:
'Divider'
,
label
:
'基础字段'
,
},
{
field
:
'field1'
,
field
:
'field1'
,
component
:
'Input'
,
component
:
'Input'
,
label
:
'字段1'
,
label
:
'字段1'
,
...
@@ -294,6 +299,11 @@
...
@@ -294,6 +299,11 @@
},
},
},
},
{
{
field
:
''
,
component
:
'Divider'
,
label
:
'远程下拉演示'
,
},
{
field
:
'field30'
,
field
:
'field30'
,
component
:
'ApiSelect'
,
component
:
'ApiSelect'
,
label
:
'懒加载远程下拉'
,
label
:
'懒加载远程下拉'
,
...
@@ -363,6 +373,11 @@
...
@@ -363,6 +373,11 @@
},
},
},
},
{
{
field
:
''
,
component
:
'Divider'
,
label
:
'其它'
,
},
{
field
:
'field20'
,
field
:
'field20'
,
component
:
'InputNumber'
,
component
:
'InputNumber'
,
label
:
'字段20'
,
label
:
'字段20'
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论