yudaocode / yudao-ui-admin-vue3

芋道管理后台,基于 Vue3 + Element Plus 实现,支持 RBAC 动态权限、数据权限、SaaS 多租户、Flowable 工作流、三方登录、支付、短信、商城、CRM、ERP、AI 大模型等功能。
MIT License
1.74k stars 753 forks source link

【欢迎认领】uploadfile组件调用出错 #61

Open javachens opened 4 months ago

javachens commented 4 months ago

在crm模块中使用到文件上传的均出错如下,而且该组件在表单中使用时候为自动上传且清掉filelist,如果此时想删除时则无法操作,上传文件市错误如下,原因好像是得不到绑定值modelValue chunk-ZM53WNRW.js?v=41a044d2:1784 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core . at <UploadFile modelValue= (2) [undefined, undefined] onUpdate:modelValue=fn class="min-w-80px" > at at at at <ElForm ref="formRef" model= {bizType: 1, bizId: '9', picUrls: Array(0), fileUrls: Array(2)} rules= {type: Array(1), content: Array(1), nextTime: Array(1)} ... > at <ElDialogContent key=0 ref_key="dialogContentRef" ref=Ref< Proxy(Object) {…}

... > at <ElFocusTrap loop="" trapped=true focus-start-el="container" ... > at <ElOverlay custom-mask-event="" mask=true overlay-class=undefined ... > at <BaseTransition onAfterEnter=fn onAfterLeave=fn onBeforeLeave=fn ... > at <Transition name="dialog-fade" onAfterEnter=fn onAfterLeave=fn ... > at <ElDialog onUpdate:modelValue=fn modelValue=true width="50%" ... > at <Dialog modelValue=true onUpdate:modelValue=fn title="新增" ... > at <FollowUpRecordForm ref="formRef" onSuccess=fn > at at at at at <CrmClueDetail onVnodeUnmounted=fn ref=Ref< Proxy(Object) {__v_skip: true} key="/crm/clue/detail/9" > at <KeepAlive include= ['Index']

at at at at <Layout class="" onVnodeUnmounted=fn ref=Ref< Proxy(Object) {…}

at at <ElConfigProvider namespace="el" locale= {name: 'zh-cn', el: {…}} message= {max: 1} ... > at at UploadFile.vue:158 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'substring') at UploadFile.vue:158:20 at Proxy.map () at watch.immediate (UploadFile.vue:158:20) at callWithErrorHandling (chunk-ZM53WNRW.js?v=41a044d2:1868:19) at callWithAsyncErrorHandling (chunk-ZM53WNRW.js?v=41a044d2:1875:17) at job (chunk-ZM53WNRW.js?v=41a044d2:3444:9) at flushPreFlushCbs (chunk-ZM53WNRW.js?v=41a044d2:2010:7) at updateComponentPreRender (chunk-ZM53WNRW.js?v=41a044d2:6974:5) at ReactiveEffect.componentUpdateFn [as fn] (chunk-ZM53WNRW.js?v=41a044d2:6887:11) at ReactiveEffect.run (chunk-ZM53WNRW.js?v=41a044d2:1410:23)

错误处代码为 // 监听模型绑定值变动 watch( () => props.modelValue, (val: string | string[]) => { console.log(val) if (!val) { fileList.value = [] // fix:处理掉缓存,表单重置后上传组件的内容并没有重置 return }

fileList.value = [] // 保障数据为空
// 情况1:字符串
if (isString(val)) {
  fileList.value.push(
    ...val.split(',').map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
  )
  return
}
// 情况2:数组
fileList.value.push(
  ...(val as string[]).map((url) => ({ name: url.substring(url.lastIndexOf('/') + 1), url }))
)

}, { immediate: true, deep: true } )

YunaiV commented 4 months ago

有兴趣 pull request 尝试修复下么?