diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index d00767f5..d613ac58 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -9,6 +9,10 @@ - 更新 antdv 到`2.0.0-rc.1` +### 🐛 Bug Fixes + +- 修复表单 inputNumber 校验错误 + ## 2.0.0-rc.10 (2020-11-13) ### ✨ Refactor diff --git a/src/components/Form/src/FormItem.tsx b/src/components/Form/src/FormItem.tsx index 16acb76d..c013d0b8 100644 --- a/src/components/Form/src/FormItem.tsx +++ b/src/components/Form/src/FormItem.tsx @@ -122,10 +122,10 @@ export default defineComponent({ } = props.schema; if (isFunction(dynamicRules)) { - return dynamicRules(unref(getValuesRef)); + return dynamicRules(unref(getValuesRef)) as ValidationRule[]; } - let rules: ValidationRule[] = cloneDeep(defRules); + let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[]; if ((!rules || rules.length === 0) && required) { rules = [{ required }]; @@ -157,6 +157,9 @@ export default defineComponent({ if (component.includes('RangePicker')) { rule.type = 'array'; } + if (component.includes('InputNumber')) { + rule.type = 'number'; + } } } diff --git a/src/hooks/web/useMessage.tsx b/src/hooks/web/useMessage.tsx index a2380ec1..02bc4267 100644 --- a/src/hooks/web/useMessage.tsx +++ b/src/hooks/web/useMessage.tsx @@ -1,5 +1,4 @@ import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal'; -import type { MessageApi } from 'ant-design-vue/lib/message'; import { Modal, message as Message, notification } from 'ant-design-vue'; import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue'; @@ -100,7 +99,7 @@ notification.config({ */ export function useMessage() { return { - createMessage: Message as MessageApi, + createMessage: Message, notification: notification as NotifyApi, createConfirm: createConfirm, createSuccessModal, diff --git a/src/views/demo/form/index.vue b/src/views/demo/form/index.vue index 28001818..ae473fcd 100644 --- a/src/views/demo/form/index.vue +++ b/src/views/demo/form/index.vue @@ -208,6 +208,15 @@ ], }, }, + { + field: 'field20', + component: 'InputNumber', + label: '字段20', + required: true, + colProps: { + span: 8, + }, + }, ]; export default defineComponent({