Commit ab931088 authored by zhanglw's avatar zhanglw

照片上传

parent 70316fa7
...@@ -38,12 +38,24 @@ ...@@ -38,12 +38,24 @@
</el-form-item> </el-form-item>
<el-form-item label="营业执照:" class="form-cell"> <el-form-item label="营业执照:" class="form-cell">
<div class="cell-box"> <div class="cell-box">
<el-input v-model="formData.picFileName" style="width:160px;" placeholder="请上传图片" disabled /> <el-upload
<input type="file" name="image" @change="excelImport($event)"> action="/api/bsw/users/updateBusinessLicense"
name="businessLicense"
list-type="picture-card"
:headers="uploadHeaders"
:limit="2"
:on-exceed="handleExceed"
:on-success="excelImported"
:on-preview="handlePictureCardPreview"
:on-remove="handleRemove"
>
<i class="el-icon-plus" />
</el-upload>
<el-dialog append-to-body :visible.sync="dialogImageVisible">
<img width="100%" :src="dialogImageUrl">
</el-dialog>
</div> </div>
<el-image v-show="formData.picFileName" :src="formData.picFileName?imgSrcStart+'/businessLicense/'+formData.picFileName:''" :preview-src-list="[imgSrcStart+'/businessLicense/'+formData.picFileName]" style="width: 300px;"> {{ formData.picFileName }}
<div slot="placeholder" class="image-slot">加载中<span class="dot">...</span></div>
</el-image>
</el-form-item> </el-form-item>
<el-form-item label="统一社会信用代码:" class="form-cell" prop="xxxxx"> <el-form-item label="统一社会信用代码:" class="form-cell" prop="xxxxx">
<div class="cell-box"> <div class="cell-box">
...@@ -150,13 +162,17 @@ ...@@ -150,13 +162,17 @@
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { getToken } from '@/utils/auth'
import { HttpReq } from '@/api/common.js' import { HttpReq } from '@/api/common.js'
export default { export default {
dicts: ['industry_type', 'supplier_rank', 'company_type', 'business_status'], dicts: ['industry_type', 'supplier_rank', 'company_type', 'business_status'],
data() { data() {
return { return {
uploadHeaders: { 'Authorization': getToken() },
imgSrcStart: process.env.VUE_APP_BASE_API, imgSrcStart: process.env.VUE_APP_BASE_API,
dialogImageUrl: '',
dialogImageVisible: false,
visible: false, visible: false,
title: '客户信息', title: '客户信息',
provinceOpts: [], provinceOpts: [],
...@@ -195,24 +211,43 @@ export default { ...@@ -195,24 +211,43 @@ export default {
this.hideView() this.hideView()
}, },
submitForm() { submitForm() {
this.$refs.formViewRef.validate(valid => { this.$refs.formViewRef.validate((valid, obj) => {
if (valid) { if (valid) {
console.log(this.formData) console.log(this.formData)
} else {
this.$message({
message: '表单信息有误,请核对无误后提交!',
type: 'error'
})
} }
}) })
}, },
excelImport(event) { handleExceed() {
const file = event.target.files[0] this.$message({
const formData = new FormData() message: '超出最大上传数量限制',
formData.append('businessLicense', file) type: 'info'
HttpReq.backstageApi.uploadBusinessLicense(formData).then((res) => { })
this.$nextTick(() => { },
this.formData.picFileName = res.businessLicense handleRemove(file, fileList) {
this.$notify({ const arr = []
title: '上传成功!', fileList.forEach(item => {
type: 'success', arr.push(item.response.businessLicense)
duration: 2500 })
}) this.formData.picFileName = arr.join(';')
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url
this.dialogImageVisible = true
},
excelImported(response, file, fileList) {
this.$nextTick(() => {
const arr = this.formData.picFileName ? this.formData.picFileName.split(';') : []
arr.push(response.businessLicense)
this.formData.picFileName = arr.join(';')
this.$notify({
title: '上传成功!',
type: 'success',
duration: 2500
}) })
}) })
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment