chore: fix type:check error (#3139)

This commit is contained in:
bowen 2023-10-12 14:50:32 +08:00 committed by GitHub
parent 4d02205839
commit f87e078402
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 41 additions and 27 deletions

View File

@ -2,7 +2,7 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
/** /**
* @description: Request list interface parameters * @description: Request list interface parameters
*/ */
export type DemoParams = BasicPageParams; export type DemoParams = Partial<BasicPageParams>;
export interface DemoListItem { export interface DemoListItem {
id: string; id: string;

View File

@ -107,7 +107,7 @@ export function useForm(props?: Props): UseFormReturnType {
return form.submit(); return form.submit();
}, },
validate: async (nameList?: NamePath[] | false): Promise<Recordable> => { validate: async <T = Recordable>(nameList?: NamePath[] | false): Promise<T> => {
const form = await getForm(); const form = await getForm();
return form.validate(nameList); return form.validate(nameList);
}, },

View File

@ -39,7 +39,7 @@ export interface FormActionType {
first?: boolean | undefined, first?: boolean | undefined,
) => Promise<void>; ) => Promise<void>;
validateFields: (nameList?: NamePath[]) => Promise<any>; validateFields: (nameList?: NamePath[]) => Promise<any>;
validate: <T = any>(nameList?: NamePath[] | false) => Promise<T>; validate: <T = Recordable>(nameList?: NamePath[] | false) => Promise<T>;
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>; scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>;
} }

View File

@ -3,7 +3,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { defineProps, onBeforeUnmount, onDeactivated, Ref, ref, unref, watch } from 'vue'; import { onBeforeUnmount, onDeactivated, Ref, ref, unref, watch } from 'vue';
import VditorPreview from 'vditor/dist/method.min'; import VditorPreview from 'vditor/dist/method.min';
import { onMountedOrActivated } from '@vben/hooks'; import { onMountedOrActivated } from '@vben/hooks';
import { useRootSetting } from '/@/hooks/setting/useRootSetting'; import { useRootSetting } from '/@/hooks/setting/useRootSetting';

View File

