| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import { ref as u, watch as O, resolveComponent as v, openBlock as w, createElementBlock as g, createElementVNode as a, toDisplayString as T, createCommentVNode as j, createVNode as c, withCtx as y, pushScopeId as q, popScopeId as z } from "vue";
- import { r as A, v as E } from "./index2.js";
- import { a as F, d as M, b as $ } from "./upload.js";
- import { U as P } from "./index6.js";
- import { M as H } from "./index7.js";
- const b = (n) => (q("data-v-6353f81e"), n = n(), z(), n), V = { class: "s-file-upload-common" }, G = { class: "head" }, K = {
- key: 0,
- class: "label"
- }, X = { class: "ant-upload-drag-icon" }, J = /* @__PURE__ */ b(() => /* @__PURE__ */ a("p", { class: "ant-upload-text" }, "点击或拖入文件到此处", -1)), Q = /* @__PURE__ */ b(() => /* @__PURE__ */ a("p", { class: "ant-upload-hint" }, "支持单个或批量上传", -1)), W = { class: "preview-content" }, Y = ["src"], Z = /* @__PURE__ */ Object.assign({
- inheritAttrs: !0
- }, {
- __name: "SDraggerUpload",
- props: {
- /**
- * 文件列表
- * @list
- */
- list: {
- type: Array,
- default: () => []
- },
- /**
- * 标题
- * @label
- */
- label: {
- type: String,
- default: ""
- },
- /**
- * 只读
- * @readonly
- */
- readonly: {
- type: Boolean,
- default: !1
- },
- /**
- * 是否显示删除
- * @delete
- */
- showRemoveIcon: {
- type: Boolean,
- default: !1
- },
- /**
- * 是否显示新增
- * @isAdd
- */
- isAdd: {
- type: Boolean,
- default: !0
- },
- /**
- * 文件类型
- * @accept
- */
- accept: {
- type: String,
- default: ""
- },
- // 展示类型 picture | picture-card 注:规范内不设定text上传类型
- listType: {
- type: String,
- default: "picture"
- },
- maxFileCount: {
- type: Number,
- default: 3
- },
- sizeLimit: {
- type: Number,
- default: 50
- },
- businessTableName: {
- type: String,
- default: "sapit-ui-plus-components-upload"
- },
- businessKey: {
- type: String,
- default: void 0
- },
- showUploadList: {
- type: Boolean,
- default: !0
- }
- },
- setup(n) {
- const s = n, o = u([]), d = u(!1), p = u(""), r = u(""), l = u(0);
- O(() => s.list, (e) => {
- e && e.length && (o.value = e);
- }, { immediate: !0 });
- const _ = (e) => {
- console.log(s.sizeLimit);
- const t = e.size / 1024 / 1024 < s.sizeLimit;
- return t || E.warn({
- key: "only-you",
- message: "提醒",
- description: `文件不能大于${s.sizeLimit}MB!`
- }), t;
- }, x = ({ onSuccess: e, onError: t, file: i }) => {
- F(i, s.businessTableName, i.uid).then(() => {
- e();
- }).catch(() => {
- o.value.splice(o.value.length - 1, 1), t();
- });
- }, L = (e) => {
- o.value = e.fileList;
- };
- function C(e) {
- console.log(e);
- }
- const U = (e) => {
- l.value = o.value.findIndex((t) => t.uid === e.uid), d.value = !0, r.value = e.name || "预览", p.value = e.url || e.thumbUrl;
- }, R = (e) => {
- const t = document.createElement("a");
- t.href = M(e.uid), t.download = "test", t.click();
- }, S = () => {
- d.value = !1;
- }, h = (e) => {
- var t;
- l.value = l.value + e < 0 ? 0 : l.value + e > o.value.length - 1 ? o.value.length - 1 : l.value + e, (t = o.value[l.value]) != null && t.thumbUrl ? (r.value = o.value[l.value].name || "预览", p.value = o.value[l.value].thumbUrl) : D(o.value[l.value]);
- }, D = (e) => {
- if (e.type.includes("office")) {
- const t = window.open("", "");
- t.location = $(e.uid + "/" + e.name);
- } else if (e.type.includes("text"))
- k(e.url);
- else if (e.type.includes("pdf") || e.type.includes("png") || e.type.includes("gif") || e.type.includes("jpeg") || e.type.includes("bmp") || e.type.includes("ico") || e.type.includes("webp")) {
- const t = window.open("", "");
- t.location = e.url;
- } else
- this.$notification.warning({
- message: "不支持此文件类型"
- });
- }, k = (e) => {
- const t = new XMLHttpRequest();
- t.open("GET", e, !0), t.responseType = "blob", t.setRequestHeader("Content-Type", "application/json"), t.onload = function() {
- const i = new Blob([t.response], { type: "application/json;charset=utf-8" }), m = window.URL.createObjectURL(i), f = window.open("", "");
- f.location = m;
- }, t.send();
- };
- return (e, t) => {
- const i = v("inbox-outlined"), m = P, f = v("LeftOutlined"), B = v("RightOutlined"), I = H;
- return w(), g("div", V, [
- a("div", G, [
- n.label ? (w(), g("div", K, T(n.label), 1)) : j("", !0)
- ]),
- c(m, {
- accept: n.accept,
- "list-type": "picture",
- "file-list": o.value,
- disabled: n.readonly,
- maxCount: n.maxFileCount,
- multiple: n.maxFileCount > 1,
- "before-upload": _,
- "custom-request": x,
- onDrop: C,
- onChange: L,
- onPreview: U,
- onDownload: R,
- showUploadList: n.showUploadList
- }, {
- default: y(() => [
- a("p", X, [
- c(i)
- ]),
- J,
- Q
- ]),
- _: 1
- }, 8, ["accept", "file-list", "disabled", "maxCount", "multiple", "showUploadList"]),
- c(I, {
- open: d.value,
- title: r.value,
- footer: null,
- onCancel: S,
- width: "800px"
- }, {
- default: y(() => [
- a("div", W, [
- a("div", {
- class: "prev",
- onClick: t[0] || (t[0] = (N) => h(-1))
- }, [
- c(f)
- ]),
- a("img", {
- alt: "example",
- class: "view",
- src: p.value
- }, null, 8, Y),
- a("div", {
- class: "next",
- onClick: t[1] || (t[1] = (N) => h(1))
- }, [
- c(B)
- ])
- ])
- ]),
- _: 1
- }, 8, ["open", "title"])
- ]);
- };
- }
- }), ae = /* @__PURE__ */ A(Z, [["__scopeId", "data-v-6353f81e"]]);
- export {
- ae as default
- };
|