import { ref as n, computed as G, watch as ye, onMounted as ve, onActivated as we, nextTick as C, resolveComponent as S, resolveDirective as he, openBlock as o, createElementBlock as s, createElementVNode as u, toDisplayString as O, Fragment as $e, renderList as ke, withDirectives as D, createBlock as k, withCtx as g, createTextVNode as J, resolveDynamicComponent as ge, createCommentVNode as r, vShow as E, renderSlot as d, normalizeStyle as v, createVNode as R, h as _e } from "vue"; import { useRoute as be } from "vue-router"; import { n as Ce, B as Se, y as Oe } from "./index2.js"; const De = { class: "tools" }, Be = { class: "title" }, He = { class: "btns" }, Le = { key: 0, style: { "margin-left": "8px" } }, Ae = { key: 0, class: "filter-content" }, Me = { class: "filter" }, Ne = { key: 1, class: "reset-wrap" }, ze = { key: 1, class: "filter-more-content" }, Pe = { key: 2, class: "desc-wrap" }, Te = { class: "table-content" }, Ee = { class: "other" }, Re = /* @__PURE__ */ Object.assign({ name: "SListCardLayout" }, { __name: "SListCardLayout", props: { col: { type: [Number, String], default: 4 }, cardHeight: { type: Number, default: 300 }, // 页面标题 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"], setup(B, { expose: Q, emit: Y }) { const V = B, w = Y; be(); const H = n(null), Z = n(null), F = n(null), U = n(null), L = n(null), ee = n(null), _ = n(!1), c = n(0), I = n(0); n(!1); const h = n(!1), $ = n(!1), te = n(20), b = n(232), oe = n(!1), f = n([]), m = n([]), ne = { 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" }, W = G(() => m.value.map((e) => e.key).includes("import")), A = G(() => m.value.find((e) => e.key === "import") || {}); ye( () => V.buttons, (e) => { e && e.length && se(e); }, { immediate: !0, deep: !0 } ); function le(e, t = "") { return !!(e && typeof e == "function"); } function x(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ne[e.key] || ""; } function se(e) { m.value = e.map((t) => (t.key === "remove" && (oe.value = !0), t)); } function ie() { C(() => { T(), te.value = V.pSize; }); } function M() { h.value = !h.value, T(); } function N() { w("reset"); } function z() { L.value && L.value.refresh(!0); } function X(e) { w("btnCallback", e.key, f.value); const t = de[e.key]; typeof t == "function" ? t(e) : P(e); } function P(e) { if (e.selection !== !1 && !f.value.length) { window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`); return; } if (le(e.api, e.name, e.key)) { if (e.confirm) { window.$confirm({ title: `${e.name}`, content: () => _e( "div", { style: "color:red" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { $.value = !0, e.api(f.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), w("reset"); }).finally(() => { $.value = !1; }); } }); return; } $.value = !0, e.api(f.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), w("reset"); }).finally(() => { $.value = !1; }); } } function j(e, t) { typeof e == "string" ? q(e, t) : e.forEach((a) => { q(a, t); }); } function q(e, t) { const a = m.value.find((l) => l.key === e); if (!a) { console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`); return; } Object.keys(t).forEach((l) => { a[l] = t[l]; }); } function ae() { } function re(e) { P(e); } function ue() { if (!W.value) { w("btnCallback", "import"); return; } _.value = !0; } function T() { C(() => { var e, t; c.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, K(); }); } function K() { C(() => { var l, y; const t = ((l = F.value) == null ? void 0 : l.offsetHeight) || 0, a = ((y = U.value) == null ? void 0 : y.offsetHeight) || 0; I.value = c.value - t - 0 - a; }); } const de = { add: ae, delete: re, import: ue, reload: z, filterReset: N, toggleFilter: M, setStateBtn: j, handAction: P }, ce = { mounted(e) { e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => { t.preventDefault(); }), e.onmousedown = (t) => { const a = t.clientX, l = b.value; document.onmousemove = (y) => { const p = y.clientX - a; if (p < 0) { if (l + p <= 232) return; b.value = l + p; } else { if (l + p >= 500) return; b.value = l + p; } }, document.onmouseup = () => { document.onmousemove = document.onmousedown = null; }; }; } }; return ve(() => { ie(); }), we(() => { C(() => { var e, t; c.value = (((t = (e = H.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, K(); }); }), Q({ reload: z, spinning: $, selectedRowKeys: f, renderButtons: m, setStateBtn: j, btnCallback: X, filterReset: N, toggleFilter: M, table: L, importVisible: _, measureLayout: T }), (e, t) => { const a = Se, l = S("down-outlined"), y = S("up-outlined"), p = S("sync-outlined"), pe = Oe, fe = S("s-import-modal"), me = he("action"); return o(), s("div", { class: "list-layout", ref_key: "layout", ref: H }, [ u("div", De, [ u("div", Be, O(B.title), 1), u("div", He, [ (o(!0), s($e, null, ke(m.value, (i) => (o(), s("span", { class: "item-btn", key: i.key }, [ D((o(), k(a, { class: "btn", disabled: !!i.disabled, type: i.type || i.key === "add" ? "primary" : "default", onClick: (Ve) => X(i) }, { icon: g(() => [ x(i) ? (o(), k(ge(x(i)), { key: 0 })) : r("", !0) ]), default: g(() => [ J(" " + O(e.$l(i.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [me, i.action || i.key], [E, i.show !== !1] ]) ]))), 128)), e.$slots.otherBtns ? (o(), s("span", Le, [ d(e.$slots, "otherBtns", { selections: f.value }, void 0, !0) ])) : r("", !0) ]) ]), u("div", { class: "list-layout-main", style: v({ height: c.value + "px" }) }, [ e.$slots.tree ? (o(), s("div", { key: 0, class: "side s-side-tree", ref_key: "side", ref: Z, style: v([{ height: c.value + "px", width: b.value + "px" }, { "overflow-y": "auto" }]) }, [ d(e.$slots, "tree", {}, void 0, !0) ], 4)) : r("", !0), e.$slots.tree ? D((o(), s("div", { key: 1, class: "side-bar s-theme-bg", style: v({ height: c.value + "px" }) }, null, 4)), [ [ce] ]) : r("", !0), e.$slots.empty ? (o(), s("div", { key: 3, class: "layout-list-content", style: v({ height: c.value + "px" }) }, [ d(e.$slots, "empty", {}, void 0, !0) ], 4)) : (o(), s("div", { key: 2, class: "layout-list-content", style: v({ height: c.value - 1 + "px" }) }, [ D(u("div", { class: "list-filter-wrap", ref_key: "filters", ref: F }, [ e.$slots.filter ? (o(), s("div", Ae, [ u("div", Me, [ d(e.$slots, "filter", {}, void 0, !0) ]), e.$slots.filterMore ? (o(), s("a", { key: 0, class: "filter-more-btn", onClick: M }, [ J(O(h.value ? e.$l("收起") : e.$l("更多")) + " ", 1), h.value ? (o(), k(y, { key: 1, style: { "font-size": "12px" } })) : (o(), k(l, { key: 0, style: { "font-size": "12px" } })) ])) : r("", !0), e.$slots.filter ? (o(), s("div", Ne, [ R(pe, { placement: "top", overlayStyle: { maxWidth: "500px" }, mouseEnterDelay: 1.5, mouseLeaveDelay: 0.5 }, { title: g(() => [ u("span", null, O(e.$l("条件重置")), 1) ]), default: g(() => [ R(a, { style: { "padding-bottom": "2px" }, onClick: N }, { icon: g(() => [ R(p) ]), _: 1 }) ]), _: 1 }) ])) : r("", !0) ])) : r("", !0), e.$slots.filterMore ? D((o(), s("div", ze, [ d(e.$slots, "filterMore", {}, void 0, !0) ], 512)), [ [E, h.value] ]) : r("", !0), e.$slots.desc ? (o(), s("div", Pe, [ d(e.$slots, "desc", {}, void 0, !0) ])) : r("", !0) ], 512), [ [E, e.$slots.filter] ]), u("div", Te, [ e.$slots.tabs ? (o(), s("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: U }, [ d(e.$slots, "tabs", {}, void 0, !0) ], 512)) : r("", !0), u("div", { class: "table-container", style: v({ display: "grid", gridTemplateColumns: `repeat(${B.col}, 1fr)`, gap: "12px", height: I.value - 1 + "px" }) }, [ d(e.$slots, "default", {}, void 0, !0) ], 4) ]) ], 4)) ], 4), u("div", Ee, [ d(e.$slots, "other", {}, void 0, !0) ]), W.value ? (o(), k(fe, { key: 0, ref_key: "importModalRef", ref: ee, "upload-url": A.value.importUploadUrl, value: _.value, "onUpdate:value": t[0] || (t[0] = (i) => _.value = i), columns: A.value.importColumns, apis: A.value.importApis, onReload: z }, null, 8, ["upload-url", "value", "columns", "apis"])) : r("", !0) ], 512); }; } }), We = /* @__PURE__ */ Ce(Re, [["__scopeId", "data-v-078574c4"]]); export { We as default };