Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
file-uploader
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4157e9b3
authored
Sep 07, 2022
by
杨北旺
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
添加理赔系统模块上传模块
1 parent
0fe4bc1c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
405 additions
and
163 deletions
src/main.js
src/views/upload/components/claims.vue
src/views/upload/index.vue
src/main.js
View file @
4157e9b
...
@@ -59,3 +59,5 @@ fetchConfig(!isMock).then(res => {
...
@@ -59,3 +59,5 @@ fetchConfig(!isMock).then(res => {
render
:
h
=>
h
(
App
)
render
:
h
=>
h
(
App
)
})
})
})
})
const
IMAGE
=
'https://img01.glsx.com.cn/weapp/resource/saas/h5/file-uploader/'
window
.
$imageBase
=
IMAGE
src/views/upload/components/claims.vue
0 → 100644
View file @
4157e9b
<
template
>
<div
class=
"container"
>
<div
class=
"wrapper"
>
<template
v-for=
"(item, index) in list"
>
<div
:key=
"index"
class=
"pannel"
>
<!-- 菜单项 -->
<div
class=
"header flex_scb"
@
click=
"openLine(item, index)"
>
<span>
{{
item
.
title
}}
</span>
<van-icon
v-if=
"currentIndex == index"
color=
"#969799"
name=
"arrow-down"
/>
<van-icon
v-else
color=
"#969799"
name=
"arrow"
/>
</div>
<!-- 内容区域 -->
<div
v-if=
"currentIndex == index"
class=
"main"
>
<template
v-if=
"item.spectical"
>
<div
v-for=
"(el, inx) in item.content"
:key=
"inx"
class=
"widget"
>
<div
class=
"label flex_ss"
>
<div
class=
"til"
>
{{
el
.
name
}}
</div>
<div
v-if=
"el.tip"
class=
"tip"
>
{{
el
.
tip
}}
</div>
</div>
<div
class=
"wrap flex_scb"
>
<div
v-for=
"(ele, idx) in el.images"
:key=
"idx"
class=
"imageBox flex_ccc"
>
<img
class=
"icon"
:src=
"imageBase + ele.icon"
/>
<span
class=
"tips"
>
{{
ele
.
label
}}
</span>
<div
class=
"opa_upload"
@
click=
"toClickUpoload(ele)"
>
<van-uploader
max-count=
"1"
:before-delete=
"beforeDelete"
v-on:click-upload=
"beforeRead"
:before-read=
"checkRead"
:after-read=
"afterRread"
></van-uploader>
</div>
</div>
</div>
</div>
</
template
>
<
template
v-else
>
<div
class=
"widget flex_ss flex_wrap"
>
<div
v-for=
"(img, i) in item.content"
:key=
"i"
class=
"image_wrap"
:style=
"
{ width: size, height: size }" :class="[{ mar0: (i + 1) % 3 == 0 }]">
</div>
<div
:style=
"
{ width: size, height: size }" class="upload_area flex_ccc">
<van-icon
name=
"plus"
size=
"20px"
color=
"#999999"
/>
<span
class=
"text"
>
上传照片
</span>
<div
class=
"opa_upload"
>
<van-uploader
max-count=
"4"
:before-delete=
"beforeDelete"
v-on:click-upload=
"beforeRead"
:before-read=
"checkRead"
:after-read=
"afterRread"
></van-uploader>
</div>
</div>
</div>
</
template
>
</div>
</div>
</template>
</div>
<div
class=
"sumbit_btn flex_ccc"
>
传送图片
</div>
</div>
</template>
<
script
>
export
default
{
name
:
'cliaims'
,
data
()
{
return
{
imageBase
:
''
,
list
:
[
{
title
:
'基本资料'
,
content
:
[
{
name
:
'身份证照片'
,
tip
:
''
,
images
:
[
{
prop
:
'positive'
,
url
:
''
,
label
:
'上传身份证人像面'
,
icon
:
'claims_icon_1.png'
},
{
prop
:
'reverse'
,
url
:
''
,
label
:
'上传身份证国徽面'
,
icon
:
'claims_icon_2.png'
}
]
},
{
name
:
'驾驶证'
,
tip
:
''
,
images
:
[
{
prop
:
'positive'
,
url
:
''
,
label
:
'上传驾驶证'
,
icon
:
'claims_icon_3.png'
}
]
},
{
name
:
'行驶证'
,
tip
:
'正本及副证年审合格页面出险时车辆在年审有效期内'
,
images
:
[
{
prop
:
'positive'
,
url
:
''
,
label
:
'上传行驶证'
,
icon
:
'claims_icon_3.png'
}
]
},
{
name
:
'人车合照'
,
tip
:
'须清晰体现车牌、车辆全貌'
,
images
:
[
{
prop
:
'positive'
,
url
:
''
,
label
:
'上传人车合照'
,
icon
:
'claims_icon_4.png'
}
]
},
{
name
:
'前挡车架号'
,
tip
:
'车架号清晰可见'
,
images
:
[
{
prop
:
'positive'
,
url
:
''
,
label
:
'上传前挡车架号'
,
icon
:
'claims_icon_4.png'
}
]
}
],
spectical
:
true
},
{
title
:
'定损细节资料'
,
content
:
[],
spectical
:
false
},
{
title
:
'现场照片'
,
content
:
[],
spectical
:
false
},
{
title
:
'其他资料'
,
content
:
[],
spectical
:
false
}
],
currentIndex
:
0
,
size
:
'102px'
}
},
props
:
{},
created
()
{
this
.
imageBase
=
window
.
$imageBase
this
.
computedWidth
()
},
methods
:
{
computedWidth
()
{
const
screen
=
window
.
screen
.
width
const
imageW
=
(
screen
-
16
*
4
)
/
3
this
.
size
=
`
${
imageW
}
px`
},
openLine
(
item
,
index
)
{
this
.
currentIndex
=
index
},
toClickUpoload
(
current
){
console
.
log
(
current
);
},
beforeRead
(
e
)
{},
checkRead
(
file
)
{
if
(
file
.
size
>
1024
)
{
this
.
showLoading
()
return
true
}
return
true
},
afterRread
(
file
,
e
)
{
console
.
log
(
file
)
this
.
hideLoading
()
// this.uploadImage(file)
},
beforeDelete
(
file
,
e
)
{
// this.currentDelImg = file.url
// this.deleteFile()
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.wrapper
{
background
:
white
;
.pannel
{
border-top
:
2px
solid
#f8f8f8
;
.header
{
padding
:
13px
21px
13px
16px
;
font-size
:
18px
;
font-weight
:
500
;
color
:
#323233
;
}
.main
{
padding
:
16px
;
background
:
#f8f8f8
;
.widget
{
margin-bottom
:
16px
;
.label
{
margin-bottom
:
10px
;
.til
{
font-size
:
16px
;
font-weight
:
400
;
color
:
#282829
;
line-height
:
22px
;
}
.tip
{
font-size
:
12px
;
font-weight
:
400
;
color
:
#999999
;
margin-left
:
8px
;
line-height
:
24px
;
}
}
.wrap
{
.imageBox
{
width
:
166.5px
;
height
:
104px
;
background
:
#ffffff
;
box-shadow
:
0px
3px
10px
0px
rgba
(
197
,
202
,
213
,
0.25
);
border-radius
:
4px
;
position
:
relative
;
.icon
{
width
:
85px
;
height
:
56px
;
}
.tips
{
font-size
:
12px
;
font-weight
:
400
;
color
:
#656566
;
line-height
:
16px
;
margin-top
:
9px
;
}
}
}
.upload_area
{
width
:
104px
;
height
:
104px
;
background
:
rgba
(
0
,
0
,
0
,
0.04
);
border-radius
:
4px
;
position
:
relative
;
.text
{
font-size
:
14px
;
font-weight
:
400
;
color
:
#666666
;
line-height
:
22px
;
margin-top
:
10px
;
}
}
.image_wrap
{
display
:
inline-block
;
border-radius
:
4px
;
margin-right
:
16px
;
margin-bottom
:
16px
;
}
.mar0
{
margin-right
:
0
;
}
}
.flex_wrap
{
display
:
flex
;
flex-wrap
:
wrap
;
}
}
}
}
.sumbit_btn
{
width
:
69.33%
;
height
:
40px
;
background
:
#00a77b
;
border-radius
:
20px
;
font-size
:
14px
;
font-weight
:
500
;
color
:
#ffffff
;
letter-spacing
:
1px
;
margin
:
20px
auto
;
}
.opa_upload
{
position
:
absolute
;
left
:
0
;
right
:
0
;
top
:
0
;
bottom
:
0
;
opacity
:
0
;
z-index
:
1
;
}
.flex_scb
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
}
.flex_ss
{
display
:
flex
;
}
.flex_ccc
{
display
:
flex
;
flex-direction
:
column
;
align-items
:
center
;
justify-content
:
center
;
}
</
style
>
\ No newline at end of file
\ No newline at end of file
src/views/upload/index.vue
View file @
4157e9b
<
template
>
<
template
>
<div
class=
"contaienr"
>
<div
class=
"contaienr"
>
<div
class=
"upload_box_wrapper"
>
<cliaims
v-if=
"type == 'claims'"
></cliaims>
<!--
<div
class=
"upload_box_wrapper"
>
<div
class=
"title flex_scb"
>
<div
class=
"title flex_scb"
>
<span
class=
"require"
>
*
</span>
<span
class=
"require"
>
*
</span>
<span>
基础资料
</span>
<span>
基础资料
</span>
...
@@ -20,86 +21,37 @@
...
@@ -20,86 +21,37 @@
</div>
</div>
</van-uploader>
</van-uploader>
</div>
</div>
</div>
</div>
-->
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
import
{
upload
}
from
'@/api'
import
{
upload
}
from
'@/api'
const
baseImg
=
'https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/
'
import
cliaims
from
'./components/claims.vue
'
export
default
{
export
default
{
components
:
{
cliaims
},
data
()
{
data
()
{
return
{
return
{
imgBase
:
baseImg
,
fileList
:
[],
fileList
:
[
{
url
:
'http://qcimg01.glsx.com.cn/group1/M00/00/6F/wKgD3mINtxWAV8xYAAF0Ps_hc1c683.png'
,
isImage
:
true
}
],
uploadList
:
[],
uploadList
:
[],
fileURL
:
{},
fileURL
:
{},
loadingFinish
:
false
,
loadingFinish
:
false
,
size
:
'102px
'
type
:
'
'
}
}
},
},
created
()
{
created
()
{
this
.
computedWidth
()
this
.
getQuery
()
},
mounted
()
{
},
},
mounted
()
{},
methods
:
{
methods
:
{
getQuery
()
{
getQuery
()
{
return
window
.
vm
.
$route
.
query
const
{
type
}
=
window
.
vm
.
$route
.
query
},
this
.
type
=
type
// 根据手机屏幕宽度计算图片宽度
computedWidth
()
{
const
screen
=
window
.
screen
.
width
const
imageW
=
(
screen
-
(
16
*
2
+
10
*
2
+
8
*
3
))
/
3
this
.
size
=
`
${
imageW
}
px`
},
// 获取附件信息
getFileInof
(
packageCode
,
contractNo
)
{
upload
.
fileInfoApi
({
packageCode
}).
then
(
res
=>
{
this
.
uploadList
=
res
.
data
this
.
getFileValue
(
contractNo
,
res
.
data
)
})
},
// 获取附件信息的值
getFileValue
(
contractNo
,
list
)
{
upload
.
fileDataApi
({
contractNo
}).
then
(
res
=>
{
if
(
res
.
code
==
0
)
{
this
.
fileURL
=
{}
res
.
data
.
forEach
(
el
=>
{
list
.
forEach
(
item
=>
{
if
(
el
.
attachmentCode
===
item
.
attachmentCode
)
{
let
name
=
`
${
item
.
attachmentCode
}
`
let
newArr
=
[]
el
.
attachmentFiles
.
forEach
(
str
=>
{
let
temp
=
{
url
:
str
,
isImage
:
true
}
newArr
.
push
(
temp
)
})
let
obj
=
{
[
name
]:
newArr
}
this
.
fileURL
=
Object
.
assign
(
this
.
fileURL
,
obj
)
}
})
})
this
.
loadingFinish
=
true
}
})
},
},
// 获取当前点击的位置
// 获取当前点击的位置
toClickUpoload
()
{
toClickUpoload
()
{},
beforeRead
(
e
)
{},
},
beforeRead
(
e
)
{
},
checkRead
(
file
)
{
checkRead
(
file
)
{
if
(
file
.
size
>
1024
)
{
if
(
file
.
size
>
1024
)
{
this
.
showLoading
()
this
.
showLoading
()
...
@@ -117,8 +69,9 @@ export default {
...
@@ -117,8 +69,9 @@ export default {
// 上传图片
// 上传图片
uploadImage
(
file
)
{
uploadImage
(
file
)
{
const
imgFile
=
file
.
content
const
imgFile
=
file
.
content
//
两
种写法
//
三
种写法
// 1.substring字符串截取 2.split方法截取 比如:let temp = file.name.split('.');temp = temp[temp.length-1]
// 1.substring字符串截取 2.split方法截取 比如:let temp = file.name.split('.');temp = temp[temp.length-1]
// 3.[].pop()
let
fileName
=
file
.
file
.
name
let
fileName
=
file
.
file
.
name
let
index
=
fileName
.
lastIndexOf
(
'.'
)
let
index
=
fileName
.
lastIndexOf
(
'.'
)
fileName
=
fileName
.
substring
(
index
+
1
,
fileName
.
length
)
fileName
=
fileName
.
substring
(
index
+
1
,
fileName
.
length
)
...
@@ -138,108 +91,89 @@ export default {
...
@@ -138,108 +91,89 @@ export default {
// })
// })
},
},
// 上传附件
// 上传附件
uploadFile
(
url
)
{
uploadFile
(
url
)
{},
let
para
=
{
contractNo
:
this
.
contractNo
,
attachmentCode
:
this
.
currentItem
.
attachmentCode
,
attachmentType
:
this
.
currentItem
.
attachmentType
,
attachmentFile
:
url
}
upload
.
uploadFileApi
(
para
).
then
(
res
=>
{
this
.
hideLoading
()
this
.
getFileInof
(
this
.
packageCode
,
this
.
contractNo
)
})
},
// 删除附件
// 删除附件
deleteFile
()
{
deleteFile
()
{}
let
para
=
{
contractNo
:
this
.
contractNo
,
attachmentFile
:
this
.
currentDelImg
}
upload
.
deleteFileApi
(
para
).
then
(
res
=>
{
this
.
getFileInof
(
this
.
packageCode
,
this
.
contractNo
)
})
}
}
}
}
}
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.flex_ccc
{
//
.flex_ccc
{
display
:
flex
;
//
display
:
flex
;
flex-direction
:
column
;
//
flex-direction
:
column
;
align-items
:
center
;
//
align-items
:
center
;
justify-content
:
center
;
//
justify-content
:
center
;
}
//
}
.flex_scb
{
//
.flex_scb
{
display
:
flex
;
//
display
:
flex
;
align-items
:
center
;
//
align-items
:
center
;
}
//
}
.contaienr
{
//
.contaienr
{
padding
:
10px
16px
;
//
padding
:
10px
16px
;
.upload_box_wrapper
{
//
.upload_box_wrapper
{
width
:
100%
;
//
width
:
100%
;
min-height
:
156px
;
//
min-height
:
156px
;
padding-bottom
:
16px
;
//
padding-bottom
:
16px
;
background
:
#ffffff
;
//
background
:
#ffffff
;
box-shadow
:
0px
4px
8px
0px
rgba
(
224
,
224
,
224
,
0.5
);
//
box-shadow
:
0px
4px
8px
0px
rgba
(
224
,
224
,
224
,
0.5
);
border-radius
:
4px
;
//
border-radius
:
4px
;
margin-bottom
:
10px
;
//
margin-bottom
:
10px
;
.title
{
//
.title
{
box-sizing
:
border-box
;
//
box-sizing
:
border-box
;
padding
:
16px
10px
;
//
padding
:
16px
10px
;
font-size
:
16px
;
//
font-size
:
16px
;
color
:
#333333
;
//
color
:
#333333
;
font-weight
:
600
;
//
font-weight
:
600
;
.require
{
//
.require
{
font-size
:
16px
;
//
font-size
:
16px
;
color
:
#fe4b00
;
//
color
:
#fe4b00
;
font-weight
:
500
;
//
font-weight
:
500
;
}
//
}
}
//
}
.main_pannel
{
//
.main_pannel
{
box-sizing
:
border-box
;
//
box-sizing
:
border-box
;
padding
:
0
10px
;
//
padding
:
0
10px
;
display
:
flex
;
//
display
:
flex
;
flex-wrap
:
wrap
;
//
flex-wrap
:
wrap
;
.box_wrap
{
//
.box_wrap
{
width
:
102px
;
//
width
:
102px
;
height
:
102px
;
//
height
:
102px
;
background
:
#f5f6fa
;
//
background
:
#f5f6fa
;
>
p
{
//
>
p
{
font-size
:
16px
;
//
font-size
:
16px
;
color
:
#999999
;
//
color
:
#999999
;
font-weight
:
400
;
//
font-weight
:
400
;
margin-top
:
10px
;
//
margin-top
:
10px
;
}
//
}
}
//
}
.deleteWrap
{
//
.deleteWrap
{
position
:
absolute
;
//
position
:
absolute
;
left
:
0
;
//
left
:
0
;
top
:
0
;
//
top
:
0
;
height
:
20px
;
//
height
:
20px
;
width
:
20px
;
//
width
:
20px
;
z-index
:
999
;
//
z-index
:
999
;
>
img
{
//
>
img
{
height
:
20px
;
//
height
:
20px
;
width
:
20px
;
//
width
:
20px
;
}
//
}
}
//
}
}
//
}
.main_pannel
/
deep
/
.van-uploader__preview-delete
{
//
.main_pannel
/
deep
/
.van-uploader__preview-delete
{
left
:
0
;
//
left
:
0
;
width
:
20px
;
//
width
:
20px
;
height
:
20px
;
//
height
:
20px
;
border-radius
:
50%
;
//
border-radius
:
50%
;
display
:
flex
;
//
display
:
flex
;
align-items
:
center
;
//
align-items
:
center
;
justify-content
:
center
;
//
justify-content
:
center
;
background
:
#3975c6
;
//
background
:
#3975c6
;
background-image
:
url('https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/deleteIcon.png')
;
//
background-image
:
url('https://img01.glsx.com.cn/weapp/resource/equity-h5-new/mini/deleteIcon.png')
;
background-size
:
20px
20px
;
//
background-size
:
20px
20px
;
>
i
{
//
>
i
{
display
:
none
;
//
display
:
none
;
}
//
}
}
//
}
}
//
}
}
//
}
</
style
>
</
style
>
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment