UNPKG

yk-element-components-v2

Version:

257 lines (256 loc) 6.83 kB
function y(t, e, r, i, l, p, d, c) { var o = typeof t == "function" ? t.options : t; e && (o.render = e, o.staticRenderFns = r, o._compiled = !0), i && (o.functional = !0), p && (o._scopeId = "data-v-" + p); var a; if (d ? (a = function(n) { n = n || this.$vnode && this.$vnode.ssrContext || this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !n && typeof __VUE_SSR_CONTEXT__ < "u" && (n = __VUE_SSR_CONTEXT__), l && l.call(this, n), n && n._registeredComponents && n._registeredComponents.add(d); }, o._ssrRegister = a) : l && (a = c ? function() { l.call( this, (o.functional ? this.parent : this).$root.$options.shadowRoot ); } : l), a) if (o.functional) { o._injectStyles = a; var m = o.render; o.render = function(C, f) { return a.call(f), m(C, f); }; } else { var u = o.beforeCreate; o.beforeCreate = u ? [].concat(u, a) : [a]; } return { exports: t, options: o }; } function s() { } const g = { name: "yk-upload", props: { fixedCoverHeight: { type: Number, default: null }, minCoverHeight: { type: Number, default: null }, maxCoverHeight: { type: Number, default: null }, fixedCoverWidth: { type: Number, default: null }, maxCoverWidth: { type: Number, default: null }, minCoverWidth: { type: Number, default: null }, showFileList: { type: Boolean, default: !0 }, cropperWidth: { type: Number, default: 150 }, cropperHeight: { type: Number, default: 150 }, cropBoxResizable: { type: Boolean, default() { return !0; } }, guides: { type: Boolean, default() { return !0; } }, action: { type: String, required: !1, default: "#" }, aspectRatio: { type: String, default: "1/1" }, headers: { type: Object, default() { return {}; } }, data: Object, multiple: Boolean, name: { type: String, default: "file" }, drag: Boolean, accept: String, beforeUpload: Function, beforeRemove: Function, onRemove: { type: Function, default: s }, onChange: { type: Function, default: s }, onPreview: { type: Function }, onSuccess: { type: Function, default: s }, onProgress: { type: Function, default: s }, onError: { type: Function, default: s }, fileList: { type: Array, default() { return []; } }, autoUpload: { type: Boolean, default: !0 }, listType: { type: String, default: "text" }, httpRequest: Function, disabled: Boolean, limit: Number, onExceed: { type: Function, default: s }, orCropper: { type: Boolean, default: !1 }, type: { type: String, default: "select" } }, data() { return { cropper: { show: !1, file: null, loading: !1, submitted: !1, uploadFiles: [] } }; }, mounted() { this.$nextTick(() => { this.uploadFiles = this.$refs.yUpload.uploadFiles; }); }, methods: { trigger() { this.$refs.yUpload.$refs["upload-inner"].handleClick(); }, file2Base64(t, e) { let r = new FileReader(); r.onload = (i) => { typeof e == "function" && e(i.target.result); }, r.readAsDataURL(t); }, loadOnChange(t, e) { t.status === "ready" && (this.orCropper && t.raw.type.indexOf("image") != -1 && t.raw.type != "image/gif" ? this.beforeAddFile({ ...t, file: t.raw, fileList: e }) : this.autoUpload && (this.$refs.yUpload.submit(), this.onCropperCancel())), this.onChange(t, e); }, beforeAddFile(t) { if (t.file instanceof File) { if (this.cropper.show) return; this.cropper.file = t.file, this.cropper.show = !0; } }, clearFiles() { this.$refs.yUpload.clearFiles(); }, abort(t) { this.$refs.yUpload.abort(t); }, submit() { this.$refs.yUpload.submit(); }, onCropperCancel(t = !0) { const e = this.$refs.yUpload.uploadFiles; e.splice(e.indexOf(this.cropper.file), 1), this.cropper.show = !1; }, onCropperConfirm(t) { const e = this.$refs.yUpload; if (t) { let r = new File([t], this.cropper.file.name, { type: t.type }), i = e.uploadFiles[e.uploadFiles.length - 1]; r.uid = i.raw.uid, i.raw = r, this.file2Base64(i.raw, (l) => { i.url = l, this.autoUpload && this.$refs.yUpload.submit(), this.onCropperCancel(); }); } else this.autoUpload && this.$refs.yUpload.submit(), this.onCropperCancel(); }, onCropperClose() { }, onCropperClosed() { this.$refs.yUpload.$refs["upload-inner"].$el.focus(); }, onCropperOpen() { this.$refs.yUpload.$refs["upload-inner"].$el.blur(); } } }; var v = function() { var e = this, r = e._self._c; return r("div", [r("el-upload", { ref: "yUpload", attrs: { "auto-upload": !1, action: e.action, headers: e.headers, data: e.data, multiple: e.multiple, name: e.name, drag: e.drag, accept: e.accept, type: e.type, beforeUpload: e.beforeUpload, beforeRemove: e.beforeRemove, onRemove: e.onRemove, onChange: e.loadOnChange, onPreview: e.onPreview, onSuccess: e.onSuccess, onProgress: e.onProgress, onError: e.onError, fileList: e.fileList, listType: e.listType, httpRequest: e.httpRequest, disabled: e.disabled, limit: e.limit, onExceed: e.onExceed, "show-file-list": e.showFileList } }, [e._t("default"), e._t("trigger", null, { slot: "trigger" }), e._t("tip", null, { slot: "tip" })], 2), r("yk-imgCropper", { attrs: { show: e.cropper.show, file: e.cropper.file, aspectRatio: e.aspectRatio, aspectRatioDeviation: 0.1, cropBoxResizable: e.cropBoxResizable, guides: e.guides, maxCoverWidth: e.maxCoverWidth, minCoverWidth: e.minCoverWidth, fixedCoverWidth: e.fixedCoverWidth, cropperWidth: e.cropperWidth, cropperHeight: e.cropperHeight, fixedCoverHeight: e.fixedCoverHeight, minCoverHeight: e.minCoverHeight, maxCoverHeight: e.maxCoverHeight }, on: { "update:show": function(i) { return e.$set(e.cropper, "show", i); }, confirm: e.onCropperConfirm, cancel: e.onCropperCancel, close: e.onCropperClose, open: e.onCropperOpen, closed: e.onCropperClosed } })], 1); }, _ = [], b = /* @__PURE__ */ y( g, v, _, !1, null, null, null, null ); const h = b.exports, F = { install(t) { t.component(h.name, h); } }; export { F as default };