|
|
|
@ -8126,8 +8126,10 @@
|
|
|
|
name: 'file',
|
|
|
|
name: 'file',
|
|
|
|
|
|
|
|
|
|
|
|
postAction: './post.php',
|
|
|
|
postAction: './post.php',
|
|
|
|
|
|
|
|
|
|
|
|
putAction: './put.php',
|
|
|
|
putAction: './put.php',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
headers: {
|
|
|
|
headers: {
|
|
|
|
"X-Csrf-Token": "xxxx"
|
|
|
|
"X-Csrf-Token": "xxxx"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
@ -8166,34 +8168,34 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
filter: function filter(file) {
|
|
|
|
|
|
|
|
if (file.size < 100 * 1024) {
|
|
|
|
|
|
|
|
file = this.$refs.upload.update(file, { error: 'size' });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return file;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
inputFile: function inputFile(newFile, oldFile) {
|
|
|
|
inputFile: function inputFile(newFile, oldFile) {
|
|
|
|
|
|
|
|
|
|
|
|
if (newFile && !oldFile) {
|
|
|
|
if (newFile && !oldFile) {
|
|
|
|
console.log('add', newFile);
|
|
|
|
|
|
|
|
var URL = window.URL || window.webkitURL;
|
|
|
|
var URL = window.URL || window.webkitURL;
|
|
|
|
if (URL && URL.createObjectURL) {
|
|
|
|
if (URL && URL.createObjectURL && file.type.substr(0, 6) == 'image/') {
|
|
|
|
this.$refs.upload.update(newFile, { blob: URL.createObjectURL(newFile.file) });
|
|
|
|
newFile = this.$refs.upload.update(newFile, { blob: URL.createObjectURL(newFile.file) });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
newFile.data.name = newFile.name;
|
|
|
|
newFile.data.name = newFile.name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (newFile && oldFile) {
|
|
|
|
if (newFile && oldFile) {
|
|
|
|
console.log('update', newFile, oldFile);
|
|
|
|
|
|
|
|
if (newFile.progress != oldFile.progress) {
|
|
|
|
if (newFile.active && !oldFile.active) {
|
|
|
|
console.log('progress', newFile.progress);
|
|
|
|
if (newFile.size < 100 * 1024) {
|
|
|
|
|
|
|
|
newFile = this.$refs.upload.update(newFile, { error: 'size' });
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!newFile && oldFile) {
|
|
|
|
if (newFile.progress != oldFile.progress) {}
|
|
|
|
console.log('remove', oldFile);
|
|
|
|
|
|
|
|
|
|
|
|
if (newFile.error && !oldFile.error) {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newFile.success && !oldFile.success) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!newFile && 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -8247,6 +8249,9 @@
|
|
|
|
InputFile: _InputFile2.default
|
|
|
|
InputFile: _InputFile2.default
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
props: {
|
|
|
|
|
|
|
|
inputId: {
|
|
|
|
|
|
|
|
type: String
|
|
|
|
|
|
|
|
},
|
|
|
|
name: {
|
|
|
|
name: {
|
|
|
|
type: String,
|
|
|
|
type: String,
|
|
|
|
default: 'file'
|
|
|
|
default: 'file'
|
|
|
|
@ -8330,8 +8335,6 @@
|
|
|
|
};
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted: function mounted() {
|
|
|
|
mounted: function mounted() {
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var input = document.createElement('input');
|
|
|
|
var input = document.createElement('input');
|
|
|
|
input.type = 'file';
|
|
|
|
input.type = 'file';
|
|
|
|
if (window.FormData && input.files) {
|
|
|
|
if (window.FormData && input.files) {
|
|
|
|
@ -8344,7 +8347,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
this.$parent.$forceUpdate();
|
|
|
|
this.$parent.$forceUpdate();
|
|
|
|
this.$nextTick(function () {
|
|
|
|
this.$nextTick(function () {
|
|
|
|
_this.watchDrop(_this.drop);
|
|
|
|
this.watchDrop(this.drop);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
beforeDestroy: function beforeDestroy() {
|
|
|
|
beforeDestroy: function beforeDestroy() {
|
|
|
|
@ -8387,29 +8390,40 @@
|
|
|
|
this.files = _value;
|
|
|
|
this.files = _value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
files: function files(_files, oldFiles) {
|
|
|
|
files: function files(_files) {
|
|
|
|
var _this2 = this;
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.input = true;
|
|
|
|
|
|
|
|
this.$emit('input', _files);
|
|
|
|
|
|
|
|
this.$nextTick(function () {
|
|
|
|
|
|
|
|
this.input = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this._oldFiles = oldFiles;
|
|
|
|
|
|
|
|
var idMaps = {};
|
|
|
|
var idMaps = {};
|
|
|
|
|
|
|
|
|
|
|
|
var _loop = function _loop() {
|
|
|
|
var _loop = function _loop() {
|
|
|
|
var file = _files[i];
|
|
|
|
var file = _files[i];
|
|
|
|
var old = _this2._maps[file.id];
|
|
|
|
var old = _this._maps[file.id];
|
|
|
|
|
|
|
|
|
|
|
|
idMaps[file.id] = true;
|
|
|
|
idMaps[file.id] = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (!old || old != file) {
|
|
|
|
if (!old || old != file) {
|
|
|
|
_this2.$emit('input-file', file, old);
|
|
|
|
_this.$emit('input-file', file, old);
|
|
|
|
_this2._maps[file.id] = file;
|
|
|
|
_this._maps[file.id] = file;
|
|
|
|
if (file.active && (!old || !old.active)) {
|
|
|
|
if (file.active && (!old || !old.active)) {
|
|
|
|
_this2.upload(file).then(function () {
|
|
|
|
_this.$nextTick(function () {
|
|
|
|
_this2.update(file, { active: false, success: true });
|
|
|
|
var _this2 = this;
|
|
|
|
}).catch(function (e) {
|
|
|
|
|
|
|
|
_this2.update(file, { active: false, success: false, error: e.code || e.error || e.message });
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
|
|
_this2.upload(file).then(function () {
|
|
|
|
|
|
|
|
_this2.update(file, { active: false, success: true });
|
|
|
|
|
|
|
|
}).catch(function (e) {
|
|
|
|
|
|
|
|
_this2.update(file, { active: false, success: false, error: e.code || e.error || e.message || e });
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}, 64);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (!file.active && !file.error && !file.success && old && old.active) {
|
|
|
|
} else if (!file.active && !file.error && !file.success && old && old.active) {
|
|
|
|
_this2.update(file, { error: 'abort' });
|
|
|
|
_this.update(file, { error: 'abort' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -8426,14 +8440,8 @@
|
|
|
|
delete this._maps[id];
|
|
|
|
delete this._maps[id];
|
|
|
|
this.$emit('input-file', undefined, old);
|
|
|
|
this.$emit('input-file', undefined, old);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.input = true;
|
|
|
|
|
|
|
|
this.$emit('input', _files);
|
|
|
|
this.active && this.watchActive(true);
|
|
|
|
this.$nextTick(function () {
|
|
|
|
|
|
|
|
_this2.input = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (this.active) {
|
|
|
|
|
|
|
|
this.watchActive(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
drop: function drop(value) {
|
|
|
|
drop: function drop(value) {
|
|
|
|
this.watchDrop(value);
|
|
|
|
this.watchDrop(value);
|
|
|
|
@ -8605,11 +8613,15 @@
|
|
|
|
},
|
|
|
|
},
|
|
|
|
upload: function upload(file) {
|
|
|
|
upload: function upload(file) {
|
|
|
|
if (!(file = this.get(file))) {
|
|
|
|
if (!(file = this.get(file))) {
|
|
|
|
return _promise2.default.reject(new Error('not_exists'));
|
|
|
|
return _promise2.default.reject('not_exists');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (file.error) {
|
|
|
|
|
|
|
|
return _promise2.default.reject(file.error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (file.error || file.success) {
|
|
|
|
if (file.success) {
|
|
|
|
file = this.update(file, { error: '', success: false });
|
|
|
|
return _promise2.default.resolve(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var extensions = this.extensions;
|
|
|
|
var extensions = this.extensions;
|
|
|
|
@ -8625,18 +8637,26 @@
|
|
|
|
extensions = new RegExp('\\.(' + extensions.join('|').replace(/\./g, '\\.') + ')$', 'i');
|
|
|
|
extensions = new RegExp('\\.(' + extensions.join('|').replace(/\./g, '\\.') + ')$', 'i');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (file.name.search(extensions) == -1) {
|
|
|
|
if (file.name.search(extensions) == -1) {
|
|
|
|
return _promise2.default.reject(new Error('extension'));
|
|
|
|
return _promise2.default.reject('extension');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.size > 0 && file.size >= 0 && file.size > this.size) {
|
|
|
|
if (this.size > 0 && file.size >= 0 && file.size > this.size) {
|
|
|
|
return _promise2.default.reject(new Error('size'));
|
|
|
|
return _promise2.default.reject('size');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
file = this.filter(file) || this.get(file);
|
|
|
|
file = this.filter(file) || this.get(file);
|
|
|
|
|
|
|
|
|
|
|
|
if (!file || file.error || file.success) {
|
|
|
|
if (!file) {
|
|
|
|
return _promise2.default.reject(new Error(file ? file.error : 'not_exists'));
|
|
|
|
return _promise2.default.reject('not_exists');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (file.error) {
|
|
|
|
|
|
|
|
return _promise2.default.reject(file.error);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (file.success) {
|
|
|
|
|
|
|
|
return _promise2.default.resolve(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.mode == 'html5' && file.putAction) {
|
|
|
|
if (this.mode == 'html5' && file.putAction) {
|
|
|
|
@ -10451,7 +10471,7 @@
|
|
|
|
attrs: {
|
|
|
|
attrs: {
|
|
|
|
"type": "file",
|
|
|
|
"type": "file",
|
|
|
|
"name": _vm.$parent.name,
|
|
|
|
"name": _vm.$parent.name,
|
|
|
|
"id": _vm.$parent.id || _vm.$parent.name,
|
|
|
|
"id": _vm.$parent.inputId || _vm.$parent.name,
|
|
|
|
"accept": _vm.$parent.accept,
|
|
|
|
"accept": _vm.$parent.accept,
|
|
|
|
"webkitdirectory": _vm.$parent.directory && _vm.$parent.mode === 'html5',
|
|
|
|
"webkitdirectory": _vm.$parent.directory && _vm.$parent.mode === 'html5',
|
|
|
|
"directory": _vm.$parent.directory && _vm.$parent.mode === 'html5',
|
|
|
|
"directory": _vm.$parent.directory && _vm.$parent.mode === 'html5',
|
|
|
|
@ -10475,7 +10495,9 @@
|
|
|
|
"id": "lists"
|
|
|
|
"id": "lists"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [_c('table', [_vm._m(0), _vm._v(" "), _c('tbody', _vm._l((_vm.files), function(file, index) {
|
|
|
|
}, [_c('table', [_vm._m(0), _vm._v(" "), _c('tbody', _vm._l((_vm.files), function(file, index) {
|
|
|
|
return _c('tr', [_c('td', [_vm._v(_vm._s(index))]), _vm._v(" "), _c('td', [_vm._v(_vm._s(file.id))]), _vm._v(" "), (file.type.substr(0, 6) == 'image/' && file.blob) ? _c('td', [_c('img', {
|
|
|
|
return _c('tr', {
|
|
|
|
|
|
|
|
key: file.id
|
|
|
|
|
|
|
|
}, [_c('td', [_vm._v(_vm._s(index))]), _vm._v(" "), _c('td', [_vm._v(_vm._s(file.id))]), _vm._v(" "), (file.type.substr(0, 6) == 'image/' && file.blob) ? _c('td', [_c('img', {
|
|
|
|
attrs: {
|
|
|
|
attrs: {
|
|
|
|
"src": file.blob,
|
|
|
|
"src": file.blob,
|
|
|
|
"width": "50",
|
|
|
|
"width": "50",
|
|
|
|
@ -10519,7 +10541,6 @@
|
|
|
|
}, [_c('table', [_c('tbody', [_c('tr', [_c('td', [_c('file-upload', {
|
|
|
|
}, [_c('table', [_c('tbody', [_c('tr', [_c('td', [_c('file-upload', {
|
|
|
|
ref: "upload",
|
|
|
|
ref: "upload",
|
|
|
|
attrs: {
|
|
|
|
attrs: {
|
|
|
|
"name": _vm.name,
|
|
|
|
|
|
|
|
"post-action": _vm.postAction,
|
|
|
|
"post-action": _vm.postAction,
|
|
|
|
"put-action": _vm.putAction,
|
|
|
|
"put-action": _vm.putAction,
|
|
|
|
"extensions": _vm.extensions,
|
|
|
|
"extensions": _vm.extensions,
|
|
|
|
@ -10531,7 +10552,6 @@
|
|
|
|
"headers": _vm.headers,
|
|
|
|
"headers": _vm.headers,
|
|
|
|
"data": _vm.data,
|
|
|
|
"data": _vm.data,
|
|
|
|
"drop": _vm.drop,
|
|
|
|
"drop": _vm.drop,
|
|
|
|
"filter": _vm.filter,
|
|
|
|
|
|
|
|
"dropDirectory": _vm.dropDirectory
|
|
|
|
"dropDirectory": _vm.dropDirectory
|
|
|
|
},
|
|
|
|
},
|
|
|
|
on: {
|
|
|
|
on: {
|
|
|
|
|