var ce = ($, G, S) => new Promise((f, v) => { var H = (y) => { try { O(S.next(y)); } catch (N) { v(N); } }, T = (y) => { try { O(S.throw(y)); } catch (N) { v(N); } }, O = (y) => y.done ? f(y.value) : Promise.resolve(y.value).then(H, T); O((S = S.apply($, G)).next()); }); import { ref as s, computed as de, watch as De, onMounted as He, onActivated as Le, nextTick as X, resolveComponent as j, resolveDirective as Be, openBlock as n, createElementBlock as a, createElementVNode as d, toDisplayString as _, Fragment as pe, renderList as fe, withDirectives as q, createBlock as D, withCtx as w, createTextVNode as F, resolveDynamicComponent as Me, createCommentVNode as u, vShow as te, renderSlot as p, normalizeStyle as b, createVNode as C, h as Pe } from "vue"; import { n as Fe, B as Te, y as Ee, ao as Ue, ah as Ve, aO as Ke } from "./index2.js"; const Ie = { class: "tools" }, Re = { class: "title" }, We = { class: "btns" }, Xe = { key: 0, style: { "margin-left": "8px" } }, je = { key: 0, class: "filter-content" }, qe = { class: "filter" }, Ge = { key: 1, class: "reset-wrap" }, Je = { key: 1, class: "filter-more-content" }, Qe = { key: 2, class: "desc-wrap" }, Ye = { class: "table-content" }, Ze = { key: 0, class: "s-card-header" }, xe = { class: "s-card-body" }, et = { class: "s-card-footer" }, tt = { class: "other" }, ot = /* @__PURE__ */ Object.assign({ name: "SListCardLayout" }, { __name: "SListCardLayout", props: { // 每行卡片个数(不传默认每行 5 个) column: { type: [Number, String], default: 5 }, // 卡片数据主键字段(用于 v-for key) rowKey: { type: [Function, String], default: "id" }, // 每页条数可选项 pageSizeOptions: { type: Array, default: () => ["10", "20", "40", "80"] }, // 页面标题 title: { type: String, required: !0 }, buttons: { type: Array, default: () => [ { name: window.$l("添加"), key: "add", show: !0, type: "primary", icon: !0, api: null }, { name: window.$l("批量删除"), key: "remove", action: "remove", show: !0, icon: !0, api: null }, { name: window.$l("导入"), key: "import", show: !0, icon: !0, importColumns: [], // 预览的表头信息 importUploadUrl: null, // 上传url importApis: { templateDownload: null, importPreview: null, importData: null, exportExceptionData: null } }, { name: window.$l("导出"), key: "export", show: !0, icon: !0, api: null } ] }, showPagination: { type: Boolean, default: !0 }, loadData: { type: Function, required: !0 }, pSize: { type: [String, Number], default: 20 } }, emits: ["reset", "btnCallback", "cardAction"], setup($, { expose: G, emit: S }) { const f = $, v = S, H = s(null), T = s(null), O = s(null), y = s(null), N = s(null), E = s(!1), h = s(0), oe = s(0), L = s(!1), B = s(!1), M = s(20), U = s(232), ve = s(!1), z = s([]), A = s([]), P = s([]), V = s(0), g = s(1), K = s(!1), ye = { add: "PlusCircleOutlined", edit: "FormOutlined", delete: "DeleteOutlined", remove: "DeleteOutlined", import: "UploadOutlined", export: "DownloadOutlined", assign: "ClusterOutlined", execute: "PlayCircleOutlined", pause: "PauseCircleOutlined", resume: "PoweroffOutlined", approve: "HighlightOutlined", setting: "SettingOutlined", TopOfType: "VerticalAlignTopOutlined", TOP: "VerticalAlignTopOutlined", synchronize: "SyncOutlined" }, ne = de(() => A.value.map((e) => e.key).includes("import")), J = de(() => A.value.find((e) => e.key === "import") || {}); De( () => f.buttons, (e) => { e && e.length && he(e); }, { immediate: !0, deep: !0 } ); function me(e, t = "") { return !!(e && typeof e == "function"); } function le(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ye[e.key] || ""; } function he(e) { A.value = e.map((t) => (t.key === "remove" && (ve.value = !0), t)); } function ge() { X(() => { ee(), M.value = f.pSize, I(); }); } function Q() { L.value = !L.value, ee(); } function Y() { v("reset"); } function Z(e = !1) { I(e); } function I(e = !1) { return ce(this, null, function* () { var t, l, i, m, c; if (typeof f.loadData == "function") { e && (g.value = 1), K.value = !0; try { const r = (yield f.loadData({ pageNo: g.value, pageSize: Number(M.value) })) || {}, R = r.list || r.data || []; P.value = Array.isArray(R) ? R : [], V.value = (m = (i = (l = r.total) != null ? l : (t = r.pagination) == null ? void 0 : t.total) != null ? i : r.totalCount) != null ? m : 0; const W = r.pageNo || r.pageNum || ((c = r.pagination) == null ? void 0 : c.current); W && (g.value = W); } catch (r) { console.warn("[SListCardLayout] 卡片数据加载失败:", r), P.value = [], V.value = 0; } finally { K.value = !1; } } }); } function we(e, t) { t && Number(t) !== Number(M.value) ? (M.value = Number(t), g.value = 1) : g.value = e, I(); } function se(e, t, l) { v("cardAction", e, t, l); } function $e(e, t) { if (typeof f.rowKey == "function") return f.rowKey(e, t); const l = e == null ? void 0 : e[f.rowKey]; return l == null || l === "" ? t : l; } function ae(e) { v("btnCallback", e.key, z.value); const t = Ce[e.key]; typeof t == "function" ? t(e) : x(e); } function x(e) { if (e.selection !== !1 && !z.value.length) { window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`); return; } if (me(e.api, e.name, e.key)) { if (e.confirm) { window.$confirm({ title: `${e.name}`, content: () => Pe( "div", { style: "color:red" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { B.value = !0, e.api(z.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), v("reset"); }).finally(() => { B.value = !1; }); } }); return; } B.value = !0, e.api(z.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), v("reset"); }).finally(() => { B.value = !1; }); } } function ie(e, t) { typeof e == "string" ? re(e, t) : e.forEach((l) => { re(l, t); }); } function re(e, t) { const l = A.value.find((i) => i.key === e); if (!l) { console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`); return; } Object.keys(t).forEach((i) => { l[i] = t[i]; }); } function ke() { } function _e(e) { x(e); } function be() { if (!ne.value) { v("btnCallback", "import"); return; } E.value = !0; } function ee() { X(() => { var e, t; h.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, ue(); }); } function ue() { X(() => { var m, c, r; const t = ((m = T.value) == null ? void 0 : m.offsetHeight) || 0, l = ((c = O.value) == null ? void 0 : c.offsetHeight) || 0, i = ((r = N.value) == null ? void 0 : r.offsetHeight) || 0; oe.value = Math.max(0, h.value - t - 0 - l - i); }); } const Ce = { add: ke, delete: _e, import: be, reload: Z, filterReset: Y, toggleFilter: Q, setStateBtn: ie, handAction: x }, Se = { mounted(e) { e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => { t.preventDefault(); }), e.onmousedown = (t) => { const l = t.clientX, i = U.value; document.onmousemove = (m) => { const c = m.clientX - l; if (c < 0) { if (i + c <= 232) return; U.value = i + c; } else { if (i + c >= 500) return; U.value = i + c; } }, document.onmouseup = () => { document.onmousemove = document.onmousedown = null; }; }; } }; return He(() => { ge(); }), Le(() => { X(() => { var e, t; h.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, ue(); }); }), G({ reload: Z, spinning: B, selectedRowKeys: z, renderButtons: A, setStateBtn: ie, btnCallback: ae, filterReset: Y, toggleFilter: Q, table: y, importVisible: E, measureLayout: ee, // 卡片列表 list: P, total: V, pageNo: g, fetchList: I }), (e, t) => { const l = Te, i = j("down-outlined"), m = j("up-outlined"), c = j("sync-outlined"), r = Ee, R = Ve, W = Ue, Oe = Ke, Ne = j("s-import-modal"), ze = Be("action"); return n(), a("div", { class: "list-layout", ref_key: "layout", ref: H }, [ d("div", Ie, [ d("div", Re, _($.title), 1), d("div", We, [ (n(!0), a(pe, null, fe(A.value, (o) => (n(), a("span", { class: "item-btn", key: o.key }, [ q((n(), D(l, { class: "btn", disabled: !!o.disabled, type: o.type || o.key === "add" ? "primary" : "default", onClick: (k) => ae(o) }, { icon: w(() => [ le(o) ? (n(), D(Me(le(o)), { key: 0 })) : u("", !0) ]), default: w(() => [ F(" " + _(e.$l(o.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [ze, o.action || o.key], [te, o.show !== !1] ]) ]))), 128)), e.$slots.otherBtns ? (n(), a("span", Xe, [ p(e.$slots, "otherBtns", { selections: z.value }, void 0, !0) ])) : u("", !0) ]) ]), d("div", { class: "list-layout-main", style: b({ height: h.value + "px" }) }, [ e.$slots.tree ? (n(), a("div", { key: 0, class: "side s-side-tree", ref: "side", style: b([{ height: h.value + "px", width: U.value + "px" }, { "overflow-y": "auto" }]) }, [ p(e.$slots, "tree", {}, void 0, !0) ], 4)) : u("", !0), e.$slots.tree ? q((n(), a("div", { key: 1, class: "side-bar s-theme-bg", style: b({ height: h.value + "px" }) }, null, 4)), [ [Se] ]) : u("", !0), e.$slots.empty ? (n(), a("div", { key: 3, class: "layout-list-content", style: b({ height: h.value + "px" }) }, [ p(e.$slots, "empty", {}, void 0, !0) ], 4)) : (n(), a("div", { key: 2, class: "layout-list-content", style: b({ height: h.value - 1 + "px" }) }, [ q(d("div", { class: "list-filter-wrap", ref_key: "filters", ref: T }, [ e.$slots.filter ? (n(), a("div", je, [ d("div", qe, [ p(e.$slots, "filter", {}, void 0, !0) ]), e.$slots.filterMore ? (n(), a("a", { key: 0, class: "filter-more-btn", onClick: Q }, [ F(_(L.value ? e.$l("收起") : e.$l("更多")) + " ", 1), L.value ? (n(), D(m, { key: 1, style: { "font-size": "12px" } })) : (n(), D(i, { key: 0, style: { "font-size": "12px" } })) ])) : u("", !0), e.$slots.filter ? (n(), a("div", Ge, [ C(r, { placement: "top", overlayStyle: { maxWidth: "500px" }, mouseEnterDelay: 1.5, mouseLeaveDelay: 0.5 }, { title: w(() => [ d("span", null, _(e.$l("条件重置")), 1) ]), default: w(() => [ C(l, { style: { "padding-bottom": "2px" }, onClick: Y }, { icon: w(() => [ C(c) ]), _: 1 }) ]), _: 1 }) ])) : u("", !0) ])) : u("", !0), e.$slots.filterMore ? q((n(), a("div", Je, [ p(e.$slots, "filterMore", {}, void 0, !0) ], 512)), [ [te, L.value] ]) : u("", !0), e.$slots.desc ? (n(), a("div", Qe, [ p(e.$slots, "desc", {}, void 0, !0) ])) : u("", !0) ], 512), [ [te, e.$slots.filter] ]), d("div", Ye, [ e.$slots.tabs ? (n(), a("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: O }, [ p(e.$slots, "tabs", {}, void 0, !0) ], 512)) : u("", !0), d("div", { class: "table-container", style: b({ height: oe.value - 1 + "px" }) }, [ C(W, { spinning: K.value }, { default: w(() => [ d("div", { class: "s-card-grid", style: b({ gridTemplateColumns: `repeat(${$.column}, 1fr)` }) }, [ (n(!0), a(pe, null, fe(P.value, (o, k) => (n(), a("div", { class: "s-card-item", key: $e(o, k) }, [ e.$slots.cardHeader || o.title ? (n(), a("div", Ze, [ p(e.$slots, "cardHeader", { item: o, index: k }, () => [ F(_(o.title), 1) ], !0) ])) : u("", !0), d("div", xe, [ p(e.$slots, "default", { item: o, index: k }, void 0, !0) ]), d("div", et, [ p(e.$slots, "cardFooter", { item: o, index: k }, () => [ C(l, { type: "link", size: "small", onClick: (Ae) => se("edit", o, k) }, { default: w(() => [ F(_(e.$l("编辑")), 1) ]), _: 1 }, 8, ["onClick"]), C(l, { type: "link", size: "small", danger: "", onClick: (Ae) => se("delete", o, k) }, { default: w(() => [ F(_(e.$l("删除")), 1) ]), _: 1 }, 8, ["onClick"]) ], !0) ]) ]))), 128)), !K.value && !P.value.length ? (n(), D(R, { key: 0, class: "s-card-empty", description: e.$l("暂无数据") }, null, 8, ["description"])) : u("", !0) ], 4) ]), _: 3 }, 8, ["spinning"]) ], 4), $.showPagination ? (n(), a("div", { key: 1, class: "s-card-pagination", ref_key: "pager", ref: N }, [ C(Oe, { current: g.value, "onUpdate:current": t[0] || (t[0] = (o) => g.value = o), "page-size": Number(M.value), total: V.value, "show-size-changer": "", "page-size-options": $.pageSizeOptions, "show-total": (o) => `${e.$l("共")}${o}${e.$l("条")}`, onChange: we }, null, 8, ["current", "page-size", "total", "page-size-options", "show-total"]) ], 512)) : u("", !0) ]) ], 4)) ], 4), d("div", tt, [ p(e.$slots, "other", {}, void 0, !0) ]), ne.value ? (n(), D(Ne, { key: 0, ref: "importModalRef", "upload-url": J.value.importUploadUrl, value: E.value, "onUpdate:value": t[1] || (t[1] = (o) => E.value = o), columns: J.value.importColumns, apis: J.value.importApis, onReload: Z }, null, 8, ["upload-url", "value", "columns", "apis"])) : u("", !0) ], 512); }; } }), at = /* @__PURE__ */ Fe(ot, [["__scopeId", "data-v-65914cae"]]); export { at as default };