Commit 1e91559b by 蒋勇

d

parent 82a85904
<template> <template>
<div> <div>
<div class="demo-upload-list" :key="item.name" v-for="item in ups"> <div class="demo-upload-list" :key="'d'+index" v-for="(item,index) in ups">
<template v-if="item.status === 'finished'"> <template v-if="item.status === 'finished'">
<img :src="item.url"> <img :src="item.url">
<div class="demo-upload-list-cover"> <div class="demo-upload-list-cover">
...@@ -96,22 +96,31 @@ export default { ...@@ -96,22 +96,31 @@ export default {
}, },
handleRemove(file) { handleRemove(file) {
//to do --添加修改时已经有逻辑,fileList中没有 //to do --添加修改时已经有逻辑,fileList中没有
const fileList = this.$refs.upload.fileList; const fileList = this.uploadList;
this.$refs.upload.fileList.splice(fileList.indexOf(file), 1); this.uploadList.splice(fileList.indexOf(file), 1);
let cresults= this.result.split(",")
let cs =cresults.filter(r=>{
return r!=file.url
})
this.result=cs.join(",")
this.$emit('change',this.result)
}, },
handleSuccess(res, file, fileList) { handleSuccess(res, file, fileList) {
// var xml= this.loadXML(res); // var xml= this.loadXML(res);
// this.result=xml.documentElement.getElementsByTagName("Location")[0].textContent; // this.result=xml.documentElement.getElementsByTagName("Location")[0].textContent;
//解析filelist,构造逗号分隔的文件列表 //解析filelist,构造逗号分隔的文件列表
console.log(fileList); console.log("/////////////////////////////////////////",fileList);
let mps = fileList.map(item => { let mps = fileList.map(item => {
if (item.status == "finished") { if (item.status == "finished") {
if (item.response) {
let xml = this.loadXML(item.response); let xml = this.loadXML(item.response);
let tmp = xml.documentElement.getElementsByTagName("Location")[0] let tmp = xml.documentElement.getElementsByTagName("Location")[0]
.textContent; .textContent;
return tmp; return tmp;
} }
}
}); });
mps.push(this.result);
this.result = mps.join(","); this.result = mps.join(",");
this.$emit("change", this.result); this.$emit("change", this.result);
}, },
...@@ -137,7 +146,7 @@ export default { ...@@ -137,7 +146,7 @@ export default {
title: "Up to five pictures can be uploaded." title: "Up to five pictures can be uploaded."
}); });
} }
this.result = ""; // this.result = "";
var myDate = new Date(); var myDate = new Date();
var key = var key =
"zc_" + "zc_" +
...@@ -158,6 +167,7 @@ export default { ...@@ -158,6 +167,7 @@ export default {
created() {}, created() {},
computed: { computed: {
ups() { ups() {
let tmpary = [];
let ti = this.uploadList.map(item => { let ti = this.uploadList.map(item => {
console.log(item); console.log(item);
if (item.status == "finished" && item.response) { if (item.status == "finished" && item.response) {
...@@ -169,15 +179,8 @@ export default { ...@@ -169,15 +179,8 @@ export default {
return item; return item;
} }
}); });
// if(this.result){ let t = tmpary.concat(ti);
// let tmpats=[] return t;
// let i=1
// this.result.split(",").forEach(item=>{
// tmpats.push( {name:i++,url:item,status:'finished'})
// })
// return tmpats
// }
return ti;
} }
}, },
mounted() { mounted() {
...@@ -197,18 +200,31 @@ export default { ...@@ -197,18 +200,31 @@ export default {
console.log("cofig fetch failuer"); console.log("cofig fetch failuer");
} }
}); });
this.$refs.upload.fileList = [];
this.uploadList = this.$refs.upload.fileList; this.uploadList = this.$refs.upload.fileList;
}, },
watch: { watch: {
value: function(v) { value: function(v) {
this.result = v; this.result = v;
if (this.result) { //打开窗口,给vaue属性赋予值
this.$refs.upload.fileList = [];
if (this.result && this.result!="") {
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>."); console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.");
let i = 10; let i = 10;
this.result.split(",").forEach(item => { this.result.split(",").forEach(item => {
let sb = this.uploadList.some(s => {
if (s.url) {
return s.url == item;
}
});
if (!sb) {
this.uploadList.push({ name: i++, url: item, status: "finished" }); this.uploadList.push({ name: i++, url: item, status: "finished" });
}
}); });
}else{
this.uploadList=[]
} }
} }
} }
}; };
......
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