import { getCurrentInstance as De, ref as l, computed as Z, watch as Ie, onMounted as Le, resolveComponent as A, resolveDirective as Re, openBlock as n, createElementBlock as a, createElementVNode as d, toDisplayString as g, Fragment as ee, renderList as Be, withDirectives as P, createBlock as b, withCtx as w, createTextVNode as te, resolveDynamicComponent as Me, createCommentVNode as i, vShow as oe, renderSlot as c, normalizeStyle as _, createVNode as D, nextTick as z, h as ne } from "vue"; import { useRoute as He } from "vue-router"; import { n as Ke, B as Ee, y as Pe } from "./index2.js"; import { _ as ze } from "./index12.js"; const Fe = { class: "tools" }, Ue = { class: "title" }, Ve = { class: "btns" }, Ne = { style: { "margin-left": "8px" } }, qe = { key: 0, class: "filter-content" }, We = { class: "filter" }, Xe = { key: 1, class: "reset-wrap" }, je = { key: 1, class: "filter-more-content" }, Ge = { key: 2, class: "desc-wrap" }, Je = { class: "table-content" }, Qe = { class: "table-container" }, Ye = ["onClick"], Ze = { class: "other" }, et = /* @__PURE__ */ Object.assign({ name: "SListTableTreeLayout" }, { __name: "SListTableTreeLayout", props: { // 页面标题 title: { type: String, required: !0 }, buttons: { type: Array, default: () => [ { name: window.$l("添加"), key: "add", show: !0, type: "primary", icon: "plus-circle", api: null }, { name: window.$l("批量删除"), key: "remove", action: "remove", show: !0, icon: "delete", api: null }, { name: window.$l("导入"), key: "import", show: !0, icon: "upload", importColumns: [], // 预览的表头信息 importUploadUrl: null, // 上传url importApis: { templateDownload: null, importPreview: null, importData: null, exportExceptionData: null } }, { name: window.$l("导出"), key: "export", show: !0, icon: "download", api: null } ] }, // 列表checkbox列 isSelection: { type: Boolean, default: !1 }, showBtnIcon: { type: Boolean, default: !0 }, showPagination: { type: Boolean, default: !0 }, columns: { type: Array, default: () => [] }, rowKey: { type: [Function, String], default: "id" }, tableLoading: { type: Boolean, default: !1 }, loadData: { type: Function, required: !0 } }, emits: ["reset", "btnCallback", "tableColCallback", "handExpand"], setup(h, { expose: le, emit: ae }) { const I = h, p = ae; He(), De(); const F = l(null), ie = l(null), U = l(null), V = l(null), N = l(null), se = l(null), C = l(!1), u = l(0), q = l(0), $ = l(!1), m = l(!1), S = l(232), r = l([]), x = l([]), k = l([]), W = l(!1), ue = l([]), O = l([]), L = 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" }, X = Z(() => k.value.map((e) => e.key).includes("import")), R = Z(() => k.value.find((e) => e.key === "import") || {}); Ie( () => I.buttons, (e) => { e && e.length && de(e); }, { immediate: !0, deep: !0 } ); function B(e, t = "") { return !!(e && typeof e == "function"); } function j(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && re[e.key] || ""; } function de(e) { k.value = e.map((t) => (t.key === "remove" && (W.value = !0), t)); } function ce() { z(() => { E(), x.value = I.columns.map((t) => ((t.template || t.isClick || t.dataIndex === "action" && !t.customRender) && !t.scopedSlots && (t.scopedSlots = { customRender: t.dataIndex }), t)), T(); }); const e = setTimeout(() => { const t = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), s = document.querySelector(".ant-table-thead tr"); t && s && s.removeChild(t), clearTimeout(e); }, 100); } function pe() { ce(); } function M() { $.value = !$.value, E(); } function G(e, t) { const s = Y[e]; return s(t); } function H() { p("reset"); } function T() { I.loadData({ pageNo: 1, pageSize: 0 }).then((e) => { !e.list || !e.list.length ? O.value = ue.value : O.value = e.list; }); } function J(e) { p("btnCallback", e.key, r.value); const t = Y[e.key]; typeof t == "function" ? t(e) : Q(e); } function Q(e) { if (e.selection !== !1 && !r.value.length) { window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`); return; } if (B(e.api, e.name)) { if (e.confirm) { window.$confirm({ title: `${e.name}`, content: () => ne( "div", { style: "color:red" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { m.value = !0, e.api(r.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset"); }).finally(() => { m.value = !1; }); } }); return; } m.value = !0, e.api(r.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), p("reset"); }).finally(() => { m.value = !1; }); } } function me() { p("btnCallback", "add"); } function fe() { if (!r.value.length) { window.$notice.warn({ key: "only-you", message: window.$l("操作失败"), description: window.$l("请选择要删除的数据") }); return; } B("deletesApi") && window.$confirm({ title: window.$l("确认删除"), content: () => ne("div", { style: "color: red" }, window.$l("确认要批量删除数据吗?")), onOk: () => { m.value = !0, G("deletesApi", r.value).then(() => { window.$notice.success({ key: "only-you", message: window.$l("操作成功"), description: window.$l("删除成功") }), p("reset"); }).finally(() => { m.value = !1; }); } }); } function ye() { if (!X.value) { p("btnCallback", "import"); return; } C.value = !0; } function ve() { B("exportApi") && (m.value = !0, G("exportApi").then(() => { m.value = !1; })); } function we(e, t) { p("tableColCallback", e, t); } function K(e) { return x.value.find((t) => t.dataIndex === e); } function he(e) { const t = K(e); return !!(t && t.template); } function $e(e) { const t = K(e); return !!(t && t.isClick); } function ke(e) { return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e; } function ge(e) { r.value = e; } function E() { z(() => { var e, t; u.value = (((t = (e = F.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, be(); }); } function be() { z(() => { var f, v; const t = ((f = U.value) == null ? void 0 : f.offsetHeight) || 0, s = ((v = V.value) == null ? void 0 : v.offsetHeight) || 0; (!u.value || u.value < 200) && (u.value = 400), q.value = u.value - t - 60 - s; }); } function _e(e, t) { p("handExpand", e, t); } const Y = { add: me, remove: fe, import: ye, export: ve, reload: T, filterReset: H, toggleFilter: M, handAction: Q }, Ce = { mounted(e) { e.style.cursor = "e-resize", document.addEventListener("selectstart", (t) => { t.preventDefault(); }), e.onmousedown = (t) => { const s = t.clientX, f = S.value; document.onmousemove = (v) => { const y = v.clientX - s; if (y < 0) { if (f + y <= 232) return; S.value = f + y; } else { if (f + y >= 500) return; S.value = f + y; } }, document.onmouseup = () => { document.onmousemove = document.onmousedown = null; }; }; } }; return Le(() => { pe(); }), le({ reload: T, spinning: m, selectedRowKeys: r, expandedRowKeys: L, renderColumns: x, renderButtons: k, tableData: O, table: N, importVisible: C, measureLayout: E, toggleFilter: M, filterReset: H, btnCallback: J }), (e, t) => { const s = Ee, f = A("down-outlined"), v = A("up-outlined"), y = A("sync-outlined"), Se = Pe, xe = ze, Oe = A("s-import-modal"), Te = Re("action"); return n(), a("div", { class: "list-layout", ref_key: "layout", ref: F }, [ d("div", Fe, [ d("div", Ue, g(h.title), 1), d("div", Ve, [ (n(!0), a(ee, null, Be(k.value, (o) => (n(), a("span", { class: "item-btn", key: o.key }, [ P((n(), b(s, { class: "btn", disabled: !!o.disabled, type: o.type || o.key === "add" ? "primary" : "default", onClick: (Ae) => J(o) }, { icon: w(() => [ j(o) ? (n(), b(Me(j(o)), { key: 0 })) : i("", !0) ]), default: w(() => [ te(" " + g(e.$l(o.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [Te, o.action || o.key], [oe, o.show !== !1] ]) ]))), 128)), d("span", Ne, [ c(e.$slots, "otherBtns", { selections: r.value }, void 0, !0) ]) ]) ]), d("div", { class: "list-layout-main", style: _({ height: u.value + "px" }) }, [ e.$slots.tree ? (n(), a("div", { key: 0, class: "side s-side-tree", ref_key: "side", ref: ie, style: _({ height: u.value + "px", width: S.value + "px" }) }, [ c(e.$slots, "tree", {}, void 0, !0) ], 4)) : i("", !0), e.$slots.tree ? P((n(), a("div", { key: 1, class: "side-bar s-theme-bg", style: _({ height: u.value + "px" }) }, null, 4)), [ [Ce] ]) : i("", !0), e.$slots.empty ? (n(), a("div", { key: 3, class: "layout-list-content", style: _({ height: u.value + "px" }) }, [ c(e.$slots, "empty", {}, void 0, !0) ], 4)) : (n(), a("div", { key: 2, class: "layout-list-content", style: _({ height: u.value + "px" }) }, [ e.$slots.filter || e.$slots.filterMore ? (n(), a("div", { key: 0, class: "list-filter-wrap", ref_key: "filters", ref: U }, [ e.$slots.filter ? (n(), a("div", qe, [ d("div", We, [ c(e.$slots, "filter", {}, void 0, !0) ]), e.$slots.filterMore ? (n(), a("a", { key: 0, class: "filter-more-btn", onClick: M }, [ te(g($.value ? e.$l("收起") : e.$l("更多")) + " ", 1), $.value ? (n(), b(v, { key: 1, style: { "font-size": "12px" } })) : (n(), b(f, { key: 0, style: { "font-size": "12px" } })) ])) : i("", !0), e.$slots.filter ? (n(), a("div", Xe, [ D(Se, { placement: "top", overlayStyle: { maxWidth: "500px" }, mouseEnterDelay: 1.5, mouseLeaveDelay: 0.5 }, { title: w(() => [ d("span", null, g(e.$l("条件重置")), 1) ]), default: w(() => [ D(s, { style: { "padding-bottom": "2px" }, onClick: H }, { icon: w(() => [ D(y) ]), _: 1 }) ]), _: 1 }) ])) : i("", !0) ])) : i("", !0), e.$slots.filterMore ? P((n(), a("div", je, [ c(e.$slots, "filterMore", {}, void 0, !0) ], 512)), [ [oe, $.value] ]) : i("", !0), e.$slots.desc ? (n(), a("div", Ge, [ c(e.$slots, "desc", {}, void 0, !0) ])) : i("", !0) ], 512)) : i("", !0), d("div", Je, [ e.$slots.tabs ? (n(), a("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: V }, [ c(e.$slots, "tabs", {}, void 0, !0) ], 512)) : i("", !0), d("div", Qe, [ D(xe, { ref_key: "table", ref: N, size: "middle", scroll: { y: q.value }, rowKey: h.rowKey, tableLoading: h.tableLoading, columns: x.value, dataSource: O.value, expandedRowKeys: L.value, "onUpdate:expandedRowKeys": t[0] || (t[0] = (o) => L.value = o), rowSelection: W.value || h.isSelection ? { selectedRowKeys: r.value, onChange: ge } : null, pagination: !1, onExpand: _e }, { bodyCell: w((o) => [ o.column ? (n(), a(ee, { key: 0 }, [ he(o.column.dataIndex) ? c(e.$slots, o.column.dataIndex, { text: o.text, record: o.record, index: o.index, item: K(o.column.dataIndex) }, void 0, !0, 0) : $e(o.column.dataIndex) ? (n(), a("a", { key: 1, onClick: (Ae) => we(o.column.dataIndex, o.record) }, g(ke(o.text)), 9, Ye)) : o.column.dataIndex === "action" ? c(e.$slots, "action", { record: o.record }, void 0, !0, 2) : i("", !0) ], 64)) : i("", !0) ]), _: 3 }, 8, ["scroll", "rowKey", "tableLoading", "columns", "dataSource", "expandedRowKeys", "rowSelection"]) ]) ]) ], 4)) ], 4), d("div", Ze, [ c(e.$slots, "other", {}, void 0, !0) ]), X.value ? (n(), b(Oe, { key: 0, ref_key: "importModalRef", ref: se, "upload-url": R.value.importUploadUrl, value: C.value, "onUpdate:value": t[1] || (t[1] = (o) => C.value = o), columns: R.value.importColumns, apis: R.value.importApis, onReload: T }, null, 8, ["upload-url", "value", "columns", "apis"])) : i("", !0) ], 512); }; } }), at = /* @__PURE__ */ Ke(et, [["__scopeId", "data-v-99511031"]]); export { at as default };