zcloud-ui
Version:
A Component Library for Vue.js.
1,601 lines (1,398 loc) • 444 kB
JavaScript
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 = "/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 43);
/******/ })
/************************************************************************/
/******/ ([
/* 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,
(options.functional ? this.parent : 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 functional 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
}
}
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/config/index");
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/utils/util");
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/utils/global");
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/mixins/emitter");
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function (useSourceMap) {
var list = []; // return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);
if (item[2]) {
return '@media ' + item[2] + '{' + content + '}';
} else {
return content;
}
}).join('');
}; // import a list of modules into the list
list.i = function (modules, mediaQuery) {
if (typeof modules === 'string') {
modules = [[null, modules, '']];
}
var alreadyImportedModules = {};
for (var i = 0; i < this.length; i++) {
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
for (i = 0; i < modules.length; i++) {
var item = modules[i]; // skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if (item[0] == null || !alreadyImportedModules[item[0]]) {
if (mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if (mediaQuery) {
item[2] = '(' + item[2] + ') and (' + mediaQuery + ')';
}
list.push(item);
}
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || '';
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}
return [content].join('\n');
} // Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
return '/*# ' + data + ' */';
}
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {};
var memoize = function (fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
};
var isOldIE = memoize(function () {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
return window && document && document.all && !window.atob;
});
var getTarget = function (target, parent) {
if (parent){
return parent.querySelector(target);
}
return document.querySelector(target);
};
var getElement = (function (fn) {
var memo = {};
return function(target, parent) {
// If passing function in options, then use it for resolve "head" element.
// Useful for Shadow Root style i.e
// {
// insertInto: function () { return document.querySelector("#foo").shadowRoot }
// }
if (typeof target === 'function') {
return target();
}
if (typeof memo[target] === "undefined") {
var styleTarget = getTarget.call(this, target, parent);
// Special case to return head of iframe instead of iframe itself
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch(e) {
styleTarget = null;
}
}
memo[target] = styleTarget;
}
return memo[target]
};
})();
var singleton = null;
var singletonCounter = 0;
var stylesInsertedAtTop = [];
var fixUrls = __webpack_require__(51);
module.exports = function(list, options) {
if (typeof DEBUG !== "undefined" && DEBUG) {
if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
options.attrs = typeof options.attrs === "object" ? options.attrs : {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
// By default, add <style> tags to the <head> element
if (!options.insertInto) options.insertInto = "head";
// By default, add <style> tags to the bottom of the target
if (!options.insertAt) options.insertAt = "bottom";
var styles = listToStyles(list, options);
addStylesToDom(styles, options);
return function update (newList) {
var mayRemove = [];
for (var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList, options);
addStylesToDom(newStyles, options);
}
for (var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
};
function addStylesToDom (styles, options) {
for (var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles (list, options) {
var styles = [];
var newStyles = {};
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
else newStyles[id].parts.push(part);
}
return styles;
}
function insertStyleElement (options, style) {
var target = getElement(options.insertInto)
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
}
var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if (!lastStyleElementInsertedAtTop) {
target.insertBefore(style, target.firstChild);
} else if (lastStyleElementInsertedAtTop.nextSibling) {
target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
} else {
target.appendChild(style);
}
stylesInsertedAtTop.push(style);
} else if (options.insertAt === "bottom") {
target.appendChild(style);
} else if (typeof options.insertAt === "object" && options.insertAt.before) {
var nextSibling = getElement(options.insertAt.before, target);
target.insertBefore(style, nextSibling);
} else {
throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
}
}
function removeStyleElement (style) {
if (style.parentNode === null) return false;
style.parentNode.removeChild(style);
var idx = stylesInsertedAtTop.indexOf(style);
if(idx >= 0) {
stylesInsertedAtTop.splice(idx, 1);
}
}
function createStyleElement (options) {
var style = document.createElement("style");
if(options.attrs.type === undefined) {
options.attrs.type = "text/css";
}
if(options.attrs.nonce === undefined) {
var nonce = getNonce();
if (nonce) {
options.attrs.nonce = nonce;
}
}
addAttrs(style, options.attrs);
insertStyleElement(options, style);
return style;
}
function createLinkElement (options) {
var link = document.createElement("link");
if(options.attrs.type === undefined) {
options.attrs.type = "text/css";
}
options.attrs.rel = "stylesheet";
addAttrs(link, options.attrs);
insertStyleElement(options, link);
return link;
}
function addAttrs (el, attrs) {
Object.keys(attrs).forEach(function (key) {
el.setAttribute(key, attrs[key]);
});
}
function getNonce() {
if (false) {}
return __webpack_require__.nc;
}
function addStyle (obj, options) {
var style, update, remove, result;
// If a transform function was defined, run it on the css
if (options.transform && obj.css) {
result = typeof options.transform === 'function'
? options.transform(obj.css)
: options.transform.default(obj.css);
if (result) {
// If transform returns a value, use that instead of the original css.
// This allows running runtime transformations on the css.
obj.css = result;
} else {
// If the transform function returns a falsy value, don't add this css.
// This allows conditional loading of css
return function() {
// noop
};
}
}
if (options.singleton) {
var styleIndex = singletonCounter++;
style = singleton || (singleton = createStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else if (
obj.sourceMap &&
typeof URL === "function" &&
typeof URL.createObjectURL === "function" &&
typeof URL.revokeObjectURL === "function" &&
typeof Blob === "function" &&
typeof btoa === "function"
) {
style = createLinkElement(options);
update = updateLink.bind(null, style, options);
remove = function () {
removeStyleElement(style);
if(style.href) URL.revokeObjectURL(style.href);
};
} else {
style = createStyleElement(options);
update = applyToTag.bind(null, style);
remove = function () {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle (newObj) {
if (newObj) {
if (
newObj.css === obj.css &&
newObj.media === obj.media &&
newObj.sourceMap === obj.sourceMap
) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
var replaceText = (function () {
var textStore = [];
return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();
function applyToSingletonTag (style, index, remove, obj) {
var css = remove ? "" : obj.css;
if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = style.childNodes;
if (childNodes[index]) style.removeChild(childNodes[index]);
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag (style, obj) {
var css = obj.css;
var media = obj.media;
if(media) {
style.setAttribute("media", media)
}
if(style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while(style.firstChild) {
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
function updateLink (link, options, obj) {
var css = obj.css;
var sourceMap = obj.sourceMap;
/*
If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
and there is no publicPath defined then lets turn convertToAbsoluteUrls
on by default. Otherwise default to the convertToAbsoluteUrls option
directly
*/
var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
if (options.convertToAbsoluteUrls || autoFixUrls) {
css = fixUrls(css);
}
if (sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
var blob = new Blob([css], { type: "text/css" });
var oldSrc = link.href;
link.href = URL.createObjectURL(blob);
if(oldSrc) URL.revokeObjectURL(oldSrc);
}
/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var zcloud_ui_src_utils_boxer_jquery_fs_boxer_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44);
/* harmony import */ var zcloud_ui_src_utils_boxer_jquery_fs_boxer_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(zcloud_ui_src_utils_boxer_jquery_fs_boxer_js__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var zcloud_ui_src_utils_boxer_jquery_fs_boxer_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(45);
/* harmony import */ var zcloud_ui_src_utils_boxer_jquery_fs_boxer_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(zcloud_ui_src_utils_boxer_jquery_fs_boxer_css__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var zcloud_ui_src_utils_global__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
/* harmony import */ var zcloud_ui_src_utils_global__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(zcloud_ui_src_utils_global__WEBPACK_IMPORTED_MODULE_2__);
/* eslint-disable */
var _bind = function _bind(el, binding, vnode) {
var imgSrc = binding.value;
if (imgSrc) {
var type = Object(zcloud_ui_src_utils_global__WEBPACK_IMPORTED_MODULE_2__["getFileType"])(imgSrc);
if (['pdf', 'image'].includes(type)) {
$(el).boxer2();
}
}
$(el).click(function () {
return false;
});
};
/* harmony default export */ __webpack_exports__["a"] = ({
bind: function bind() {
_bind.apply(undefined, arguments);
},
update: function update() {
_bind.apply(undefined, arguments);
}
});
/***/ }),
/* 8 */
/***/ (function(module, exports) {
module.exports = require("lodash");
/***/ }),
/* 9 */
/***/ (function(module, exports) {
module.exports = require("zcloud-ui/lib/utils/axios");
/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__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/file-upload/src/main.vue?vue&type=template&id=950efe76&
var render = function() {
var _vm = this
var _h = _vm.$createElement
var _c = _vm._self._c || _h
return _c(
"div",
{ ref: "imgUpload", staticClass: "zl-file-upload" },
[
_c(
"el-upload",
_vm._g(
_vm._b(
{
directives: [
{
name: "loading",
rawName: "v-loading",
value: _vm.loading,
expression: "loading"
}
],
ref: "zlUpload",
attrs: {
"http-request": _vm.httpRequire,
data: _vm.parmasData,
disabled: _vm.disabled,
action: _vm.action,
headers: _vm.headers,
"list-type": _vm.listType,
"on-success": _vm.success,
"on-error": _vm.errors,
"before-upload": _vm.beforeUpload,
drag: _vm.drag,
"on-remove": _vm.remove,
"file-list": _vm.fileLists,
"on-exceed": _vm.handleExceed,
"before-remove": _vm.beforeRemove,
limit: _vm.limit
},
scopedSlots: _vm._u(
[
{
key: "file",
fn: function(ref) {
var file = ref.file
return _vm.listType === "picture-card"
? _c(
"div",
{ staticClass: "zl-file-img" },
[
file.status === "uploading"
? _c("el-progress", {
attrs: {
type: "circle",
percentage: _vm.parsePercentage(
file.percentage
),
width: 80
}
})
: _vm._e(),
_c("img", {
staticClass: "el-upload-list__item-thumbnail",
attrs: { src: file.url, alt: "" }
}),
_c(
"span",
{ staticClass: "el-upload-list__item-actions" },
[
_c(
"span",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.showPreview(file),
expression: "showPreview(file)"
}
],
staticClass:
"el-upload-list__item-preview",
on: {
click: function($event) {
return _vm.review(file)
}
}
},
[
_c("i", {
staticClass: "el-icon-zoom-in"
})
]
),
_vm.showDown
? _c(
"span",
{
staticClass:
"el-upload-list__item-delete",
on: {
click: function($event) {
return _vm.handleDownload(file)
}
}
},
[
_c("i", {
staticClass: "el-icon-download"
})
]
)
: _vm._e(),
!_vm.disabled
? _c(
"span",
{
staticClass:
"el-upload-list__item-delete",
on: {
click: function($event) {
return _vm.handleRemove(file)
}
}
},
[
_c("i", {
staticClass: "el-icon-delete"
})
]
)
: _vm._e()
]
)
],
1
)
: _vm.listType === "text"
? _c("div", {}, [
_c(
"a",
{ staticClass: "el-upload-list__item-name" },
[
_c("i", { staticClass: "el-icon-document" }),
[
_vm.showPreview(file)
? _c(
"span",
{
staticClass:
"el-upload-list__item-name-span",
on: {
click: function($event) {
return _vm.review(file)
}
}
},
[_vm._v(_vm._s(file.name))]
)
: _c(
"span",
{
staticClass:
"el-upload-list__item-name-span",
on: {
click: function($event) {
return _vm.handleDownload(file)
}
}
},
[_vm._v(_vm._s(file.name))]
)
],
_c("div", { staticClass: "zl-right" }, [
_vm.showDown
? _c("i", {
staticClass: "el-icon-download",
on: {
click: function($event) {
return _vm.handleDownload(file)
}
}
})
: _vm._e(),
_vm.showPreview(file)
? _c("i", {
staticClass: "el-icon-zoom-in",
on: {
click: function($event) {
return _vm.review(file)
}
}
})
: _c("i", {
staticClass: "el-icon-zoom-in",
on: {
click: function($event) {
return _vm.handleDownload(file)
}
}
})
])
],
2
),
!_vm.disabled
? _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._e(),
!_vm.disabled
? _c("i", {
staticClass: "el-icon-close",
on: {
click: function($event) {
return _vm.handleRemove(file)
}
}
})
: _vm._e()
])
: _vm._e()
}
}
],
null,
true
)
},
"el-upload",
_vm.$attrs,
false
),
_vm.$listeners
),
[_vm._t("imgs"), _c("i", { staticClass: "el-icon-plus" })],
2
),
_c(
"div",
{
directives: [
{
name: "show",
rawName: "v-show",
value: false,
expression: "false"
}
],
ref: "boxer"
},
_vm._l(_vm.files, function(item) {
return _c("a", {
directives: [
{
name: "boxer",
rawName: "v-boxer",
value: item.fullUrl,
expression: "item.fullUrl"
}
],
key: item.fullUrl,
class: "link-view-" + item.uid,
attrs: { href: item.fullUrl }
})
}),
0
),
_c("el-image", {
class: "file-upload-review-image-" + _vm.reviewImgsObj.id,
staticStyle: { width: "0", height: "0" },
attrs: {
src: _vm.reviewImgsObj.url,
"preview-src-list": _vm.reviewImgs
},
on: { load: _vm.imageLoad }
})
],
1
)
}
var staticRenderFns = []
render._withStripped = true
// CONCATENATED MODULE: ./packages/file-upload/src/main.vue?vue&type=template&id=950efe76&
// EXTERNAL MODULE: external "zcloud-ui/lib/mixins/emitter"
var emitter_ = __webpack_require__(4);
var emitter_default = /*#__PURE__*/__webpack_require__.n(emitter_);
// EXTERNAL MODULE: ./src/directives/boxer.js
var boxer = __webpack_require__(7);
// EXTERNAL MODULE: external "zcloud-ui/lib/utils/global"
var global_ = __webpack_require__(3);
// EXTERNAL MODULE: external "zcloud-ui/lib/config/index"
var index_ = __webpack_require__(1);
// CONCATENATED MODULE: ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./packages/file-upload/src/main.vue?vue&type=script&lang=js&
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/* harmony default export */ var mainvue_type_script_lang_js_ = ({
name: 'ZlFileUpload',
mixins: [emitter_default.a],
data: function data() {
return {
headers: {}, // 添加请求头{}
fileList: [], // test
fileLists: [], // 默认已上传 文件地址[{name,url}]
files: [], // 放大图片的集合
isChange: false, // 是否有变更
imgUrls: [], // 原地址
loading: false,
parmasData: _extends({
fileName: '',
resourceSize: '',
fileSuffix: '',
cover: false,
verification: true }, index_["Environment"].FILE_UPLOAD_PARAMS, {
resourceUrl: index_["Environment"].IMAGE_DOWNLOAD
}),
reviewImgsObj: {
url: '',
pageDom: '',
id: ''
},
ajaxData: {},
lookStr: [],
sign: ''
};
},
directives: {
boxer: boxer["a" /* default */]
},
props: {
// 签名上传需要先请求签名
beforeHttpRequire: {
type: Function
},
// 签名下载需要先请求签名
beforeHttpRequireLook: {
type: Function
},
fileMaxSize: {
type: [Number, String],
default: ''
},
action: {
type: String,
default: function _default() {
return index_["Environment"].FILE_URL + 'upload/addFiles';
} // 中通
},
listType: {
type: String,
default: 'text'
},
limit: {
// 最大上传数量
type: [Number, String],
default: function _default() {
return 5;
}
},
suffixWhite: {
type: [String, Array],
default: ''
},
supportType: {
type: String,
default: 'all',
validator: function validator(value) {
return ['img', 'file', 'bids', 'zto', 'all'].indexOf(value) !== -1;
}
},
disabled: {
type: Boolean,
default: false
},
drag: {
type: Boolean,
default: false
},
value: {
// 图片地址
type: [String, Array],
required: true
},
hideUploadBtn: {
type: Boolean,
default: false
},
validateEvent: {
type: Boolean,
default: true
},
string: {
type: Boolean,
default: true
},
join: {
type: String,
default: ','
},
token: {
type: String,
default: ''
},
showDown: {
type: Boolean,
default: false
},
extendParmas: {
type: Object,
default: function _default() {
return {};
}
}
},
computed: {
reviewImgs: function reviewImgs() {
return this.files.filter(function (img) {
return Object(global_["getFileType"])(img.fullUrl) === 'image';
}).map(function (url) {
return url.fullUrl;
});
}
},
mounted: function mounted() {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return _this.getSign();
case 2:
_this.headers.Authorization = _this.token || index_["Environment"].TOKEN;
_this.reviewImgsObj.pageDom = document.createElement('div');
_this.reviewImgsObj.pageDom.style = 'font-size: 18px';
_this.initFiles(_this.value);
case 6:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}))();
},
created: function created() {},
watch: {
value: {
deep: true,
handler: function handler(val, oldVal) {
val && !this.isChange && this.initFiles(val);
}
}
},
methods: {
getSign: function getSign() {
var _this2 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var str, res;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// 签名处理
str = '';
_this2.lookStr = [];
if (!_this2.beforeHttpRequireLook) {
_context2.next = 8;
break;
}
_context2.next = 5;
return _this2.beforeHttpRequireLook();
case 5:
res = _context2.sent;
// res 是签名数组排序好的 [{key:'appkey',value:asa}]
res.forEach(function (item) {
_this2.lookStr.push(item.key + '=' + item.value);
});
str = _this2.lookStr.join('&');
case 8:
_this2.sign = str;
case 9:
case 'end':
return _context2.stop();
}
}
}, _callee2, _this2);
}))();
},
beforeRemove: function beforeRemove() {
// this.$refs.zlUpload.clearFiles();
},
addReviewImgPage: function addReviewImgPage(parent) {
var img = parent.find('.el-image-viewer__canvas img').attr('src');
var index = this.reviewImgs.findIndex(function (item) {
return item === img;
});
this.reviewImgsObj.pageDom.innerHTML = index + 1 + '/' + this.reviewImgs.length;
parent.find('.el-image-viewer__actions__inner').prepend(this.reviewImgsObj.pageDom);
},
imageLoad: function imageLoad() {
var _this3 = this;
var parentDom = $('.zl-file-upload .file-upload-review-image-' + this.reviewImgsObj.id);
var imgDom = parentDom.find('img')[0];
if (imgDom) {
imgDom.click();
this.$nextTick(function () {
_this3.addReviewImgPage(parentDom);
if (!parentDom.find('.el-image-viewer__prev')[0]) return;
parentDom.find('.el-image-viewer__prev')[0].addEventListener('click', function () {
return _this3.addReviewImgPage(parentDom);
});
parentDom.find('.el-image-viewer__next')[0].addEventListener('click', function () {
return _this3.addReviewImgPage(parentDom);
});
});
}
},
// 强制更新
fourceUpdate: function fourceUpdate() {
this.initFiles(this.value);
},
fourceRemove: function fourceRemove() {
this.initFiles('', true);
},
// 初始化file
initFiles: function initFiles(val, flag) {
var _this4 = this;
if (!val && !flag) return;
if (typeof val === 'string') {
// 处理后台返回空格问题
val = val.replace(/(&?)nbsp;|(&?)amp;/gi, ' ');
}
var splitCode = val.includes(',') ? ',' : val.includes(';') ? ';' : null;
var src = typeof val === 'string' ? val.split(splitCode) : val instanceof Array ? val : null,
list = [],
reUrls = []; // 全地址
this.imgUrls = [];
src && src.forEach(function (item) {
if (item) {
var formatUrl = _this4.formatFile(item);
list.push(formatUrl);
reUrls.push(formatUrl.reUrl); // 全地址
}
});
this.imgUrls = reUrls; // 原地址
this.files = this.fileLists = [].concat(list);
this.updateUploadBtn();
},
// 格式化文件
formatFile: function formatFile(item, uid) {
var fullUrlDown = void 0,
fullUrl = void 0,
reUrl = void 0;
if (item.includes('upload/files/')) {
// 老数据处理
fullUrlDown = index_["Environment"].IMAGE_DOWNLOAD_OLD + item;
fullUrl = fullUrlDown + '&isShow=true';
reUrl = item;
console.log('老数据暂无处理', item);
} else {
if (item.includes(index_["Environment"].IMG_PREFIX)) {
// 文件名称处理
item = item.split(index_["Environment"].IMG_PREFIX).reverse()[0];
}
// 签名处理
if (this.sign) {
fullUrlDown = index_["Environment"].IMAGE_DOWNLOAD + item + '?' + this.sign;
} else {
fullUrlDown = index_["Environment"].IMAGE_DOWNLOAD + item + '?token=' + (this.token || index_["Environment"].TOKEN);
}
fullUrl = fullUrlDown + '&isShow=true';
reUrl = index_["Environment"].IMG_PREFIX + item;
}
var thumbnail = Object(global_["formatFile"])(item, this.token || index_["Environment"].TOKEN || '', this.sign);
var name = item.split('/').reverse()[0];
var nameLength = this.extendParmas.nameLength ? this.extendParmas.nameLength : 20;
return {
uid: uid || parseInt(Math.random() * 1000000000),
url: thumbnail, // 缩略图地址
name: name.length > nameLength ? name.substr(nameLength * -1) : name,
fullUrlDown: fullUrlDown, // 下载
fullUrl: fullUrl, // 预览
reUrl: reUrl // 原地址
};
},
// 更新上传按钮是否显示
updateUploadBtn: function updateUploadBtn() {
var $card = this.$refs.imgUpload.querySelector('.el-upload'),
$icon = this.$refs.imgUpload.querySelector('.el-icon-plus');
if (this.hideUploadBtn || this.disabled) {
$card.style.display = 'none';
$icon.style.display = 'none';
return Promise.reject();
}
var _flag = this.imgUrls.length >= this.limit; // 默认5条
$card.style.display = _flag ? 'none' : 'inline-block';
$icon.style.display = _flag ? 'none' : 'inline-block';
},
// 上传前
beforeUpload: function beforeUpload(file) {
var _this5 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
var isLt2M, suffixWhite, fileSuffix, reg, fileMax;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
isLt2M = file.size / 1024 / 1024;
// 文件类型
suffixWhite = _this5.suffixWhite && typeof _this5.suffixWhite === 'string' ? _this5.suffixWhite.split(',') : _this5.suffixWhite instanceof Array ? _this5.suffixWhite : [];
fileSuffix = (file.name.split('.').pop() || '').toLowerCase();
if (!(_this5.supportType && !Object(global_["getFileType"])(file.name, _this5.supportType) || suffixWhite.length && !suffixWhite.includes(fileSuffix))) {
_context3.next = 6;
break;
}
_this5.$message.error('暂不支持上传文件 ' + fileSuffix + ' 格式。');
return _context3.abrupt('return', Promise.reject());
case 6:
reg = index_["Environment"].FILE_UPLOAD_REG instanceof RegExp ? index_["Environment"].FILE_UPLOAD_REG : /[`~!@#$%^&*()\+=<>?:"{}|,\/;'\\ [\]·~!@#¥%……&*()——\+={}|《》?:“”【】、;‘',。、]/im;
if (!reg.test(file.name.replace(/ /g, ''))) {
_context3.next = 10;
break;
}
_this5.$message.error('文件名不支持特殊字符,请修改名称后再上传');
return _context3.abrupt('return', Promise.reject());
case 10:
// 文件大小不能超过5M
fileMax = _this5.fileMaxSize || index_["Environment"].IMG_SIZE_MAX;
if (!(isLt2M > fileMax)) {
_context3.next = 14;
break;
}
_this5.$message.error('\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ' + fileMax + 'MB\u3002');
return _context3.abrupt('return', Promise.reject());
case 14:
_this5.isChange = true;
if (_this5.fileLists.length === _this5.limit - 1) {
// why
_this5.$refs.imgUpload.querySelector('.el-upload').style.display = 'none';
_this5.$refs.imgUpload.querySelector('.el-icon-plus').style.display = 'none';
}
_this5.loading = true;
_this5.setParams(file);
// 上传前的执行函数
if (!_this5.extendParmas.beforeUploadFunc) {
_context3.next = 21;
break;
}
_context3.next = 21;
return _this5.extendParmas.beforeUploadFunc(_this5.parmasData);
case 21:
case 'end':
return _context3.stop();
}
}
}, _callee3, _this5);
}))();
},
// 上传失败错误
errors: function errors() {
console.log('文件上传失败');
this.$message.error('文件上传失败');
this.loading = false;
this.updateUploadBtn();
},
// 设置请参数
setParams: function setParams(file) {
var suffix = file.name.split('.').reverse()[0]; // 文件后缀名
var parmasData = this.parmasData;
parmasData.fileName = file.name || ''; // 文件名称
parmasData.resourceSize = file.size || ''; // 文件大小
parmasData.fileSuffix = suffix || ''; // 后缀名
for (var _iterator = Object.keys(this.extendParmas), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var key = _ref;
parmasData[key] = this.extendParmas[key];
}
},
// 自定义上传文件
httpRequire: function httpRequire(content) {
var _this6 = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var formData, res, prom;
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
formData = new FormData();
content.file && formData.append('file', content.file);