|
38 | 38 | } from 'vue';
|
39 | 39 | import { Form, Row } from 'ant-design-vue';
|
40 | 40 | import { formProps } from 'ant-design-vue/lib/form';
|
41 |
| - import { isNullOrUnDef, isObject, isArray, isFunction, isBoolean } from '@/utils/is'; |
| 41 | + import { isNullOrUnDef, isObject, isArray, isFunction, isBoolean, isString } from '@/utils/is'; |
42 | 42 | import { deepMerge } from '@/utils/';
|
43 | 43 | import SchemaFormItem from './schema-form-item.vue';
|
44 | 44 | import type { FormItemSchema, FormSchema, FormActionType } from './types/form';
|
|
71 | 71 | let oldFormSchema: FormSchema;
|
72 | 72 | // TODO 将formSchema克隆一份,避免修改原有的formSchema
|
73 | 73 | // TODO 类型为FormSchema 提示:类型实例化过深,且可能无限
|
74 |
| - const formSchemaRef = ref<any>({}); |
| 74 | + const formSchemaRef = ref<FormSchema>(cloneDeep(props.formSchema)); |
75 | 75 | // 表单项数据
|
76 | 76 | const formModel = reactive({ ...props.initialValues });
|
77 | 77 | // 表单默认数据
|
|
172 | 172 | */
|
173 | 173 | function itemIsDateType(key: string) {
|
174 | 174 | return unref(formSchemaRef).schemas.some((item) => {
|
175 |
| - return item.field === key ? dateItemType.includes(item.component) : false; |
| 175 | + return item.field === key && isString(item.component) |
| 176 | + ? dateItemType.includes(item.component) |
| 177 | + : false; |
176 | 178 | });
|
177 | 179 | }
|
178 | 180 |
|
|
191 | 193 | let value = values[key];
|
192 | 194 |
|
193 | 195 | const hasKey = Reflect.has(values, key);
|
194 |
| - value = handleInputNumberValue(schema?.component, value); |
| 196 | + if (isString(schema?.component)) { |
| 197 | + value = handleInputNumberValue(schema?.component, value); |
| 198 | + } |
195 | 199 | // 0| '' is allow
|
196 | 200 | if (hasKey && fields.includes(key)) {
|
197 | 201 | // time type
|
|
227 | 231 | if (isArray(data)) {
|
228 | 232 | updateData = [...data];
|
229 | 233 | }
|
230 |
| -
|
| 234 | + // @ts-ignore |
231 | 235 | unref(formSchemaRef).schemas = updateData as FormItemSchema[];
|
232 | 236 | }
|
233 | 237 |
|
|
0 commit comments