fix(type): type:check error (#3309)

This commit is contained in:
bowen 2023-11-21 15:38:00 +08:00 committed by GitHub
parent 82671d0750
commit 2cd5a40322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 18 deletions

View File

@ -273,7 +273,7 @@
}
}
const formActionType: Partial<FormActionType> = {
const formActionType = {
getFieldsValue,
setFieldsValue,
resetFields,

View File

@ -22,6 +22,7 @@
import { type Recordable } from '@vben/types';
import { PropType, ref, unref, watch, watchEffect } from 'vue';
import { Cascader } from 'ant-design-vue';
import type { CascaderProps } from 'ant-design-vue';
import { propTypes } from '@/utils/propTypes';
import { isFunction } from '@/utils/is';
import { get, omit } from 'lodash-es';
@ -131,7 +132,7 @@
}
}
async function loadData(selectedOptions: Option[]) {
const loadData: CascaderProps['loadData'] = async (selectedOptions) => {
const targetOption = selectedOptions[selectedOptions.length - 1];
targetOption.loading = true;
@ -155,7 +156,7 @@
} finally {
targetOption.loading = false;
}
}
};
watchEffect(() => {
props.immediate && initialFetch();
@ -174,13 +175,13 @@
emit('defaultChange', keys, args);
}
function handleRenderDisplay({ labels, selectedOptions }) {
if (unref(emitData).length === selectedOptions.length) {
const handleRenderDisplay: CascaderProps['displayRender'] = ({ labels, selectedOptions }) => {
if (unref(emitData).length === selectedOptions?.length) {
return labels.join(' / ');
}
if (props.displayRenderArray) {
return props.displayRenderArray.join(' / ');
}
return '';
}
};
</script>

View File

@ -27,7 +27,7 @@
import { ref, toRefs, watch } from 'vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import { Upload, Modal } from 'ant-design-vue';
import type { UploadProps } from 'ant-design-vue';
import type { UploadProps, UploadFile } from 'ant-design-vue';
import { UploadRequestOption } from 'ant-design-vue/lib/vc-upload/interface';
import { useMessage } from '@/hooks/web/useMessage';
import { isArray, isFunction, isObject, isString } from '@/utils/is';
@ -77,32 +77,35 @@
} else {
return;
}
}) as UploadProps['fileList'][number];
}) as UploadProps['fileList'];
}
},
);
function getBase64(file: File) {
return new Promise((resolve, reject) => {
function getBase64<T extends string | ArrayBuffer | null>(file: File) {
return new Promise<T>((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onload = () => {
resolve(reader.result as T);
};
reader.onerror = (error) => reject(error);
});
}
const handlePreview = async (file: UploadProps['fileList'][number]) => {
const handlePreview = async (file: UploadFile) => {
if (!file.url && !file.preview) {
file.preview = (await getBase64(file.originFileObj)) as string;
file.preview = await getBase64<string>(file.originFileObj!);
}
previewImage.value = file.url || file.preview;
previewImage.value = file.url || file.preview || '';
previewOpen.value = true;
previewTitle.value = file.name || file.url.substring(file.url.lastIndexOf('/') + 1);
previewTitle.value =
file.name || previewImage.value.substring(previewImage.value.lastIndexOf('/') + 1);
};
const handleRemove = async (file: UploadProps['fileList'][number]) => {
const handleRemove = async (file: UploadFile) => {
if (fileList.value) {
const index = fileList.value.findIndex((item: any) => item.uuid === file.uuid);
const index = fileList.value.findIndex((item) => item.uid === file.uid);
index !== -1 && fileList.value.splice(index, 1);
emit('change', fileList.value);
emit('delete', file);

View File

@ -22,7 +22,7 @@
:actions="[
{
label: t('sys.errorLog.tableActionDesc'),
onClick: handleDetail.bind(null, record),
onClick: handleDetail.bind(null, record as ErrorLogInfo),
},
]"
/>