文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit a0a1bc40 by 李严凡

创建任务上传文件

parent 04bbbd2b
......@@ -30,7 +30,7 @@
:on-remove="handleRemoveF"
:on-success="uploadSuccessF"
multiple
:http-request="uploadFile"
:http-request="uploadFileF"
:limit="7"
:data="'3:'+(index)"
:on-exceed="handleExceed"
......@@ -85,11 +85,11 @@
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="removeSuccess"
:on-remove="handleRemoveP"
:before-remove="beforeRemove"
:on-success="uploadSuccessP"
:data="'3:'+(index)"
:http-request="uploadFile"
:http-request="uploadFileP"
multiple
:limit="7"
:on-exceed="handleExceed"
......@@ -135,9 +135,9 @@
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
:on-remove="handleRemoveL"
:on-success="uploadSuccessL"
:http-request="uploadFile"
:http-request="uploadFileL"
multiple
:data="'3:'+(index)"
:limit="7"
......@@ -356,9 +356,16 @@
}
},
methods: {
uploadFile(fileObj){
setIndex(index){
// alert(index);
this.Index = index;
},
//上传文件
uploadFileF(fileObj){
let formData = new window.FormData();
formData.set("file",fileObj.file);
var file = formData.getAll("file");
// console.log(file[0].name);
this.axios.post("/files/upload",formData,{
headers:{
"Content-type":"multipart/form-data"
......@@ -367,44 +374,137 @@
if(res.code == 0)
alert("文件上传失败,请重新上传");
else{
console(res.data);
this.url = res.data;
this.dynamicValidateForm.domains[this.Index ].fileName.push({name:file[0].name,url:this.url});
}
})
},
setIndex(index){
this.Index = index;
},
//上传文件
uploadSuccessF(response,file,fileList){
this.fName=file.name;
this.url=file.url;
this.dynamicValidateForm.domains[this.Index ].fileName.push({name:this.fName,url:this.url});
//console.log(this.fName);
//console.log(this.taskName);
// console.log(this.dynamicValidateForm.domains[this.Index].fileName);
},
uploadSuccessP(response,file,fileList){
this.fName=file.name;
this.url=file.url;
this.dynamicValidateForm.pictureDomains[this.Index ].fileName.push({name:this.fName,url:this.url});
//console.log(this.fName);
//console.log(this.taskName);
uploadFileP(fileObj){
let formData = new window.FormData();
formData.set("file",fileObj.file);
var file = formData.getAll("file");
this.axios.post("/files/upload",formData,{
headers:{
"Content-type":"multipart/form-data"
}
}).then(res=>{
if(res.code == 0)
alert("文件上传失败,请重新上传");
else{
this.url = res.data;
this.dynamicValidateForm.pictureDomains[this.Index ].fileName.push({name:file[0].name,url:this.url});
}
})
},
uploadSuccessL(response,file,fileList){
this.fName=file.name;
this.url=file.url;
this.dynamicValidateForm.layerDomains[this.Index ].fileName.push({name:this.fName,url:this.url});
// console.log(this.fName);
// console.log(this.dynamicValidateForm.layerDoamins[this.Index].fileName);
uploadFileL(fileObj){
let formData = new window.FormData();
formData.set("file",fileObj.file);
var file = formData.getAll("file");
this.axios.post("/files/upload",formData,{
headers:{
"Content-type":"multipart/form-data"
}
}).then(res=>{
if(res.code == 0)
alert("文件上传失败,请重新上传");
else{
this.url = res.data;
this.dynamicValidateForm.layerDomains[this.Index ].fileName.push({name:file[0].name,url:this.url});
}
})
},
// //上传文件
// uploadSuccessF(response,file,fileList){
// this.fName=file.name;
// this.url=file.url;
// this.dynamicValidateForm.domains[this.Index ].fileName.push({name:this.fName,url:this.url});
// //console.log(this.fName);
// //console.log(this.taskName);
// // console.log(this.dynamicValidateForm.domains[this.Index].fileName);
// },
// uploadSuccessP(response,file,fileList){
// this.fName=file.name;
// this.url=file.url;
// this.dynamicValidateForm.pictureDomains[this.Index ].fileName.push({name:this.fName,url:this.url});
// //console.log(this.fName);
// //console.log(this.taskName);
// },
// uploadSuccessL(response,file,fileList){
// this.fName=file.name;
// this.url=file.url;
// this.dynamicValidateForm.layerDomains[this.Index ].fileName.push({name:this.fName,url:this.url});
// // console.log(this.fName);
// // console.log(this.dynamicValidateForm.layerDoamins[this.Index].fileName);
// },
//删除上传的文件
handleRemoveF(file,fileList){
var flag = 0;
var url ;
for(i = 0 ; i < this.dynamicValidateForm.domains.length && flag == 0;i++){
for(j = 0 ; j < this.dynamicValidateForm.domains[i].fileName.length ; j++){
if(file.name == this.dynamicValidateForm.domains[i].fileName[j].name){
url = this.dynamicValidateForm.domain[i].fileName[j].url;
this.dynamicValidateForm.domains[i].fileName.splice(j,1);
flag = 1;
break;
}
}
}
// this.axios({
// method:'post',
// params:{
// url : url
// },
// url:'/files/del',
// }).then(res=>{
//
// })
},
handleRemoveP(file,fileList){
var flag = 0;
var url;
for(i = 0 ; i < this.dynamicValidateForm.pictureDomains.length && flag ==0;i++){
for(j = 0 ; j < this.dynamicValidateForm.pictureDomains[i].fileName.length ; j++){
if(file.name == this.dynamicValidateForm.pictureDomains[i].fileName[j].name){
url = this.dynamicValidateForm.pictureDomains[i].fileName[j].url;
this.dynamicValidateForm.pictureDomains[i].fileName.splice(j,1);
flag = 1;
break;
}
}
}
// this.axios({
// method:'post',
// params:{
// url : url
// },
// url:'/files/del',
// }).then(res=>{
//
// })
},
handleRemoveL(file,fileList){
var flag = 0;
var url;
for(i = 0 ; i < this.dynamicValidateForm.layerDomains.length && flag == 0 ;i++){
for(j = 0 ; j < this.dynamicValidateForm.layerDomains[i].fileName.length ; j++){
if(file.name == this.dynamicValidateForm.layerDomains[i].fileName[j].name){
url = this.dynamicValidateForm.layerDomains[i].fileName[j].url;
this.dynamicValidateForm.layerDomains[i].fileName.splice(j,1);
flag = 1;
break;
}
}
}
// this.axios({
// method:'post',
// params:{
// url : url
// },
// url:'/files/del',
// }).then(res=>{
//
// })
},
submitForm(formName) {
console.log(this.dynamicValidateForm);
......
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