|
@@ -38,16 +38,23 @@ const handlePictureCardPreview = async (file: any) => {
|
|
|
dialogVisible.value = true
|
|
|
}
|
|
|
// 图片上传之前
|
|
|
-const beforeUpload = async (file: any) => {
|
|
|
+const beforeUpload = (file: any) => {
|
|
|
loadingInstance = ElLoading.service({
|
|
|
lock: true,
|
|
|
text: 'Loading',
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
- }) // 加载蒙版
|
|
|
- let suffix = file.type.split('/')[1]
|
|
|
- const res: any = await UpFileToken({ User_tokey: globalStore.GET_User_tokey, T_suffix: suffix })
|
|
|
- uploadData.token = res.Data
|
|
|
- uploadData.key = file.name
|
|
|
+ })
|
|
|
+ uploadData.key = file.name
|
|
|
+}
|
|
|
+
|
|
|
+const clickToken = async()=>{
|
|
|
+
|
|
|
+ UpFileToken({ User_tokey: globalStore.GET_User_tokey}).then(res=>{
|
|
|
+ uploadData.token = res.Data as string
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
// 图片上传超出界限
|
|
|
const handleExceed: UploadProps['onExceed'] = (files: any) => {
|
|
@@ -57,6 +64,7 @@ const handleExceed: UploadProps['onExceed'] = (files: any) => {
|
|
|
upload.value.handleStart(file)
|
|
|
upload.value.submit()
|
|
|
}
|
|
|
+
|
|
|
// 图片上传成功
|
|
|
const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
|
let ERPOSS = import.meta.env.VITE_BZD_ERPOSS_APP_API
|
|
@@ -68,13 +76,16 @@ const onSuccess = (response: any, uploadFile: UploadFile, uploadFiles: UploadFil
|
|
|
}
|
|
|
ElMessage.success(props.successText)
|
|
|
loadingInstance.close()
|
|
|
+ console.log('onSuccess')
|
|
|
}
|
|
|
// 图片上传失败
|
|
|
const onError = () => {
|
|
|
ElMessage.error(props.errorText)
|
|
|
+ console.log('onError')
|
|
|
}
|
|
|
// 图片移除
|
|
|
const handleRemove: UploadProps['onRemove'] = (uploadFile: any, uploadFiles: UploadFiles) => {
|
|
|
+ loadingInstance.close()
|
|
|
if (limit.value === 1) {
|
|
|
emit('update:modelValue', '')
|
|
|
} else {
|
|
@@ -138,14 +149,15 @@ defineExpose({
|
|
|
action="https://up-z2.qiniup.com"
|
|
|
:list-type="listType"
|
|
|
:limit="limit"
|
|
|
- :auto-upload="true"
|
|
|
:before-upload="beforeUpload"
|
|
|
+ :auto-upload="true"
|
|
|
:on-success="onSuccess"
|
|
|
:on-error="onError"
|
|
|
:on-exceed="handleExceed"
|
|
|
:on-remove="handleRemove"
|
|
|
:on-preview="handlePictureCardPreview"
|
|
|
:data="uploadData"
|
|
|
+ @click="clickToken"
|
|
|
>
|
|
|
<slot></slot>
|
|
|
<template #tip>
|