1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408 |
- 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] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = 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;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "/dist/";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 57);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ 0:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return normalizeComponent; });
- /* globals __VUE_SSR_CONTEXT__ */
- // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
- // This module is a runtime utility for cleaner component module output and will
- // be included in the final webpack user bundle.
- function normalizeComponent (
- scriptExports,
- render,
- staticRenderFns,
- functionalTemplate,
- injectStyles,
- scopeId,
- moduleIdentifier, /* server only */
- shadowMode /* vue-cli only */
- ) {
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (render) {
- options.render = render
- options.staticRenderFns = staticRenderFns
- options._compiled = true
- }
- // functional template
- if (functionalTemplate) {
- options.functional = true
- }
- // scopedId
- if (scopeId) {
- options._scopeId = 'data-v-' + scopeId
- }
- var hook
- if (moduleIdentifier) { // server build
- hook = function (context) {
- // 2.3 injection
- context =
- context || // cached call
- (this.$vnode && this.$vnode.ssrContext) || // stateful
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
- // 2.2 with runInNewContext: true
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
- context = __VUE_SSR_CONTEXT__
- }
- // inject component styles
- if (injectStyles) {
- injectStyles.call(this, context)
- }
- // register component module identifier for async chunk inferrence
- if (context && context._registeredComponents) {
- context._registeredComponents.add(moduleIdentifier)
- }
- }
- // used by ssr in case component is cached and beforeCreate
- // never gets called
- options._ssrRegister = hook
- } else if (injectStyles) {
- hook = shadowMode
- ? function () { injectStyles.call(this, this.$root.$options.shadowRoot) }
- : injectStyles
- }
- if (hook) {
- if (options.functional) {
- // for template-only hot-reload because in that case the render fn doesn't
- // go through the normalizer
- options._injectStyles = hook
- // register for functioal component in vue file
- var originalRender = options.render
- options.render = function renderWithStyleInjection (h, context) {
- hook.call(context)
- return originalRender(h, context)
- }
- } else {
- // inject component registration as beforeCreate hook
- var existing = options.beforeCreate
- options.beforeCreate = existing
- ? [].concat(existing, hook)
- : [hook]
- }
- }
- return {
- exports: scriptExports,
- options: options
- }
- }
- /***/ }),
- /***/ 11:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/mixins/migrating");
- /***/ }),
- /***/ 26:
- /***/ (function(module, exports) {
- module.exports = require("babel-helper-vue-jsx-merge-props");
- /***/ }),
- /***/ 42:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/progress");
- /***/ }),
- /***/ 57:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- __webpack_require__.r(__webpack_exports__);
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload-list.vue?vue&type=template&id=173fedf5&
- var upload_listvue_type_template_id_173fedf5_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,
- { "is-disabled": _vm.disabled }
- ],
- attrs: { tag: "ul", name: "el-list" }
- },
- _vm._l(_vm.files, function(file) {
- return _c(
- "li",
- {
- key: file.uid,
- class: [
- "el-upload-list__item",
- "is-" + file.status,
- _vm.focusAble && _vm.focusing ? "focusing" : ""
- ],
- attrs: { tabindex: "0" },
- on: {
- keydown: function($event) {
- if (
- !("button" in $event) &&
- _vm._k($event.keyCode, "delete", [8, 46], $event.key, [
- "Backspace",
- "Delete",
- "Del"
- ])
- ) {
- return null
- }
- !_vm.disabled && _vm.$emit("remove", file)
- },
- focus: function($event) {
- _vm.focusing = true
- },
- blur: function($event) {
- _vm.focusing = false
- },
- click: function($event) {
- _vm.focusing = false
- }
- }
- },
- [
- _vm._t(
- "default",
- [
- file.status !== "uploading" &&
- ["picture-card", "picture"].indexOf(_vm.listType) > -1
- ? _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, $event)
- }
- }
- },
- [
- _c("i", { staticClass: "el-icon-document" }),
- _vm._v(_vm._s(file.name) + "\n ")
- ]
- ),
- _c(
- "label",
- { staticClass: "el-upload-list__item-status-label" },
- [
- _c("i", {
- class: {
- "el-icon-upload-success": true,
- "el-icon-circle-check": _vm.listType === "text",
- "el-icon-check":
- ["picture-card", "picture"].indexOf(_vm.listType) > -1
- }
- })
- ]
- ),
- !_vm.disabled
- ? _c("i", {
- staticClass: "el-icon-close",
- on: {
- click: function($event) {
- _vm.$emit("remove", file)
- }
- }
- })
- : _vm._e(),
- !_vm.disabled
- ? _c("i", { staticClass: "el-icon-close-tip" }, [
- _vm._v(_vm._s(_vm.t("el.upload.deleteTip")))
- ])
- : _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(),
- _vm.listType === "picture-card"
- ? _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, $event)
- }
- }
- },
- [_c("i", { staticClass: "el-icon-zoom-in" })]
- )
- : _vm._e(),
- !_vm.disabled
- ? _c(
- "span",
- {
- staticClass: "el-upload-list__item-delete",
- on: {
- click: function($event) {
- _vm.$emit("remove", file)
- }
- }
- },
- [_c("i", { staticClass: "el-icon-delete" })]
- )
- : _vm._e()
- ])
- : _vm._e()
- ],
- { file: file }
- )
- ],
- 2
- )
- }),
- 0
- )
- }
- var staticRenderFns = []
- upload_listvue_type_template_id_173fedf5_render._withStripped = true
- // CONCATENATED MODULE: ./packages/upload/src/upload-list.vue?vue&type=template&id=173fedf5&
- // EXTERNAL MODULE: external "element-ui/lib/mixins/locale"
- var locale_ = __webpack_require__(6);
- var locale_default = /*#__PURE__*/__webpack_require__.n(locale_);
- // EXTERNAL MODULE: external "element-ui/lib/progress"
- var progress_ = __webpack_require__(42);
- var progress_default = /*#__PURE__*/__webpack_require__.n(progress_);
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload-list.vue?vue&type=script&lang=js&
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- /* harmony default export */ var upload_listvue_type_script_lang_js_ = ({
- name: 'ElUploadList',
- mixins: [locale_default.a],
- data: function data() {
- return {
- focusing: false
- };
- },
- components: { ElProgress: progress_default.a },
- props: {
- files: {
- type: Array,
- default: function _default() {
- return [];
- }
- },
- disabled: {
- type: Boolean,
- default: false
- },
- handlePreview: Function,
- listType: String,
- focusAble: {
- type: Boolean,
- default: true
- }
- },
- methods: {
- parsePercentage: function parsePercentage(val) {
- return parseInt(val, 10);
- },
- handleClick: function handleClick(file, event) {
- this.handlePreview && this.handlePreview(file, event);
- }
- }
- });
- // CONCATENATED MODULE: ./packages/upload/src/upload-list.vue?vue&type=script&lang=js&
- /* harmony default export */ var src_upload_listvue_type_script_lang_js_ = (upload_listvue_type_script_lang_js_);
- // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
- var componentNormalizer = __webpack_require__(0);
- // CONCATENATED MODULE: ./packages/upload/src/upload-list.vue
- /* normalize component */
- var component = Object(componentNormalizer["a" /* default */])(
- src_upload_listvue_type_script_lang_js_,
- upload_listvue_type_template_id_173fedf5_render,
- staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var api; }
- component.options.__file = "packages/upload/src/upload-list.vue"
- /* harmony default export */ var upload_list = (component.exports);
- // EXTERNAL MODULE: external "babel-helper-vue-jsx-merge-props"
- var external_babel_helper_vue_jsx_merge_props_ = __webpack_require__(26);
- var external_babel_helper_vue_jsx_merge_props_default = /*#__PURE__*/__webpack_require__.n(external_babel_helper_vue_jsx_merge_props_);
- // CONCATENATED MODULE: ./packages/upload/src/ajax.js
- function getError(action, option, xhr) {
- var msg = void 0;
- if (xhr.response) {
- msg = '' + (xhr.response.error || xhr.response);
- } else if (xhr.responseText) {
- msg = '' + 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).forEach(function (key) {
- formData.append(key, option.data[key]);
- });
- }
- formData.append(option.filename, option.file, option.file.name);
- 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;
- }
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload-dragger.vue?vue&type=template&id=7ebbf219&
- var upload_draggervue_type_template_id_7ebbf219_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()
- return _vm.onDrop($event)
- },
- dragover: function($event) {
- $event.preventDefault()
- return _vm.onDragover($event)
- },
- dragleave: function($event) {
- $event.preventDefault()
- _vm.dragover = false
- }
- }
- },
- [_vm._t("default")],
- 2
- )
- }
- var upload_draggervue_type_template_id_7ebbf219_staticRenderFns = []
- upload_draggervue_type_template_id_7ebbf219_render._withStripped = true
- // CONCATENATED MODULE: ./packages/upload/src/upload-dragger.vue?vue&type=template&id=7ebbf219&
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload-dragger.vue?vue&type=script&lang=js&
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- /* harmony default export */ var upload_draggervue_type_script_lang_js_ = ({
- name: 'ElUploadDrag',
- props: {
- disabled: Boolean
- },
- inject: {
- uploader: {
- default: ''
- }
- },
- data: function data() {
- return {
- dragover: false
- };
- },
- methods: {
- onDragover: function onDragover() {
- if (!this.disabled) {
- this.dragover = true;
- }
- },
- onDrop: function onDrop(e) {
- if (this.disabled || !this.uploader) return;
- var accept = this.uploader.accept;
- this.dragover = false;
- if (!accept) {
- this.$emit('file', e.dataTransfer.files);
- return;
- }
- this.$emit('file', [].slice.call(e.dataTransfer.files).filter(function (file) {
- var type = file.type,
- name = file.name;
- var extension = name.indexOf('.') > -1 ? '.' + name.split('.').pop() : '';
- var baseType = type.replace(/\/.*$/, '');
- return accept.split(',').map(function (type) {
- return type.trim();
- }).filter(function (type) {
- return type;
- }).some(function (acceptedType) {
- if (/\..+$/.test(acceptedType)) {
- return extension === acceptedType;
- }
- if (/\/\*$/.test(acceptedType)) {
- return baseType === acceptedType.replace(/\/\*$/, '');
- }
- if (/^[^\/]+\/[^\/]+$/.test(acceptedType)) {
- return type === acceptedType;
- }
- return false;
- });
- }));
- }
- }
- });
- // CONCATENATED MODULE: ./packages/upload/src/upload-dragger.vue?vue&type=script&lang=js&
- /* harmony default export */ var src_upload_draggervue_type_script_lang_js_ = (upload_draggervue_type_script_lang_js_);
- // CONCATENATED MODULE: ./packages/upload/src/upload-dragger.vue
- /* normalize component */
- var upload_dragger_component = Object(componentNormalizer["a" /* default */])(
- src_upload_draggervue_type_script_lang_js_,
- upload_draggervue_type_template_id_7ebbf219_render,
- upload_draggervue_type_template_id_7ebbf219_staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var upload_dragger_api; }
- upload_dragger_component.options.__file = "packages/upload/src/upload-dragger.vue"
- /* harmony default export */ var upload_dragger = (upload_dragger_component.exports);
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/upload.vue?vue&type=script&lang=js&
- /* harmony default export */ var uploadvue_type_script_lang_js_ = ({
- inject: ['uploader'],
- components: {
- UploadDragger: upload_dragger
- },
- 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: upload
- },
- disabled: Boolean,
- limit: Number,
- onExceed: Function
- },
- data: function data() {
- return {
- mouseover: false,
- reqs: {}
- };
- },
- 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);
- },
- uploadFiles: function uploadFiles(files) {
- var _this = this;
- if (this.limit && this.fileList.length + files.length > this.limit) {
- this.onExceed && this.onExceed(files, this.fileList);
- return;
- }
- 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) {
- var _this2 = this;
- this.$refs.input.value = null;
- if (!this.beforeUpload) {
- return this.post(rawFile);
- }
- var before = this.beforeUpload(rawFile);
- if (before && before.then) {
- before.then(function (processedFile) {
- var fileType = Object.prototype.toString.call(processedFile);
- if (fileType === '[object File]' || fileType === '[object Blob]') {
- if (fileType === '[object Blob]') {
- processedFile = new File([processedFile], rawFile.name, {
- type: rawFile.type
- });
- }
- for (var p in rawFile) {
- if (rawFile.hasOwnProperty(p)) {
- processedFile[p] = rawFile[p];
- }
- }
- _this2.post(processedFile);
- } else {
- _this2.post(rawFile);
- }
- }, function () {
- _this2.onRemove(null, rawFile);
- });
- } else if (before !== false) {
- this.post(rawFile);
- } else {
- this.onRemove(null, rawFile);
- }
- },
- abort: function abort(file) {
- var reqs = this.reqs;
- if (file) {
- var uid = file;
- if (file.uid) uid = file.uid;
- if (reqs[uid]) {
- reqs[uid].abort();
- }
- } else {
- Object.keys(reqs).forEach(function (uid) {
- if (reqs[uid]) reqs[uid].abort();
- delete reqs[uid];
- });
- }
- },
- post: function post(rawFile) {
- var _this3 = this;
- var uid = rawFile.uid;
- 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);
- delete _this3.reqs[uid];
- },
- onError: function onError(err) {
- _this3.onError(err, rawFile);
- delete _this3.reqs[uid];
- }
- };
- var req = this.httpRequest(options);
- this.reqs[uid] = req;
- if (req && req.then) {
- req.then(options.onSuccess, options.onError);
- }
- },
- handleClick: function handleClick() {
- if (!this.disabled) {
- this.$refs.input.value = null;
- this.$refs.input.click();
- }
- },
- handleKeydown: function handleKeydown(e) {
- if (e.target !== e.currentTarget) return;
- if (e.keyCode === 13 || e.keyCode === 32) {
- this.handleClick();
- }
- }
- },
- render: function render(h) {
- var handleClick = this.handleClick,
- drag = this.drag,
- name = this.name,
- handleChange = this.handleChange,
- multiple = this.multiple,
- accept = this.accept,
- listType = this.listType,
- uploadFiles = this.uploadFiles,
- disabled = this.disabled,
- handleKeydown = this.handleKeydown;
- var data = {
- class: {
- 'el-upload': true
- },
- on: {
- click: handleClick,
- keydown: handleKeydown
- }
- };
- data.class['el-upload--' + listType] = true;
- return h(
- 'div',
- external_babel_helper_vue_jsx_merge_props_default()([data, {
- attrs: { tabindex: '0' }
- }]),
- [drag ? h(
- 'upload-dragger',
- {
- attrs: { disabled: disabled },
- on: {
- 'file': uploadFiles
- }
- },
- [this.$slots.default]
- ) : this.$slots.default, h('input', { 'class': 'el-upload__input', attrs: { type: 'file', name: name, multiple: multiple, accept: accept },
- ref: 'input', on: {
- 'change': handleChange
- }
- })]
- );
- }
- });
- // CONCATENATED MODULE: ./packages/upload/src/upload.vue?vue&type=script&lang=js&
- /* harmony default export */ var src_uploadvue_type_script_lang_js_ = (uploadvue_type_script_lang_js_);
- // CONCATENATED MODULE: ./packages/upload/src/upload.vue
- var upload_render, upload_staticRenderFns
- /* normalize component */
- var upload_component = Object(componentNormalizer["a" /* default */])(
- src_uploadvue_type_script_lang_js_,
- upload_render,
- upload_staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var upload_api; }
- upload_component.options.__file = "packages/upload/src/upload.vue"
- /* harmony default export */ var src_upload = (upload_component.exports);
- // EXTERNAL MODULE: external "element-ui/lib/mixins/migrating"
- var migrating_ = __webpack_require__(11);
- var migrating_default = /*#__PURE__*/__webpack_require__.n(migrating_);
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/upload/src/index.vue?vue&type=script&lang=js&
- function noop() {}
- /* harmony default export */ var srcvue_type_script_lang_js_ = ({
- name: 'ElUpload',
- mixins: [migrating_default.a],
- components: {
- ElProgress: progress_default.a,
- UploadList: upload_list,
- Upload: src_upload
- },
- provide: function provide() {
- return {
- uploader: this
- };
- },
- inject: {
- elForm: {
- 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,
- beforeRemove: 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
- },
- focusAble: {
- type: Boolean,
- default: true
- },
- fileList: {
- type: Array,
- default: function _default() {
- return [];
- }
- },
- autoUpload: {
- type: Boolean,
- default: true
- },
- listType: {
- type: String,
- default: 'text' // text,picture,picture-card
- },
- httpRequest: Function,
- disabled: Boolean,
- limit: Number,
- onExceed: {
- type: Function,
- default: noop
- }
- },
- data: function data() {
- return {
- uploadFiles: [],
- dragOver: false,
- draging: false,
- tempIndex: 1
- };
- },
- computed: {
- uploadDisabled: function uploadDisabled() {
- return this.disabled || (this.elForm || {}).disabled;
- }
- },
- watch: {
- listType: function listType(type) {
- if (type === 'picture-card' || type === 'picture') {
- this.uploadFiles = this.uploadFiles.map(function (file) {
- if (!file.url && file.raw) {
- try {
- file.url = URL.createObjectURL(file.raw);
- } catch (err) {
- console.error('[Element Error][Upload]', err);
- }
- }
- return file;
- });
- }
- },
- 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 = 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
- };
- if (this.listType === 'picture-card' || this.listType === 'picture') {
- try {
- file.url = URL.createObjectURL(rawFile);
- } catch (err) {
- console.error('[Element Error][Upload]', err);
- return;
- }
- }
- this.uploadFiles.push(file);
- this.onChange(file, this.uploadFiles);
- },
- 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) {
- var _this2 = this;
- if (raw) {
- file = this.getFile(raw);
- }
- var doRemove = function doRemove() {
- _this2.abort(file);
- var fileList = _this2.uploadFiles;
- fileList.splice(fileList.indexOf(file), 1);
- _this2.onRemove(file, fileList);
- };
- if (!this.beforeRemove) {
- doRemove();
- } else if (typeof this.beforeRemove === 'function') {
- var before = this.beforeRemove(file, this.uploadFiles);
- if (before && before.then) {
- before.then(function () {
- doRemove();
- }, noop);
- } else if (before !== false) {
- doRemove();
- }
- }
- },
- getFile: function getFile(rawFile) {
- var fileList = this.uploadFiles;
- var target = void 0;
- fileList.every(function (item) {
- target = rawFile.uid === item.uid ? item : null;
- return !target;
- });
- return target;
- },
- abort: function abort(file) {
- this.$refs['upload-inner'].abort(file);
- },
- clearFiles: function clearFiles() {
- this.uploadFiles = [];
- },
- submit: function submit() {
- var _this3 = this;
- this.uploadFiles.filter(function (file) {
- return file.status === 'ready';
- }).forEach(function (file) {
- _this3.$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'
- }
- };
- }
- },
- beforeDestroy: function beforeDestroy() {
- this.uploadFiles.forEach(function (file) {
- if (file.url && file.url.indexOf('blob:') === 0) {
- URL.revokeObjectURL(file.url);
- }
- });
- },
- render: function render(h) {
- var _this4 = this;
- var uploadList = void 0;
- if (this.showFileList) {
- uploadList = h(
- upload_list,
- {
- attrs: {
- disabled: this.uploadDisabled,
- listType: this.listType,
- files: this.uploadFiles,
- focusAble: this.focusAble,
- handlePreview: this.onPreview },
- on: {
- 'remove': this.handleRemove
- }
- },
- [function (props) {
- if (_this4.$scopedSlots.file) {
- return _this4.$scopedSlots.file({
- file: props.file
- });
- }
- }]
- );
- }
- 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,
- disabled: this.uploadDisabled,
- limit: this.limit,
- 'on-exceed': this.onExceed,
- '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,
- focusAble: this.focusAble
- },
- ref: 'upload-inner'
- };
- var trigger = this.$slots.trigger || this.$slots.default;
- var uploadComponent = h(
- 'upload',
- uploadData,
- [trigger]
- );
- return h('div', [this.listType === 'picture-card' ? uploadList : '', this.$slots.trigger ? [uploadComponent, this.$slots.default] : uploadComponent, this.$slots.tip, this.listType !== 'picture-card' ? uploadList : '']);
- }
- });
- // CONCATENATED MODULE: ./packages/upload/src/index.vue?vue&type=script&lang=js&
- /* harmony default export */ var upload_srcvue_type_script_lang_js_ = (srcvue_type_script_lang_js_);
- // CONCATENATED MODULE: ./packages/upload/src/index.vue
- var src_render, src_staticRenderFns
- /* normalize component */
- var src_component = Object(componentNormalizer["a" /* default */])(
- upload_srcvue_type_script_lang_js_,
- src_render,
- src_staticRenderFns,
- false,
- null,
- null,
- null
-
- )
- /* hot reload */
- if (false) { var src_api; }
- src_component.options.__file = "packages/upload/src/index.vue"
- /* harmony default export */ var src = (src_component.exports);
- // CONCATENATED MODULE: ./packages/upload/index.js
- /* istanbul ignore next */
- src.install = function (Vue) {
- Vue.component(src.name, src);
- };
- /* harmony default export */ var packages_upload = __webpack_exports__["default"] = (src);
- /***/ }),
- /***/ 6:
- /***/ (function(module, exports) {
- module.exports = require("element-ui/lib/mixins/locale");
- /***/ })
- /******/ });
|