UNPKG

@aplus-frontend/ui

Version:

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