Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
9f7879f2
提交
9f7879f2
编写于
8月 11, 2025
作者:
Cano1997
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: 文件下载越权漏洞修复
上级
c65dc5f0
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
576 行增加
和
508 行删除
+576
-508
app-file-upload.vue
src/components/app-file-upload/app-file-upload.vue
+525
-505
app-upload-file-info.vue
src/components/app-upload-file-info/app-upload-file-info.vue
+30
-2
disk-file-upload.vue
src/components/disk-file-upload/disk-file-upload.vue
+21
-1
未找到文件。
src/components/app-file-upload/app-file-upload.vue
浏览文件 @
9f7879f2
...
@@ -47,508 +47,528 @@
...
@@ -47,508 +47,528 @@
</ul>
</ul>
</modal>
</modal>
</div>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
'vue-property-decorator'
;
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
'vue-property-decorator'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
CreateElement
}
from
'vue'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
Axios
from
'axios'
;
import
Axios
from
'axios'
;
import
{
Message
}
from
'element-ui'
;
import
{
Message
}
from
'element-ui'
;
import
EntityService
from
'@/service/entity-service'
;
@
Component
({
})
@
Component
({
export
default
class
AppFileUpload
extends
Vue
{
})
export
default
class
AppFileUpload
extends
Vue
{
/**
* 表单状态
/**
*
* 表单状态
* @type {Subject<any>}
*
* @memberof AppFileUpload
* @type {Subject<any>}
*/
* @memberof AppFileUpload
@
Prop
()
public
formState
?:
Subject
<
any
>
*/
@
Prop
()
public
formState
?:
Subject
<
any
>
/**
* 是否忽略表单项书香值变化
/**
*
* 是否忽略表单项书香值变化
* @type {boolean}
*
* @memberof AppFileUpload
* @type {boolean}
*/
* @memberof AppFileUpload
@
Prop
()
public
ignorefieldvaluechange
?:
boolean
;
*/
@
Prop
()
public
ignorefieldvaluechange
?:
boolean
;
/**
* 是否支持拖拽
/**
*
* 是否支持拖拽
* @type {boolean}
*
* @memberof AppFileUpload
* @type {boolean}
*/
* @memberof AppFileUpload
@
Prop
()
public
isdrag
?:
boolean
;
*/
@
Prop
()
public
isdrag
?:
boolean
;
/**
* 表单状态事件
/**
*
* 表单状态事件
* @private
*
* @type {(Unsubscribable | undefined)}
* @private
* @memberof AppFileUpload
* @type {(Unsubscribable | undefined)}
*/
* @memberof AppFileUpload
private
formStateEvent
:
Unsubscribable
|
undefined
;
*/
private
formStateEvent
:
Unsubscribable
|
undefined
;
/**
* 表单数据
/**
*
* 表单数据
* @type {string}
*
* @memberof AppFileUpload
* @type {string}
*/
* @memberof AppFileUpload
@
Prop
()
public
data
!
:
string
;
*/
@
Prop
()
public
data
!
:
string
;
/**
* 视图参数
/**
*
* 视图参数
* @type {*}
*
* @memberof AppFormDRUIPart
* @type {*}
*/
* @memberof AppFormDRUIPart
@
Prop
()
public
viewparams
!
:
any
;
*/
@
Prop
()
public
viewparams
!
:
any
;
/**
* 视图上下文
/**
*
* 视图上下文
* @type {*}
*
* @memberof AppAutocomplete
* @type {*}
*/
* @memberof AppAutocomplete
@
Prop
()
public
context
!
:
any
;
*/
@
Prop
()
public
context
!
:
any
;
/**
* 初始化值
/**
*
* 初始化值
* @type {*}
*
* @memberof AppFileUpload
* @type {*}
*/
* @memberof AppFileUpload
@
Prop
()
public
value
?:
any
;
*/
@
Prop
()
public
value
?:
any
;
/**
* 数据值变化
/**
*
* 数据值变化
* @param {*} newval
*
* @param {*} val
* @param {*} newval
* @memberof AppFileUpload
* @param {*} val
*/
* @memberof AppFileUpload
@
Watch
(
'value'
)
*/
onValueChange
(
newval
:
any
,
val
:
any
)
{
@
Watch
(
'value'
)
if
(
this
.
ignorefieldvaluechange
)
{
onValueChange
(
newval
:
any
,
val
:
any
)
{
return
;
if
(
this
.
ignorefieldvaluechange
)
{
}
return
;
this
.
getParams
();
}
this
.
setFiles
(
newval
);
this
.
getParams
();
this
.
dataProcess
();
this
.
setFiles
(
newval
);
}
this
.
dataProcess
();
}
/**
* 所属表单项名称
/**
*
* 所属表单项名称
* @type {string}
*
* @memberof AppFileUpload
* @type {string}
*/
* @memberof AppFileUpload
@
Prop
()
public
name
!
:
string
;
*/
@
Prop
()
public
name
!
:
string
;
/**
* 是否禁用
/**
*
* 是否禁用
* @type {boolean}
*
* @memberof AppFileUpload
* @type {boolean}
*/
* @memberof AppFileUpload
@
Prop
()
public
disabled
?:
boolean
;
*/
@
Prop
()
public
disabled
?:
boolean
;
/**
* 上传参数
/**
*
* 上传参数
* @type {string}
*
* @memberof AppFileUpload
* @type {string}
*/
* @memberof AppFileUpload
@
Prop
()
public
uploadparams
?:
any
;
*/
@
Prop
()
public
uploadparams
?:
any
;
/**
* 下载参数
/**
*
* 下载参数
* @type {string}
*
* @memberof AppFileUpload
* @type {string}
*/
* @memberof AppFileUpload
@
Prop
()
public
exportparams
?:
any
;
*/
@
Prop
()
public
exportparams
?:
any
;
/**
* 文件列表
/**
*
* 实体服务
* @memberof AppFileUpload
*
*/
* @type {EntityService}
public
files
=
[];
* @memberof AppFileUpload
*/
/**
@
Prop
()
public
appEntityService
!
:
EntityService
;
* 上传params
*
/**
* @type {Array<any>}
* 默认为当前实体主键id,有指定则按表单参数
* @memberof AppFileUpload
*
*/
* @type {string}
public
upload_params
:
Array
<
any
>
=
[];
* @memberof AppFileUpload
*/
/**
@
Prop
()
public
ownerid
!
:
string
;
* 导出params
*
/**
* @type {Array<any>}
* 文件列表
* @memberof AppFileUpload
*
*/
* @memberof AppFileUpload
public
export_params
:
Array
<
any
>
=
[];
*/
public
files
=
[];
/**
* 自定义数组
/**
*
* 上传params
* @type {Array<any>}
*
* @memberof AppFileUpload
* @type {Array<any>}
*/
* @memberof AppFileUpload
public
custom_arr
:
Array
<
any
>
=
[];
*/
public
upload_params
:
Array
<
any
>
=
[];
/**
* 应用参数
/**
*
* 导出params
* @type {*}
*
* @memberof AppImageUpload
* @type {Array<any>}
*/
* @memberof AppFileUpload
public
appData
:
any
;
*/
public
export_params
:
Array
<
any
>
=
[];
/**
* 文件上传限制类型
/**
*
* 自定义数组
* @type {*}
*
* @memberof DiskFileUpload
* @type {Array<any>}
*/
* @memberof AppFileUpload
limitType
:
Array
<
String
>
=
[
'application/x-msdownload'
,
'text/x-sh'
,
'text/html'
,
'text/javascript'
]
*/
public
custom_arr
:
Array
<
any
>
=
[];
/**
* 当前登陆人的token
/**
*
* 应用参数
* @type {string}
*
* @memberof DiskFileUpload
* @type {*}
*/
* @memberof AppImageUpload
public
token
:
string
=
"Bearer "
+
localStorage
.
getItem
(
'token'
);
*/
public
appData
:
any
;
/**
* 上传文件请求头
/**
*
* 文件上传限制类型
* @type {*}
*
* @memberof DiskFileUpload
* @type {*}
*/
* @memberof DiskFileUpload
public
myHeaders
:
any
=
{
Authorization
:
this
.
token
};
*/
limitType
:
Array
<
String
>
=
[
'application/x-msdownload'
,
'text/x-sh'
,
'text/html'
,
'text/javascript'
]
/**
* 拼接上传路径
/**
*
* 当前登陆人的token
* @memberof DiskFileUpload
*
*/
* @type {string}
public
getAction
()
{
* @memberof DiskFileUpload
return
Environment
.
BaseUrl
+
`
${(
window
as
any
).
Environment
.
UploadFile
}
`
+
'?ownertype='
+
this
.
name
+
'&ownerid='
+
JSON
.
parse
(
this
.
data
).
srfkey
;
*/
}
public
token
:
string
=
"Bearer "
+
localStorage
.
getItem
(
'token'
);
/**
* 设置files
/**
*
* 上传文件请求头
* @private
*
* @memberof AppFileUpload
* @type {*}
*/
* @memberof DiskFileUpload
private
setFiles
(
value
:
any
):
void
{
*/
if
(
value
==
null
){
public
myHeaders
:
any
=
{
Authorization
:
this
.
token
};
this
.
files
=
[];
return
;
/**
}
* 拼接上传路径
let
_files
=
JSON
.
parse
(
value
);
*
if
(
value
&&
Object
.
prototype
.
toString
.
call
(
_files
)
==
'[object Array]'
)
{
* @memberof DiskFileUpload
this
.
files
=
_files
;
*/
}
else
{
public
getAction
()
{
this
.
files
=
[];
return
Environment
.
BaseUrl
+
`
${(
window
as
any
).
Environment
.
UploadFile
}
`
+
'?ownertype='
+
this
.
name
+
'&ownerid='
+
JSON
.
parse
(
this
.
data
).
srfkey
;
}
}
}
/**
* 设置files
/**
*
* 数据处理
* @private
*
* @memberof AppFileUpload
* @private
*/
* @memberof AppFileUpload
private
setFiles
(
value
:
any
):
void
{
*/
if
(
value
==
null
){
private
dataProcess
():
void
{
this
.
files
=
[];
let
_url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
UploadFile
}
`
;
return
;
if
(
this
.
upload_params
.
length
>
0
)
{
}
_url
+=
'?'
;
let
_files
=
JSON
.
parse
(
value
);
this
.
upload_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
if
(
value
&&
Object
.
prototype
.
toString
.
call
(
_files
)
==
'[object Array]'
)
{
_url
+=
`
${
Object
.
keys
(
item
)[
0
]}
=
${
Object
.
values
(
item
)[
0
]}
`
;
this
.
files
=
_files
;
if
(
i
<
this
.
upload_params
.
length
-
1
){
}
else
{
_url
+=
'&'
;
this
.
files
=
[];
}
}
})
}
}
this
.
files
.
forEach
((
file
:
any
)
=>
{
/**
let
url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
ExportFile
}
/
${
file
.
id
}
`
;
* 数据处理
if
(
this
.
export_params
.
length
>
0
)
{
*
url
+=
'?'
;
* @private
this
.
export_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
* @memberof AppFileUpload
url
+=
`
${
Object
.
keys
(
item
)[
0
]}
=
${
Object
.
values
(
item
)[
0
]}
`
;
*/
if
(
i
<
this
.
export_params
.
length
-
1
){
private
dataProcess
():
void
{
url
+=
'&'
;
let
_url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
UploadFile
}
`
;
}
if
(
this
.
upload_params
.
length
>
0
)
{
})
_url
+=
'?'
;
}
this
.
upload_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
file
.
url
=
url
;
_url
+=
`
${
Object
.
keys
(
item
)[
0
]}
=
${
Object
.
values
(
item
)[
0
]}
`
;
});
if
(
i
<
this
.
upload_params
.
length
-
1
){
}
_url
+=
'&'
;
}
})
}
/**
this
.
files
.
forEach
((
file
:
any
)
=>
{
* vue 生命周期
let
url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
ExportFile
}
/
${
file
.
id
}
`
;
*
if
(
this
.
export_params
.
length
>
0
)
{
* @memberof AppFileUpload
url
+=
'?'
;
*/
this
.
export_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
public
created
()
{
url
+=
`
${
Object
.
keys
(
item
)[
0
]}
=
${
Object
.
values
(
item
)[
0
]}
`
;
if
(
this
.
formState
)
{
if
(
i
<
this
.
export_params
.
length
-
1
){
this
.
formStateEvent
=
this
.
formState
.
subscribe
((
$event
:
any
)
=>
{
url
+=
'&'
;
// 表单加载完成
}
if
(
Object
.
is
(
$event
.
type
,
'load'
))
{
})
this
.
getParams
();
}
this
.
setFiles
(
this
.
value
);
file
.
url
=
url
;
this
.
dataProcess
();
});
}
}
});
}
}
/**
/**
* vue 生命周期
* vue 生命周期
*
*
* @memberof AppFileUpload
* @returns
*/
* @memberof AppFileUpload
public
created
()
{
*/
if
(
this
.
formState
)
{
public
mounted
()
{
this
.
formStateEvent
=
this
.
formState
.
subscribe
((
$event
:
any
)
=>
{
this
.
appData
=
this
.
$store
.
getters
.
getAppData
();
// 表单加载完成
this
.
getParams
();
if
(
Object
.
is
(
$event
.
type
,
'load'
))
{
this
.
setFiles
(
this
.
value
);
this
.
getParams
();
this
.
dataProcess
();
this
.
setFiles
(
this
.
value
);
}
this
.
dataProcess
();
}
/**
});
*获取上传,导出参数
}
*
}
*@memberof AppFileUpload
*/
/**
public
getParams
(){
* vue 生命周期
let
uploadparams
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
uploadparams
));
*
let
exportparams
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
exportparams
));
* @returns
* @memberof AppFileUpload
let
upload_params
:
Array
<
string
>
=
[];
*/
let
export_params
:
Array
<
string
>
=
[];
public
mounted
()
{
this
.
appData
=
this
.
$store
.
getters
.
getAppData
();
let
param
:
any
=
this
.
viewparams
;
this
.
getParams
();
let
context
:
any
=
this
.
context
;
this
.
setFiles
(
this
.
value
);
let
_data
:
any
=
JSON
.
parse
(
this
.
data
);
this
.
dataProcess
();
}
if
(
this
.
uploadparams
&&
!
Object
.
is
(
this
.
uploadparams
,
''
))
{
upload_params
=
this
.
$util
.
computedNavData
(
_data
,
param
,
context
,
uploadparams
);
/**
}
*获取上传,导出参数
if
(
this
.
exportparams
&&
!
Object
.
is
(
this
.
exportparams
,
''
))
{
*
export_params
=
this
.
$util
.
computedNavData
(
_data
,
param
,
context
,
exportparams
);
*@memberof AppFileUpload
}
*/
public
getParams
(){
this
.
upload_params
=
[];
let
uploadparams
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
uploadparams
));
this
.
export_params
=
[];
let
exportparams
:
any
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
exportparams
));
for
(
const
item
in
upload_params
)
{
let
upload_params
:
Array
<
string
>
=
[];
this
.
upload_params
.
push
({
let
export_params
:
Array
<
string
>
=
[];
[
item
]:
upload_params
[
item
]
})
let
param
:
any
=
this
.
viewparams
;
}
let
context
:
any
=
this
.
context
;
for
(
const
item
in
export_params
)
{
let
_data
:
any
=
JSON
.
parse
(
this
.
data
);
this
.
export_params
.
push
({
[
item
]:
export_params
[
item
]
if
(
this
.
uploadparams
&&
!
Object
.
is
(
this
.
uploadparams
,
''
))
{
})
upload_params
=
this
.
$util
.
computedNavData
(
_data
,
param
,
context
,
uploadparams
);
}
}
}
if
(
this
.
exportparams
&&
!
Object
.
is
(
this
.
exportparams
,
''
))
{
export_params
=
this
.
$util
.
computedNavData
(
_data
,
param
,
context
,
exportparams
);
/**
}
* 组件销毁
*
this
.
upload_params
=
[];
* @memberof AppFileUpload
this
.
export_params
=
[];
*/
public
destroyed
():
void
{
for
(
const
item
in
upload_params
)
{
if
(
this
.
formStateEvent
)
{
this
.
upload_params
.
push
({
this
.
formStateEvent
.
unsubscribe
();
[
item
]:
upload_params
[
item
]
}
})
}
}
for
(
const
item
in
export_params
)
{
/**
this
.
export_params
.
push
({
* 上传之前
[
item
]:
export_params
[
item
]
*
})
* @param {*} file
}
* @memberof AppFileUpload
}
*/
public
beforeUpload
(
file
:
any
)
{
/**
const
blackList
=
Environment
.
blackList
;
* 组件销毁
const
fileName
=
file
.
name
?.
trim
().
toLowerCase
();
*
if
(
Array
.
isArray
(
blackList
)
&&
typeof
fileName
===
'string'
&&
blackList
.
some
(
item
=>
fileName
.
endsWith
(
`.
${
item
}
`
)))
{
* @memberof AppFileUpload
Message
.
error
(
`不可上传
${
blackList
.
join
(
'、'
)}
类型的文件!`
);
*/
return
false
;
public
destroyed
():
void
{
}
if
(
this
.
formStateEvent
)
{
if
(
this
.
imageOnly
){
this
.
formStateEvent
.
unsubscribe
();
const
imageTypes
=
[
"image/jpeg"
,
"image/gif"
,
"image/png"
,
"image/bmp"
];
}
const
isImage
=
imageTypes
.
some
((
type
:
any
)
=>
Object
.
is
(
type
,
file
.
type
));
}
if
(
!
isImage
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'components.appFileUpload.fileTypeErrorTitle'
)
as
any
)
,
desc
:
(
this
.
$t
(
'components.appFileUpload.fileTypeErrorInfo'
)
as
any
)});
/**
}
* 上传之前
return
isImage
;
*
}
* @param {*} file
}
* @memberof AppFileUpload
*/
/**
public
beforeUpload
(
file
:
any
)
{
* 上传成功回调
const
blackList
=
Environment
.
blackList
;
*
const
fileName
=
file
.
name
?.
trim
().
toLowerCase
();
* @param {*} response
if
(
Array
.
isArray
(
blackList
)
&&
typeof
fileName
===
'string'
&&
blackList
.
some
(
item
=>
fileName
.
endsWith
(
`.
${
item
}
`
)))
{
* @param {*} file
Message
.
error
(
`不可上传
${
blackList
.
join
(
'、'
)}
类型的文件!`
);
* @param {*} fileList
return
false
;
* @memberof AppFileUpload
}
*/
if
(
this
.
imageOnly
){
public
onSuccess
(
response
:
any
,
file
:
any
,
fileList
:
any
)
{
const
imageTypes
=
[
"image/jpeg"
,
"image/gif"
,
"image/png"
,
"image/bmp"
];
if
(
!
response
)
{
const
isImage
=
imageTypes
.
some
((
type
:
any
)
=>
Object
.
is
(
type
,
file
.
type
));
return
;
if
(
!
isImage
)
{
}
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'components.appFileUpload.fileTypeErrorTitle'
)
as
any
)
,
desc
:
(
this
.
$t
(
'components.appFileUpload.fileTypeErrorInfo'
)
as
any
)});
const
data
=
{
name
:
response
.
filename
,
id
:
response
.
fileid
};
}
let
arr
:
Array
<
any
>
=
[];
return
isImage
;
this
.
files
.
forEach
((
_file
:
any
)
=>
{
}
arr
.
push
({
name
:
_file
.
name
,
id
:
_file
.
id
})
}
});
arr
.
push
(
data
);
/**
* 上传成功回调
let
value
:
any
=
arr
.
length
>
0
?
JSON
.
stringify
(
arr
)
:
null
;
*
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
value
});
* @param {*} response
}
* @param {*} file
* @param {*} fileList
/**
* @memberof AppFileUpload
* 上传失败回调
*/
*
public
onSuccess
(
response
:
any
,
file
:
any
,
fileList
:
any
)
{
* @param {*} error
if
(
!
response
)
{
* @param {*} file
return
;
* @param {*} fileList
}
* @memberof AppFileUpload
const
data
=
{
name
:
response
.
filename
,
id
:
response
.
fileid
};
*/
let
arr
:
Array
<
any
>
=
[];
public
onError
(
error
:
any
,
file
:
any
,
fileList
:
any
)
{
this
.
files
.
forEach
((
_file
:
any
)
=>
{
const
data
=
JSON
.
parse
(
error
.
message
)
arr
.
push
({
name
:
_file
.
name
,
id
:
_file
.
id
})
this
.
$Notice
.
error
({
title
:
data
.
message
||
(
this
.
$t
(
'components.appFileUpload.uploadError'
)
as
any
)});
});
}
arr
.
push
(
data
);
/**
let
value
:
any
=
arr
.
length
>
0
?
JSON
.
stringify
(
arr
)
:
null
;
* 删除文件
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
value
});
*
}
* @param {*} file
* @param {*} fileList
/**
* @memberof AppFileUpload
* 上传失败回调
*/
*
public
onRemove
(
file
:
any
,
fileList
:
any
)
{
* @param {*} error
let
arr
:
Array
<
any
>
=
[];
* @param {*} file
fileList
.
forEach
((
f
:
any
)
=>
{
* @param {*} fileList
if
(
f
.
id
!=
file
.
id
)
{
* @memberof AppFileUpload
arr
.
push
({
name
:
f
.
name
,
id
:
f
.
id
});
*/
}
public
onError
(
error
:
any
,
file
:
any
,
fileList
:
any
)
{
});
const
data
=
JSON
.
parse
(
error
.
message
)
let
value
:
any
=
arr
.
length
>
0
?
JSON
.
stringify
(
arr
)
:
null
;
this
.
$Notice
.
error
({
title
:
data
.
message
||
(
this
.
$t
(
'components.appFileUpload.uploadError'
)
as
any
)});
if
(
arr
.
length
==
0
){
}
this
.
dialogVisible
=
false
;
}
/**
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
value
});
* 删除文件
}
*
* @param {*} file
/**
* @param {*} fileList
* 下载文件
* @memberof AppFileUpload
*
*/
* @param {*} file
public
onRemove
(
file
:
any
,
fileList
:
any
)
{
* @memberof AppFileUpload
let
arr
:
Array
<
any
>
=
[];
*/
fileList
.
forEach
((
f
:
any
)
=>
{
public
onDownload
(
file
:
any
)
{
if
(
f
.
id
!=
file
.
id
)
{
// 拼接url
arr
.
push
({
name
:
f
.
name
,
id
:
f
.
id
});
let
_this
:
any
=
this
;
}
const
id
=
typeof
file
.
id
==
"string"
?
file
.
id
:
JSON
.
stringify
(
file
.
id
);
});
const
name
=
typeof
file
.
name
==
"string"
?
file
.
name
:
JSON
.
stringify
(
file
.
filename
);
let
value
:
any
=
arr
.
length
>
0
?
JSON
.
stringify
(
arr
)
:
null
;
const
downloadUrl
=
`
${(
window
as
any
).
Environment
.
ExportFile
}
`
+
'/'
+
id
+
'/'
+
name
;
if
(
arr
.
length
==
0
){
// 发送get请求
this
.
dialogVisible
=
false
;
Axios
.
get
(
downloadUrl
,
{
}
responseType
:
'arraybuffer'
,
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
value
});
}).
then
((
response
:
any
)
=>
{
}
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
'!'
);
/**
return
;
* 下载文件
}
*
// 请求成功,后台返回的是一个文件流
* @param {*} file
if
(
response
.
data
)
{
* @memberof AppFileUpload
// 获取文件名
*/
const
disposition
=
response
.
headers
[
'content-disposition'
];
public
onDownload
(
file
:
any
)
{
const
filename
=
disposition
.
split
(
'filename='
)[
1
];
// 拼接url
const
actualFileName
=
file
.
name
||
filename
;
let
_this
:
any
=
this
;
// 用blob对象获取文件流
const
id
=
typeof
file
.
id
==
"string"
?
file
.
id
:
JSON
.
stringify
(
file
.
id
);
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
const
name
=
typeof
file
.
name
==
"string"
?
file
.
name
:
JSON
.
stringify
(
file
.
filename
);
// 兼容ie语法
// const downloadUrl = '/ibizutilrpm/download/' + this.getFolder() + '/' + id + '/' + encodeURIComponent(name);
if
(
'msSaveOrOpenBlob'
in
navigator
){
const
entityName
=
this
.
appEntityService
.
APPDENAME
;
window
.
navigator
.
msSaveOrOpenBlob
(
blob
,
actualFileName
);
const
base64
=
`
${
id
}
|
${
entityName
}
|
${
this
.
ownerid
}
|
${
this
.
context
.
srfpersonid
||
this
.
context
.
srfuserid
}
`
;
return
;
const
downloadUrl
=
`http://downloadpath?key=
${
window
.
btoa
(
base64
)}
`
}
// 发送get请求
// 通过文件流创建下载链接
Axios
.
get
(
downloadUrl
,
{
var
href
=
URL
.
createObjectURL
(
blob
);
responseType
:
'arraybuffer'
,
// 创建一个a元素并设置相关属性
}).
then
((
response
:
any
)
=>
{
let
a
=
document
.
createElement
(
'a'
);
if
(
!
response
||
response
.
status
!=
200
)
{
a
.
href
=
href
;
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
'!'
);
a
.
download
=
actualFileName
;
return
;
// 添加a元素到当前网页
}
document
.
body
.
appendChild
(
a
);
// 请求成功,后台返回的是一个文件流
// 触发a元素的点击事件,实现下载
if
(
response
.
data
)
{
a
.
click
();
// 获取文件名
// 从当前网页移除a元素
const
disposition
=
response
.
headers
[
'content-disposition'
];
document
.
body
.
removeChild
(
a
);
const
filename
=
disposition
.
split
(
'filename='
)[
1
];
// 释放blob对象
const
actualFileName
=
file
.
name
||
filename
;
URL
.
revokeObjectURL
(
href
);
// 用blob对象获取文件流
}
else
{
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile1'
));
// 兼容ie语法
}
if
(
'msSaveOrOpenBlob'
in
navigator
){
}).
catch
((
error
:
any
)
=>
{
window
.
navigator
.
msSaveOrOpenBlob
(
blob
,
actualFileName
);
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
':'
+
error
);
return
;
});
}
}
// 通过文件流创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
/**
// 创建一个a元素并设置相关属性
* 是否只支持图片上传
let
a
=
document
.
createElement
(
'a'
);
*
a
.
href
=
href
;
* @type {boolean}
a
.
download
=
actualFileName
;
* @memberof AppFileUpload
// 添加a元素到当前网页
*/
document
.
body
.
appendChild
(
a
);
@
Prop
({
default
:
false
})
public
imageOnly
!
:
boolean
;
// 触发a元素的点击事件,实现下载
a
.
click
();
/**
// 从当前网页移除a元素
* 是否开启行内预览
document
.
body
.
removeChild
(
a
);
*
// 释放blob对象
* @type {boolean}
URL
.
revokeObjectURL
(
href
);
* @memberof AppFileUpload
}
else
{
*/
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile1'
));
@
Prop
({
default
:
false
})
public
rowPreview
!
:
boolean
;
}
}).
catch
((
error
:
any
)
=>
{
/**
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
':'
+
error
);
* 是否开启行内预览
});
*
}
* @type {boolean}
* @memberof AppFileUpload
/**
*/
* 是否只支持图片上传
public
dialogVisible
:
boolean
=
false
;
*
/**
* @type {boolean}
* 是否开启行内预览
* @memberof AppFileUpload
*
*/
* @type {boolean}
@
Prop
({
default
:
false
})
public
imageOnly
!
:
boolean
;
* @memberof AppFileUpload
*/
/**
public
showActions
:
boolean
=
false
;
* 是否开启行内预览
*
* @type {boolean}
}
* @memberof AppFileUpload
</
script
>
*/
@
Prop
({
default
:
false
})
public
rowPreview
!
:
boolean
;
<
style
lang=
'less'
>
@import './app-file-upload.less';
/**
</
style
>
* 是否开启行内预览
\ No newline at end of file
*
* @type {boolean}
* @memberof AppFileUpload
*/
public
dialogVisible
:
boolean
=
false
;
/**
* 是否开启行内预览
*
* @type {boolean}
* @memberof AppFileUpload
*/
public
showActions
:
boolean
=
false
;
}
</
script
>
<
style
lang=
'less'
>
@import './app-file-upload.less';
</
style
>
\ No newline at end of file
src/components/app-upload-file-info/app-upload-file-info.vue
浏览文件 @
9f7879f2
...
@@ -9,6 +9,7 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
...
@@ -9,6 +9,7 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import
{
Environment
}
from
'@/environments/environment'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
CreateElement
}
from
'vue'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
EntityService
from
'@/service/entity-service'
;
@
Component
({
@
Component
({
})
})
...
@@ -42,6 +43,30 @@ export default class AppUploadFileInfo extends Vue {
...
@@ -42,6 +43,30 @@ export default class AppUploadFileInfo extends Vue {
*/
*/
@
Prop
()
public
name
!
:
string
;
@
Prop
()
public
name
!
:
string
;
/**
* 应用上下文
*
* @type {*}
* @memberof AppUploadFileInfo
*/
@
Prop
()
public
context
!
:
any
;
/**
* 实体服务
*
* @type {EntityService}
* @memberof AppUploadFileInfo
*/
@
Prop
()
public
appEntityService
!
:
EntityService
;
/**
* 默认为当前实体主键id,有指定则按表单参数
*
* @type {string}
* @memberof AppUploadFileInfo
*/
@
Prop
()
public
ownerid
!
:
string
;
/**
/**
* 上传文件路径
* 上传文件路径
*
*
...
@@ -74,8 +99,11 @@ export default class AppUploadFileInfo extends Vue {
...
@@ -74,8 +99,11 @@ export default class AppUploadFileInfo extends Vue {
let
files
=
JSON
.
parse
(
this
.
value
);
let
files
=
JSON
.
parse
(
this
.
value
);
if
(
files
.
length
){
if
(
files
.
length
){
files
.
forEach
((
file
:
any
)
=>
{
files
.
forEach
((
file
:
any
)
=>
{
let
url
=
`
${
this
.
downloadUrl
}
/
${
file
.
id
}
`
;
// let url = `${this.downloadUrl}/${file.id}`;
file
.
url
=
url
;
const
entityName
=
this
.
appEntityService
.
APPDENAME
;
const
base64
=
`
${
file
.
id
}
|
${
entityName
}
|
${
this
.
ownerid
}
|
${
this
.
context
.
srfpersonid
||
this
.
context
.
srfuserid
}
`
;
const
downloadUrl
=
`http://downloadpath?key=
${
window
.
btoa
(
base64
)}
`
file
.
url
=
downloadUrl
;
});
});
}
else
{
}
else
{
files
=
[]
files
=
[]
...
...
src/components/disk-file-upload/disk-file-upload.vue
浏览文件 @
9f7879f2
...
@@ -71,6 +71,7 @@ import Axios from 'axios';
...
@@ -71,6 +71,7 @@ import Axios from 'axios';
import
{
Unsubscribable
}
from
'rxjs'
;
import
{
Unsubscribable
}
from
'rxjs'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
encode
}
from
"js-base64"
;
import
{
encode
}
from
"js-base64"
;
import
EntityService
from
'@/service/entity-service'
;
@
Component
({})
@
Component
({})
export
default
class
DiskFileUpload
extends
Vue
{
export
default
class
DiskFileUpload
extends
Vue
{
...
@@ -195,6 +196,22 @@ export default class DiskFileUpload extends Vue {
...
@@ -195,6 +196,22 @@ export default class DiskFileUpload extends Vue {
*/
*/
@
Prop
({
default
:
false
})
public
showOcrview
?:
boolean
;
@
Prop
({
default
:
false
})
public
showOcrview
?:
boolean
;
/**
* 实体服务
*
* @type {EntityService}
* @memberof DiskFileUpload
*/
@
Prop
()
public
appEntityService
!
:
EntityService
;
/**
* 应用上下文
*
* @type {*}
* @memberof DiskFileUpload
*/
@
Prop
()
public
context
!
:
any
;
/**
/**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
*
*
...
@@ -519,7 +536,10 @@ export default class DiskFileUpload extends Vue {
...
@@ -519,7 +536,10 @@ export default class DiskFileUpload extends Vue {
let
_this
:
any
=
this
;
let
_this
:
any
=
this
;
const
id
=
typeof
item
.
id
==
"string"
?
item
.
id
:
JSON
.
stringify
(
item
.
id
);
const
id
=
typeof
item
.
id
==
"string"
?
item
.
id
:
JSON
.
stringify
(
item
.
id
);
const
name
=
typeof
item
.
name
==
"string"
?
item
.
name
:
JSON
.
stringify
(
item
.
filename
);
const
name
=
typeof
item
.
name
==
"string"
?
item
.
name
:
JSON
.
stringify
(
item
.
filename
);
const
downloadUrl
=
'/ibizutilrpm/download/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
encodeURIComponent
(
name
);
// const downloadUrl = '/ibizutilrpm/download/' + this.getFolder() + '/' + id + '/' + encodeURIComponent(name);
const
entityName
=
this
.
appEntityService
.
APPDENAME
;
const
base64
=
`
${
id
}
|
${
entityName
}
|
${
this
.
getOwnerid
()}
|
${
this
.
context
.
srfpersonid
||
this
.
context
.
srfuserid
}
`
;
const
downloadUrl
=
`http://downloadpath?key=
${
window
.
btoa
(
base64
)}
`
// 发送get请求
// 发送get请求
Axios
.
get
(
downloadUrl
,
{
Axios
.
get
(
downloadUrl
,
{
headers
:
{
headers
:
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录