@ -25,7 +25,7 @@
<script lang="ts"> <script lang="ts">
import type { SizeType } from '../../types/table'; import type { SizeType } from '../../types/table';
import { defineComponent, ref } from 'vue'; import { defineComponent, ref } from 'vue';
import { Tooltip, Dropdown, Menu } from 'ant-design-vue'; import { Tooltip, Dropdown, Menu, type MenuProps } from 'ant-design-vue';
import { ColumnHeightOutlined } from '@ant-design/icons-vue'; import { ColumnHeightOutlined } from '@ant-design/icons-vue';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { useTableContext } from '../../hooks/useTableContext'; import { useTableContext } from '../../hooks/useTableContext';
@ -46,12 +46,12 @@
const selectedKeysRef = ref<SizeType[]>([table.getSize()]); const selectedKeysRef = ref<SizeType[]>([table.getSize()]);
function handleTitleClick({ key }: { key: SizeType }) { const handleTitleClick: MenuProps['onClick'] = ({ key }) => {
selectedKeysRef.value = [key]; selectedKeysRef.value = [key as SizeType];
table.setProps({ table.setProps({
size: key, size: key as SizeType,
}); });
} };
return { return {
handleTitleClick, handleTitleClick,

View File

@ -65,7 +65,7 @@ export function useTree(treeDataRef: Ref<TreeDataItem[]>, getFieldNames: Compute
} }
// Update node // Update node
function updateNodeByKey(key: string, node: TreeDataItem, list?: TreeDataItem[]) { function updateNodeByKey(key: string, node: Omit<TreeDataItem, 'key'>, list?: TreeDataItem[]) {
if (!key) return; if (!key) return;
const treeData = list || unref(treeDataRef); const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames); const { key: keyField, children: childrenField } = unref(getFieldNames);
@ -184,7 +184,7 @@ export function useTree(treeDataRef: Ref<TreeDataItem[]>, getFieldNames: Compute
if (!key && key !== 0) return null; if (!key && key !== 0) return null;
const treeData = list || unref(treeDataRef); const treeData = list || unref(treeDataRef);
const { key: keyField, children: childrenField } = unref(getFieldNames); const { key: keyField, children: childrenField } = unref(getFieldNames);
if (!keyField) return; if (!keyField) return null;
treeData.forEach((item) => { treeData.forEach((item) => {
if (selectedNode?.key || selectedNode?.key === 0) return selectedNode; if (selectedNode?.key || selectedNode?.key === 0) return selectedNode;
if (item[keyField] === key) { if (item[keyField] === key) {

View File

@ -3,7 +3,7 @@
<BasicTable @register="registerTable" @edit-change="handleEditChange"> <BasicTable @register="registerTable" @edit-change="handleEditChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction :actions="createActions(record, column)" /> <TableAction :actions="createActions(record)" />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
@ -107,7 +107,7 @@
data.push(addRow); data.push(addRow);
} }
function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] { function createActions(record: EditRecordRow): ActionItem[] {
if (!record.editable) { if (!record.editable) {
return [ return [
{ {
@ -122,13 +122,13 @@
return [ return [
{ {
label: '保存', label: '保存',
onClick: handleSave.bind(null, record, column), onClick: handleSave.bind(null, record),
}, },
{ {
label: '取消', label: '取消',
popConfirm: { popConfirm: {
title: '是否取消编辑', title: '是否取消编辑',
confirm: handleCancel.bind(null, record, column), confirm: handleCancel.bind(null, record),
}, },
}, },
]; ];

View File

@ -3,7 +3,7 @@
<BasicTable @register="registerTable" @edit-change="onEditChange"> <BasicTable @register="registerTable" @edit-change="onEditChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction :actions="createActions(record, column)" /> <TableAction :actions="createActions(record)" />
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
@ -278,7 +278,7 @@
} }
} }
function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] { function createActions(record: EditRecordRow): ActionItem[] {
if (!record.editable) { if (!record.editable) {
return [ return [
{ {
@ -291,13 +291,13 @@
return [ return [
{ {
label: '保存', label: '保存',
onClick: handleSave.bind(null, record, column), onClick: handleSave.bind(null, record),
}, },
{ {
label: '取消', label: '取消',
popConfirm: { popConfirm: {
title: '是否取消编辑', title: '是否取消编辑',
confirm: handleCancel.bind(null, record, column), confirm: handleCancel.bind(null, record),
}, },
}, },
]; ];

View File

@ -78,9 +78,16 @@
const fApi = useVModel(props, 'fApi', emit); const fApi = useVModel(props, 'fApi', emit);
const { submit, validate, clearValidate, resetFields, validateField } = const { submit, validate, clearValidate, resetFields, validateField } =
useFormInstanceMethods(props, formModelNew, context, eFormModel); useFormInstanceMethods<['submit', 'change', 'update:fApi', 'update:formModel']>(
props,
formModelNew,
context,
eFormModel,
);
const { linkOn, ...methods } = useVFormMethods( const { linkOn, ...methods } = useVFormMethods<
['submit', 'change', 'update:fApi', 'update:formModel']
>(
{ formConfig: props.formConfig, formData: props.formModel } as unknown as IProps, { formConfig: props.formConfig, formData: props.formModel } as unknown as IProps,
context, context,
eFormModel, eFormModel,

View File

@ -1,13 +1,13 @@
import { IAnyObject } from '../typings/base-type'; import { IAnyObject } from '../typings/base-type';
import { Ref, SetupContext, getCurrentInstance, toRaw } from 'vue'; import { Ref, SetupContext, getCurrentInstance, toRaw, type EmitsOptions } from 'vue';
import { cloneDeep, forOwn, isFunction } from 'lodash-es'; import { cloneDeep, forOwn, isFunction } from 'lodash-es';
import { AForm, IVFormComponent } from '../typings/v-form-component'; import { AForm, IVFormComponent } from '../typings/v-form-component';
import { Form } from 'ant-design-vue'; import { Form } from 'ant-design-vue';
export function useFormInstanceMethods( export function useFormInstanceMethods<E extends EmitsOptions = EmitsOptions>(
props: IAnyObject, props: IAnyObject,
formdata, formdata,
context: Partial<SetupContext>, context: SetupContext<E>,
_formInstance: Ref<AForm | null>, _formInstance: Ref<AForm | null>,
) { ) {
/** /**

View File

@ -1,4 +1,4 @@
import { Ref, SetupContext } from 'vue'; import { Ref, SetupContext, type EmitsOptions } from 'vue';
import { IVFormComponent, IFormConfig, AForm } from '../typings/v-form-component'; import { IVFormComponent, IFormConfig, AForm } from '../typings/v-form-component';
import { findFormItem, formItemsForEach } from '../utils'; import { findFormItem, formItemsForEach } from '../utils';
import { cloneDeep, isFunction } from 'lodash-es'; import { cloneDeep, isFunction } from 'lodash-es';
@ -52,9 +52,9 @@ export interface IVFormMethods extends Partial<IFormInstanceMethods> {
getData: IGetData; getData: IGetData;
disable: IDisable; disable: IDisable;
} }
export function useVFormMethods( export function useVFormMethods<E extends EmitsOptions = EmitsOptions>(
props: IProps, props: IProps,
_context: Partial<SetupContext>, _context: SetupContext<E>,
formInstance: Ref<AForm | null>, formInstance: Ref<AForm | null>,
formInstanceMethods: Partial<IFormInstanceMethods>, formInstanceMethods: Partial<IFormInstanceMethods>,
): IVFormMethods { ): IVFormMethods {

7
types/global.d.ts vendored
View File

@ -22,6 +22,13 @@ declare global {
// __APP__: App<Element>; // __APP__: App<Element>;
// } // }
// fix FullScreen type error
interface Document {
mozFullScreenElement?: Element;
msFullscreenElement?: Element;
webkitFullscreenElement?: Element;
}
// vue // vue
declare type PropType<T> = VuePropType<T>; declare type PropType<T> = VuePropType<T>;
declare type VueNode = VNodeChild | JSX.Element; declare type VueNode = VNodeChild | JSX.Element;