Commit 86f2d00e by 张权

合并

1 parent 9854a015
<template> <template>
<div class="report-components"> <div class="report-components">
<div class="title">上传资料</div> <div class="title">上传资料</div>
<el-upload action="https://jsonplaceholder.typicode.com/posts/" list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"> <div v-for="item in materialData" :key="item.name">
<i class="el-icon-plus"></i> <div>{{ item.label }}</div>
</el-upload> <el-upload :class="[(item.imgList ? item.limit != item.imgList.length : true) ? '' : 'hidePlusBtn']" :limit="item.limit" action="#" :before-upload="beforeAvatarUpload" list-type="picture-card" :ref="item.name + 'Ref'" :on-preview="handlePictureCardPreview" :on-remove="e => handleRemove(e, item.name)" :http-request="e => httpRequest(e, item.name)">
<el-dialog :visible.sync="dialogVisible"> <i slot="default" class="el-icon-plus"></i>
<img width="100%" :src="dialogImageUrl" alt="" /> </el-upload>
</el-dialog> <el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="" />
</el-dialog>
</div>
</div> </div>
</template> </template>
...@@ -22,34 +25,98 @@ export default { ...@@ -22,34 +25,98 @@ export default {
// }, // },
data() { data() {
return { return {
dialogVisible: false,
materialForm: { materialForm: {
cardInfo: '', cardInfo: '',
billInfo: '', billInfo: '',
otherInfo: '' otherInfo: ''
}, },
fieldInfo: {
cardInfo: [],
billInfo: [],
otherInfo: []
},
materialData: [ materialData: [
{ {
label: '身份证', label: '身份证',
name: 'cardInfo', name: 'cardInfo',
type: 'upload' limit: 2,
imgList: []
}, },
{ {
label: '发票', label: '发票',
name: 'billInfo', name: 'billInfo',
type: 'upload' limit: 10,
imgList: []
}, },
{ {
label: '其他', label: '其他',
name: 'otherInfo', name: 'otherInfo',
type: 'upload' limit: 1,
imgList: []
} }
] ]
} }
}, },
methods: {} methods: {
beforeAvatarUpload(e) {
let AllImgExt = '.zip|.rar|.png|.jpg'
let extName = e.name.substring(e.name.lastIndexOf('.')).toLowerCase()
if (AllImgExt.indexOf(extName) === -1) {
this.$message.error('上传格式不正确')
return false
}
const size = e.size / 1024 / 1024
if (size > 9) {
this.$message.error('上传文件不可超过9M')
return false
}
},
httpRequest({ file: e }, fieldName) {
console.log(e, 456)
// // 转码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]
this.$apis.ghBeforeSale.uploadImgApi({ file: fileInfo }).then(res => {
console.log(res)
if (res) {
let targetItem = this.materialData.find(item => item.name === fieldName)
targetItem.imgList.push(res)
this.fieldInfo[fieldName].push(e.uid)
} else {
this.handleRemove(e, fieldName, 1)
}
})
}
},
handleRemove(e, fieldName, isDel) {
if (isDel) {
let id = this.$refs[fieldName + 'Ref'][0].uploadFiles.findIndex(item => item.uid === e.uid)
this.$refs[fieldName + 'Ref'][0].uploadFiles.splice(id, 1)
} else {
console.log(this.fieldInfo[fieldName], e.uid)
let targetId = this.fieldInfo[fieldName].findIndex(item => item === e.uid)
console.log(targetId)
}
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url
this.dialogVisible = true
}
}
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/deep/ .hidePlusBtn {
.el-upload--picture-card {
display: none;
}
}
.report-components { .report-components {
background: white; background: white;
.title { .title {
......
...@@ -30,9 +30,9 @@ ...@@ -30,9 +30,9 @@
</div> </div>
<div class="account-info"> <div class="account-info">
<glsx-combi-form ref="accountRef" :formRules="accountRule" labelWidth="144px" defaultWidth="320px" :formObj="accountForm" :formData="accountData"> <glsx-combi-form ref="accountRef" :formRules="accountRule" labelWidth="144px" defaultWidth="320px" :formObj="accountForm" :formData="accountData">
<template slot="collectCity"> <!-- <template slot="collectCity">
<city-select @onChange="selectAddress"></city-select> <city-select @onChange="selectAddress"></city-select>
</template> </template> -->
</glsx-combi-form> </glsx-combi-form>
</div> </div>
</div> </div>
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import citySelect from './citySelect.vue'
import glsxCombiForm from '@/components/glsx-combi-form' import glsxCombiForm from '@/components/glsx-combi-form'
const phoneReg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/ const phoneReg = /^(13[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9]|14[0-9])[0-9]{8}$/
export default { export default {
...@@ -51,7 +50,6 @@ export default { ...@@ -51,7 +50,6 @@ export default {
}, },
components: { components: {
glsxCombiForm, glsxCombiForm,
citySelect,
}, },
data() { data() {
return { return {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!