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