Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
d8e29d2d
提交
d8e29d2d
编写于
6月 20, 2023
作者:
fzh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update: 修改限制文件上传类型
上级
9fbb2bc9
变更
3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
1299 行增加
和
1174 行删除
+1299
-1174
app-file-upload.vue
src/components/app-file-upload/app-file-upload.vue
+552
-528
disk-file-upload.vue
src/components/disk-file-upload/disk-file-upload.vue
+691
-646
environment.ts
src/environment/environment.ts
+56
-0
未找到文件。
src/components/app-file-upload/app-file-upload.vue
浏览文件 @
d8e29d2d
...
...
@@ -8,11 +8,8 @@
<el-upload
:disabled=
"disabled"
:file-list=
"files"
:action=
"uploadUrl"
:limit=
"multiple ? limit: 1"
:accept=
"accept"
:multiple=
"multiple"
:headers=
"
{}"
:action=
"getAction()"
:headers=
"myHeaders"
:before-upload=
"beforeUpload"
:before-remove=
"onRemove"
:on-success=
"onSuccess"
...
...
@@ -20,9 +17,8 @@
:on-preview=
"onDownload"
:drag=
"isdrag"
:show-file-list=
"!rowPreview"
:on-exceed = "handleExceed"
>
<el-button
v-if=
"!isdrag"
size=
'small'
icon=
'el-icon-upload'
:disabled=
"disabled || !(multiple || files.length === 0)
"
>
{{
this
.
$t
(
'app.fileUpload.caption'
)
}}
</el-button>
<el-button
v-if=
"!isdrag"
size=
'small'
icon=
'el-icon-upload'
:disabled=
"disabled
"
>
{{
this
.
$t
(
'app.fileUpload.caption'
)
}}
</el-button>
<i
v-if=
"isdrag"
class=
"el-icon-upload"
></i>
<div
v-if=
"isdrag"
class=
"el-upload__text"
v-html=
"$t('components.appFileUpload.uploadText')"
></div>
</el-upload>
...
...
@@ -51,17 +47,19 @@
</ul>
</modal>
</div>
</
template
>
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
'vue-property-decorator'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
'vue-property-decorator'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
CreateElement
}
from
'vue'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
Axios
from
'axios'
;
import
{
Message
}
from
'element-ui'
;
@
Component
({
})
export
default
class
AppFileUpload
extends
Vue
{
@
Component
({
})
export
default
class
AppFileUpload
extends
Vue
{
/**
* 表单状态
...
...
@@ -177,44 +175,6 @@ export default class AppFileUpload extends Vue {
*/
@
Prop
()
public
exportparams
?:
any
;
/**
* 是否支持多个文件上传
*
* @type {string}
* @memberof AppFileUpload
*/
@
Prop
({
default
:
true
})
public
multiple
!
:
boolean
;
/**
* 最大允许上传个数
*
* @type {*}
* @memberof AppImageUpload
*/
@
Prop
({
default
:
9999
})
public
limit
!
:
number
;
/**
* 接受上传的文件类型
*
* @type {*}
* @memberof AppImageUpload
*/
@
Prop
({
default
:
'*'
})
public
accept
!
:
string
;
/**
* 上传文件路径
*
* @memberof AppFileUpload
*/
public
uploadUrl
=
Environment
.
BaseUrl
+
Environment
.
UploadFile
;
/**
* 下载文件路径
*
* @memberof AppFileUpload
*/
public
downloadUrl
=
Environment
.
BaseUrl
+
Environment
.
ExportFile
;
/**
* 文件列表
*
...
...
@@ -262,6 +222,30 @@ export default class AppFileUpload extends Vue {
*/
limitType
:
Array
<
String
>
=
[
'application/x-msdownload'
,
'text/x-sh'
,
'text/html'
,
'text/javascript'
]
/**
* 当前登陆人的token
*
* @type {string}
* @memberof DiskFileUpload
*/
public
token
:
string
=
"Bearer "
+
localStorage
.
getItem
(
'token'
);
/**
* 上传文件请求头
*
* @type {*}
* @memberof DiskFileUpload
*/
public
myHeaders
:
any
=
{
Authorization
:
this
.
token
};
/**
* 拼接上传路径
*
* @memberof DiskFileUpload
*/
public
getAction
()
{
return
`
${(
window
as
any
).
Environment
.
UploadFile
}
`
+
'?ownertype='
+
this
.
name
+
'&ownerid='
+
JSON
.
parse
(
this
.
data
).
srfkey
;
}
/**
* 设置files
*
...
...
@@ -269,6 +253,10 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
private
setFiles
(
value
:
any
):
void
{
if
(
value
==
null
){
this
.
files
=
[];
return
;
}
let
_files
=
JSON
.
parse
(
value
);
if
(
value
&&
Object
.
prototype
.
toString
.
call
(
_files
)
==
'[object Array]'
)
{
this
.
files
=
_files
;
...
...
@@ -284,8 +272,7 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
private
dataProcess
():
void
{
let
_url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
UploadFile
}
`
;
let
_url
=
`
${(
window
as
any
).
Environment
.
UploadFile
}
`
;
if
(
this
.
upload_params
.
length
>
0
)
{
_url
+=
'?'
;
this
.
upload_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
...
...
@@ -295,11 +282,8 @@ export default class AppFileUpload extends Vue {
}
})
}
this
.
uploadUrl
=
_url
;
this
.
files
.
forEach
((
file
:
any
)
=>
{
let
url
=
`
${
this
.
downloadUrl
}
/
${
file
.
id
}
`
;
let
url
=
`
${(
window
as
any
).
Environment
.
ExportFile
}
/
${
file
.
id
}
`
;
if
(
this
.
export_params
.
length
>
0
)
{
url
+=
'?'
;
this
.
export_params
.
forEach
((
item
:
any
,
i
:
any
)
=>
{
...
...
@@ -402,9 +386,11 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
public
beforeUpload
(
file
:
any
)
{
if
(
this
.
limitType
.
includes
(
file
.
type
)){
Message
.
error
(
'不可上传 html、js、 exe、sh类型的文件!'
)
return
false
const
blackList
=
Environment
.
blackList
;
const
fileName
=
file
.
name
?.
trim
().
toLowerCase
();
if
(
typeof
fileName
===
'string'
&&
blackList
.
some
(
item
=>
fileName
.
endsWith
(
`.
${
item
}
`
)))
{
Message
.
error
(
`不可上传
${
blackList
.
join
(
'、'
)}
类型的文件!`
);
return
false
;
}
if
(
this
.
imageOnly
){
const
imageTypes
=
[
"image/jpeg"
,
"image/gif"
,
"image/png"
,
"image/bmp"
];
...
...
@@ -448,7 +434,8 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
public
onError
(
error
:
any
,
file
:
any
,
fileList
:
any
)
{
this
.
$Notice
.
error
({
title
:
(
this
.
$t
(
'components.appFileUpload.uploadError'
)
as
any
)
});
const
data
=
JSON
.
parse
(
error
.
message
)
this
.
$Notice
.
error
({
title
:
data
.
message
||
(
this
.
$t
(
'components.appFileUpload.uploadError'
)
as
any
)});
}
/**
...
...
@@ -479,7 +466,52 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
public
onDownload
(
file
:
any
)
{
window
.
open
(
file
.
url
);
// 拼接url
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
);
const
downloadUrl
=
`
${(
window
as
any
).
Environment
.
ExportFile
}
`
+
'/'
+
id
+
'/'
+
name
;
// 发送get请求
Axios
.
get
(
downloadUrl
,
{
responseType
:
'arraybuffer'
,
}).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
'!'
);
return
;
}
// 请求成功,后台返回的是一个文件流
if
(
response
.
data
)
{
// 获取文件名
const
disposition
=
response
.
headers
[
'content-disposition'
];
const
filename
=
disposition
.
split
(
'filename='
)[
1
];
const
actualFileName
=
file
.
name
||
filename
;
// 用blob对象获取文件流
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
// 兼容ie语法
if
(
'msSaveOrOpenBlob'
in
navigator
){
window
.
navigator
.
msSaveOrOpenBlob
(
blob
,
actualFileName
);
return
;
}
// 通过文件流创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
// 创建一个a元素并设置相关属性
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
href
;
a
.
download
=
actualFileName
;
// 添加a元素到当前网页
document
.
body
.
appendChild
(
a
);
// 触发a元素的点击事件,实现下载
a
.
click
();
// 从当前网页移除a元素
document
.
body
.
removeChild
(
a
);
// 释放blob对象
URL
.
revokeObjectURL
(
href
);
}
else
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile1'
));
}
}).
catch
((
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
':'
+
error
);
});
}
/**
...
...
@@ -513,18 +545,10 @@ export default class AppFileUpload extends Vue {
*/
public
showActions
:
boolean
=
false
;
/**
* 处理多选超出
*
* @memberof AppFileUpload
*/
public
handleExceed
(
files
:
any
,
fileList
:
any
)
{
this
.
$message
.
warning
(
`
${
this
.
$t
(
'components.appFileUpload.limitselect'
)}
${
this
.
limit
}
`
);
}
}
</
script
>
}
</
script
>
<
style
lang=
'less'
>
@import './app-file-upload.less';
</
style
>
\ No newline at end of file
<
style
lang=
'less'
>
@import './app-file-upload.less';
</
style
>
\ No newline at end of file
src/components/disk-file-upload/disk-file-upload.vue
浏览文件 @
d8e29d2d
...
...
@@ -2,85 +2,60 @@
<div
id=
"file-upload"
>
<el-row
id=
"el-row"
>
<!--拖拽上传-->
<el-col
v-if=
"showDrag==true"
class=
"withDrag"
>
<el-upload
ref=
"upload"
drag
multiple
list-type=
"text"
:disabled=
"disabled"
:action=
"getAction()"
:headers=
"myHeaders"
:before-upload=
"beforeUpload"
:file-list=
"uploadFileList"
:show-file-list=
"false"
:http-request=
"customUploadFile"
>
<el-col
v-if=
"showDrag == true"
class=
"withDrag"
>
<el-upload
v-if=
"!disabled"
ref=
"upload"
drag
multiple
list-type=
"text"
:before-upload=
"beforeUploadLimit"
:disabled=
"disabled"
:action=
"getAction()"
:headers=
"myHeaders"
:file-list=
"uploadFileList"
:show-file-list=
"false"
:on-error=
"onError"
:on-success=
"onSuccess"
>
<div>
<i
class=
"el-icon-upload"
></i>
<div>
<span>
{{
$t
(
'components.diskFileUpload.fileDrag'
)
}}
</span>
<span
style=
"color:#409EFF;"
>
{{
$t
(
'components.diskFileUpload.clickUpload'
)
}}
</span>
<span>
{{
$t
(
'components.diskFileUpload.fileDrag'
)
}}
</span>
<span
style=
"color:#409EFF;"
>
{{
$t
(
'components.diskFileUpload.clickUpload'
)
}}
</span>
</div>
</div>
</el-upload>
</el-col>
<!--点击上传-->
<el-col
v-else
class=
"withoutDrag"
>
<el-upload
ref=
"upload"
multiple
list-type=
"text"
:disabled=
"disabled"
:action=
"getAction()"
:headers=
"myHeaders"
:before-upload=
"beforeUpload"
:file-list=
"uploadFileList"
:show-file-list=
"false"
:http-request=
"customUploadFile"
>
<el-button
type=
"primary"
size=
"small"
icon=
"el-icon-upload"
:disabled=
"disabled"
>
{{
$t
(
'components.diskFileUpload.clickUpload'
)
}}
<el-upload
v-if=
"!disabled"
ref=
"upload"
multiple
list-type=
"text"
:before-upload=
"beforeUploadLimit"
:disabled=
"disabled"
:action=
"getAction()"
:headers=
"myHeaders"
:file-list=
"uploadFileList"
:show-file-list=
"false"
:on-error=
"onError"
:on-success=
"onSuccess"
>
<el-button
type=
"primary"
size=
"small"
icon=
"el-icon-upload"
>
{{
$t
(
'components.diskFileUpload.clickUpload'
)
}}
</el-button>
</el-upload>
</el-col>
<!--文件操作-->
<el-col
v-for=
"(item,index) in uploadFileList"
:key=
"index"
class=
"fileList"
>
<el-col
v-for=
"(item,
index) in uploadFileList"
:key=
"index"
class=
"fileList"
>
<div
class=
"fileTitle"
>
<i
class=
"el-icon-document"
></i>
<span>
{{
item
.
name
}}
</span>
<span>
{{
item
.
name
}}
</span>
</div>
<div
class=
"fileMain"
>
<el-link
type=
"success"
icon=
"el-icon-download"
@
click=
"onDownload(item)"
>
{{
$t
(
'components.diskFileUpload.load'
)
}}
<el-link
type=
"success"
v-show=
"showDownload"
icon=
"el-icon-download"
@
click=
"onDownload(item)"
>
{{
$t
(
'components.diskFileUpload.load'
)
}}
</el-link>
<el-link
type=
"warning"
icon=
"el-icon-view"
v-show=
"showPreview"
@
click=
"onPreview(item)"
>
{{
$t
(
'components.diskFileUpload.preview'
)
}}
{{
$t
(
'components.diskFileUpload.preview'
)
}}
</el-link>
<el-link
type=
"primary"
icon=
"el-icon-edit"
v-show=
"showEdit && (item.name.match(/^.+\.(doc|DOC|docx|DOCX|wps|WPS|xls|XLS|xlsx|XLSX|ppt|PPT|et|ET)$/))"
@
click=
"onEdit(item)"
>
{{
$t
(
'components.diskFileUpload.edit'
)
}}
@
click=
"onEdit(item)"
>
{{
$t
(
'components.diskFileUpload.edit'
)
}}
</el-link>
<el-link
icon=
"el-icon-camera"
v-show=
"showOcrview && (item.name.match(/^.+\.(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|bmp|BMP|pdf|PDF)$/))"
@
click=
"onOcr(item)"
>
OCR
</el-link>
<el-link
type=
"danger"
icon=
"el-icon-delete"
@
click=
"onRemove(item,
index)"
>
{{
$t
(
'components.diskFileUpload.delete'
)
}}
<el-link
type=
"danger"
v-show=
"showDelete"
icon=
"el-icon-delete"
@
click=
"onRemove(item,
index)"
>
{{
$t
(
'components.diskFileUpload.delete'
)
}}
</el-link>
</div>
</el-col>
</el-row>
<!-- 自定义弹框 -->
<div
class=
"dialogDiv"
>
<el-dialog
:title=
"dialogTitle"
center
width=
"70%"
top=
"5vh"
:visible=
"showDialog"
:close-on-click-modal=
"true"
:show-close=
"true"
:before-close=
"dialogClose"
:modal-append-to-body=
"false"
>
<el-dialog
:title=
"dialogTitle"
center
width=
"70%"
top=
"5vh"
:visible=
"showDialog"
:close-on-click-modal=
"true"
:show-close=
"true"
:before-close=
"dialogClose"
:modal-append-to-body=
"false"
>
<div
style=
"height: 100%;"
>
<iframe
id=
"fileIframe"
:src=
"iframeUrl"
frameborder=
"0"
width=
"100%"
></iframe>
</div>
...
...
@@ -90,13 +65,15 @@
</
template
>
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
'vue-property-decorator'
;
import
{
Button
,
Row
,
Col
,
Link
,
Icon
,
Upload
,
Message
,
MessageBox
}
from
'element-ui'
;
import
Axios
from
'axios'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
{
Component
,
Vue
,
Prop
}
from
'vue-property-decorator'
;
import
{
Message
,
MessageBox
}
from
'element-ui'
;
import
Axios
from
'axios'
;
import
{
Unsubscribable
}
from
'rxjs'
;
import
{
Environment
}
from
'@/environments/environment'
;
import
{
encode
}
from
"js-base64"
;
@
Component
({})
export
default
class
DiskFileUpload
extends
Vue
{
@
Component
({})
export
default
class
DiskFileUpload
extends
Vue
{
/**
* 当前表单对象
...
...
@@ -160,7 +137,7 @@
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
persistence
?:
boolean
;
@
Prop
({
default
:
false
})
public
persistence
?:
boolean
;
/**
* 是否启用
...
...
@@ -168,7 +145,7 @@
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
disabled
?:
boolean
;
@
Prop
({
default
:
false
})
public
disabled
?:
boolean
;
/**
* 是否显示拖拽区域
...
...
@@ -176,15 +153,31 @@
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showDrag
?:
boolean
;
@
Prop
({
default
:
false
})
public
showDrag
?:
boolean
;
/**
* 是否显示预览
按钮
* 是否显示删除
按钮
*
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showPreview
?:
boolean
;
@
Prop
({
default
:
false
})
public
showDownload
?:
boolean
;
/**
* 是否显示删除按钮
*
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showDelete
?:
boolean
;
/**
* 是否显示按钮
*
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showPreview
?:
boolean
;
/**
* 是否显示在线编辑按钮
...
...
@@ -192,7 +185,7 @@
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showEdit
?:
boolean
;
@
Prop
({
default
:
false
})
public
showEdit
?:
boolean
;
/**
* 是否显示OCR按钮
...
...
@@ -200,7 +193,7 @@
* @type {boolean}
* @memberof DiskFileUpload
*/
@
Prop
({
default
:
false
})
public
showOcrview
?:
boolean
;
@
Prop
({
default
:
false
})
public
showOcrview
?:
boolean
;
/**
* 表单是否处于编辑状态(有真实主键,srfuf='1';srfuf='0'时处于新建未保存)
...
...
@@ -233,7 +226,7 @@
* @type {*}
* @memberof DiskFileUpload
*/
public
myHeaders
:
any
=
{
Authorization
:
this
.
token
};
public
myHeaders
:
any
=
{
Authorization
:
this
.
token
};
/**
* 表单状态事件
...
...
@@ -283,14 +276,6 @@
*/
public
iframeUrl
:
any
=
''
;
/**
* 文件上传限制类型
*
* @type {*}
* @memberof DiskFileUpload
*/
limitType
:
Array
<
String
>
=
[
'application/x-msdownload'
,
'text/x-sh'
,
'text/html'
,
'text/javascript'
]
/**
* 关闭自定义弹框
*
...
...
@@ -304,6 +289,14 @@
iframe
.
parentNode
.
removeChild
(
"fileIframe"
);
}
/**
* 文件上传限制类型
*
* @type {*}
* @memberof DiskFileUpload
*/
limitType
:
Array
<
String
>
=
[
'application/x-msdownload'
,
'text/x-sh'
,
'text/html'
,
'text/javascript'
]
/**
* 拼接上传路径
*
...
...
@@ -411,6 +404,71 @@
});
}
/**
* 上传成功回调
*
* @param {*} response
* @param {*} file
* @param {*} fileList
* @memberof AppFileUpload
*/
public
onSuccess
(
response
:
any
,
file
:
any
,
fileList
:
any
)
{
if
(
!
response
)
{
return
;
}
// 返回的是一个jsonobject
// 新建表单上传,后续需要批量更新操作
if
(
this
.
isCreate
==
true
)
{
this
.
isUpdateBatch
=
true
;
}
// 保存到文件列表进行显示
this
.
uploadFileList
.
push
(
response
);
// persistence=true时需要持久化表单属性
if
(
this
.
persistence
==
true
&&
this
.
uploadFileList
.
length
>
0
)
{
const
value
=
JSON
.
stringify
(
this
.
uploadFileList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}
/**
* 上传失败回调
*
* @param {*} error
* @param {*} file
* @param {*} fileList
* @memberof AppFileUpload
*/
public
onError
(
error
:
any
,
file
:
any
,
fileList
:
any
)
{
const
data
=
JSON
.
parse
(
error
.
message
)
this
.
$Notice
.
error
({
title
:
data
.
message
||
(
this
.
$t
(
'components.appFileUpload.uploadError'
)
as
any
)
});
}
str2utf8
(
str
:
string
)
{
const
encoder
=
new
TextEncoder
();
const
bytes
=
encoder
.
encode
(
str
)
let
result
=
''
;
for
(
let
i
=
0
;
i
<
bytes
.
length
;
i
++
)
{
result
+=
String
.
fromCharCode
(
bytes
[
i
])
}
return
result
}
/**
* 上传之前
*
* @param {*} file
* @memberof AppFileUpload
*/
beforeUploadLimit
(
file
:
any
)
{
const
blackList
=
Environment
.
blackList
;
const
fileName
=
file
.
name
?.
trim
().
toLowerCase
();
if
(
typeof
fileName
===
'string'
&&
blackList
.
some
(
item
=>
fileName
.
endsWith
(
`.
${
item
}
`
)))
{
Message
.
error
(
`不可上传
${
blackList
.
join
(
'、'
)}
类型的文件!`
);
return
false
;
}
return
true
;
}
/**
* 自定义上传文件
*
...
...
@@ -427,7 +485,7 @@
// 拼接url
const
uploadUrl
=
this
.
getAction
();
// 发送post请求
Axios
.
post
(
uploadUrl
,
formData
).
then
((
response
:
any
)
=>
{
Axios
.
post
(
uploadUrl
,
formData
,
{
timeout
:
6000
}
).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.loadFailure'
)
+
'!'
);
}
...
...
@@ -442,7 +500,7 @@
// persistence=true时需要持久化表单属性
if
(
this
.
persistence
==
true
&&
this
.
uploadFileList
.
length
>
0
)
{
const
value
=
JSON
.
stringify
(
this
.
uploadFileList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}
}).
catch
((
error
:
any
)
=>
{
...
...
@@ -450,20 +508,6 @@
})
}
/**
* 上传之前
*
* @param file
* @memberof DiskFileUpload
*/
public
beforeUpload
(
file
:
any
){
if
(
this
.
limitType
.
includes
(
file
.
type
)){
Message
.
error
(
'不可上传 html、js、 exe、sh类型的文件!'
)
return
false
}
return
true
}
/**
* 下载文件
*
...
...
@@ -475,7 +519,7 @@
let
_this
:
any
=
this
;
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
downloadUrl
=
'/net-disk
/download/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
;
const
downloadUrl
=
'/ibizutilrpm
/download/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
;
// 发送get请求
Axios
.
get
(
downloadUrl
,
{
headers
:
{
...
...
@@ -492,18 +536,24 @@
// 获取文件名
const
disposition
=
response
.
headers
[
'content-disposition'
];
const
filename
=
disposition
.
split
(
'filename='
)[
1
];
const
filenameArr
=
filename
.
split
(
'.'
)
const
itemname
=
item
.
name
.
split
(
'.'
)
const
docType
=
'.'
+
filenameArr
[
filenameArr
.
length
-
1
]
itemname
.
splice
(
itemname
.
length
-
1
,
1
,
docType
)
const
actualFileName
=
itemname
.
join
(
''
);
// 用blob对象获取文件流
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]
});
// 兼容ie语法
if
(
'msSaveOrOpenBlob'
in
navigator
)
{
window
.
navigator
.
msSaveOrOpenBlob
(
blob
,
actualFileName
);
return
;
}
// 通过文件流创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
// 创建一个a元素并设置相关属性
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
href
;
if
(
name
)
{
a
.
download
=
name
;
}
else
{
a
.
download
=
filename
;
}
a
.
download
=
actualFileName
;
// 添加a元素到当前网页
document
.
body
.
appendChild
(
a
);
// 触发a元素的点击事件,实现下载
...
...
@@ -530,20 +580,15 @@
// 拼接url
const
id
=
typeof
item
.
id
==
"string"
?
item
.
id
:
JSON
.
stringify
(
item
.
id
);
const
name
=
typeof
item
.
name
==
"string"
?
item
.
name
:
JSON
.
stringify
(
item
.
name
);
let
previewUrl
=
'/net-disk/preview/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
+
'?authcode='
+
item
.
authcode
;
Axios
.
get
(
previewUrl
).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
return
;
}
// 返回一个url,通过自定义弹框打开
if
(
response
.
data
)
{
const
downloadUrl
=
(
window
as
any
).
Environment
.
ExportFile
+
'/'
+
id
+
'/'
+
name
;
const
previewFileUrl
=
Environment
.
previewFileUrl
;
if
(
previewFileUrl
)
{
const
url
=
encodeURIComponent
(
encode
(
`
${
window
.
location
.
origin
}${
downloadUrl
}
?fullfilename=
${
name
}
`
));
this
.
dialogTitle
=
name
;
this
.
showDialog
=
true
;
this
.
iframeUrl
=
response
.
data
;
this
.
iframeUrl
=
`
${
previewFileUrl
}
/onlinePreview?url=
${
url
}
`
;
}
}).
catch
((
error
:
any
)
=>
{
Message
.
error
(
error
);
});
}
/**
...
...
@@ -613,8 +658,8 @@
this
.
uploadFileList
.
splice
(
index
,
1
);
// persistence=true时需要持久化表单属性
if
(
this
.
persistence
==
true
)
{
const
value
=
JSON
.
stringify
(
this
.
uploadFileList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
const
value
=
this
.
uploadFileList
.
length
==
0
?
null
:
JSON
.
stringify
(
this
.
uploadFileList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}).
catch
((
error
:
any
)
=>
{
// 提示删除失败
...
...
@@ -653,60 +698,61 @@
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.updateFailure'
)
+
':'
+
error
);
});
}
}
}
</
script
>
<
style
lang=
"less"
>
#file-upload {
#file-upload {
width: auto;
height: auto;
border: 0px solid black;
}
}
#el-row {
#el-row {
border: 0px solid red;
width: 400px;
}
}
.withDrag {
.withDrag {
border: 0px solid grey;
width: 400px;
}
}
.withoutDrag {
.withoutDrag {
border: 0px solid grey;
width: 400px;
text-align: left;
padding-left: 0px;
padding-top: 0px;
margin-top: 0px;
}
}
.fileList {
.fileList {
width: 400px;
border: 0px solid grey;
margin-top: 0px;
}
}
.fileTitle {
.fileTitle {
text-align: left;
margin-left: 0px;
}
}
.fileTitle i {
.fileTitle i {
margin-right: 5px;
}
}
.fileMain {
.fileMain {
text-align: left;
margin-left: 0px;
margin-top: -10px;
}
}
.fileMain .el-link:nth-child(n+2) {
.fileMain .el-link:nth-child(n+2) {
margin-left: 10px;
}
}
.dialogDiv {
.dialogDiv {
// el-dialog头部
.el-dialog__header {
height: 40px;
...
...
@@ -731,6 +777,5 @@
#fileIframe {
height: calc(100% - 40px);
}
}
}
</
style
>
\ No newline at end of file
src/environment/environment.ts
0 → 100644
浏览文件 @
d8e29d2d
export
const
Environment
=
{
// 原型示例数模式
SampleMode
:
false
,
// 应用名称
AppName
:
'rpm'
,
// 应用 title
AppTitle
:
'制度流程管理系统'
,
// 应用基础路径
BaseUrl
:
''
,
// 系统名称
SysName
:
'rpm'
,
// 远程登录地址,本地开发调试使用
RemoteLogin
:
'/ibizutil/login'
,
// 文件导出
ExportFile
:
'/ibizutil/download'
,
// 文件上传
UploadFile
:
'/ibizutil/upload'
,
// 数据导入单次上传最大数量
sliceUploadCnt
:
100
,
// 是否为pc端应用
isAppMode
:
true
,
//统一地址
uniteAddress
:
"http://172.16.100.202:8114"
,
// 是否为开发模式
devMode
:
true
,
// 是否开启权限认证
enablePermissionValid
:
false
,
// 菜单权限模式,可选值:RT(RT模式),RESOURCE(资源模式),MINIX(混合模式),默认MINIX
menuPermissionMode
:
"MINIX"
,
// 项目模板地址
ProjectUrl
:
"http://demo.ibizlab.cn/ibizr7pfstdtempl/ibizvuer7"
,
// 打开目标工具,可选参数:sln、mos
debugOpenMode
:
'mos'
,
// 配置平台地址
StudioUrl
:
"http://172.16.170.145/mos/"
,
// 中心标识
SlnId
:
"B4BF5C84-D020-4D9A-A986-8FA4FD72816C"
,
// 系统标识
SysId
:
"B428B5BE-EA90-4101-A493-BA7085D89F0A"
,
// 前端应用标识
AppId
:
"6e0b7357169ef4eba84e1347ed94bd84"
,
// 项目发布文件地址
PublishProjectUrl
:
'http://ibiz.ibizee.cn/t7d01aab0f300e1f75fad0314e98cecab/RPM.git'
,
// ibiz开放平台地址
ibizlabtUrl
:
'https://www.ibizlab.cn'
,
// ibiz论坛地址
ibizbbstUrl
:
'https://bbs.ibizlab.cn'
,
// 是否启用工作流
workflow
:
false
,
previewFileUrl
:
'http://172.16.103.143:8013'
,
blackList
:
[
'html'
,
'js'
,
'exe'
,
'sh'
,
'bat'
,
'css'
,
'htm'
,
'aspx'
,
'jsp'
,
'asp'
,
'php'
]
};
// 挂载外部配置文件
if
((
window
as
any
).
Environment
)
{
Object
.
assign
(
Environment
,
(
window
as
any
).
Environment
);
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录