Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz-Vue-Mob-R7-Res
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7前端标准模板
iBiz-Vue-Mob-R7-Res
提交
212eeb04
提交
212eeb04
编写于
6月 05, 2020
作者:
zcdtk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
图片上传
上级
28ddd16e
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
73 行增加
和
136 行删除
+73
-136
app-mob-file-upload.vue
src/components/app-mob-file-upload/app-mob-file-upload.vue
+4
-0
app-mob-picture.vue
src/components/app-mob-picture/app-mob-picture.vue
+69
-136
未找到文件。
src/components/app-mob-file-upload/app-mob-file-upload.vue
浏览文件 @
212eeb04
...
...
@@ -30,6 +30,7 @@ import { Environment } from '@/environments/environment';
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
Axios
from
'axios'
;
import
qs
from
'qs'
;
import
{
Loading
}
from
'@/ibiz-core/utils'
;
import
{
Uploader
}
from
'vant'
;
...
...
@@ -143,7 +144,9 @@ export default class AppMobFileUpload extends Vue {
'Content-Type'
:
'multipart/form-data'
}
}
Loading
.
show
(
'上传中'
);
Axios
.
post
(
this
.
uploadUrl
,
params
,
config
).
then
((
response
:
any
)
=>
{
Loading
.
hidden
();
if
(
response
&&
response
.
data
&&
response
.
status
===
200
)
{
let
data
:
any
=
response
.
data
;
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
...
...
@@ -156,6 +159,7 @@ export default class AppMobFileUpload extends Vue {
this
.
onError
(
response
,
file
,
this
.
files
);
}
}).
catch
((
response
:
any
)
=>
{
Loading
.
hidden
();
this
.
onError
(
response
,
file
,
this
.
files
);
});
}
...
...
src/components/app-mob-picture/app-mob-picture.vue
浏览文件 @
212eeb04
...
...
@@ -28,10 +28,13 @@ import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorat
import
{
Environment
}
from
'@/environments/environment'
;
import
{
Subject
,
Unsubscribable
}
from
'rxjs'
;
import
Axios
from
'axios'
;
import
{
Plugins
,
CameraResultType
,
Capacitor
}
from
'@capacitor/core'
;
import
qs
from
'qs'
;
import
{
Plugins
,
CameraResultType
,
Capacitor
}
from
'@capacitor/core'
;
const
{
Camera
}
=
Plugins
;
import
{
Uploader
}
from
'vant'
;
import
{
Loading
,
Util
}
from
'@/ibiz-core/utils'
;
import
{
Loading
,
Util
}
from
'@/ibiz-core/utils'
;
Vue
.
use
(
Uploader
);
@
Component
({
components
:
{
...
...
@@ -42,7 +45,7 @@ export default class AppMobPicture extends Vue {
/**
* 当前设备信息
*/
public
platform
:
any
;
public
platform
:
any
;
// MOB LOGIC BEGIN
/**
...
...
@@ -76,7 +79,7 @@ export default class AppMobPicture extends Vue {
}
return
false
;
}
/**
* 开发模式文件数组
*
...
...
@@ -102,7 +105,6 @@ export default class AppMobPicture extends Vue {
* @memberof AppMobPicture
*/
public
onDelete
(
file
:
any
,
detail
:
any
):
void
{
console
.
log
(
this
.
files
,
file
);
this
.
onRemove
({
id
:
file
.
id
,
name
:
file
.
name
},
this
.
files
);
}
...
...
@@ -115,6 +117,7 @@ export default class AppMobPicture extends Vue {
* @memberof AppMobPicture
*/
public
beforeRead
(
file
:
any
,
detail
:
any
):
boolean
{
this
.
dataProcess
();
if
(
file
&&
Array
.
isArray
(
file
))
{
this
.
$notify
({
type
:
'warning'
,
message
:
'该功能只支持单个文件上传'
});
return
false
;
...
...
@@ -157,6 +160,14 @@ export default class AppMobPicture extends Vue {
}
// MOB LOGIC END
/**
* 是否支持多个上传
*
* @type {boolean}
* @memberof AppMobPicture
*/
@
Prop
({
default
:
true
})
public
multiple
?:
boolean
;
/**
* 表单状态
*
...
...
@@ -236,28 +247,36 @@ export default class AppMobPicture extends Vue {
@
Prop
()
public
disabled
?:
boolean
;
/**
*
上传参数
*
视图上下文
*
* @type {
string
}
* @type {
*
}
* @memberof AppMobPicture
*/
@
Prop
(
)
public
uploadparams
?:
string
;
@
Prop
(
{
default
:
{}
})
context
:
any
;
/**
*
下载
参数
*
视图
参数
*
* @type {string}
* @type {*}
* @memberof AppMobPicture
*/
@
Prop
({
default
:
{}
})
viewparams
:
any
;
/**
* 上传参数
*
* @type {*}
* @memberof AppMobPicture
*/
@
Prop
(
)
public
exportparams
?:
string
;
@
Prop
(
{
default
:
{}
})
uploadParam
:
any
;
/**
*
自定义
参数
*
下载
参数
*
* @type {*}
* @memberof AppMobPicture
*/
@
Prop
(
)
public
customparams
?
:
any
;
@
Prop
(
{
default
:
{}
})
exportParam
:
any
;
/**
* 上传文件路径
...
...
@@ -280,30 +299,6 @@ export default class AppMobPicture extends Vue {
*/
@
Provide
()
public
files
:
Array
<
any
>
=
[];
/**
* 上传keys
*
* @type {Array<any>}
* @memberof AppMobPicture
*/
public
upload_keys
:
Array
<
any
>
=
[];
/**
* 导出keys
*
* @type {Array<any>}
* @memberof AppMobPicture
*/
public
export_keys
:
Array
<
any
>
=
[];
/**
* 自定义数组
*
* @type {Array<any>}
* @memberof AppMobPicture
*/
public
custom_arr
:
Array
<
any
>
=
[];
/**
* 应用参数
*
...
...
@@ -319,21 +314,18 @@ export default class AppMobPicture extends Vue {
* @memberof AppMobPicture
*/
private
dataProcess
():
void
{
let
upload_arr
:
Array
<
string
>
=
[];
let
export_arr
:
Array
<
string
>
=
[];
const
_data
:
any
=
JSON
.
parse
(
this
.
data
);
this
.
upload_keys
.
forEach
((
key
:
string
)
=>
{
upload_arr
.
push
(
`
${
key
}
=
${
_data
[
key
]}
`
);
});
this
.
export_keys
.
forEach
((
key
:
string
)
=>
{
export_arr
.
push
(
`
${
key
}
=
${
_data
[
key
]}
`
);
});
let
_url
=
`
${
Environment
.
BaseUrl
}${
Environment
.
UploadFile
}
`
;
if
(
upload_arr
.
length
>
0
||
this
.
custom_arr
.
length
>
0
)
{
_url
=
`
${
_url
}
?
${
upload_arr
.
join
(
'&'
)}${
upload_arr
.
length
>
0
?
'&'
:
''
}${
this
.
custom_arr
.
join
(
'&'
)}
`
;
const
{
context
:
uploadContext
,
param
:
uploadParam
}
=
this
.
$viewTool
.
doEditorItemParam
(
this
.
uploadParam
,
this
.
context
,
this
.
viewparams
,
JSON
.
parse
(
this
.
data
));
const
{
context
:
exportContext
,
param
:
exportParam
}
=
this
.
$viewTool
.
doEditorItemParam
(
this
.
exportParam
,
this
.
context
,
this
.
viewparams
,
JSON
.
parse
(
this
.
data
));
let
_uploadUrl
=
`
${
Environment
.
BaseUrl
}${
Environment
.
UploadFile
}
`
;
const
uploadContextStr
:
string
=
qs
.
stringify
(
uploadContext
,
{
delimiter
:
'&'
});
const
uploadParamStr
:
string
=
qs
.
stringify
(
uploadParam
,
{
delimiter
:
'&'
});
if
(
!
Object
.
is
(
uploadContextStr
,
''
)
||
!
Object
.
is
(
uploadParamStr
,
''
))
{
_uploadUrl
=
`
${
_uploadUrl
}
?
${
uploadContextStr
}
&
${
uploadParamStr
}
`
;
}
this
.
uploadUrl
=
_url
;
this
.
uploadUrl
=
_u
ploadU
rl
;
this
.
files
.
forEach
((
file
:
any
)
=>
{
if
(
process
.
env
.
NODE_ENV
===
'development'
)
{
...
...
@@ -344,12 +336,15 @@ export default class AppMobPicture extends Vue {
}
return
;
}
let
url
=
`
${
this
.
downloadUrl
}
/
${
file
.
id
}
`
;
if
(
upload_arr
.
length
>
0
||
this
.
custom_arr
.
length
>
0
)
{
url
=
`
${
url
}
?
${
upload_arr
.
join
(
'&'
)}${
upload_arr
.
length
>
0
?
'&'
:
''
}${
this
.
custom_arr
.
join
(
'&'
)}
`
;
let
_downloadUrl
=
`
${
this
.
downloadUrl
}
/
${
file
.
id
}
`
;
const
exportContextStr
:
string
=
qs
.
stringify
(
exportContext
,
{
delimiter
:
'&'
});
const
exportParamStr
:
string
=
qs
.
stringify
(
exportParam
,
{
delimiter
:
'&'
});
if
(
!
Object
.
is
(
exportContextStr
,
''
)
||
!
Object
.
is
(
exportParamStr
,
''
))
{
_downloadUrl
=
`
${
_downloadUrl
}
?
${
exportContextStr
}
&
${
exportParamStr
}
`
;
}
file
.
isImage
=
true
;
file
.
url
=
u
rl
;
file
.
url
=
_downloadU
rl
;
});
}
...
...
@@ -365,11 +360,14 @@ export default class AppMobPicture extends Vue {
// 表单加载完成
if
(
Object
.
is
(
$event
.
type
,
'load'
))
{
if
(
this
.
value
)
{
// console.log(this.value);
this
.
files
=
JSON
.
parse
(
this
.
value
);
}
this
.
dataProcess
();
}
// 表单保存完成 和 表单项更新
if
(
Object
.
is
(
$event
.
type
,
"save"
)
||
Object
.
is
(
$event
.
type
,
"updateformitem"
))
{
this
.
dataProcess
();
}
});
}
}
...
...
@@ -381,26 +379,6 @@ export default class AppMobPicture extends Vue {
*/
public
mounted
()
{
this
.
appData
=
this
.
$store
.
getters
.
getAppData
();
let
custom_arr
:
Array
<
string
>
=
[];
let
upload_keys
:
Array
<
string
>
=
[];
let
export_keys
:
Array
<
string
>
=
[];
if
(
this
.
uploadparams
&&
!
Object
.
is
(
this
.
uploadparams
,
''
))
{
upload_keys
=
this
.
uploadparams
.
split
(
';'
);
}
if
(
this
.
exportparams
&&
!
Object
.
is
(
this
.
exportparams
,
''
))
{
export_keys
=
this
.
exportparams
.
split
(
';'
);
}
if
(
this
.
customparams
&&
!
Object
.
is
(
this
.
customparams
,
''
))
{
Object
.
keys
(
this
.
customparams
).
forEach
((
name
:
string
)
=>
{
custom_arr
.
push
(
`
${
name
}
=
${
this
.
customparams
[
name
]}
`
);
});
}
this
.
upload_keys
=
upload_keys
;
this
.
export_keys
=
export_keys
;
this
.
custom_arr
=
custom_arr
;
if
(
this
.
value
)
{
this
.
files
=
JSON
.
parse
(
this
.
value
);
}
...
...
@@ -428,18 +406,18 @@ export default class AppMobPicture extends Vue {
* @memberof AppMobPicture
*/
public
getNearEle
(
ele
:
any
,
type
:
any
)
{
type
=
type
==
1
?
"previousSibling"
:
"nextSibling"
;
var
nearEle
=
ele
[
type
];
while
(
nearEle
)
{
if
(
nearEle
.
nodeType
===
1
)
{
return
nearEle
;
}
nearEle
=
nearEle
[
type
];
if
(
!
nearEle
)
{
break
;
type
=
type
==
1
?
"previousSibling"
:
"nextSibling"
;
var
nearEle
=
ele
[
type
];
while
(
nearEle
)
{
if
(
nearEle
.
nodeType
===
1
)
{
return
nearEle
;
}
nearEle
=
nearEle
[
type
];
if
(
!
nearEle
)
{
break
;
}
}
}
return
null
;
return
null
;
}
/**
...
...
@@ -453,16 +431,6 @@ export default class AppMobPicture extends Vue {
}
}
/**
* 上传之前
*
* @param {*} file
* @memberof AppMobPicture
*/
public
beforeUpload
(
file
:
any
)
{
// console.log('上传之前');
}
/**
* 上传成功回调
*
...
...
@@ -513,7 +481,6 @@ export default class AppMobPicture extends Vue {
arr
.
push
({
name
:
f
.
name
,
id
:
f
.
id
});
}
});
console
.
log
(
arr
);
let
value
:
any
=
arr
.
length
>
0
?
JSON
.
stringify
(
arr
)
:
null
;
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
value
});
}
...
...
@@ -525,44 +492,10 @@ export default class AppMobPicture extends Vue {
* @memberof AppMobPicture
*/
public
onDownload
(
file
:
any
)
{
this
.
dataProcess
();
window
.
open
(
file
.
url
);
}
/**
* 预览图片地址
*
* @type {string}
* @memberof AppMobPicture
*/
public
dialogImageUrl
:
string
=
''
;
/**
* 是否显示预览界面
*
* @type {boolean}
* @memberof AppMobPicture
*/
public
dialogVisible
:
boolean
=
false
;
/**
* 是否支持多个上传
*
* @type {boolean}
* @memberof AppMobPicture
*/
@
Prop
({
default
:
true
})
public
multiple
?:
boolean
;
/**
* 预览
*
* @param {*} file
* @memberof AppMobPicture
*/
public
onPreview
(
file
:
any
)
{
this
.
dialogImageUrl
=
file
.
url
;
this
.
dialogVisible
=
true
;
}
/**
* 原生相机上传事件
*
...
...
@@ -576,9 +509,9 @@ export default class AppMobPicture extends Vue {
});
this
.
files
.
push
({
id
:
Util
.
createUUID
(),
name
:
image
.
webPath
,
url
:
image
.
webPath
,
isImage
:
true
,
name
:
image
.
webPath
,
url
:
image
.
webPath
,
isImage
:
true
,
});
let
base
=
image
.
base64String
;
this
.
$emit
(
'formitemvaluechange'
,
{
name
:
this
.
name
,
value
:
this
.
files
});
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录