Commit 4ddee05dee87c944ba95dca54a754e048b8cfc84

Authored by vben
1 parent abb0cfae

fix(form): fix form inputNumber verification error

CHANGELOG.zh_CN.md
... ... @@ -9,6 +9,10 @@
9 9  
10 10 - 更新 antdv 到`2.0.0-rc.1`
11 11  
  12 +### 🐛 Bug Fixes
  13 +
  14 +- 修复表单 inputNumber 校验错误
  15 +
12 16 ## 2.0.0-rc.10 (2020-11-13)
13 17  
14 18 ### ✨ Refactor
... ...
src/components/Form/src/FormItem.tsx
... ... @@ -122,10 +122,10 @@ export default defineComponent({
122 122 } = props.schema;
123 123  
124 124 if (isFunction(dynamicRules)) {
125   - return dynamicRules(unref(getValuesRef));
  125 + return dynamicRules(unref(getValuesRef)) as ValidationRule[];
126 126 }
127 127  
128   - let rules: ValidationRule[] = cloneDeep(defRules);
  128 + let rules: ValidationRule[] = cloneDeep(defRules) as ValidationRule[];
129 129  
130 130 if ((!rules || rules.length === 0) && required) {
131 131 rules = [{ required }];
... ... @@ -157,6 +157,9 @@ export default defineComponent({
157 157 if (component.includes('RangePicker')) {
158 158 rule.type = 'array';
159 159 }
  160 + if (component.includes('InputNumber')) {
  161 + rule.type = 'number';
  162 + }
160 163 }
161 164 }
162 165  
... ...
src/hooks/web/useMessage.tsx
1 1 import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal';
2   -import type { MessageApi } from 'ant-design-vue/lib/message';
3 2  
4 3 import { Modal, message as Message, notification } from 'ant-design-vue';
5 4 import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
... ... @@ -100,7 +99,7 @@ notification.config({
100 99 */
101 100 export function useMessage() {
102 101 return {
103   - createMessage: Message as MessageApi,
  102 + createMessage: Message,
104 103 notification: notification as NotifyApi,
105 104 createConfirm: createConfirm,
106 105 createSuccessModal,
... ...
src/views/demo/form/index.vue
... ... @@ -208,6 +208,15 @@
208 208 ],
209 209 },
210 210 },
  211 + {
  212 + field: 'field20',
  213 + component: 'InputNumber',
  214 + label: '字段20',
  215 + required: true,
  216 + colProps: {
  217 + span: 8,
  218 + },
  219 + },
211 220 ];
212 221  
213 222 export default defineComponent({
... ...