uploadInfo.vue
4.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<template>
<div class="upload-contianer">
<div class="title">上传资料</div>
<div class="widget">
<uploadHandler :isRequire="true" :disabled="disabled" @getImages="getImages($event, 'YB0001')" title="购车发票" limitNum="1" :imagesList="uploadMessage.buyCar"></uploadHandler>
<uploadHandler :isRequire="true" :disabled="disabled" @getImages="getImages($event, 'YB0002')" title="合同购买时里程数" limitNum="1" :imagesList="uploadMessage.mileage"></uploadHandler>
<uploadHandler :isRequire="true" :disabled="disabled" @getCardImg="getCardImg" uploadType="1" title="行驶证或车辆合格证" :cardImg="cardImg"></uploadHandler>
<uploadHandler :disabled="disabled" @getImages="getImages($event, 'YB0005')" title="其他" limitNum="9" :imagesList="uploadMessage.others"></uploadHandler>
</div>
</div>
</template>
<script type="text/ecmascript-6">
import upload_img from '@/assets/beforeSale/upload.png'
import uploadHandler from './components/UploadHandler.vue'
export default {
name: 'uploadInfo',
components: {
uploadHandler
},
data() {
return {
upload_img,
dialogVisible: false,
attachmentList: [],
license: [{}, {}]
}
},
props: {
uploadMessage: Object,
cardImg: Object,
disabled: Boolean,
imgsQuery: Array
},
mounted() {},
methods: {
getImages(e, code) {
this.handlerData()
if (code === 'YB0005') {
this.others = []
} else if (code === 'YB0001' && !e.length) {
this.buyCar = []
} else if (code === 'YB0002' && !e.length) {
this.mileage = []
}
e.forEach(url => {
let obj = {
attachmentCode: code,
attachmentFile: url,
attachmentType: 'IMG'
}
if (code === 'YB0001') {
this.buyCar = [obj]
} else if (code === 'YB0002') {
this.mileage = [obj]
} else if (code === 'YB0005') {
this.others.push(obj)
}
})
this.getAllImages()
},
getCardImg(e) {
this.handlerData()
const _value = e.detail,
type = e.type
const _attachmentCode = type == 1 ? 'YB0003' : 'YB0004'
const _attachmentFile = type == 1 ? _value.font : _value.reverse
const _obj = {
attachmentCode: _attachmentCode,
attachmentFile: _attachmentFile,
attachmentType: 'IMG'
}
if (!_attachmentFile && type == 1) {
this.license[0] = {}
} else if (!_attachmentFile && type == 2) {
this.license[1] = {}
} else {
this.license[type - 1] = _obj
}
this.getAllImages()
},
getAllImages() {
let attachmentList = [],
_tempArr1 = [],
_tempArr2 = [],
_tempArr3 = [],
_tempArr4 = []
if (this.buyCar) {
this.buyCar.forEach(e => {
_tempArr1.push(e)
})
}
if (this.mileage) {
this.mileage.forEach(e => {
_tempArr2.push(e)
})
}
if (this.others) {
this.others.forEach(e => {
_tempArr3.push(e)
})
}
if (this.license) {
this.license.forEach(e => {
if (e.attachmentFile) {
_tempArr4.push(e)
}
})
}
attachmentList = [..._tempArr1, ..._tempArr2, ..._tempArr3, ..._tempArr4]
this.$emit('getAttachmentList', attachmentList)
},
handlerData() {
if (this.imgsQuery.length && !this.active) {
this.buyCar = []
this.mileage = []
this.license = [{}, {}]
this.others = []
this.imgsQuery.forEach(el => {
if (el.attachmentCode === 'YB0001') {
this.buyCar = [el]
} else if (el.attachmentCode === 'YB0002') {
this.mileage = [el]
} else if (el.attachmentCode === 'YB0003') {
this.license[0] = el
} else if (el.attachmentCode === 'YB0004') {
this.license[1] = el
} else if (el.attachmentCode === 'YB0005') {
this.others.push(el)
}
})
this.active = true
}
}
}
}
</script>
<style lang="scss" scoped>
.upload-contianer {
background: white;
margin: 10px 0 0;
.title {
font-size: 16px;
font-weight: 600;
padding: 15px 20px;
border-bottom: 1px solid #e7eaec;
margin: 0 0;
}
.widget {
padding: 32px 0px;
}
}
</style>