Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-R7-Res
提交
3e1a5719
提交
3e1a5719
编写于
9月 24, 2020
作者:
llz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改disk表单文件上传控件预览ocr接口处理
上级
30bf7934
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
140 行增加
和
61 行删除
+140
-61
disk-file-upload.vue
src/components/disk-file-upload/disk-file-upload.vue
+77
-32
disk-image-upload.vue
src/components/disk-image-upload/disk-image-upload.vue
+63
-29
未找到文件。
src/components/disk-file-upload/disk-file-upload.vue
浏览文件 @
3e1a5719
...
...
@@ -68,6 +68,8 @@
<!-- 自定义弹框 -->
<div
class=
"dialogDiv"
>
<el-dialog
:title=
"dialogTitle"
center
width=
"70%"
top=
"5vh"
:visible=
"showDialog"
...
...
@@ -245,23 +247,40 @@
*/
public
isCreate
:
boolean
=
true
;
/**
* 自定义弹框标题
*
* @type {*}
* @memberof DiskFileUpload
*/
public
dialogTitle
:
any
=
''
;
/**
* 是否显示自定义弹框
*
* @type {boolean}
* @memberof DiskFileUpload
*/
public
showDialog
=
false
;
public
showDialog
:
boolean
=
false
;
/**
* 嵌入自定义弹框中iframe的url
*
* @type {*}
* @memberof DiskFileUpload
*/
public
iframeUrl
:
any
=
''
;
/**
* 关闭自定义弹框
*
* @memberof DiskFileUpload
*/
public
dialogClose
()
{
this
.
dialogTitle
=
''
;
this
.
showDialog
=
false
;
this
.
iframeUrl
=
''
;
let
iframe
:
any
=
document
.
getElementById
(
"fileIframe"
);
let
iframe
:
any
=
document
.
getElementById
(
"fileIframe"
);
iframe
.
parentNode
.
removeChild
(
"fileIframe"
);
}
...
...
@@ -302,7 +321,7 @@
}
/**
*
*
vue创建
*
* @memberof DiskFileUpload
*/
...
...
@@ -334,7 +353,7 @@
if
(
Object
.
is
(
$event
.
type
,
'save'
))
{
// 批量更新文件表中的ownerid
if
(
this
.
isUpdateBatch
==
true
&&
this
.
uploadFileList
.
length
>
0
)
{
this
.
updateFileBatch
(
this
.
uploadFileList
,
'update'
);
this
.
updateFileBatch
(
this
.
uploadFileList
);
}
}
});
...
...
@@ -355,7 +374,7 @@
ownertype
:
this
.
getOwnertype
(),
ownerid
:
this
.
getOwnerid
(),
},
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.getFileFailure'
)
+
'!'
);
return
;
...
...
@@ -367,7 +386,7 @@
this
.
uploadFileList
.
push
.
apply
(
this
.
uploadFileList
,
files
);
}
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.getFileFailure'
)
+
':'
+
error
);
});
}
...
...
@@ -388,7 +407,7 @@
// 拼接url
const
uploadUrl
=
this
.
getAction
();
// 发送post请求
Axios
.
post
(
uploadUrl
,
formData
,
{
timeout
:
2000
}).
then
(
response
=>
{
Axios
.
post
(
uploadUrl
,
formData
,
{
timeout
:
2000
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.loadFailure'
)
+
'!'
);
}
...
...
@@ -406,8 +425,8 @@
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}
}).
catch
(
err
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.loadFailure'
)
+
':'
+
err
);
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.loadFailure'
)
+
':'
+
err
or
);
})
}
...
...
@@ -426,10 +445,10 @@
// 发送get请求
Axios
.
get
(
downloadUrl
,
{
headers
:
{
'authcode'
:
item
.
authcode
'authcode'
:
item
.
authcode
,
},
responseType
:
'arraybuffer'
,
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
'!'
);
return
;
...
...
@@ -440,13 +459,17 @@
const
disposition
=
response
.
headers
[
'content-disposition'
];
const
filename
=
disposition
.
split
(
'filename='
)[
1
];
// 用blob对象获取文件流
var
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
// 创建下载链接
let
blob
=
new
Blob
([
response
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
//
通过文件流
创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
// 创建一个a元素并设置相关属性
var
a
=
document
.
createElement
(
'a'
);
let
a
=
document
.
createElement
(
'a'
);
a
.
href
=
href
;
if
(
name
)
{
a
.
download
=
name
;
}
else
{
a
.
download
=
filename
;
}
// 添加a元素到当前网页
document
.
body
.
appendChild
(
a
);
// 触发a元素的点击事件,实现下载
...
...
@@ -458,7 +481,7 @@
}
else
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile1'
));
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.downloadFile'
)
+
':'
+
error
);
});
}
...
...
@@ -473,10 +496,20 @@
// 拼接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
);
const
previewUrl
=
'/net-disk/preview/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
+
'?authcode='
+
item
.
authcode
;
// 自定义弹框打开url
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
)
{
this
.
dialogTitle
=
name
;
this
.
showDialog
=
true
;
this
.
iframeUrl
=
previewUrl
;
this
.
iframeUrl
=
response
.
data
;
}
}).
catch
((
error
:
any
)
=>
{
Message
.
error
(
error
);
});
}
/**
...
...
@@ -505,9 +538,19 @@
const
id
=
typeof
item
.
id
==
"string"
?
item
.
id
:
JSON
.
stringify
(
item
.
id
);
const
name
=
typeof
item
.
name
==
"string"
?
item
.
name
:
JSON
.
stringify
(
item
.
name
);
const
ocrUrl
=
'/net-disk/ocrview/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
+
'?authcode='
+
item
.
authcode
;
// 自定义弹框打开url
Axios
.
get
(
ocrUrl
).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
return
;
}
// 返回一个url,通过自定义弹框打开
if
(
response
.
data
)
{
this
.
dialogTitle
=
name
;
this
.
showDialog
=
true
;
this
.
iframeUrl
=
ocrUrl
;
this
.
iframeUrl
=
response
.
data
;
}
}).
catch
((
error
:
any
)
=>
{
Message
.
error
(
error
);
});
}
/**
...
...
@@ -528,7 +571,7 @@
// 拼接url
const
deleteUrl
=
'/net-disk/files/'
+
item
.
id
;
// 发送delete请求
Axios
.
delete
(
deleteUrl
).
then
(
response
=>
{
Axios
.
delete
(
deleteUrl
).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.deleteFileFailure'
)
+
'!'
);
}
...
...
@@ -539,7 +582,7 @@
const
value
=
JSON
.
stringify
(
this
.
uploadFileList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
// 提示删除失败
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.deleteFileFailure'
)
+
':'
+
error
);
});
...
...
@@ -552,7 +595,7 @@
*
* @memberof DiskFileUpload
*/
public
updateFileBatch
(
files
:
any
,
opt
:
any
)
{
public
updateFileBatch
(
files
:
any
)
{
let
_this
:
any
=
this
;
// 拼接url
const
updateUrl
=
'/net-disk/files/'
+
this
.
getFolder
()
+
'?ownertype='
+
this
.
getOwnertype
()
+
"&ownerid="
+
this
.
getOwnerid
();
...
...
@@ -567,12 +610,12 @@
"Content-Type"
:
"application/json;charset=UTF-8"
},
timeout
:
2000
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.updateFailure'
)
+
'!'
);
return
;
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskFileUpload.updateFailure'
)
+
':'
+
error
);
});
}
...
...
@@ -629,11 +672,12 @@
margin-left: 10px;
}
.dialogDiv{
.dialogDiv
{
// el-dialog头部
.el-dialog__header{
height:40px;
.el-dialog__header
{
height:
40px;
}
// el-dialog面板
.el-dialog__wrapper {
height: 90vh;
...
...
@@ -649,7 +693,8 @@
.el-dialog__body {
height: inherit;
}
#fileIframe{
#fileIframe {
height: calc(100% - 40px);
}
}
...
...
src/components/disk-image-upload/disk-image-upload.vue
浏览文件 @
3e1a5719
...
...
@@ -45,6 +45,8 @@
<!-- 自定义弹框 -->
<div
class=
"dialogDiv"
>
<el-dialog
:title=
"dialogTitle"
center
width=
"70%"
top=
"5vh"
:visible=
"showDialog"
...
...
@@ -231,23 +233,40 @@
*/
public
imageFileids
:
Array
<
any
>
=
[];
/**
* 自定义弹框标题
*
* @type {*}
* @memberof DiskImageUplaod
*/
public
dialogTitle
:
any
=
''
;
/**
* 是否显示自定义弹框
*
* @type {boolean}
* @memberof DiskImageUplaod
*/
public
showDialog
=
false
;
public
showDialog
:
boolean
=
false
;
/**
* 嵌入自定义弹框中iframe的url
*
* @type {*}
* @memberof DiskImageUplaod
*/
public
iframeUrl
:
any
=
''
;
/**
* 关闭自定义弹框
*
* @memberof DiskImageUplaod
*/
public
dialogClose
()
{
this
.
dialogTitle
=
''
;
this
.
showDialog
=
false
;
this
.
iframeUrl
=
''
;
let
iframe
:
any
=
document
.
getElementById
(
"fileIframe"
);
let
iframe
:
any
=
document
.
getElementById
(
"fileIframe"
);
iframe
.
parentNode
.
removeChild
(
"fileIframe"
);
}
...
...
@@ -288,7 +307,7 @@
}
/**
* vue
生命周期create
* vue
创建
*
* @memberof DiskImageUplaod
*/
...
...
@@ -344,7 +363,7 @@
ownertype
:
this
.
getOwnertype
(),
ownerid
:
this
.
getOwnerid
(),
},
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.getImageFailure'
)
+
"!"
);
return
;
...
...
@@ -361,7 +380,7 @@
});
}
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.getImageFailure'
)
+
':'
+
error
);
});
}
...
...
@@ -382,14 +401,14 @@
'authcode'
:
fileData
.
authcode
},
responseType
:
'blob'
,
}).
then
(
res
=>
{
if
(
!
res
||
res
.
status
!=
200
)
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
res
ponse
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure'
)
+
'!'
);
}
// 请求成功,后台返回的是一个文件流
if
(
res
.
data
)
{
if
(
res
ponse
.
data
)
{
// 用blob对象获取文件流
var
blob
=
new
Blob
([
res
.
data
],
{
type
:
res
.
headers
[
'content-type'
]});
var
blob
=
new
Blob
([
res
ponse
.
data
],
{
type
:
response
.
headers
[
'content-type'
]});
// 通过文件流创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
// 将下载链接保存到图片中
...
...
@@ -408,7 +427,7 @@
}
else
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure1'
));
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure'
)
+
':'
+
error
);
});
}
...
...
@@ -442,7 +461,7 @@
// 拼接url
const
uploadUrl
=
this
.
getAction
();
// 发送post请求
Axios
.
post
(
uploadUrl
,
formData
,
{
timeout
:
2000
}).
then
(
response
=>
{
Axios
.
post
(
uploadUrl
,
formData
,
{
timeout
:
2000
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.uploadImageFailure'
)
+
"!"
);
}
...
...
@@ -457,15 +476,15 @@
'authcode'
:
returnData
.
authcode
},
responseType
:
'blob'
,
}).
then
(
res
=>
{
if
(
!
res
||
res
.
status
!=
200
)
{
}).
then
(
(
response2
)
=>
{
if
(
!
res
ponse2
||
response2
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure'
)
+
"!"
);
return
;
}
// 请求成功,后台返回的是一个文件流
if
(
res
.
data
)
{
if
(
res
ponse2
.
data
)
{
// 用blob对象获取文件流
var
blob
=
new
Blob
([
res
.
data
],
{
type
:
res
.
headers
[
'content-type'
]});
var
blob
=
new
Blob
([
res
ponse2
.
data
],
{
type
:
response2
.
headers
[
'content-type'
]});
// 通过文件流创建下载链接
var
href
=
URL
.
createObjectURL
(
blob
);
// 将下载链接保存到本次上传成功后返回的jsonobject中
...
...
@@ -493,12 +512,12 @@
}
else
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure1'
));
}
}).
catch
(
error
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure'
)
+
':'
+
error
);
}).
catch
(
(
error2
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure'
)
+
':'
+
error
2
);
});
}
}).
catch
(
err
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.uploadImageFailure'
)
+
':'
+
err
);
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.uploadImageFailure'
)
+
':'
+
err
or
);
});
}
...
...
@@ -528,9 +547,19 @@
const
id
=
typeof
file
.
id
==
"string"
?
file
.
id
:
JSON
.
stringify
(
file
.
id
);
const
name
=
typeof
file
.
name
==
"string"
?
file
.
name
:
JSON
.
stringify
(
file
.
name
);
const
ocrUrl
=
'/net-disk/ocrview/'
+
this
.
getFolder
()
+
'/'
+
id
+
'/'
+
name
+
'?authcode='
+
file
.
authcode
;
// 自定义弹框打开url
Axios
.
get
(
ocrUrl
).
then
((
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
return
;
}
// 返回一个url,通过自定义弹框打开
if
(
response
.
data
)
{
this
.
dialogTitle
=
name
;
this
.
showDialog
=
true
;
this
.
iframeUrl
=
ocrUrl
;
this
.
iframeUrl
=
response
.
data
;
}
}).
catch
((
error
:
any
)
=>
{
Message
.
error
(
error
);
});
}
/**
...
...
@@ -550,7 +579,7 @@
'authcode'
:
file
.
authcode
},
responseType
:
'blob'
,
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure2'
)
+
'!'
);
return
;
...
...
@@ -567,7 +596,11 @@
// 创建一个a元素并设置相关属性
var
a
=
document
.
createElement
(
'a'
);
a
.
href
=
href
;
if
(
name
)
{
a
.
download
=
name
;
}
else
{
a
.
download
=
filename
;
}
// 添加a元素到当前网页
document
.
body
.
appendChild
(
a
);
// 触发a元素的点击事件,实现下载
...
...
@@ -579,7 +612,7 @@
}
else
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure3'
));
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.loadImageFailure2'
)
+
':'
+
error
);
});
}
...
...
@@ -604,7 +637,7 @@
// 拼接url
const
deleteUrl
=
'/net-disk/files/'
+
file
.
id
;
// 发送delete请求
Axios
.
delete
(
deleteUrl
).
then
(
response
=>
{
Axios
.
delete
(
deleteUrl
).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.deleteImageFailure'
)
+
'!'
);
}
...
...
@@ -617,7 +650,7 @@
const
value
=
JSON
.
stringify
(
this
.
imageList
);
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
formItemName
,
value
:
value
});
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
// 提示删除失败
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.deleteImageFailure'
)
+
':'
+
error
);
});
...
...
@@ -647,12 +680,12 @@
"Content-Type"
:
"application/json;charset=UTF-8"
},
timeout
:
2000
}).
then
(
response
=>
{
}).
then
(
(
response
:
any
)
=>
{
if
(
!
response
||
response
.
status
!=
200
)
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.updateFailure'
)
+
'!'
);
return
;
}
}).
catch
(
error
=>
{
}).
catch
(
(
error
:
any
)
=>
{
Message
.
error
(
_this
.
$t
(
'components.diskImageUpload.updateFailure'
)
+
':'
+
error
);
});
}
...
...
@@ -684,6 +717,7 @@
height: inherit;
}
// iframe
#fileIframe {
height: calc(100% - 40px);
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录