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