UNPKG

@aplus-frontend/ui

Version:

213 lines (212 loc) 7.46 kB
import { defineComponent as V, computed as g, ref as j, createElementBlock as L, openBlock as p, mergeProps as M, unref as e, renderSlot as d, createCommentVNode as k, createVNode as r, withCtx as c, createElementVNode as s, normalizeClass as a, createBlock as C, Fragment as G, renderList as U, createSlots as x, createTextVNode as N, toDisplayString as h } from "vue"; import { LoadingOutlined as z } from "@ant-design/icons-vue"; import { Tooltip as $, TypographyText as R, Empty as I } from "@aplus-frontend/antdv"; import { IconVariantDownload as q, IconApAdLineCloseAttachments as H, IconApAdLineDownload as J } from "@aplus-frontend/icon"; import "../../config-provider/index.mjs"; import "../ap-download/ap-download.vue2.mjs"; import { ApFilePreview as K } from "../ap-file-preview/index.mjs"; import "../ap-title/ApTitle.vue.mjs"; import Q from "./style/index.mjs"; import { getFileInfo as W } from "./utils/index.mjs"; import { useNamespace as X } from "../../config-provider/hooks/use-namespace.mjs"; import { useLocale as Y } from "../../config-provider/hooks/use-locale.mjs"; import { useGlobalConfig as E } from "../../config-provider/hooks/use-global-config.mjs"; import Z from "../ap-title/ApTitle.vue2.mjs"; import ee from "../ap-download/ap-download.vue.mjs"; const te = ["onClick"], ie = ["onClick"], Ae = /* @__PURE__ */ V({ __name: "ap-appendix", props: { fileList: {}, needName: { type: [Boolean, Object], default: void 0 }, getOssAccess: {}, title: {}, tooltip: {}, column: { default: 2 }, isFileAreaBorder: { type: Boolean, default: !1 }, emptyText: {} }, setup(T) { const { b: B, e: i, em: w } = X("ap-appendix"), { t: m } = Y(), b = Q("ap-appendix"), t = T, _ = E("apUpload"), F = E( "downloadCenterTriggerConfig" ), y = g( () => W( t?.needName ?? _?.value?.needName, t?.fileList ?? [] ) ), O = g( () => t.getOssAccess || _.value?.getOssAccess ), A = g( () => !(Array.isArray(y.value) && y.value.length) ), o = j([]), S = g(() => t.title || m("ap.apAppendix.appendix")); async function P(n, f) { if (!(o.value.findIndex((l) => l === f) > -1)) { o.value = [...o.value, f]; try { if (F.value?.trigger) { let l = [n].map((v) => ({ objectName: v.path, fileName: v.fileName })); await F.value?.trigger(l); } } finally { o.value = o.value.filter((l) => l !== f); } } } async function D(n) { K.createFilePreviewModal({ src: n.path, fileName: n.fileName }); } return (n, f) => (p(), L("div", M({ class: [e(B)(), e(b)] }, { ...n.$attrs }, { style: { "--ap-appendix-column": `repeat(${Number(t?.column || 2)}, 1fr)` } }), [ d(n.$slots, "title", { fileList: t.fileList }, () => [ r(Z, { title: S.value, "help-message": t?.tooltip }, { suffix: c(() => [ s("div", { class: a([e(i)("suffix")]) }, [ d(n.$slots, "titleSuffix", { fileList: t.fileList }), d(n.$slots, "titleDownloadAllBtn", { fileList: t.fileList }, () => [ A.value ? k("", !0) : (p(), C(ee, { key: 0, class: a([e(i)("download-all")]), text: e(m)("ap.apAppendix.downloadAll"), "get-oss-access": O.value, "file-name": t?.fileList ?? [], "need-name": t.needName }, { icon: c(() => [ r(e(q)) ]), _: 1 }, 8, ["class", "text", "get-oss-access", "file-name", "need-name"])) ]) ], 2) ]), _: 3 }, 8, ["title", "help-message"]) ]), A.value ? k("", !0) : d(n.$slots, "fileArea", { key: 0, fileList: t.fileList }, () => [ s("div", { class: a({ [e(i)("file-area")]: !0, [e(w)("file-area", "border")]: !!t.isFileAreaBorder }) }, [ s("div", { class: a([e(i)("file-area-content")]) }, [ (p(!0), L(G, null, U(y.value, (u, l) => (p(), L("div", { key: l, class: a({ [e(i)("file-area-content-item")]: !0, [e(w)("file-area-content-item", "loading")]: o.value.includes(l) }) }, [ s("div", { class: a({ [e(i)("file-area-content-item-content")]: !0, [e(i)("file-area-content-item--loading-content")]: o.value.includes(l) }) }, [ r(e($), null, x({ default: c(() => [ s("div", { class: a([e(i)("file-area-content-item-content-text")]), onClick: (v) => D(u) }, [ s("div", { class: a([e(i)("file-area-content-item-icon")]) }, [ o.value.includes(l) ? (p(), C(e(z), { key: 0 })) : (p(), C(e(H), { key: 1 })) ], 2), s("div", { class: a([e(i)("file-area-content-item-file-name")]) }, [ r(e(R), { ellipsis: "", content: u.fileName }, null, 8, ["content"]) ], 2) ], 10, te) ]), _: 2 }, [ o.value.includes(l) ? void 0 : { name: "title", fn: c(() => [ N(h(e(m)("ap.apAppendix.previewFile")), 1) ]), key: "0" } ]), 1024), r(e($), null, x({ default: c(() => [ s("div", { class: a([e(i)("file-area-content-item-icon-preview")]), onClick: (v) => P(u, l) }, [ r(e(J)) ], 10, ie) ]), _: 2 }, [ o.value.includes(l) ? void 0 : { name: "title", fn: c(() => [ N(h(e(m)("ap.apAppendix.downloadFile")), 1) ]), key: "0" } ]), 1024) ], 2) ], 2))), 128)) ], 2) ], 2) ]), A.value ? d(n.$slots, "empty", { key: 1 }, () => [ s("div", { class: a([e(i)("empty")]) }, [ s("div", { class: a([e(i)("empty-content")]) }, [ r(e(I), { image: e(I).PRESENTED_IMAGE_SIMPLE }, { description: c(() => [ N(h(t.emptyText || e(m)("ap.apAppendix.empty")), 1) ]), _: 1 }, 8, ["image"]) ], 2) ], 2) ]) : k("", !0) ], 16)); } }); export { Ae as default };