Detailed event type judgment

master
git 8 years ago
parent f6e09f2141
commit f0972e48b3

@ -83,7 +83,6 @@ table th,table td {
<tr> <tr>
<td> <td>
<file-upload <file-upload
:name="name"
:post-action="postAction" :post-action="postAction"
:put-action="putAction" :put-action="putAction"
:extensions="extensions" :extensions="extensions"
@ -241,37 +240,63 @@ export default {
// Custom filter // Custom filter
filter(file) { filter(file) {
// beforeSend
// min size // min size
if (file.size < 100 * 1024) { if (file.size < 100 * 1024) {
file = this.$refs.upload.update(file, {error: 'size'}) file = this.$refs.upload.update(file, {error: 'size'})
} }
return file return file
}, },
// File Event // File Event
inputFile(newFile, oldFile) { inputFile(newFile, oldFile) {
if (newFile && !oldFile) { if (newFile && !oldFile) {
console.log('add', newFile) console.log('add', newFile)
//
var URL = window.URL || window.webkitURL var URL = window.URL || window.webkitURL
if (URL && URL.createObjectURL) { if (URL && URL.createObjectURL) {
this.$refs.upload.update(newFile, {blob: URL.createObjectURL(newFile.file)}) this.$refs.upload.update(newFile, {blob: URL.createObjectURL(newFile.file)})
} }
// post filename // post filename
newFile.data.name = newFile.name newFile.data.name = newFile.name
} }
if (newFile && oldFile) { if (newFile && oldFile) {
console.log('update', newFile, oldFile) console.log('update', newFile, oldFile)
if (newFile.progress != oldFile.progress) { if (newFile.progress != oldFile.progress) {
// this.progress(newFile)
console.log('progress', newFile.progress) console.log('progress', newFile.progress)
} }
if (newFile.error && !oldFile.error) {
// this.error(newFile)
console.log('error', newFile.error, newFile.response)
} }
if (newFile.success && !oldFile.success) {
// this.success(newFile)
console.log('success', newFile.response)
}
}
if (!newFile && oldFile) { if (!newFile && oldFile) {
// this.remove(oldFile)
console.log('remove', oldFile) console.log('remove', oldFile)
} }
//
if (this.auto && !this.$refs.upload.uploaded && !this.$refs.upload.active) { if (this.auto && !this.$refs.upload.uploaded && !this.$refs.upload.active) {
this.$refs.upload.active = true this.$refs.upload.active = true
} }

Loading…
Cancel
Save