Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
rs-admin
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
翟畅
rs-admin
Commits
b8fe4bc4
提交
b8fe4bc4
authored
7月 15, 2022
作者:
翟畅
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
http://test16.zhongdianyun.com/zhaichang/rs-admin
into dev
上级
4a5c89b6
275839c9
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
67 行增加
和
12 行删除
+67
-12
common.js
src/api/common.js
+11
-0
request1.js
src/utils/request1.js
+6
-1
component.vue
src/views/resource_manage/annex_module/component.vue
+7
-7
component.vue
src/views/resource_manage/video_module/component.vue
+43
-4
没有找到文件。
src/api/common.js
浏览文件 @
b8fe4bc4
...
...
@@ -57,4 +57,14 @@ export function deleteFileAPI(data) {
method
:
'post'
,
data
})
}
//文件上传
export
function
uploadFileAPI
(
data
,
config
=
{})
{
return
request
({
url
:
`
${
requestPath
.
file
}
/upload/info`
,
method
:
'post'
,
data
,
...
config
,
})
}
\ No newline at end of file
src/utils/request1.js
浏览文件 @
b8fe4bc4
...
...
@@ -7,7 +7,12 @@ import { isPhone } from "@/libs/wechat";
const
qs
=
require
(
'qs'
);
const
service
=
axios
.
create
({
baseURL
:
SettingMer
.
httpUrl
,
timeout
:
60000
// 过期时间
timeout
:
60000
,
// 过期时间
// onUploadProgress: event => {
// // event.loaded:已上传文件大小
// // event.total:被上传文件的总大小
// console.log(Number((event.loaded / event.total * 100) | 0));
// }
})
// request interceptor
...
...
src/views/resource_manage/annex_module/component.vue
浏览文件 @
b8fe4bc4
...
...
@@ -42,7 +42,7 @@
<el-input
v-model=
"dataForm.source"
style=
"width:85%;"
></el-input>
</el-form-item>
-->
<el-form-item
label=
"附件:"
prop=
"annexName"
>
<el-upload
:action=
"`$
{fileUrl}upload/info`" :show-file-list="false"
accept=".rar,.zip"
<el-upload
:action=
"`$
{fileUrl}upload/info`" :show-file-list="false"
:on-success="handleSuccess" :on-error="handleError" :before-upload="beforeUpload" style="float:left;">
<el-button
size=
"small"
type=
"primary"
:loading=
'loading'
:disabled=
"loading"
>
上传文件
</el-button>
</el-upload>
...
...
@@ -459,12 +459,12 @@ export default {
this
.
loading
=
false
this
.
$message
.
error
(
'文件上传失败'
);
},
beforeUpload
(
file
)
{
//
annex
限制
let
type
=
file
.
name
.
slice
(
file
.
name
.
lastIndexOf
(
'.'
)
+
1
).
toLowerCase
()
if
(
!
(
type
==
'zip'
||
type
==
'rar'
))
{
this
.
$message
.
warning
(
'上传文件仅支持rar或zip格式!'
);
return
false
;
}
beforeUpload
(
file
)
{
//
附件
限制
//
let type = file.name.slice(file.name.lastIndexOf('.')+1).toLowerCase()
//
if (!(type == 'zip'||type == 'rar')) {
//
this.$message.warning('上传文件仅支持rar或zip格式!');
//
return false;
//
}
this
.
loading
=
true
},
...
...
src/views/resource_manage/video_module/component.vue
浏览文件 @
b8fe4bc4
...
...
@@ -59,14 +59,15 @@
</div>
</el-form-item>
<el-form-item
label=
"视频文件:"
prop=
"video"
>
<el-upload
:action=
"`$
{fileUrl}upload/info`" :show-file-list="false" style="display:inline-block;"
:on-success="handleVideoSuccess" :before-upload="beforeVideoUpload" accept=".mp4,.avi,.mov,.wmv,.3gp,.webm,.flv,.rmvb" :disabled="loading">
<!-- 使用:http-request自定义上传指令,:on-success, :on-error指令是不会触发的 -->
<el-upload
action=
"string"
:show-file-list=
"false"
style=
"display:inline-block;"
:before-upload=
"beforeVideoUpload"
:http-request=
"handleRequest"
accept=
".mp4,.avi,.mov,.wmv,.3gp,.webm,.flv,.rmvb"
:disabled=
"loading"
>
<!--
<div
class=
"upload_btn"
style=
"background:#1F71FF"
>
上传文件
</div>
-->
<el-button
size=
"small"
type=
"primary"
:loading=
'loading'
:disabled=
"loading"
>
上传文件
</el-button>
</el-upload>
<span
class=
"video_names"
>
{{
dataForm
.
videoName
?
dataForm
.
videoName
:
'未上传文件'
}}
</span>
<i
v-if=
"dataForm.video"
class=
"el-icon-delete"
style=
"color:#f56c6c;font-size:16px;cursor:pointer"
@
click=
"deleteSource"
></i>
<div
v-if=
"showProgress"
class=
"progress"
><el-progress
:percentage=
"progress
"
></el-progress></div>
<div
class=
"progress"
v-if=
"showProgress"
><el-progress
:percentage=
"progressPercent
"
></el-progress></div>
<div
v-if=
"dataForm.video"
>
<video
:src=
"`$
{fileUrl}?fileName=${dataForm.video}
&
isOnLine=true`" controls class="video_style">
</video>
</div>
...
...
@@ -101,7 +102,7 @@
<
script
>
import
{
videoSaveAPI
,
videoDetailsAPI
}
from
'@/api/resource/video'
import
{
sortListAPI
,
labelListAPI
,
authorLibraryAPI
,
deleteFileAPI
}
from
'@/api/common'
import
{
sortListAPI
,
labelListAPI
,
authorLibraryAPI
,
deleteFileAPI
,
uploadFileAPI
,
}
from
'@/api/common'
import
{
fileUrl
}
from
'@/utils/global'
import
{
formatSort
}
from
'@/utils/format'
import
{
valValidate
}
from
'@/utils/validate'
...
...
@@ -167,6 +168,7 @@ export default {
translatorList
:[],
sortList
:
[],
options
:
[],
progressPercent
:
0
,
}
},
created
()
{
...
...
@@ -329,6 +331,43 @@ export default {
}
return
isFile
&&
isLimit
;
},
handleRequest
(
data
)
{
let
formdata
=
new
FormData
();
formdata
.
append
(
'file'
,
data
.
file
);
const
config
=
{
onUploadProgress
:
event
=>
{
this
.
showProgress
=
true
// event.loaded:已上传文件大小
// event.total:被上传文件的总大小
this
.
progressPercent
=
Number
((
event
.
loaded
/
event
.
total
*
100
)
|
0
);
// console.log(event,7777777)
}
};
uploadFileAPI
(
formdata
,
config
).
then
(
res
=>
{
// console.log(res,666666)
if
(
res
.
data
)
{
this
.
progressPercent
=
100
;
this
.
loading
=
false
this
.
showProgress
=
false
this
.
$message
.
success
(
"文件上传成功"
);
this
.
dataForm
.
video
=
res
.
data
.
fileName
this
.
dataForm
.
videoName
=
res
.
data
.
originalFileName
this
.
dataForm
.
size
=
res
.
data
.
size
this
.
dataForm
.
timeLength
=
res
.
data
.
time
this
.
$nextTick
(()
=>
{
this
.
$refs
[
'dataForm'
].
clearValidate
(
'video'
);
})
}
else
{
this
.
progressPercent
=
0
;
this
.
loading
=
false
this
.
showProgress
=
false
this
.
$message
.
warning
(
"文件上传失败"
);
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
// console.log('uploadRes',uploadRes);
},
handleVideoSuccess
(
response
,
file
,
fileList
){
//视频上传成功
this
.
loading
=
false
this
.
dataForm
.
video
=
response
.
fileName
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论