From 076dc79896496776701b158950960a08a4490707 Mon Sep 17 00:00:00 2001 From: bqy_fe <1743369777@qq.com> Date: Fri, 7 Jan 2022 17:42:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B7=A6=E4=BE=A7=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E8=B6=85=E5=87=BA=E5=B1=8F=E5=B9=95=E4=B8=8D=E8=83=BD=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- .../core/schema-form/schema-form.vue | 14 +++++---- src/components/core/schema-form/types/form.ts | 8 ++--- src/layout/menu/menu.vue | 29 ++++++++++--------- src/layout/tabs/tabs-view.vue | 6 ++-- src/views/system/permission/user/index.vue | 11 +++---- yarn.lock | 8 ++--- 7 files changed, 40 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index cd2693a58..5b35aa7f4 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "nprogress": "^1.0.0-1", "pinia": "2.0.9", "qs": "^6.10.2", - "socket.io-client": "4.4.0", + "socket.io-client": "4.4.1", "sortablejs": "^1.14.0", "vue": "^3.2.26", "vue-i18n": "^9.2.0-beta.26", diff --git a/src/components/core/schema-form/schema-form.vue b/src/components/core/schema-form/schema-form.vue index d740003fe..e940ed170 100644 --- a/src/components/core/schema-form/schema-form.vue +++ b/src/components/core/schema-form/schema-form.vue @@ -38,7 +38,7 @@ } from 'vue'; import { Form, Row } from 'ant-design-vue'; import { formProps } from 'ant-design-vue/lib/form'; - import { isNullOrUnDef, isObject, isArray, isFunction, isBoolean } from '@/utils/is'; + import { isNullOrUnDef, isObject, isArray, isFunction, isBoolean, isString } from '@/utils/is'; import { deepMerge } from '@/utils/'; import SchemaFormItem from './schema-form-item.vue'; import type { FormItemSchema, FormSchema, FormActionType } from './types/form'; @@ -71,7 +71,7 @@ let oldFormSchema: FormSchema; // TODO 将formSchema克隆一份,避免修改原有的formSchema // TODO 类型为FormSchema 提示:类型实例化过深,且可能无限 - const formSchemaRef = ref({}); + const formSchemaRef = ref(cloneDeep(props.formSchema)); // 表单项数据 const formModel = reactive({ ...props.initialValues }); // 表单默认数据 @@ -172,7 +172,9 @@ */ function itemIsDateType(key: string) { return unref(formSchemaRef).schemas.some((item) => { - return item.field === key ? dateItemType.includes(item.component) : false; + return item.field === key && isString(item.component) + ? dateItemType.includes(item.component) + : false; }); } @@ -191,7 +193,9 @@ let value = values[key]; const hasKey = Reflect.has(values, key); - value = handleInputNumberValue(schema?.component, value); + if (isString(schema?.component)) { + value = handleInputNumberValue(schema?.component, value); + } // 0| '' is allow if (hasKey && fields.includes(key)) { // time type @@ -227,7 +231,7 @@ if (isArray(data)) { updateData = [...data]; } - + // @ts-ignore unref(formSchemaRef).schemas = updateData as FormItemSchema[]; } diff --git a/src/components/core/schema-form/types/form.ts b/src/components/core/schema-form/types/form.ts index c26d8863c..2e23b4f2b 100644 --- a/src/components/core/schema-form/types/form.ts +++ b/src/components/core/schema-form/types/form.ts @@ -52,7 +52,7 @@ export type RegisterFn = (formInstance: FormActionType) => void; export type UseFormReturnType = [RegisterFn, FormActionType]; /** 表单 */ -export interface FormSchema extends FormProps { +export interface FormSchema extends FormProps { // Form value model?: any; // The width of all items in the entire form @@ -69,7 +69,7 @@ export interface FormSchema extends FormProps { baseColProps?: Partial; // Form configuration rules - schemas: FormItemSchema[]; + schemas: FormItemSchema[]; // Function values used to merge into dynamic control form items mergeDynamicData?: any; // Compact mode for search forms @@ -116,9 +116,9 @@ export interface FormSchema extends FormProps { transformDateFunc?: (date: any) => string; } /** 表单项 */ -export interface FormItemSchema { +export interface FormItemSchema { /** 字段名 */ - field: T extends string ? string : keyof T; + field: T extends any ? string : keyof T; // Event name triggered by internal value change, default change changeEvent?: string; // Variable name bound to v-model Default value diff --git a/src/layout/menu/menu.vue b/src/layout/menu/menu.vue index 6737eaa80..f287f1172 100644 --- a/src/layout/menu/menu.vue +++ b/src/layout/menu/menu.vue @@ -1,18 +1,19 @@