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