Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏日掠影
vue-vben-admin
提交
bb1b267e
V
vue-vben-admin
项目概览
夏日掠影
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bb1b267e
编写于
11月 26, 2020
作者:
V
vben
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(form): fix form verification and console error message issues
上级
e04aaa06
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
27 addition
and
19 deletion
+27
-19
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+1
-0
src/components/Form/src/BasicForm.vue
src/components/Form/src/BasicForm.vue
+6
-6
src/components/Form/src/FormItem.tsx
src/components/Form/src/FormItem.tsx
+11
-6
src/components/Form/src/hooks/useFormAction.ts
src/components/Form/src/hooks/useFormAction.ts
+1
-3
src/components/Form/src/hooks/useFormValues.ts
src/components/Form/src/hooks/useFormValues.ts
+4
-4
src/locales/lang/en/component/form.ts
src/locales/lang/en/component/form.ts
+2
-0
src/locales/lang/zh_CN/component/form.ts
src/locales/lang/zh_CN/component/form.ts
+2
-0
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
bb1b267e
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
-
修复 tree 文本超出挡住操作按钮问题
-
修复 tree 文本超出挡住操作按钮问题
-
修复通过 useRedo 刷新页面参数丢失问题
-
修复通过 useRedo 刷新页面参数丢失问题
-
修复表单校验先设置在校验及控制台错误信息问题
### 🎫 Chores
### 🎫 Chores
...
...
src/components/Form/src/BasicForm.vue
浏览文件 @
bb1b267e
...
@@ -71,17 +71,17 @@
...
@@ -71,17 +71,17 @@
const
schemaRef
=
ref
<
Nullable
<
FormSchema
[]
>>
(
null
);
const
schemaRef
=
ref
<
Nullable
<
FormSchema
[]
>>
(
null
);
const
formElRef
=
ref
<
Nullable
<
FormActionType
>>
(
null
);
const
formElRef
=
ref
<
Nullable
<
FormActionType
>>
(
null
);
const
getRowWrapStyleRef
=
computed
(():
any
=>
{
const
{
baseRowStyle
}
=
unref
(
getProps
);
return
baseRowStyle
||
{};
});
const
getMergePropsRef
=
computed
(
const
getMergePropsRef
=
computed
(
():
FormProps
=>
{
():
FormProps
=>
{
return
deepMerge
(
cloneDeep
(
props
),
unref
(
propsRef
));
return
deepMerge
(
cloneDeep
(
props
),
unref
(
propsRef
));
}
}
);
);
const
getRowWrapStyleRef
=
computed
(():
any
=>
{
const
{
baseRowStyle
}
=
unref
(
getMergePropsRef
);
return
baseRowStyle
||
{};
});
// 获取表单基本配置
// 获取表单基本配置
const
getProps
=
computed
(
const
getProps
=
computed
(
():
FormProps
=>
{
():
FormProps
=>
{
...
@@ -103,7 +103,7 @@
...
@@ -103,7 +103,7 @@
const
schemas
:
FormSchema
[]
=
unref
(
schemaRef
)
||
(
unref
(
getProps
).
schemas
as
any
);
const
schemas
:
FormSchema
[]
=
unref
(
schemaRef
)
||
(
unref
(
getProps
).
schemas
as
any
);
for
(
const
schema
of
schemas
)
{
for
(
const
schema
of
schemas
)
{
const
{
defaultValue
,
component
}
=
schema
;
const
{
defaultValue
,
component
}
=
schema
;
if
(
defaultValue
&&
dateItemType
.
includes
(
component
!
))
{
if
(
defaultValue
&&
dateItemType
.
includes
(
component
))
{
if
(
!
Array
.
isArray
(
defaultValue
))
{
if
(
!
Array
.
isArray
(
defaultValue
))
{
schema
.
defaultValue
=
moment
(
defaultValue
);
schema
.
defaultValue
=
moment
(
defaultValue
);
}
else
{
}
else
{
...
...
src/components/Form/src/FormItem.tsx
浏览文件 @
bb1b267e
...
@@ -17,6 +17,7 @@ import { upperFirst, cloneDeep } from 'lodash-es';
...
@@ -17,6 +17,7 @@ import { upperFirst, cloneDeep } from 'lodash-es';
import
{
useItemLabelWidth
}
from
'
./hooks/useLabelWidth
'
;
import
{
useItemLabelWidth
}
from
'
./hooks/useLabelWidth
'
;
import
{
ComponentType
}
from
'
./types
'
;
import
{
ComponentType
}
from
'
./types
'
;
import
{
isNumber
}
from
'
/@/utils/is
'
;
import
{
isNumber
}
from
'
/@/utils/is
'
;
import
{
useI18n
}
from
'
/@/hooks/web/useI18n
'
;
export
default
defineComponent
({
export
default
defineComponent
({
name
:
'
BasicFormItem
'
,
name
:
'
BasicFormItem
'
,
...
@@ -46,6 +47,8 @@ export default defineComponent({
...
@@ -46,6 +47,8 @@ export default defineComponent({
},
},
},
},
setup
(
props
,
{
slots
})
{
setup
(
props
,
{
slots
})
{
const
{
t
}
=
useI18n
(
'
component.form
'
);
// @ts-ignore
const
itemLabelWidthRef
=
useItemLabelWidth
(
toRef
(
props
,
'
schema
'
),
toRef
(
props
,
'
formProps
'
));
const
itemLabelWidthRef
=
useItemLabelWidth
(
toRef
(
props
,
'
schema
'
),
toRef
(
props
,
'
formProps
'
));
const
getValuesRef
=
computed
(()
=>
{
const
getValuesRef
=
computed
(()
=>
{
...
@@ -132,7 +135,7 @@ export default defineComponent({
...
@@ -132,7 +135,7 @@ export default defineComponent({
let
rules
:
ValidationRule
[]
=
cloneDeep
(
defRules
)
as
ValidationRule
[];
let
rules
:
ValidationRule
[]
=
cloneDeep
(
defRules
)
as
ValidationRule
[];
if
((
!
rules
||
rules
.
length
===
0
)
&&
required
)
{
if
((
!
rules
||
rules
.
length
===
0
)
&&
required
)
{
rules
=
[{
required
}];
rules
=
[{
required
,
type
:
'
string
'
}];
}
}
const
requiredRuleIndex
:
number
=
rules
.
findIndex
(
const
requiredRuleIndex
:
number
=
rules
.
findIndex
(
...
@@ -142,6 +145,9 @@ export default defineComponent({
...
@@ -142,6 +145,9 @@ export default defineComponent({
if
(
requiredRuleIndex
!==
-
1
)
{
if
(
requiredRuleIndex
!==
-
1
)
{
const
rule
=
rules
[
requiredRuleIndex
];
const
rule
=
rules
[
requiredRuleIndex
];
if
(
rule
.
required
&&
component
)
{
if
(
rule
.
required
&&
component
)
{
if
(
!
Reflect
.
has
(
rule
,
'
type
'
))
{
rule
.
type
=
'
string
'
;
}
const
joinLabel
=
Reflect
.
has
(
props
.
schema
,
'
rulesMessageJoinLabel
'
)
const
joinLabel
=
Reflect
.
has
(
props
.
schema
,
'
rulesMessageJoinLabel
'
)
?
rulesMessageJoinLabel
?
rulesMessageJoinLabel
:
globalRulesMessageJoinLabel
;
:
globalRulesMessageJoinLabel
;
...
@@ -157,11 +163,9 @@ export default defineComponent({
...
@@ -157,11 +163,9 @@ export default defineComponent({
component
.
includes
(
'
TimePicker
'
)
component
.
includes
(
'
TimePicker
'
)
)
{
)
{
rule
.
type
=
'
object
'
;
rule
.
type
=
'
object
'
;
}
}
else
if
(
component
.
includes
(
'
RangePicker
'
)
||
component
.
includes
(
'
Upload
'
))
{
if
(
component
.
includes
(
'
RangePicker
'
)
||
component
.
includes
(
'
Upload
'
))
{
rule
.
type
=
'
array
'
;
rule
.
type
=
'
array
'
;
}
}
else
if
(
component
.
includes
(
'
InputNumber
'
))
{
if
(
component
.
includes
(
'
InputNumber
'
))
{
rule
.
type
=
'
number
'
;
rule
.
type
=
'
number
'
;
}
}
}
}
...
@@ -171,7 +175,7 @@ export default defineComponent({
...
@@ -171,7 +175,7 @@ export default defineComponent({
const
characterInx
=
rules
.
findIndex
((
val
)
=>
val
.
max
);
const
characterInx
=
rules
.
findIndex
((
val
)
=>
val
.
max
);
if
(
characterInx
!==
-
1
&&
!
rules
[
characterInx
].
validator
)
{
if
(
characterInx
!==
-
1
&&
!
rules
[
characterInx
].
validator
)
{
rules
[
characterInx
].
message
=
rules
[
characterInx
].
message
=
rules
[
characterInx
].
message
||
`字符数应小于
${
rules
[
characterInx
].
max
}
位`
;
rules
[
characterInx
].
message
||
t
(
'
maxTip
'
,
[
rules
[
characterInx
].
max
])
;
}
}
return
rules
;
return
rules
;
}
}
...
@@ -237,6 +241,7 @@ export default defineComponent({
...
@@ -237,6 +241,7 @@ export default defineComponent({
const
bindValue
=
{
const
bindValue
=
{
[
valueField
||
(
isCheck
?
'
checked
'
:
'
value
'
)]:
handleValue
(
component
,
field
),
[
valueField
||
(
isCheck
?
'
checked
'
:
'
value
'
)]:
handleValue
(
component
,
field
),
};
};
if
(
!
renderComponentContent
)
{
if
(
!
renderComponentContent
)
{
return
<
Comp
{
...
propsData
}
{
...
on
}
{
...
bindValue
}
/>;
return
<
Comp
{
...
propsData
}
{
...
on
}
{
...
bindValue
}
/>;
}
}
...
...
src/components/Form/src/hooks/useFormAction.ts
浏览文件 @
bb1b267e
...
@@ -79,9 +79,7 @@ export function useFormAction({
...
@@ -79,9 +79,7 @@ export function useFormAction({
validKeys
.
push
(
key
);
validKeys
.
push
(
key
);
}
}
});
});
// if (formEl) {
validateFields
(
validKeys
);
// formEl.validateFields(validKeys);
// }
}
}
/**
/**
* @description: Delete based on field name
* @description: Delete based on field name
...
...
src/components/Form/src/hooks/useFormValues.ts
浏览文件 @
bb1b267e
...
@@ -19,11 +19,11 @@ export function useFormValues({
...
@@ -19,11 +19,11 @@ export function useFormValues({
formModel
,
formModel
,
}:
UseFormValuesContext
)
{
}:
UseFormValuesContext
)
{
// Processing form values
// Processing form values
function
handleFormValues
(
values
:
any
)
{
function
handleFormValues
(
values
:
Record
<
string
,
any
>
)
{
if
(
!
isObject
(
values
))
{
if
(
!
isObject
(
values
))
{
return
{};
return
{};
}
}
const
resMap
:
any
=
{};
const
resMap
:
Record
<
string
,
any
>
=
{};
for
(
const
item
of
Object
.
entries
(
values
))
{
for
(
const
item
of
Object
.
entries
(
values
))
{
let
[,
value
]
=
item
;
let
[,
value
]
=
item
;
const
[
key
]
=
item
;
const
[
key
]
=
item
;
...
@@ -49,7 +49,7 @@ export function useFormValues({
...
@@ -49,7 +49,7 @@ export function useFormValues({
/**
/**
* @description: Processing time interval parameters
* @description: Processing time interval parameters
*/
*/
function
handleRangeTimeValue
(
values
:
any
)
{
function
handleRangeTimeValue
(
values
:
Record
<
string
,
any
>
)
{
const
fieldMapToTime
=
unref
(
fieldMapToTimeRef
);
const
fieldMapToTime
=
unref
(
fieldMapToTimeRef
);
if
(
!
fieldMapToTime
||
!
Array
.
isArray
(
fieldMapToTime
))
{
if
(
!
fieldMapToTime
||
!
Array
.
isArray
(
fieldMapToTime
))
{
...
@@ -72,7 +72,7 @@ export function useFormValues({
...
@@ -72,7 +72,7 @@ export function useFormValues({
function
initDefault
()
{
function
initDefault
()
{
const
schemas
=
unref
(
getSchema
);
const
schemas
=
unref
(
getSchema
);
const
obj
:
any
=
{};
const
obj
:
Record
<
string
,
any
>
=
{};
schemas
.
forEach
((
item
)
=>
{
schemas
.
forEach
((
item
)
=>
{
if
(
item
.
defaultValue
)
{
if
(
item
.
defaultValue
)
{
obj
[
item
.
field
]
=
item
.
defaultValue
;
obj
[
item
.
field
]
=
item
.
defaultValue
;
...
...
src/locales/lang/en/component/form.ts
浏览文件 @
bb1b267e
...
@@ -6,4 +6,6 @@ export default {
...
@@ -6,4 +6,6 @@ export default {
input
:
'
Please Input
'
,
input
:
'
Please Input
'
,
choose
:
'
Please Choose
'
,
choose
:
'
Please Choose
'
,
maxTip
:
'
The number of characters should be less than {0}
'
,
};
};
src/locales/lang/zh_CN/component/form.ts
浏览文件 @
bb1b267e
...
@@ -6,4 +6,6 @@ export default {
...
@@ -6,4 +6,6 @@ export default {
input
:
'
请输入
'
,
input
:
'
请输入
'
,
choose
:
'
请选择
'
,
choose
:
'
请选择
'
,
maxTip
:
'
字符数应小于{0}位
'
,
};
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录