< el-form >
< el-form-item id= "inputWrap1" label= "upload picture": label-width= "formLabelWidth" required >
<el-upload class="upload-demo" ref="upload1" :action="idNumPic" :data="fileData1" :before-upload="beforeUpload1" :onError="uploadError" :onSuccess="uploadSuccess" :auto-upload="false">
<el-button slot="trigger" size="small" type="primary"></el-button>
<div slot="tip" class="el-upload__tip">jpg5MB</div>
</el-upload>
</el-form-item>
<el-form-item id="inputWrap2" label="" :label-width="formLabelWidth" required>
<el-upload class="upload-demo" ref="upload2" :action="busPic" :data="fileData2" :before-upload="beforeUpload1" :onError="uploadError" :onSuccess="uploadSuccess" :auto-upload="false">
<el-button slot="trigger" size="small" type="primary"></el-button>
<div slot="tip" class="el-upload__tip">jpg5MB</div>
</el-upload>
</el-form-item>
< / el-form >
idNumPic: this.$baseUrl + "haimen",
busPic: this.$baseUrl +" haimen",
fileData1: {
idNumPic:"",
},
fileData2: {
busPic:"",
},
methods: {
register() {
const self = this
const mParams = {
idNumPic: self.idNumPic,
busPic: self.busPic,
}
this.$ajax.post("cand/register", Qs.stringify(mParams)).then(function(resp) {
if(resp.data.respCode === "1000000") {
alert("!")
} else {
alert("")
}
})
},
uploadSuccess(response, file, fileList) {
const self = this
document.getElementById("inputWrap1").getElementsByTagName("ul")[0].innerHTML = ""
document.getElementById("inputWrap2").getElementsByTagName("ul")[0].innerHTML = ""
self.getFileList(1, self.currentPageSize1)
self.$message({
message: "",
type: "success"
})
self.addFileDia = false
self.addVideoDia = false
},
uploadError(response, file, fileList) {
const self = this
self.$message({
message: "",
type: "error"
})
},
beforeUpload1(file) {
let a = file.name.split(".").length - 1
const extension8 = file.name.split(".")[a] === "jpg"
const isLt2M = file.size / 1024 / 1024 < 5
if(!extension8) {
alert("jpg!")
}
if(!isLt2M) {
alert(" 5MB!")
}
return extension8 && isLt2M
},
changeModel(model) {
this.model = model
}
}
}