UNPKG

@ykcl/smart-ui-oversea

Version:

A Component Library for Vue.js.

1,842 lines (1,666 loc) 79.2 kB
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 = 111); /******/ }) /************************************************************************/ /******/ ({ /***/ 0: /***/ (function(module, exports) { module.exports = require("vue"); /***/ }), /***/ 11: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // EXPORTS __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ t; }); // UNUSED EXPORTS: use, i18n // CONCATENATED MODULE: ./src/locale/lang/zh-CN.js /* harmony default export */ var zh_CN = ({ el: { colorpicker: { confirm: '确定', clear: '清空' }, datepicker: { now: '此刻', today: '今天', cancel: '取消', clear: '清空', confirm: '确定', selectDate: '选择日期', selectTime: '选择时间', startDate: '开始日期', startTime: '开始时间', endDate: '结束日期', endTime: '结束时间', prevYear: '前一年', nextYear: '后一年', prevMonth: '上个月', nextMonth: '下个月', year: '年', month1: '1 月', month2: '2 月', month3: '3 月', month4: '4 月', month5: '5 月', month6: '6 月', month7: '7 月', month8: '8 月', month9: '9 月', month10: '10 月', month11: '11 月', month12: '12 月', // week: '周次', weeks: { sun: '日', mon: '一', tue: '二', wed: '三', thu: '四', fri: '五', sat: '六' }, months: { jan: '一月', feb: '二月', mar: '三月', apr: '四月', may: '五月', jun: '六月', jul: '七月', aug: '八月', sep: '九月', oct: '十月', nov: '十一月', dec: '十二月' }, shortcuts: { Today: '今天', Yestoday: '昨天', FirstSecondDay: '前两天', FirstThreeDays: '前三天', LastThreeDays: '近三天', LastSevenDays: '近七天', ThisWeek: '本周', LastSecondWeek: '近两周', LastThirdWeek: '近三周', LastWeek: '上周', ThisMoth: '本月', LastMonth: '上月', LastSecondMonth: '近两月', LastThreeMonths: '近三月', LastSixMonths: '近六月' } }, select: { loading: '加载中', noMatch: '无匹配数据', noData: '无数据', placeholder: '请选择' }, cascader: { noMatch: '无匹配数据', loading: '加载中', placeholder: '请选择', noData: '暂无数据' }, pagination: { goto: '前往', pagesize: '条/页', total: '共 {total} 条', pageClassifier: '页' }, messagebox: { title: '提示', confirm: '确定', cancel: '取消', error: '输入的数据不合法!' }, upload: { deleteTip: '按 delete 键可删除', delete: '删除', preview: '查看图片', continue: '继续上传' }, table: { emptyText: '暂无数据', confirmFilter: '筛选', resetFilter: '重置', clearFilter: '全部', sumText: '合计', tableSize: '表格显示', large: '大', medium: '中', small: '小', customize: '自定义显示' }, tree: { emptyText: '暂无数据' }, transfer: { noMatch: '无匹配数据', noData: '无数据', titles: ['列表 1', '列表 2'], filterPlaceholder: '请输入搜索内容', noCheckedFormat: '共 {total} 项', hasCheckedFormat: '已选 {checked}/{total} 项' }, image: { error: '加载失败' }, pageHeader: { title: '返回' }, popconfirm: { confirmButtonText: '确认', cancelButtonText: '取消' }, empty: { description: '暂无数据' } } }); // EXTERNAL MODULE: external "vue" var external_vue_ = __webpack_require__(0); var external_vue_default = /*#__PURE__*/__webpack_require__.n(external_vue_); // EXTERNAL MODULE: external "deepmerge" var external_deepmerge_ = __webpack_require__(17); var external_deepmerge_default = /*#__PURE__*/__webpack_require__.n(external_deepmerge_); // EXTERNAL MODULE: ./src/utils/util.js var util = __webpack_require__(3); // CONCATENATED MODULE: ./src/locale/format.js var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var RE_NARGS = /(%|)\{([0-9a-zA-Z_]+)\}/g; /** * String format template * - Inspired: * https://github.com/Matt-Esch/string-template/index.js */ /* harmony default export */ var format = (function (Vue) { /** * template * * @param {String} string * @param {Array} ...args * @return {String} */ function template(string) { for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } if (args.length === 1 && _typeof(args[0]) === 'object') { args = args[0]; } if (!args || !args.hasOwnProperty) { args = {}; } return string.replace(RE_NARGS, function (match, prefix, i, index) { var result = void 0; if (string[index - 1] === '{' && string[index + match.length] === '}') { return i; } else { result = Object(util["k" /* hasOwn */])(args, i) ? args[i] : null; if (result === null || result === undefined) { return ''; } return result; } }); } return template; }); // CONCATENATED MODULE: ./src/locale/index.js var locale_format = format(external_vue_default.a); var lang = zh_CN; var merged = false; var locale_i18nHandler = function i18nHandler() { var vuei18n = Object.getPrototypeOf(this || external_vue_default.a).$t; if (typeof vuei18n === 'function' && !!external_vue_default.a.locale) { if (!merged) { merged = true; external_vue_default.a.locale(external_vue_default.a.config.lang, external_deepmerge_default()(lang, external_vue_default.a.locale(external_vue_default.a.config.lang) || {}, { clone: true })); } return vuei18n.apply(this, arguments); } }; var t = function t(path, options) { var value = locale_i18nHandler.apply(this, arguments); if (value !== null && value !== undefined) return value; var array = path.split('.'); var current = lang; for (var i = 0, j = array.length; i < j; i++) { var property = array[i]; value = current[property]; if (i === j - 1) return locale_format(value, options); if (!value) return ''; current = value; } return ''; }; var use = function use(l) { lang = l || lang; }; var i18n = function i18n(fn) { locale_i18nHandler = fn || locale_i18nHandler; }; /* harmony default export */ var locale = ({ use: use, t: t, i18n: i18n }); /***/ }), /***/ 111: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/_vue-loader@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/upload/src/upload-list.vue?vue&type=template&id=f886b546 var upload_listvue_type_template_id_f886b546_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "transition-group", { class: [ "yk-upload-list", "yk-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: [ "yk-upload-list__item", "is-" + file.status, _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" && file.status !== "fail" && ["picture-card", "picture"].indexOf(_vm.listType) > -1 ? _c("img", { staticClass: "yk-upload-list__item-thumbnail", attrs: { src: file.url, alt: "" }, }) : _vm._e(), (file.status === "uploading" || file.status === "fail") && ["picture"].indexOf(_vm.listType) > -1 ? _c( "div", { staticClass: "yk-upload-list__item-placeholder" }, [ _c("i", { staticClass: "yk_icon_img_outline" }), file.status === "uploading" && _vm.listType === "picture" ? _c("yk-progress", { directives: [ { name: "show", rawName: "v-show", value: _vm.hideProgress, expression: "hideProgress", }, ], staticClass: "abnormal", attrs: { type: "line", width: 100, "stroke-width": 2, percentage: _vm.parsePercentage(file.percentage), }, }) : _vm._e(), ], 1 ) : _vm._e(), _vm.listType === "picture-card" && (file.status === "fail" || file.status === "uploading") ? _c( "div", { staticClass: "yk-upload-list__item-thumbnail", class: { percentage: file.status === "uploading" }, }, [ file.status === "uploading" ? _c("span", [ _vm._v( _vm._s(_vm.parsePercentage(file.percentage)) + "%" ), ]) : _c("i", { staticClass: "yk_icon_refresh" }), _vm._v( "\n " + _vm._s( file.status === "fail" ? "重新上传" : "正在上传" ) + "\n " ), ] ) : _vm._e(), _c( "a", { staticClass: "yk-upload-list__item-name", class: [file.status === "fail" ? "failStyle" : ""], on: { click: function ($event) { _vm.handleClick(file) }, }, }, [ _c("i", { class: [ file.status === "fail" ? "failStyle" : "", _vm.listType !== "picture" ? "" + _vm.fileIcon : "", ], staticStyle: { fontSize: "16px" }, }), _vm._v(_vm._s(file.name) + "\n "), ] ), !(_vm.listType === "picture-card" && file.status === "fail") ? _c( "label", { staticClass: "yk-upload-list__item-status-label", style: { display: file.status === "uploading" && _vm.listType === "picture" ? "block" : "", }, }, [ _c("i", { class: { yk_icon_tick: file.status === "success", yk_icon_refresh: file.status === "fail", "el-icon-loading": file.status === "uploading", greenColor: _vm.listType === "text", }, }), ] ) : _vm._e(), !_vm.disabled ? _c("img", { staticClass: "yk_icon_close", attrs: { src: __webpack_require__(73) }, on: { click: function ($event) { _vm.$emit("remove", file) }, }, }) : _vm._e(), !_vm.disabled && file.status === "fail" ? _c("img", { staticClass: "icon_refresh", attrs: { src: __webpack_require__(74) }, on: { click: function ($event) { _vm.$emit("reSubmit", file) }, }, }) : _vm._e(), _vm.listType === "picture" && !_vm.disabled && file.status !== "fail" ? _c("div", { staticClass: "eye_open" }, [ _c("i", { staticClass: "yk_icon_eye_open_outline", on: { click: function ($event) { _vm.handlePreview(file) }, }, }), ]) : _vm._e(), _c("i", { staticClass: "el-icon-close-tip" }, [ _vm._v(_vm._s(_vm.t("el.upload.deleteTip"))), ]), file.status === "uploading" && _vm.listType !== "picture-card" && _vm.listType !== "picture" ? _c("yk-progress", { staticClass: "progressBar normal", attrs: { type: "line", width: _vm.listType === "picture-card" ? 100 : 126, "stroke-width": _vm.listType === "picture-card" ? 6 : 40, "text-inside": true, format: function (val) { return ( "<i class='" + _vm.fileIcon + "' style='margin-right: 8px;font-size:16px;color:#909399'></i>上传中..." + val + "%" ) }, loadingShow: true, percentage: _vm.parsePercentage(file.percentage), }, }) : _vm._e(), file.status === "uploading" && _vm.listType === "picture-card" ? _c("yk-progress", { staticClass: "abnormal", attrs: { type: "line", width: 100, "stroke-width": 5, percentage: _vm.parsePercentage(file.percentage), }, }) : _vm._e(), _vm.listType === "picture-card" ? _c("span", { staticClass: "yk-upload-list__item-actions" }, [ _vm.handlePreview && _vm.listType === "picture-card" && file.status !== "fail" ? _c( "span", { staticClass: "yk-upload-list__item-preview", on: { click: function ($event) { _vm.handlePreview(file) }, }, }, [_c("i", { staticClass: "yk_icon_eye_open_outline" })] ) : _vm._e(), _vm.listType === "picture-card" && file.status === "fail" ? _c( "span", { staticClass: "yk-upload-list__item-preview", on: { click: function ($event) { _vm.$emit("reSubmit", file) }, }, }, [_c("i", { staticClass: "yk_icon_refresh" })] ) : _vm._e(), !_vm.disabled ? _c( "span", { staticClass: "yk-upload-list__item-delete", on: { click: function ($event) { _vm.$emit("remove", file) }, }, }, [_c("i", { staticClass: "yk_icon_delete_outline" })] ) : _vm._e(), ]) : _vm._e(), ], { file: file } ), ], 2 ) }), 0 ) } var staticRenderFns = [] upload_listvue_type_template_id_f886b546_render._withStripped = true // CONCATENATED MODULE: ./packages/upload/src/upload-list.vue?vue&type=template&id=f886b546 // EXTERNAL MODULE: ./src/mixins/locale.js var locale = __webpack_require__(13); // EXTERNAL MODULE: ./packages/progress/index.js + 5 modules var progress = __webpack_require__(45); // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@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: 'YkUploadList', mixins: [locale["a" /* default */]], data: function data() { return { focusing: false, hideProgress: true // hover时隐藏进度条 }; }, components: { YkProgress: progress["default"] }, props: { files: { type: Array, default: function _default() { return []; } }, disabled: { type: Boolean, default: false }, handlePreview: Function, listType: String, fileIcon: { type: String, default: 'yk_icon_file_two_tone' } }, methods: { parsePercentage: function parsePercentage(val) { return parseInt(val, 10); }, handleClick: function handleClick(file) { this.handlePreview && this.handlePreview(file); } } }); // 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@15.11.1@vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(2); // 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_f886b546_render, staticRenderFns, false, null, null, null ) /* 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__(29); 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@15.11.1@vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/_vue-loader@15.11.1@vue-loader/lib??vue-loader-options!./packages/upload/src/upload-dragger.vue?vue&type=template&id=70948bae var upload_draggervue_type_template_id_70948bae_render = function () { var _vm = this var _h = _vm.$createElement var _c = _vm._self._c || _h return _c( "div", { staticClass: "yk-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_70948bae_staticRenderFns = [] upload_draggervue_type_template_id_70948bae_render._withStripped = true // CONCATENATED MODULE: ./packages/upload/src/upload-dragger.vue?vue&type=template&id=70948bae // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@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: 'YkUploadDrag', 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_70948bae_render, upload_draggervue_type_template_id_70948bae_staticRenderFns, false, null, null, null ) /* harmony default export */ var upload_dragger = (upload_dragger_component.exports); // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@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' }, isdefault: Boolean, 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); }); }, // 文件上传失败,重新上传 reUpload: function reUpload(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) { // this.$message.error('上传失败,请检查服务器地址或网络连接后重新上传'); _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, isdefault = this.isdefault; var data = { class: { 'yk-upload': true, 'yk-upload--default': isdefault }, on: { click: handleClick, keydown: handleKeydown } }; data.class['yk-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': 'yk-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 ) /* harmony default export */ var src_upload = (upload_component.exports); // EXTERNAL MODULE: ./src/mixins/migrating.js var migrating = __webpack_require__(12); // CONCATENATED MODULE: ./node_modules/_babel-loader@7.1.5@babel-loader/lib!./node_modules/_vue-loader@15.11.1@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: 'YkUpload', mixins: [migrating["a" /* default */]], components: { YkProgress: progress["default"], UploadList: upload_list, Upload: src_upload }, provide: function provide() { return { uploader: this }; }, inject: { ykForm: { 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 }, fileIcon: { type: String, default: 'yk_icon_file_two_tone' }, 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.ykForm || {}).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; } } if (this.uploadFiles.some(function (item) { return item.name === file.name && item.status === 'fail'; })) { var index = this.uploadFiles.findIndex(function (item) { return item.name === file.name && item.status === 'fail'; }); this.uploadFiles[index].uid = file.uid; this.uploadFiles[index].status = file.status; } else { this.uploadFiles.push(file); } this.onChange(file, this.uploadFiles); }, handleProgress: function handleProgress(ev, rawFile) { var file = this.getFile(rawFile); if (file) { 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; var successArr = this.uploadFiles.filter(function (item) { return item.status === 'success'; }); var originArr = this.uploadFiles.filter(function (item) { return item.status !== 'fail'; }); this.onSuccess(res, file, originArr, successArr); this.onChange(file, this.uploadFiles); } }, handleError: function handleError(err, rawFile) { var file = this.getFile(rawFile); var fileList = this.uploadFiles; file.status = 'fail'; if (this.$scopedSlots.file) 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); }); }, reSubmit: function reSubmit(file) { this.$refs['upload-inner'].reUpload(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, 'file-icon': this.fileIcon, handlePreview: this.onPreview }, on: { 'reSubmit': this.reSubmit, '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 }, ref: 'upload-inner' }; var defaultBtn = h( 'yk-button', { attrs: { type: 'secondary' } }, [h('i', { 'class': 'yk_icon_export' }), '\u70B9\u51FB\u4E0A\u4F20'] ); var trigger = this.$slots.trigger || this.$slots.default || defaultBtn; var isdefault = !this.$slots.trigger && !this.$slots.default; uploadData.props.isdefault = isdefault; var uploadComponent = h( 'upload', uploadData, [trigger, isdefault ? this.$slots.tip : ''] ); return h('div', [this.listType === 'picture-card' ? uploadList : '', this.$slots.trigger ? [uploadComponent, this.$slots.default] : uploadComponent, isdefault ? '' : 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 ) /* 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); /***/ }), /***/ 12: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3); /** * Show migrating guide in browser console. * * Usage: * import Migrating from 'element-ui/src/mixins/migrating'; * * mixins: [Migrating] * * add getMigratingConfig method for your component. * getMigratingConfig() { * return { * props: { * 'allow-no-selection': 'allow-no-selection is removed.', * 'selection-mode': 'selection-mode is removed.' * }, * events: { * selectionchange: 'selectionchange is renamed to selection-change.' * } * }; * }, */ /* harmony default export */ __webpack_exports__["a"] = ({ mounted: function mounted() { if (true) return; if (!this.$vnode) return; var _getMigratingConfig = this.getMigratingConfig(), _getMigratingConfig$p = _getMigratingConfig.props, props = _getMigratingConfig$p === undefined ? {} : _getMigratingConfig$p, _getMigratingConfig$e = _getMigratingConfig.events, events = _getMigratingConfig$e === undefined ? {} : _getMigratingConfig$e; var _$vnode = this.$vnode, data = _$vnode.data, componentOptions = _$vnode.componentOptions; var definedProps = data.attrs || {}; var definedEvents = componentOptions.listeners || {}; for (var propName in definedProps) { propName = Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "q"])(propName); // compatible with camel case if (props[propName]) { console.warn('[Element Migrating][' + this.$options.name + '][Attribute]: ' + props[propName]); } } for (var eventName in definedEvents) { eventName = Object(element_ui_src_utils_util__WEBPACK_IMPORTED_MODULE_0__[/* kebabCase */ "q"])(eventName); // compatible with camel case if (events[eventName]) { console.warn('[Element Migrating][' + this.$options.name + '][Event]: ' + events[eventName]); } } }, methods: { getMigratingConfig: function getMigratingConfig() { return { props: {}, events: {} }; } } }); /***/ }), /***/ 13: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var element_ui_src_locale__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(11); /* harmony default export */ __webpack_exports__["a"] = ({ methods: { t: function t() { for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } return element_ui_src_locale__WEBPACK_IMPORTED_MODULE_0__[/* t */ "a"].appl