Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
saas-dml
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
saas-dml
Commits
07447c0c
提交
07447c0c
authored
4月 07, 2023
作者:
陈志磊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
2c23dd13
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
58 行增加
和
43 行删除
+58
-43
AppUpload copy.vue
src/components/base/AppUpload copy.vue
+0
-2
AppUpload.vue
src/components/base/AppUpload.vue
+56
-39
UploadEventsDialog.vue
src/modules/user/components/UploadEventsDialog.vue
+1
-1
UploadUserDialog.vue
src/modules/user/components/UploadUserDialog.vue
+1
-1
没有找到文件。
src/components/base/AppUpload copy.vue
浏览文件 @
07447c0c
...
@@ -12,7 +12,6 @@ const props = withDefaults(
...
@@ -12,7 +12,6 @@ const props = withDefaults(
size
?:
number
size
?:
number
beforeUploadFiles
?:
(
file
:
any
)
=>
boolean
|
void
beforeUploadFiles
?:
(
file
:
any
)
=>
boolean
|
void
onChange
?:
(
file
:
any
,
files
:
any
)
=>
void
onChange
?:
(
file
:
any
,
files
:
any
)
=>
void
limit
?:
number
}
>
(),
}
>
(),
{
{
prefix
:
'upload/admin/'
prefix
:
'upload/admin/'
...
@@ -111,7 +110,6 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
...
@@ -111,7 +110,6 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
:on-preview=
"handlePreview"
:on-preview=
"handlePreview"
:on-success=
"handleSuccess"
:on-success=
"handleSuccess"
:file-list=
"fileList"
:file-list=
"fileList"
:limit=
"limit"
class=
"uploader"
class=
"uploader"
>
>
<template
v-if=
"showFileList"
>
<template
v-if=
"showFileList"
>
...
...
src/components/base/AppUpload.vue
浏览文件 @
07447c0c
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
{
ElMessage
}
from
'element-plus'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
{
Plus
}
from
'@element-plus/icons-vue'
import
type
{
UploadProps
,
UploadUserFile
}
from
'element-plus'
import
md5
from
'blueimp-md5'
import
md5
from
'blueimp-md5'
import
{
getSignature
}
from
'@/api/base'
import
{
getSignature
}
from
'@/api/base'
const
props
=
withDefaults
(
interface
Props
{
defineProps
<
{
modelValue
:
string
|
{
name
:
string
;
url
:
string
}[]
modelValue
:
string
|
[]
prefix
?:
string
prefix
?:
string
size
?:
number
size
?:
number
limit
?:
number
beforeUploadFiles
?:
(
file
:
any
)
=>
boolean
|
void
beforeUpload
?:
(
file
:
any
)
=>
void
onChange
?:
(
file
:
any
,
files
:
any
)
=>
void
}
limit
?:
number
}
>
(),
{
prefix
:
'upload/admin/'
}
)
const
emit
=
defineEmits
([
'update:modelValue'
])
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
prefix
:
'upload/saas-lab/'
})
const
emit
=
defineEmits
([
'update:modelValue'
,
'success'
])
const
uploadData
=
ref
()
const
uploadData
=
ref
()
const
fileList
=
ref
<
UploadUserFile
[]
>
([])
const
fileList
=
ref
<
UploadUserFile
[]
>
([])
watch
(
watchEffect
(()
=>
{
()
=>
props
.
modelValue
,
fileList
.
value
=
Array
.
isArray
(
props
.
modelValue
)
?
props
.
modelValue
.
map
(
item
=>
({
...
item
}))
:
[]
value
=>
{
})
fileList
.
value
=
Array
.
isArray
(
value
)
?
[...
value
]
:
[]
}
)
const
showFileList
=
computed
(()
=>
{
const
showFileList
=
computed
(()
=>
{
return
Array
.
isArray
(
props
.
modelValue
)
return
Array
.
isArray
(
props
.
modelValue
)
...
@@ -38,8 +33,16 @@ const showFileList = computed(() => {
...
@@ -38,8 +33,16 @@ const showFileList = computed(() => {
// 上传之前
// 上传之前
const
handleBeforeUpload
=
async
(
file
:
any
)
=>
{
const
handleBeforeUpload
=
async
(
file
:
any
)
=>
{
if
(
props
.
limit
&&
fileList
.
value
.
length
>=
props
.
limit
&&
props
.
limit
>
1
)
{
ElMessage
.
error
(
`只能上传
${
props
.
limit
}
个文件`
)
return
false
}
if
(
props
.
size
&&
file
.
size
>
props
.
size
)
{
ElMessage
.
error
(
`文件大小不能超过
${
props
.
size
/
1024
/
1024
}
M`
)
return
false
}
const
fileName
=
file
.
name
const
fileName
=
file
.
name
const
key
=
props
.
prefix
+
md5
(
fileName
+
new
Date
().
getTime
())
+
'/'
+
fileName
const
key
=
props
.
prefix
+
md5
(
fileName
+
new
Date
().
getTime
())
+
fileName
.
substr
(
fileName
.
lastIndexOf
(
'.'
))
const
response
:
Record
<
string
,
any
>
=
await
getSignature
()
const
response
:
Record
<
string
,
any
>
=
await
getSignature
()
uploadData
.
value
=
{
uploadData
.
value
=
{
key
,
key
,
...
@@ -50,29 +53,42 @@ const handleBeforeUpload = async (file: any) => {
...
@@ -50,29 +53,42 @@ const handleBeforeUpload = async (file: any) => {
url
:
`
${
response
.
host
}
/
${
key
}
`
url
:
`
${
response
.
host
}
/
${
key
}
`
}
}
file
.
url
=
`
${
response
.
host
}
/
${
key
}
`
file
.
url
=
`
${
response
.
host
}
/
${
key
}
`
if
(
props
.
beforeUpload
Files
)
{
if
(
props
.
beforeUpload
)
{
return
props
.
beforeUpload
Files
(
file
)
return
props
.
beforeUpload
(
file
)
}
}
}
}
// 上传成功
// 上传成功
const
handleSuccess
:
UploadProps
[
'onSuccess'
]
=
(
response
,
file
:
any
,
files
:
any
)
=>
{
const
handleSuccess
=
(
response
:
any
,
file
:
any
,
files
:
any
)
=>
{
if
(
!
files
.
every
((
item
:
any
)
=>
item
.
status
===
'success'
))
return
if
(
!
files
.
every
((
item
:
any
)
=>
item
.
status
===
'success'
))
return
if
(
showFileList
.
value
)
{
if
(
showFileList
.
value
)
{
emit
(
if
(
props
.
limit
&&
props
.
limit
===
1
)
{
'update:modelValue'
,
const
last
=
files
[
files
.
length
-
1
]
files
.
map
((
item
:
any
)
=>
{
emit
(
'update:modelValue'
,
[
return
{
{
name
:
item
.
name
,
name
:
last
.
name
,
url
:
item
.
url
||
item
.
raw
.
url
,
url
:
last
.
url
||
last
.
raw
?
.
url
,
size
:
item
.
size
||
item
.
raw
.
size
,
size
:
last
.
size
||
last
.
raw
?
.
size
,
type
:
item
.
type
||
item
.
raw
.
type
type
:
last
.
type
||
last
.
raw
?
.
type
}
}
})
])
)
}
else
{
emit
(
'update:modelValue'
,
files
.
map
((
item
:
any
)
=>
{
return
{
name
:
item
.
name
,
url
:
item
.
url
||
item
.
raw
?.
url
,
size
:
item
.
size
||
item
.
raw
?.
size
,
type
:
item
.
type
||
item
.
raw
?.
type
}
})
)
}
}
else
{
}
else
{
emit
(
'update:modelValue'
,
file
.
raw
.
url
)
emit
(
'update:modelValue'
,
file
.
raw
.
url
)
}
}
emit
(
'success'
,
file
,
files
)
}
}
// 上传限制
// 上传限制
...
@@ -81,12 +97,12 @@ const handleExceed: UploadProps['onExceed'] = () => {
...
@@ -81,12 +97,12 @@ const handleExceed: UploadProps['onExceed'] = () => {
}
}
// 删除
// 删除
const
handleRemove
:
UploadProps
[
'onRemove'
]
=
(
uploadFile
,
uploadF
iles
)
=>
{
const
handleRemove
:
UploadProps
[
'onRemove'
]
=
(
file
,
f
iles
)
=>
{
if
(
showFileList
.
value
)
{
if
(
showFileList
.
value
)
{
emit
(
emit
(
'update:modelValue'
,
'update:modelValue'
,
uploadF
iles
.
map
((
item
:
any
)
=>
{
f
iles
.
map
((
item
:
any
)
=>
{
return
{
name
:
item
.
name
,
url
:
item
.
url
||
item
.
raw
.
url
,
size
:
item
.
size
,
type
:
item
.
type
}
return
{
name
:
item
.
name
,
url
:
item
.
url
||
item
.
raw
.
url
}
})
})
)
)
}
else
{
}
else
{
...
@@ -96,7 +112,7 @@ const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
...
@@ -96,7 +112,7 @@ const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
// 预览
// 预览
const
handlePreview
:
UploadProps
[
'onPreview'
]
=
uploadFile
=>
{
const
handlePreview
:
UploadProps
[
'onPreview'
]
=
uploadFile
=>
{
console
.
log
(
uploadFile
)
window
.
open
(
uploadFile
.
url
)
}
}
</
script
>
</
script
>
...
@@ -111,6 +127,7 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
...
@@ -111,6 +127,7 @@ const handlePreview: UploadProps['onPreview'] = uploadFile => {
:on-preview=
"handlePreview"
:on-preview=
"handlePreview"
:on-success=
"handleSuccess"
:on-success=
"handleSuccess"
:file-list=
"fileList"
:file-list=
"fileList"
:limit=
"limit"
class=
"uploader"
class=
"uploader"
>
>
<slot>
<slot>
...
...
src/modules/user/components/UploadEventsDialog.vue
浏览文件 @
07447c0c
...
@@ -60,7 +60,7 @@ const fetchFileUpload = () => {
...
@@ -60,7 +60,7 @@ const fetchFileUpload = () => {
// })
// })
}
}
const
fileData
=
$ref
<
any
>
([])
const
fileData
=
$ref
([])
</
script
>
</
script
>
<
template
>
<
template
>
...
...
src/modules/user/components/UploadUserDialog.vue
浏览文件 @
07447c0c
...
@@ -51,7 +51,7 @@ const fetchFileUpload = () => {
...
@@ -51,7 +51,7 @@ const fetchFileUpload = () => {
}
}
}
}
const
fileData
=
$ref
<
any
>
([])
const
fileData
=
$ref
([])
</
script
>
</
script
>
<
template
>
<
template
>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论