import { ref as s, computed as Z, watch as L, onMounted as Se, onActivated as Oe, nextTick as E, onBeforeUnmount as Re, resolveComponent as O, resolveDirective as Ae, openBlock as n, createElementBlock as l, createElementVNode as c, toDisplayString as g, Fragment as ee, renderList as De, withDirectives as U, createBlock as C, withCtx as k, createTextVNode as te, resolveDynamicComponent as Be, createCommentVNode as i, vShow as oe, renderSlot as u, normalizeStyle as Ie, createVNode as R, unref as ze, h as Te } from "vue"; import { n as xe, B as Pe, y as Me, cP as Ke } from "./index2.js"; const Le = { class: "tools" }, Ee = { class: "title" }, Ue = { class: "btns" }, Fe = { key: 0, style: { "margin-left": "8px" } }, Ve = { class: "list-layout-main" }, qe = { key: 1, class: "side-bar s-theme-bg" }, Ne = { key: 2, class: "layout-list-content" }, We = { key: 0, class: "desc-wrap" }, je = { key: 0, class: "filter-content" }, He = { class: "filter" }, Xe = { key: 1, class: "reset-wrap" }, Ge = { key: 1, class: "filter-more-content" }, Je = { class: "table-content" }, Qe = { class: "table-container" }, Ye = ["onClick"], Ze = { key: 3, class: "layout-list-content" }, et = { class: "other" }, tt = /* @__PURE__ */ Object.assign({ name: "SListLayout" }, { __name: "SListLayout", props: { // 页面标题 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 } ] }, // 列表checkbox列 isSelection: { type: Boolean, default: !1 }, showPagination: { type: Boolean, default: !0 }, columns: { type: Array, default: () => [] }, rowKey: { type: [Function, String], default: "id" }, loadData: { type: Function, required: !0 }, pSize: { type: [String, Number], default: 20 }, // 初始勾选的表格行 key(选择表格弹窗等场景由外部带入) selectedRowKeysArr: { type: Array, default: () => [] } }, emits: ["reset", "btnCallback", "tableColCallback"], setup(p, { expose: ne, emit: le }) { const h = p, y = le, A = s(null), se = s(null), ie = s(null), v = s(null), _ = s(!1), $ = s(!1), F = s(300), m = s(!1), V = s(20), S = s(232), q = s(!1), d = s([]), N = s([]), D = s([]), w = s([]), ae = { 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 = Z(() => w.value.map((e) => e.key).includes("import")), B = Z(() => w.value.find((e) => e.key === "import") || {}); L( () => h.buttons, (e) => { e && e.length && re(e); }, { immediate: !0, deep: !0 } ), L( () => h.columns, () => X() ), L( () => h.selectedRowKeysArr, (e) => { d.value = e || []; }, { immediate: !0 } ); function j(e, t = "") { return !!(e && typeof e == "function"); } function H(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && ae[e.key] || ""; } function re(e) { w.value = e.map((t) => (t.key === "remove" && (q.value = !0), t)); } function ue() { E(() => { Y(), V.value = h.pSize, D.value = h.columns.map((e) => ((e.template || e.isClick || e.dataIndex === "action" && !e.customRender) && !e.scopedSlots && (e.scopedSlots = { customRender: e.dataIndex }), e)); }), setTimeout(() => { const e = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), t = document.querySelector(".ant-table-thead tr"); e && t && t.removeChild(e); }, 100); } function X() { ue(); } function I() { $.value = !$.value, Y(); } function z() { y("reset"); } function T() { v.value && v.value.refresh(!0); } function G(e) { y("btnCallback", e.key, d.value); const t = he[e.key]; typeof t == "function" ? t(e) : x(e); } function x(e) { if (e.selection !== !1 && !d.value.length) { window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`); return; } if (j(e.api, e.name, e.key)) { if (e.confirm) { window.$confirm({ title: `${e.name}`, content: () => Te( "div", { style: "color:var(--s-color-error)" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { m.value = !0, e.api(d.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), y("reset"); }).finally(() => { m.value = !1; }); } }); return; } m.value = !0, e.api(d.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), y("reset"); }).finally(() => { m.value = !1; }); } } function J(e, t) { typeof e == "string" ? Q(e, t) : e.forEach((a) => { Q(a, t); }); } function Q(e, t) { const a = w.value.find((r) => r.key === e); if (!a) { console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`); return; } Object.keys(t).forEach((r) => { a[r] = t[r]; }); } function de() { } function ce(e) { x(e); } function me() { if (!W.value) { y("btnCallback", "import"); return; } _.value = !0; } function fe(e) { j(e.api, e.name, e.key) && (m.value = !0, e.api().then(() => { m.value = !1; })); } function pe(e, t) { y("tableColCallback", e, t); } function P(e) { return D.value.find((t) => t.dataIndex === e); } function ye(e) { const t = P(e); return !!(t && t.template); } function ve(e) { const t = P(e); return !!(t && t.isClick); } function we(e) { return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e; } function ke(e) { d.value = e; } function Y() { E(M); } function M() { const e = v.value && v.value.$el, t = e && e.querySelector(".ant-table-body"), a = t && t.clientHeight; a && (F.value = Math.max(a - 8, 0)); } const he = { add: de, delete: ce, import: me, export: fe, reload: T, filterReset: z, toggleFilter: I, setStateBtn: J, handAction: x }, $e = { mounted(e) { e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => { t.preventDefault(); }), e.onmousedown = (t) => { const a = t.clientX, r = S.value; document.onmousemove = (K) => { const f = K.clientX - a; if (f < 0) { if (r + f <= 232) return; S.value = r + f; } else { if (r + f >= 500) return; S.value = r + f; } }, document.onmouseup = () => { document.onmousemove = document.onmousedown = null; }; }; } }; let b = null; return Se(() => { X(), window.ResizeObserver && A.value && (b = new ResizeObserver(() => M()), b.observe(A.value)); }), Oe(() => { E(M); }), Re(() => { b && (b.disconnect(), b = null); }), ne({ reload: T, spinning: m, selectedRowKeys: d, renderButtons: w, setStateBtn: J, btnCallback: G, filterReset: z, toggleFilter: I, table: v, importVisible: _ }), (e, t) => { const a = Pe, r = O("down-outlined"), K = O("up-outlined"), f = O("sync-outlined"), be = Me, ge = O("s-import-modal"), Ce = Ae("action"); return n(), l("div", { class: "list-layout", ref_key: "layoutRef", ref: A }, [ c("div", Le, [ c("div", Ee, g(p.title), 1), c("div", Ue, [ (n(!0), l(ee, null, De(w.value, (o) => (n(), l("span", { class: "item-btn", key: o.key }, [ U((n(), C(a, { class: "btn", disabled: !!o.disabled, type: o.type || o.key === "add" ? "primary" : "default", onClick: (_e) => G(o) }, { icon: k(() => [ H(o) ? (n(), C(Be(H(o)), { key: 0 })) : i("", !0) ]), default: k(() => [ te(" " + g(e.$l(o.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [Ce, o.action || o.key], [oe, o.show !== !1] ]) ]))), 128)), e.$slots.otherBtns ? (n(), l("span", Fe, [ u(e.$slots, "otherBtns", { selections: d.value }, void 0, !0) ])) : i("", !0) ]) ]), c("div", Ve, [ e.$slots.tree ? (n(), l("div", { key: 0, class: "side s-side-tree", ref: "side", style: Ie([{ width: S.value + "px" }, { "overflow-y": "auto" }]) }, [ u(e.$slots, "tree", {}, void 0, !0) ], 4)) : i("", !0), e.$slots.tree ? U((n(), l("div", qe, null, 512)), [ [$e] ]) : i("", !0), e.$slots.empty ? (n(), l("div", Ze, [ u(e.$slots, "empty", {}, void 0, !0) ])) : (n(), l("div", Ne, [ e.$slots.desc ? (n(), l("div", We, [ u(e.$slots, "desc", {}, void 0, !0) ])) : i("", !0), e.$slots.filter || e.$slots.filterMore ? (n(), l("div", { key: 1, class: "list-filter-wrap", ref_key: "filters", ref: se }, [ e.$slots.filter ? (n(), l("div", je, [ c("div", He, [ u(e.$slots, "filter", {}, void 0, !0) ]), e.$slots.filterMore ? (n(), l("a", { key: 0, class: "filter-more-btn", onClick: I }, [ te(g($.value ? e.$l("收起") : e.$l("更多")) + " ", 1), $.value ? (n(), C(K, { key: 1, style: { "font-size": "12px" } })) : (n(), C(r, { key: 0, style: { "font-size": "12px" } })) ])) : i("", !0), e.$slots.filter ? (n(), l("div", Xe, [ R(be, { placement: "top", overlayStyle: { maxWidth: "500px" }, mouseEnterDelay: 1.5, mouseLeaveDelay: 0.5 }, { title: k(() => [ c("span", null, g(e.$l("条件重置")), 1) ]), default: k(() => [ R(a, { style: { "padding-bottom": "2px" }, onClick: z }, { icon: k(() => [ R(f) ]), _: 1 }) ]), _: 1 }) ])) : i("", !0) ])) : i("", !0), e.$slots.filterMore ? U((n(), l("div", Ge, [ u(e.$slots, "filterMore", {}, void 0, !0) ], 512)), [ [oe, $.value] ]) : i("", !0) ], 512)) : i("", !0), c("div", Je, [ e.$slots.tabs ? (n(), l("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: ie }, [ u(e.$slots, "tabs", {}, void 0, !0) ], 512)) : i("", !0), c("div", Qe, [ R(ze(Ke), { ref_key: "table", ref: v, size: "middle", scroll: { y: F.value, x: "100%" }, pageSize: V.value, rowKey: p.rowKey, columns: D.value, data: p.loadData, "expanded-row-keys": N.value, "onUpdate:expandedRowKeys": t[0] || (t[0] = (o) => N.value = o), rowSelection: q.value || p.isSelection ? { selectedRowKeys: d.value, onChange: ke } : null, showPagination: p.showPagination }, { bodyCell: k((o) => [ o.column ? (n(), l(ee, { key: 0 }, [ ye(o.column.dataIndex) ? u(e.$slots, o.column.dataIndex, { text: o.text, record: o.record, index: o.index, item: P(o.column.dataIndex) }, void 0, !0, 0) : ve(o.column.dataIndex) ? (n(), l("a", { key: 1, onClick: (_e) => pe(o.column.dataIndex, o.record) }, g(we(o.text)), 9, Ye)) : o.column.dataIndex === "action" ? u(e.$slots, "action", { record: o.record }, void 0, !0, 2) : i("", !0) ], 64)) : i("", !0) ]), _: 3 }, 8, ["scroll", "pageSize", "rowKey", "columns", "data", "expanded-row-keys", "rowSelection", "showPagination"]) ]) ]) ])) ]), c("div", et, [ u(e.$slots, "other", {}, void 0, !0) ]), W.value ? (n(), C(ge, { key: 0, ref: "importModalRef", "upload-url": B.value.importUploadUrl, value: _.value, "onUpdate:value": t[1] || (t[1] = (o) => _.value = o), columns: B.value.importColumns, apis: B.value.importApis, onReload: T }, null, 8, ["upload-url", "value", "columns", "apis"])) : i("", !0) ], 512); }; } }), lt = /* @__PURE__ */ xe(tt, [["__scopeId", "data-v-0c821990"]]); export { lt as default };