<van-uploader
:disabled="form.status=='1'"
style="display: flex;"
v-model="fileList"
multiple
:max-count="4"
:after-read="afterRead">
<div style="width: 100%;" v-show="fileList.length < 4">
<img style="width:100%;height:75px;"src="./images/uploadbg.png" alt=""></div>
</van-uploader>
new Vue({
fileList: [],
formData: new FormData(),
form: {}
})
methods: {
afterRead(file) {
if(file instanceof Array) {
file.forEach(f => {
this.formData.append('files',f.file)
})
}else{
this.formData.append("files",file.file)
}
},
submitBtn() {
if(this.fileList.length <= 0) {
vant.Toast('提示内容');
return;
}
vant.Toast.loading({
duration: 0,
message: '提交中...',
forbidClick: true
});
this.formData.append('pathCode','0102')
axios({
url:`https://www.qyflc.com/gateway-api/file/uploads`,
data:this.formData,
method:'POST',
headers: {
"content-type": "multipart/form-data",
}
}).then((res) => {
this.form.status = '1'
this.form.images = res.data.data.map((item) => {
return item.url
})
return axios({
url:`https://www.qyflc.com/gateway-api/device/maintain`,
data:this.form,
method:'PUT',
}).then((response) => {
if(response.data.code == '200') {
location.reload()
vant.Toast.clear()
vant.Toast.success('提交成功');
}else{
vant.Toast.fail('提交失败');
}
})
})
},
}