Commit 0e9a640b by 杨北旺

提交延保提单内容

1 parent 9bce928c
......@@ -53,5 +53,19 @@ const pictureUpload = params => {
noSignAttr: ['file']
})
}
const uploadFileApi = (params, callback) => {
params.method = 'scrm.api.equity.common.upload.common.multiple'
return http({
url: 'rop-scrm-equity/router',
method: 'POST',
data: params,
sign: true,
noSignAttr: ['file'],
returnAll: true,
onUploadProgress: res => {
callback(res)
}
})
}
export { getGoodsList, uploadImg, getMerchantList, getZoneList, pictureUpload }
export { getGoodsList, uploadImg, getMerchantList, getZoneList, pictureUpload,uploadFileApi }
<template>
<div class="element">
<label class="element_label">
<span v-if="isRequire" class="require">*</span>
{{ title }}:
</label>
<div class="wrapper">
<div class="upload_wrap">
<!-- 0 是默认上传类型 -->
<template v-if="uploadType == 0">
<template v-if="imagesList.length">
<div v-for="(imgItem, i) in imagesList" :key="i" class="imagBox">
<img class="imgItem" :src="imgItem" alt="" />
<div class="img_mask">
<i @click="handlePictureCardPreview(imgItem)" class="el-icon-zoom-in"></i>
<i v-if="!disabled" @click="toDeleteImg(index, i)" class="el-icon-delete"></i>
</div>
</div>
</template>
<div v-if="!(imagesList.length == limitNum)" class="upload-value">
<el-upload :disabled="disabled" list-type="picture" class="upload_item" action="#" :before-upload="e => beforeAvatarUpload(e)" :on-remove="e => handleRemove(e, index)" :http-request="e => httpRequest(e, index)">
<img class="img" slot="default" :src="upload_img" alt="" />
</el-upload>
</div>
</template>
<!-- 1 代表的是身份证、驾驶证等类型 -->
<template v-if="uploadType == 1">
<template v-for="count in 2">
<div v-if="(count == 1 && cardImg.font) || (count == 2 && cardImg.reverse)" :key="count" class="imagBox wid180">
<img class="imgItem wid180" :src="count == 2 ? cardImg.reverse : cardImg.font" alt="" />
<div class="img_mask wid180">
<i @click="handlePictureCardPreview(count == 2 ? cardImg.reverse : cardImg.font)" class="el-icon-zoom-in"></i>
<i v-if="!disabled" @click="removeCard(count)" class="el-icon-delete"></i>
</div>
</div>
</template>
<template v-for="count in 2">
<div v-if="(count == 1 && !cardImg.font&&!disabled) || (count == 2 && !cardImg.reverse&&!disabled)" :key="count" class="upload-value upload-value-max marRight-13">
<el-upload :disabled="disabled" list-type="picture" class="upload_item" action="#" :before-upload="e => beforeAvatarUpload(e)" :on-remove="e => handleRemove(e, index)" :http-request="e => httpRequest(e, count)">
<img class="img" slot="default" :src="count == 2 ? idCardBack_img : idCard_img" alt="" />
</el-upload>
</div>
</template>
</template>
</div>
<div class="tip">
图片格式为jpg,jpeg,png,大小10M以内
<span v-if="limitNum > 8 && uploadType == 0">,最多可上传{{ limitNum }}张</span>
</div>
</div>
<el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
</div>
</template>
<script type="text/ecmascript-6">
import upload_img from '@/assets/beforeSale/upload.png'
import idCard_img from '@/assets/beforeSale/idCard.png'
import idCardBack_img from '@/assets/beforeSale/idCardBack.png'
import { uploadFileApi } from '@/api/modules/common'
export default {
name: 'uploadHandler',
props: {
title: {
type: String,
default: '其他'
},
imagesList: Array,
uploadType: {
type: Number,
default: 0
},
limitNum: {
type: Number,
default: 100
},
cardImg: Object,
disabled:Boolean,
isRequire:Boolean
},
data() {
return {
upload_img,
idCard_img,
idCardBack_img,
dialogVisible: false,
hideUpload: false
}
},
mounted() {},
methods: {
toDeleteImg(index, i) {
this.imagesList.splice(i, 1)
this.$emit('getImages', this.imagesList)
},
removeCard(count) {
if (count == 1) {
this.cardImg.font = ''
} else {
this.cardImg.reverse = ''
}
this.$emit('getCardImg', {detail:this.cardImg,type:count})
},
handlePictureCardPreview(url) {
this.dialogImageUrl = url
this.dialogVisible = true
},
beforeAvatarUpload(e) {
return new Promise((resolve, reject) => {
let AllImgExt = '.png|.jpg|.jpeg'
let extName = e.name.substring(e.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName) === -1) {
this.$message.error('上传格式不正确')
return reject(false)
}
const size = e.size / 1024 / 1024
let maxSize = 10
let filetype = this.getFileType(e.type)
if (filetype == 'image') {
maxSize = 10
} else {
maxSize = 30
}
if (size > maxSize) {
this.$message.error(`上传文件不可超过${maxSize}M`)
return reject(false)
}
return resolve(true)
})
},
httpRequest({ file: e }, count) {
let size = e.size / 1024 / 1024
let loading = null
// 大于2给loading
if (size > 2) {
loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
}
// // 转码base64
const reader = new FileReader()
reader.readAsDataURL(e)
reader.onload = event => {
const imgFile = event.target.result
const arrBase64 = imgFile.split(',')
const targetNameList = e.name.split('.')
const fileInfo = targetNameList[targetNameList.length - 1] + '@' + arrBase64[1]
const fileType = this.getFileType(e.type)
const paramObj = { file: fileInfo, fileType: fileType }
let param = {}
param.fileList = [paramObj]
uploadFileApi(param, res => {
if (loading != null) {
loading.close()
loading = null
}
// let progress = ((res.loaded / res.total) * 100).toFixed(2)
// if (progress > 90) {
// progress = 90
// }
}).then(res => {
if (res.code == 0) {
const url = res.data[0]
if (this.uploadType == 0) {
this.imagesList.push(url)
this.$emit('getImages', this.imagesList)
} else if (this.uploadType == 1) {
if (count == 1) {
this.cardImg.font = url
} else {
this.cardImg.reverse = url
}
this.$emit('getCardImg', {detail:this.cardImg,type:count})
}
}
})
}
},
handleRemove(e, fieldName) {
if (e.status == 'ready') return
},
getFileType(type) {
if (!type) return 'doc'
if (type.indexOf('image') > -1) {
return 'image'
} else {
return 'doc'
}
}
}
}
</script>
<style lang="scss" scoped>
.element {
display: flex;
margin-bottom: 20px;
.element_label {
width: 154px;
font-weight: 400;
font-size: 14px;
color: #333333;
text-align: right;
.require {
color: red;
}
}
.wrapper {
width: 650px;
.upload_wrap {
display: flex;
flex-wrap: wrap;
.imagBox {
position: relative;
.imgItem {
width: 104px;
height: 104px;
border-radius: 4px;
margin-right: 10px;
margin-bottom: 10px;
border: 1px dashed #00000026;
}
.img_mask {
display: none;
}
}
.imagBox:hover {
.img_mask {
display: block;
width: 104px;
height: 104px;
border-radius: 4px;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
transition: opacity 0.3s;
display: flex;
align-items: center;
justify-content: center;
i {
color: white;
cursor: pointer;
font-weight: 400;
font-size: 21px;
}
i:first-child {
margin-right: 12px;
}
i:last-child {
margin-right: 0;
}
}
}
}
.upload-value {
width: 104px;
height: 104px;
border: 1px dashed #00000026;
border-radius: 4px;
.upload_item {
width: 104px;
height: 104px;
.img {
width: 104px;
height: 104px;
border-radius: 4px;
}
/deep/.el-upload-list--picture {
display: none;
}
}
}
.upload-value-max {
width: 180px;
.upload_item {
width: 180px;
.img {
width: 180px;
}
}
}
.wid180 {
width: 180px !important;
margin-right: 13px;
}
.marRight-13 {
margin-right: 13px;
}
.tip {
font-weight: 400;
font-size: 14px;
color: #999999;
margin-top: 8px;
}
}
}
</style>
<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>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!