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