| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
- module.exports =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId])
- /******/ return installedModules[moduleId].exports;
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ exports: {},
- /******/ id: moduleId,
- /******/ loaded: false
- /******/ };
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/ // Flag the module as loaded
- /******/ module.loaded = true;
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/dist/";
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(0);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ 0:
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(352);
- /***/ },
- /***/ 3:
- /***/ function(module, exports) {
- module.exports = function normalizeComponent (
- rawScriptExports,
- compiledTemplate,
- scopeId,
- cssModules
- ) {
- var esModule
- var scriptExports = rawScriptExports = rawScriptExports || {}
- // ES6 modules interop
- var type = typeof rawScriptExports.default
- if (type === 'object' || type === 'function') {
- esModule = rawScriptExports
- scriptExports = rawScriptExports.default
- }
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (compiledTemplate) {
- options.render = compiledTemplate.render
- options.staticRenderFns = compiledTemplate.staticRenderFns
- }
- // scopedId
- if (scopeId) {
- options._scopeId = scopeId
- }
- // inject cssModules
- if (cssModules) {
- var computed = options.computed || (options.computed = {})
- Object.keys(cssModules).forEach(function (key) {
- var module = cssModules[key]
- computed[key] = function () { return module }
- })
- }
- return {
- esModule: esModule,
- exports: scriptExports,
- options: options
- }
- }
- /***/ },
- /***/ 60:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/mixins/locale");
- /***/ },
- /***/ 352:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _src = __webpack_require__(353);
- var _src2 = _interopRequireDefault(_src);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- /* istanbul ignore next */
- _src2.default.install = function (Vue) {
- Vue.component(_src2.default.name, _src2.default);
- };
- exports.default = _src2.default;
- /***/ },
- /***/ 353:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(354),
- /* template */
- null,
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 354:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _uploadList = __webpack_require__(355);
- var _uploadList2 = _interopRequireDefault(_uploadList);
- var _upload = __webpack_require__(359);
- var _upload2 = _interopRequireDefault(_upload);
- var _iframeUpload = __webpack_require__(365);
- var _iframeUpload2 = _interopRequireDefault(_iframeUpload);
- var _progress = __webpack_require__(357);
- var _progress2 = _interopRequireDefault(_progress);
- var _migrating = __webpack_require__(367);
- var _migrating2 = _interopRequireDefault(_migrating);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function noop() {}
- exports.default = {
- name: 'ElUpload',
- mixins: [_migrating2.default],
- components: {
- ElProgress: _progress2.default,
- UploadList: _uploadList2.default,
- Upload: _upload2.default,
- IframeUpload: _iframeUpload2.default
- },
- props: {
- action: {
- type: String,
- required: true
- },
- headers: {
- type: Object,
- default: function _default() {
- return {};
- }
- },
- data: Object,
- multiple: Boolean,
- name: {
- type: String,
- default: 'file'
- },
- drag: Boolean,
- dragger: Boolean,
- withCredentials: Boolean,
- showFileList: {
- type: Boolean,
- default: true
- },
- accept: String,
- type: {
- type: String,
- default: 'select'
- },
- beforeUpload: Function,
- onRemove: {
- type: Function,
- default: noop
- },
- onChange: {
- type: Function,
- default: noop
- },
- onPreview: {
- type: Function
- },
- onSuccess: {
- type: Function,
- default: noop
- },
- onProgress: {
- type: Function,
- default: noop
- },
- onError: {
- type: Function,
- default: noop
- },
- fileList: {
- type: Array,
- default: function _default() {
- return [];
- }
- },
- autoUpload: {
- type: Boolean,
- default: true
- },
- listType: {
- type: String,
- default: 'text' // text,picture,picture-card
- },
- httpRequest: Function
- },
- data: function data() {
- return {
- uploadFiles: [],
- dragOver: false,
- draging: false,
- tempIndex: 1
- };
- },
- watch: {
- fileList: {
- immediate: true,
- handler: function handler(fileList) {
- var _this = this;
- this.uploadFiles = fileList.map(function (item) {
- item.uid = item.uid || Date.now() + _this.tempIndex++;
- item.status = 'success';
- return item;
- });
- }
- }
- },
- methods: {
- handleStart: function handleStart(rawFile) {
- rawFile.uid = Date.now() + this.tempIndex++;
- var file = {
- status: 'ready',
- name: rawFile.name,
- size: rawFile.size,
- percentage: 0,
- uid: rawFile.uid,
- raw: rawFile
- };
- try {
- file.url = URL.createObjectURL(rawFile);
- } catch (err) {
- console.error(err);
- return;
- }
- this.uploadFiles.push(file);
- },
- handleProgress: function handleProgress(ev, rawFile) {
- var file = this.getFile(rawFile);
- this.onProgress(ev, file, this.uploadFiles);
- file.status = 'uploading';
- file.percentage = ev.percent || 0;
- },
- handleSuccess: function handleSuccess(res, rawFile) {
- var file = this.getFile(rawFile);
- if (file) {
- file.status = 'success';
- file.response = res;
- this.onSuccess(res, file, this.uploadFiles);
- this.onChange(file, this.uploadFiles);
- }
- },
- handleError: function handleError(err, rawFile) {
- var file = this.getFile(rawFile);
- var fileList = this.uploadFiles;
- file.status = 'fail';
- fileList.splice(fileList.indexOf(file), 1);
- this.onError(err, file, this.uploadFiles);
- this.onChange(file, this.uploadFiles);
- },
- handleRemove: function handleRemove(file, raw) {
- if (raw) {
- file = this.getFile(raw);
- }
- var fileList = this.uploadFiles;
- fileList.splice(fileList.indexOf(file), 1);
- this.onRemove(file, fileList);
- },
- getFile: function getFile(rawFile) {
- var fileList = this.uploadFiles;
- var target;
- fileList.every(function (item) {
- target = rawFile.uid === item.uid ? item : null;
- return !target;
- });
- return target;
- },
- clearFiles: function clearFiles() {
- this.uploadFiles = [];
- },
- submit: function submit() {
- var _this2 = this;
- this.uploadFiles.filter(function (file) {
- return file.status === 'ready';
- }).forEach(function (file) {
- _this2.$refs['upload-inner'].upload(file.raw);
- });
- },
- getMigratingConfig: function getMigratingConfig() {
- return {
- props: {
- 'default-file-list': 'default-file-list is renamed to file-list.',
- 'show-upload-list': 'show-upload-list is renamed to show-file-list.',
- 'thumbnail-mode': 'thumbnail-mode has been deprecated, you can implement the same effect according to this case: http://element.eleme.io/#/zh-CN/component/upload#yong-hu-tou-xiang-shang-chuan'
- }
- };
- }
- },
- render: function render(h) {
- var uploadList;
- if (this.showFileList) {
- uploadList = h(
- _uploadList2.default,
- {
- attrs: {
- listType: this.listType,
- files: this.uploadFiles,
- handlePreview: this.onPreview },
- on: {
- 'remove': this.handleRemove
- }
- },
- []
- );
- }
- var uploadData = {
- props: {
- type: this.type,
- drag: this.drag,
- action: this.action,
- multiple: this.multiple,
- 'before-upload': this.beforeUpload,
- 'with-credentials': this.withCredentials,
- headers: this.headers,
- name: this.name,
- data: this.data,
- accept: this.accept,
- fileList: this.uploadFiles,
- autoUpload: this.autoUpload,
- listType: this.listType,
- 'on-start': this.handleStart,
- 'on-progress': this.handleProgress,
- 'on-success': this.handleSuccess,
- 'on-error': this.handleError,
- 'on-preview': this.onPreview,
- 'on-remove': this.handleRemove,
- 'http-request': this.httpRequest
- },
- ref: 'upload-inner'
- };
- var trigger = this.$slots.trigger || this.$slots.default;
- var uploadComponent = typeof FormData !== 'undefined' || this.$isServer ? h(
- 'upload',
- uploadData,
- [trigger]
- ) : h(
- 'iframeUpload',
- uploadData,
- [trigger]
- );
- return h(
- 'div',
- null,
- [this.listType === 'picture-card' ? uploadList : '', this.$slots.trigger ? [uploadComponent, this.$slots.default] : uploadComponent, this.$slots.tip, this.listType !== 'picture-card' ? uploadList : '']
- );
- }
- };
- /***/ },
- /***/ 355:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(356),
- /* template */
- __webpack_require__(358),
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 356:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _locale = __webpack_require__(60);
- var _locale2 = _interopRequireDefault(_locale);
- var _progress = __webpack_require__(357);
- var _progress2 = _interopRequireDefault(_progress);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- exports.default = {
- mixins: [_locale2.default],
- components: { ElProgress: _progress2.default },
- props: {
- files: {
- type: Array,
- default: function _default() {
- return [];
- }
- },
- handlePreview: Function,
- listType: String
- },
- methods: {
- parsePercentage: function parsePercentage(val) {
- return parseInt(val, 10);
- },
- handleClick: function handleClick(file) {
- this.handlePreview && this.handlePreview(file);
- }
- }
- };
- /***/ },
- /***/ 357:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/progress");
- /***/ },
- /***/ 358:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('transition-group', {
- class: ['el-upload-list', 'el-upload-list--' + _vm.listType],
- attrs: {
- "tag": "ul",
- "name": "list"
- }
- }, _vm._l((_vm.files), function(file) {
- return _c('li', {
- key: file,
- class: ['el-upload-list__item', 'is-' + file.status]
- }, [(['picture-card', 'picture'].indexOf(_vm.listType) > -1 && file.status === 'success') ? _c('img', {
- staticClass: "el-upload-list__item-thumbnail",
- attrs: {
- "src": file.url,
- "alt": ""
- }
- }) : _vm._e(), _c('a', {
- staticClass: "el-upload-list__item-name",
- on: {
- "click": function($event) {
- _vm.handleClick(file)
- }
- }
- }, [_c('i', {
- staticClass: "el-icon-document"
- }), _vm._v(_vm._s(file.name) + "\n ")]), _c('label', {
- directives: [{
- name: "show",
- rawName: "v-show",
- value: (file.status === 'success'),
- expression: "file.status === 'success'"
- }],
- staticClass: "el-upload-list__item-status-label"
- }, [_c('i', {
- class: {
- 'el-icon-circle-check': _vm.listType === 'text',
- 'el-icon-check': ['picture-card', 'picture'].indexOf(_vm.listType) > -1
- }
- }), _c('i', {
- staticClass: "el-icon-close",
- on: {
- "click": function($event) {
- _vm.$emit('remove', file)
- }
- }
- })]), (
- _vm.listType === 'picture-card' &&
- file.status === 'success'
- ) ? _c('span', {
- staticClass: "el-upload-list__item-actions"
- }, [(
- _vm.handlePreview &&
- _vm.listType === 'picture-card'
- ) ? _c('span', {
- staticClass: "el-upload-list__item-preview",
- on: {
- "click": function($event) {
- _vm.handlePreview(file)
- }
- }
- }, [_c('i', {
- staticClass: "el-icon-view"
- })]) : _vm._e(), _c('span', {
- staticClass: "el-upload-list__item-delete",
- on: {
- "click": function($event) {
- _vm.$emit('remove', file)
- }
- }
- }, [_c('i', {
- staticClass: "el-icon-delete2"
- })])]) : _vm._e(), (file.status === 'uploading') ? _c('el-progress', {
- attrs: {
- "type": _vm.listType === 'picture-card' ? 'circle' : 'line',
- "stroke-width": _vm.listType === 'picture-card' ? 6 : 2,
- "percentage": _vm.parsePercentage(file.percentage)
- }
- }) : _vm._e()], 1)
- }))
- },staticRenderFns: []}
- /***/ },
- /***/ 359:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(360),
- /* template */
- null,
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 360:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _ajax = __webpack_require__(361);
- var _ajax2 = _interopRequireDefault(_ajax);
- var _uploadDragger = __webpack_require__(362);
- var _uploadDragger2 = _interopRequireDefault(_uploadDragger);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = {
- components: {
- UploadDragger: _uploadDragger2.default
- },
- props: {
- type: String,
- action: {
- type: String,
- required: true
- },
- name: {
- type: String,
- default: 'file'
- },
- data: Object,
- headers: Object,
- withCredentials: Boolean,
- multiple: Boolean,
- accept: String,
- onStart: Function,
- onProgress: Function,
- onSuccess: Function,
- onError: Function,
- beforeUpload: Function,
- drag: Boolean,
- onPreview: {
- type: Function,
- default: function _default() {}
- },
- onRemove: {
- type: Function,
- default: function _default() {}
- },
- fileList: Array,
- autoUpload: Boolean,
- listType: String,
- httpRequest: {
- type: Function,
- default: _ajax2.default
- }
- },
- data: function data() {
- return {
- mouseover: false
- };
- },
- methods: {
- isImage: function isImage(str) {
- return str.indexOf('image') !== -1;
- },
- handleChange: function handleChange(ev) {
- var files = ev.target.files;
- if (!files) return;
- this.uploadFiles(files);
- this.$refs.input.value = null;
- },
- uploadFiles: function uploadFiles(files) {
- var _this = this;
- var postFiles = Array.prototype.slice.call(files);
- if (!this.multiple) {
- postFiles = postFiles.slice(0, 1);
- }
- if (postFiles.length === 0) {
- return;
- }
- postFiles.forEach(function (rawFile) {
- _this.onStart(rawFile);
- if (_this.autoUpload) _this.upload(rawFile);
- });
- },
- upload: function upload(rawFile, file) {
- var _this2 = this;
- if (!this.beforeUpload) {
- return this.post(rawFile);
- }
- var before = this.beforeUpload(rawFile);
- if (before && before.then) {
- before.then(function (processedFile) {
- if (Object.prototype.toString.call(processedFile) === '[object File]') {
- _this2.post(processedFile);
- } else {
- _this2.post(rawFile);
- }
- }, function () {
- _this2.onRemove(rawFile, true);
- });
- } else if (before !== false) {
- this.post(rawFile);
- } else {
- this.onRemove(rawFile, true);
- }
- },
- post: function post(rawFile) {
- var _this3 = this;
- var options = {
- headers: this.headers,
- withCredentials: this.withCredentials,
- file: rawFile,
- data: this.data,
- filename: this.name,
- action: this.action,
- onProgress: function onProgress(e) {
- _this3.onProgress(e, rawFile);
- },
- onSuccess: function onSuccess(res) {
- _this3.onSuccess(res, rawFile);
- },
- onError: function onError(err) {
- _this3.onError(err, rawFile);
- }
- };
- var requestPromise = this.httpRequest(options);
- if (requestPromise && requestPromise.then) {
- requestPromise.then(options.onSuccess, options.onError);
- }
- },
- handleClick: function handleClick() {
- this.$refs.input.click();
- }
- },
- render: function render(h) {
- var handleClick = this.handleClick,
- drag = this.drag,
- handleChange = this.handleChange,
- multiple = this.multiple,
- accept = this.accept,
- listType = this.listType,
- uploadFiles = this.uploadFiles;
- var data = {
- class: {
- 'el-upload': true
- },
- on: {
- click: handleClick
- }
- };
- data.class['el-upload--' + listType] = true;
- return h(
- 'div',
- data,
- [drag ? h(
- 'upload-dragger',
- {
- on: {
- 'file': uploadFiles
- }
- },
- [this.$slots.default]
- ) : this.$slots.default, h(
- 'input',
- { 'class': 'el-upload__input', attrs: { type: 'file', multiple: multiple, accept: accept },
- ref: 'input', on: {
- 'change': handleChange
- }
- },
- []
- )]
- );
- }
- };
- /***/ },
- /***/ 361:
- /***/ function(module, exports) {
- 'use strict';
- exports.__esModule = true;
- exports.default = upload;
- function getError(action, option, xhr) {
- var msg = void 0;
- if (xhr.response) {
- msg = xhr.status + ' ' + (xhr.response.error || xhr.response);
- } else if (xhr.responseText) {
- msg = xhr.status + ' ' + xhr.responseText;
- } else {
- msg = 'fail to post ' + action + ' ' + xhr.status + '\'';
- }
- var err = new Error(msg);
- err.status = xhr.status;
- err.method = 'post';
- err.url = action;
- return err;
- }
- function getBody(xhr) {
- var text = xhr.responseText || xhr.response;
- if (!text) {
- return text;
- }
- try {
- return JSON.parse(text);
- } catch (e) {
- return text;
- }
- }
- function upload(option) {
- if (typeof XMLHttpRequest === 'undefined') {
- return;
- }
- var xhr = new XMLHttpRequest();
- var action = option.action;
- if (xhr.upload) {
- xhr.upload.onprogress = function progress(e) {
- if (e.total > 0) {
- e.percent = e.loaded / e.total * 100;
- }
- option.onProgress(e);
- };
- }
- var formData = new FormData();
- if (option.data) {
- Object.keys(option.data).map(function (key) {
- formData.append(key, option.data[key]);
- });
- }
- formData.append(option.filename, option.file);
- xhr.onerror = function error(e) {
- option.onError(e);
- };
- xhr.onload = function onload() {
- if (xhr.status < 200 || xhr.status >= 300) {
- return option.onError(getError(action, option, xhr));
- }
- option.onSuccess(getBody(xhr));
- };
- xhr.open('post', action, true);
- if (option.withCredentials && 'withCredentials' in xhr) {
- xhr.withCredentials = true;
- }
- var headers = option.headers || {};
- for (var item in headers) {
- if (headers.hasOwnProperty(item) && headers[item] !== null) {
- xhr.setRequestHeader(item, headers[item]);
- }
- }
- xhr.send(formData);
- return xhr;
- }
- /***/ },
- /***/ 362:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(363),
- /* template */
- __webpack_require__(364),
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 363:
- /***/ function(module, exports) {
- 'use strict';
- exports.__esModule = true;
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- exports.default = {
- name: 'ElUploadDrag',
- data: function data() {
- return {
- dragover: false
- };
- },
- methods: {
- onDrop: function onDrop(e) {
- this.dragover = false;
- this.$emit('file', e.dataTransfer.files);
- }
- }
- };
- /***/ },
- /***/ 364:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('div', {
- staticClass: "el-upload-dragger",
- class: {
- 'is-dragover': _vm.dragover
- },
- on: {
- "drop": function($event) {
- $event.preventDefault();
- _vm.onDrop($event)
- },
- "dragover": function($event) {
- $event.preventDefault();
- _vm.dragover = true
- },
- "dragleave": function($event) {
- $event.preventDefault();
- _vm.dragover = false
- }
- }
- }, [_vm._t("default")], 2)
- },staticRenderFns: []}
- /***/ },
- /***/ 365:
- /***/ function(module, exports, __webpack_require__) {
- var Component = __webpack_require__(3)(
- /* script */
- __webpack_require__(366),
- /* template */
- null,
- /* scopeId */
- null,
- /* cssModules */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 366:
- /***/ function(module, exports, __webpack_require__) {
- 'use strict';
- exports.__esModule = true;
- var _uploadDragger = __webpack_require__(362);
- var _uploadDragger2 = _interopRequireDefault(_uploadDragger);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- exports.default = {
- components: {
- UploadDragger: _uploadDragger2.default
- },
- props: {
- type: String,
- data: {},
- action: {
- type: String,
- required: true
- },
- name: {
- type: String,
- default: 'file'
- },
- withCredentials: Boolean,
- accept: String,
- onStart: Function,
- onProgress: Function,
- onSuccess: Function,
- onError: Function,
- beforeUpload: Function,
- onPreview: {
- type: Function,
- default: function _default() {}
- },
- onRemove: {
- type: Function,
- default: function _default() {}
- },
- drag: Boolean,
- listType: String
- },
- data: function data() {
- return {
- mouseover: false,
- domain: '',
- file: null,
- disabled: false
- };
- },
- methods: {
- isImage: function isImage(str) {
- return str.indexOf('image') !== -1;
- },
- handleClick: function handleClick() {
- this.$refs.input.click();
- },
- handleChange: function handleChange(ev) {
- var file = ev.target.value;
- if (file) {
- this.uploadFiles(file);
- }
- },
- uploadFiles: function uploadFiles(file) {
- if (this.disabled) return;
- this.disabled = true;
- this.file = file;
- this.onStart(file);
- var formNode = this.getFormNode();
- var dataSpan = this.getFormDataNode();
- var data = this.data;
- if (typeof data === 'function') {
- data = data(file);
- }
- var inputs = [];
- for (var key in data) {
- if (data.hasOwnProperty(key)) {
- inputs.push('<input name="' + key + '" value="' + data[key] + '"/>');
- }
- }
- dataSpan.innerHTML = inputs.join('');
- formNode.submit();
- dataSpan.innerHTML = '';
- },
- getFormNode: function getFormNode() {
- return this.$refs.form;
- },
- getFormDataNode: function getFormDataNode() {
- return this.$refs.data;
- }
- },
- created: function created() {
- this.frameName = 'frame-' + Date.now();
- },
- mounted: function mounted() {
- var self = this;
- !this.$isServer && window.addEventListener('message', function (event) {
- if (!self.file) return;
- var targetOrigin = new URL(self.action).origin;
- if (event.origin !== targetOrigin) return;
- var response = event.data;
- if (response.result === 'success') {
- self.onSuccess(response, self.file);
- } else if (response.result === 'failed') {
- self.onError(response, self.file);
- }
- self.disabled = false;
- self.file = null;
- }, false);
- },
- render: function render(h) {
- var drag = this.drag,
- uploadFiles = this.uploadFiles,
- listType = this.listType,
- frameName = this.frameName;
- var oClass = { 'el-upload': true };
- oClass['el-upload--' + listType] = true;
- return h(
- 'div',
- {
- 'class': oClass,
- on: {
- 'click': this.handleClick
- },
- nativeOn: {
- 'drop': this.onDrop,
- 'dragover': this.handleDragover,
- 'dragleave': this.handleDragleave
- }
- },
- [h(
- 'iframe',
- {
- on: {
- 'load': this.onload
- },
- ref: 'iframe',
- attrs: { name: frameName
- }
- },
- []
- ), h(
- 'form',
- { ref: 'form', attrs: { action: this.action, target: frameName, enctype: 'multipart/form-data', method: 'POST' }
- },
- [h(
- 'input',
- {
- 'class': 'el-upload__input',
- attrs: { type: 'file',
- name: 'file',
- accept: this.accept },
- ref: 'input', on: {
- 'change': this.handleChange
- }
- },
- []
- ), h(
- 'input',
- {
- attrs: { type: 'hidden', name: 'documentDomain', value: this.$isServer ? '' : document.domain }
- },
- []
- ), h(
- 'span',
- { ref: 'data' },
- []
- )]
- ), drag ? h(
- 'upload-dragger',
- {
- on: {
- 'file': uploadFiles
- }
- },
- [this.$slots.default]
- ) : this.$slots.default]
- );
- }
- };
- /***/ },
- /***/ 367:
- /***/ function(module, exports) {
- module.exports = require("element-ui/lib/mixins/migrating");
- /***/ }
- /******/ });
|