feat: 文件上传查询不到ossId的丢弃策略

This commit is contained in:
dap 2025-03-29 21:48:46 +08:00
parent b3e2d758f6
commit 69222807a4
2 changed files with 19 additions and 1 deletions

View File

@ -249,7 +249,19 @@ export function useUpload(
};
return fileitem;
}
innerFileList.value = resp.map((item) => transformFile(item));
const transformOptions = resp.map((item) => transformFile(item));
innerFileList.value = transformOptions;
// 单文件 丢弃策略
if (props.maxCount === 1 && resp.length === 0 && !props.keepMissingId) {
bindValue.value = '';
return;
}
// 多文件
if (resp.length !== value.length && !props.keepMissingId) {
bindValue.value = (bindValue.value as string[]).filter((ossId) =>
resp.map((res) => res.ossId).includes(ossId),
);
}
},
{ immediate: true, deep: props.deepWatch },
);

View File

@ -66,4 +66,10 @@ export interface BaseUploadProps {
* @default false
*/
deepWatch?: boolean;
/**
* ossId查询不到文件信息时
* ossId
* @default false
*/
keepMissingId?: boolean;
}