Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zys-ui
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
龙菲
zys-ui
Commits
9dd5c3b4
提交
9dd5c3b4
authored
8月 28, 2023
作者:
李忠利
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改文件上传逻辑
上级
5ef27afe
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
9 行删除
+13
-9
Box.vue
src/components/file/box/uploadFile/Box.vue
+13
-9
没有找到文件。
src/components/file/box/uploadFile/Box.vue
浏览文件 @
9dd5c3b4
...
@@ -91,7 +91,7 @@
...
@@ -91,7 +91,7 @@
<ul
class=
"file-list"
v-show=
"!collapse"
>
<ul
class=
"file-list"
v-show=
"!collapse"
>
<li
<li
class=
"file-item"
class=
"file-item"
:class=
"
{ 'custom-status-item':
file.statusStr
!== '' }"
:class=
"
{ 'custom-status-item':
uploadStatus[file.id]
!== '' }"
v-for="file in props.fileList"
v-for="file in props.fileList"
:key="file.id"
:key="file.id"
>
>
...
@@ -101,7 +101,7 @@
...
@@ -101,7 +101,7 @@
:list=
"true"
:list=
"true"
></uploader-file>
></uploader-file>
<!-- 自定义状态 -->
<!-- 自定义状态 -->
<span
class=
"custom-status"
>
{{
file
.
statusStr
}}
</span>
<span
class=
"custom-status"
>
{{
uploadStatus
[
file
.
id
]
}}
</span>
</li>
</li>
<div
class=
"no-file"
v-if=
"!props.fileList.length"
>
<div
class=
"no-file"
v-if=
"!props.fileList.length"
>
<i
class=
"icon-empty-file"
></i>
暂无待上传文件
<i
class=
"icon-empty-file"
></i>
暂无待上传文件
...
@@ -123,6 +123,7 @@ import { mapState } from "vuex";
...
@@ -123,6 +123,7 @@ import { mapState } from "vuex";
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
uploadStatus
:
{},
// 上传组件配置项
// 上传组件配置项
options
:
{
options
:
{
target
:
`
${
process
.
env
.
VUE_APP_BASE_API
}
/v1/api/folder/transfer/uploadfile`
,
// 上传文件-目标 URL
target
:
`
${
process
.
env
.
VUE_APP_BASE_API
}
/v1/api/folder/transfer/uploadfile`
,
// 上传文件-目标 URL
...
@@ -304,15 +305,16 @@ export default {
...
@@ -304,15 +305,16 @@ export default {
* @param {string} response 服务端响应内容,永远都是字符串
* @param {string} response 服务端响应内容,永远都是字符串
*/
*/
handleFileSuccess
(
rootFile
,
file
,
response
)
{
handleFileSuccess
(
rootFile
,
file
,
response
)
{
if
(
response
==
""
)
{
if
(
response
==
""
)
{
file
.
statusStr
=
"上传失败"
;
this
.
uploadStatus
[
file
.
id
]
=
"上传失败"
;
this
.
callback
(
false
);
this
.
callback
(
false
);
return
;
return
;
}
}
let
result
=
JSON
.
parse
(
response
);
let
result
=
JSON
.
parse
(
response
);
if
(
result
.
success
)
{
if
(
result
.
code
===
200
)
{
file
.
statusStr
=
""
;
this
.
uploadStatus
[
file
.
id
]
=
""
;
if
(
this
.
filesLength
===
1
)
{
if
(
this
.
filesLength
===
1
)
{
// 本次所有的文件均已上传完毕
// 本次所有的文件均已上传完毕
this
.
$message
.
success
(
`上传完毕`
);
this
.
$message
.
success
(
`上传完毕`
);
...
@@ -327,7 +329,7 @@ export default {
...
@@ -327,7 +329,7 @@ export default {
}
}
}
else
{
}
else
{
this
.
$message
.
error
(
result
.
message
);
this
.
$message
.
error
(
result
.
message
);
file
.
statusStr
=
"上传失败"
;
this
.
uploadStatus
[
file
.
id
]
=
"上传失败"
;
}
}
this
.
filesLength
--
;
this
.
filesLength
--
;
},
},
...
@@ -358,7 +360,7 @@ export default {
...
@@ -358,7 +360,7 @@ export default {
let
chunks
=
Math
.
ceil
(
file
.
size
/
chunkSize
);
let
chunks
=
Math
.
ceil
(
file
.
size
/
chunkSize
);
let
spark
=
new
SparkMD5
.
ArrayBuffer
();
let
spark
=
new
SparkMD5
.
ArrayBuffer
();
// 文件状态设为"计算MD5"
// 文件状态设为"计算MD5"
file
.
statusStr
=
"计算MD5"
;
this
.
uploadStatus
[
file
.
id
]
=
"计算MD5"
;
file
.
pause
();
file
.
pause
();
loadNext
();
loadNext
();
fileReader
.
onload
=
(
e
)
=>
{
fileReader
.
onload
=
(
e
)
=>
{
...
@@ -367,9 +369,10 @@ export default {
...
@@ -367,9 +369,10 @@ export default {
currentChunk
++
;
currentChunk
++
;
loadNext
();
loadNext
();
// 实时展示MD5的计算进度
// 实时展示MD5的计算进度
file
.
statusStr
=
`校验MD5
${((
currentChunk
/
chunks
)
*
100
).
toFixed
(
this
.
uploadStatus
[
file
.
id
]
=
`校验MD5
${((
currentChunk
/
chunks
)
*
100
).
toFixed
(
0
0
)}
%`
;
)}
%`
;
this
.
uploadStatus
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
uploadStatus
))
}
else
{
}
else
{
let
md5
=
spark
.
end
();
let
md5
=
spark
.
end
();
this
.
calculateFileMD5End
(
md5
,
file
);
this
.
calculateFileMD5End
(
md5
,
file
);
...
@@ -406,7 +409,8 @@ export default {
...
@@ -406,7 +409,8 @@ export default {
file
.
uniqueIdentifier
=
md5
;
file
.
uniqueIdentifier
=
md5
;
file
.
resume
();
file
.
resume
();
// 移除自定义状态
// 移除自定义状态
file
.
statusStr
=
""
;
this
.
uploadStatus
[
file
.
id
]
=
''
this
.
uploadStatus
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
uploadStatus
))
},
},
/**
/**
* 关闭上传面板,并停止上传
* 关闭上传面板,并停止上传
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论