fix(upload): 修复上传组件删除无效bug

This commit is contained in:
wen zhenjin 2024-07-31 11:50:40 +08:00
parent 25699c0b60
commit 371c972cc1

View File

@ -57,7 +57,7 @@
import { useMessage } from '@/hooks/web/useMessage';
// types
import { FileItem, UploadResultStatus } from '../types/typing';
import { basicProps } from '../props';
import { handleFnKey, basicProps } from '../props';
import { createTableColumns, createActionColumn } from './data';
// utils
import { checkImgType, getBase64WithFile } from '../helper';
@ -161,13 +161,13 @@
}
//
function handleRemove(record: FileItem) {
const index = fileListRef.value.findIndex((item) => item.uuid === record.uuid);
index !== -1 && fileListRef.value.splice(index, 1);
isUploadingRef.value = fileListRef.value.some(
(item) => item.status === UploadResultStatus.UPLOADING,
);
emit('delete', record);
function handleRemove(obj: Record<handleFnKey, any>) {
let { record = {}, uidKey = 'uid' } = obj;
const index = fileListRef.value.findIndex((item) => item[uidKey] === record[uidKey]);
if (index !== -1) {
const removed = fileListRef.value.splice(index, 1);
emit('delete', removed[0][uidKey]);
}
}
async function uploadApiByItem(item: FileItem) {