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