修改BUG

pull/39/head
Minho 2017-05-13 08:40:59 +08:00
parent c781938c0f
commit d236a5483c
1 changed files with 15 additions and 5 deletions

View File

@ -144,14 +144,19 @@
</div> </div>
<div class="attach-list" id="attachList"> <div class="attach-list" id="attachList">
<template v-for="item in lists"> <template v-for="item in lists">
<div class="attach-item"> <div class="attach-item" :id="item.id">
<template v-if="item.state == 0"> <template v-if="item.state == 'wait'">
<div class="progress"> <div class="progress">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100"> <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100">
<span class="sr-only">0% Complete (success)</span> <span class="sr-only">0% Complete (success)</span>
</div> </div>
</div> </div>
</template> </template>
<template v-else-if="item.state == 'error'">
<div class="error-message text">
上传失败
</div>
</template>
<template v-else> <template v-else>
<input type="hidden" name="attach_id[0]" :value="item.attach_id"> <input type="hidden" name="attach_id[0]" :value="item.attach_id">
<input type="text" class="form-control" placeholder="附件名称" :value="item.file_name"> <input type="text" class="form-control" placeholder="附件名称" :value="item.file_name">
@ -249,7 +254,7 @@
uploader.reset(); uploader.reset();
}).on( 'fileQueued', function( file ) { }).on( 'fileQueued', function( file ) {
var item = { var item = {
state : 0, state : "wait",
attachment_id : file.id, attachment_id : file.id,
file_size : file.size, file_size : file.size,
file_name : file.name, file_name : file.name,
@ -258,14 +263,19 @@
window.vueApp.lists.splice(0,0,item); window.vueApp.lists.splice(0,0,item);
}).on("uploadError",function (file,reason) { }).on("uploadError",function (file,reason) {
$("#error-message").text("上传失败:" + reason); for(var i in window.vueApp.lists){
var item = window.vueApp.lists[i];
if(item.attachment_id == file.id){
item.state = "error";
}
}
}).on("uploadSuccess",function (file, res) { }).on("uploadSuccess",function (file, res) {
console.log(file); console.log(file);
for(var index in window.vueApp.lists){ for(var index in window.vueApp.lists){
var item = window.vueApp.lists[index]; var item = window.vueApp.lists[index];
if(item.id === file.id()){ if(item.id === file.id){
window.vueApp.lists.splice(index,1,res.attach); window.vueApp.lists.splice(index,1,res.attach);
break; break;
} }