diff --git a/apps/web-antd/src/components/upload/src/hook.ts b/apps/web-antd/src/components/upload/src/hook.ts index 1b5785a9..313ceae4 100644 --- a/apps/web-antd/src/components/upload/src/hook.ts +++ b/apps/web-antd/src/components/upload/src/hook.ts @@ -204,7 +204,12 @@ export function useUpload( if (props.maxCount === 1) { bindValue.value = ossId; } else { - (bindValue.value as string[]).push(ossId); + // 给默认值 + if (!Array.isArray(bindValue.value)) { + bindValue.value = []; + } + // 直接使用.value无法触发useForm的更新(原生是正常的) 需要修改地址 + bindValue.value = [...bindValue.value, ossId]; } break; } @@ -344,11 +349,16 @@ export function useUpload( !props.keepMissingId && props.maxCount !== 1 ) { - bindValue.value = (bindValue.value as string[]).filter((ossId) => + // 给默认值 + if (!Array.isArray(bindValue.value)) { + bindValue.value = []; + } + bindValue.value = bindValue.value.filter((ossId) => resp.map((res) => res.ossId).includes(ossId), ); } }, + // TODO: deepWatch参数需要删除 { immediate: true, deep: props.deepWatch }, ); diff --git a/apps/web-antd/src/views/演示使用自行删除/upload/index.vue b/apps/web-antd/src/views/演示使用自行删除/upload/index.vue index 29860163..5bf30a01 100644 --- a/apps/web-antd/src/views/演示使用自行删除/upload/index.vue +++ b/apps/web-antd/src/views/演示使用自行删除/upload/index.vue @@ -5,7 +5,7 @@ import type { CustomGetter } from '#/components/upload/src/props'; import { h, ref } from 'vue'; -import { CodeMirror, Page } from '@vben/common-ui'; +import { CodeMirror, Page, useVbenModal } from '@vben/common-ui'; import { useClipboard } from '@vueuse/core'; import { Alert, Card, Modal, RadioGroup, Switch } from 'ant-design-vue'; @@ -14,6 +14,7 @@ import { FileUpload, ImageUpload } from '#/components/upload'; import { useFileType, useImageType } from './hook'; import sql from './insert.sql?raw'; +import uploadModal from './upload-modal.vue'; const singleImageId = ref('1905537674682916865'); const singleFileId = ref('1905191167882518529'); @@ -53,6 +54,10 @@ const customThumbnailUrl: CustomGetter = () => { const { copy } = useClipboard({ legacy: true }); const animationEnable = ref(false); + +const [UploadModal, uploadModalApi] = useVbenModal({ + connectedComponent: uploadModal, +});