var Ke = Object.defineProperty; var le = Object.getOwnPropertySymbols; var Ee = Object.prototype.hasOwnProperty, Ue = Object.prototype.propertyIsEnumerable; var ae = (u, r, d) => r in u ? Ke(u, r, { enumerable: !0, configurable: !0, writable: !0, value: d }) : u[r] = d, M = (u, r) => { for (var d in r || (r = {})) Ee.call(r, d) && ae(u, d, r[d]); if (le) for (var d of le(r)) Ue.call(r, d) && ae(u, d, r[d]); return u; }; import { ref as a, computed as K, watch as ie, onMounted as Ve, onActivated as qe, resolveComponent as h, resolveDirective as Ne, openBlock as l, createElementBlock as s, createElementVNode as f, toDisplayString as C, Fragment as se, renderList as je, withDirectives as ue, createBlock as R, withCtx as k, createTextVNode as T, resolveDynamicComponent as We, createCommentVNode as c, vShow as re, renderSlot as p, createVNode as m, normalizeStyle as E, unref as Ge, nextTick as U, h as Je } from "vue"; import { n as Qe, B as Xe, y as Ye, aP as Ze } from "./index2.js"; const et = { class: "tools" }, tt = { class: "title" }, nt = { class: "btn-list" }, ot = { key: 0, style: { "margin-left": "8px" } }, lt = { key: 0, class: "filter-content" }, at = { class: "filter" }, it = { key: 1, class: "reset-wrap" }, st = { key: 1, class: "filter-more-content" }, ut = { key: 2, class: "desc-wrap" }, rt = { class: "table-content" }, dt = { class: "table-container" }, ct = ["onClick"], ft = { class: "other" }, mt = /* @__PURE__ */ Object.assign({ name: "SSuperListLayout" }, { __name: "SSuperListLayout", 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 }, /** title = String:列标题 * @dataIndex = String:列数据字段名 * @align = String:left || right || center * @ellipsis = true:是否自动换行 * @isClick = true:是否支持点击跳转 * @template = true:是否使用自定义模板 * @customRender = Function:自定义jsx模板 * @fixed = null:是否固定列 left || right || null 默认null * @isFixed = false:是否固定列 Boolean fixed存在时无效 * @width = null:列宽 不要写百分比 组件内强制转换成Number * @filterConfig = 默认null | Object: 自定义筛选配置 { @filterType = String: SINGLE_SELECT:单选/ MULTIPLE_SELECT:多选/ GANDER:性别/ IS:是否/ USER:用户/ OFFICE:组织机构/ DATE:日期/ DATETIME:时间/ INPUT:输入框 INT:整数/ FLOAT:浮点数/ @filterApi = null:自定义接口 Function => filterType = SINGLE_SELECT || MULTIPLE_SELECT || GANDER || IS 时生效 @filterData = []:自定义数据 Array => filterType = SINGLE_SELECT || MULTIPLE_SELECT || GANDER || IS 时生效 优先级大于 filterApi @props = Object:自定义属性 使用filterApi时 处理 结果集中的 key、value 键值对映射内容使用 @precision = 0:小数点后保留位数 filterType = FLOAT 时生效 @step = 1:步长 filterType = INT || FLOAT 时生效 @minValue = 0:最小值 filterType = INT || FLOAT 时生效 @maxValue = 0:最大值 filterType = INT || FLOAT 时生效 @length = 200:长度 filterType = INPUT 时生效 @startDate = null :开始可选时间 filterType = DATE || DATETIME 时生效 @endDate = null :结束可选时间 filterType = DATE || DATETIME 时生效 * } */ 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(u, { expose: r, emit: d }) { const _ = u, b = d, V = a(null), q = a(null), N = a(null), v = a(null), j = a(null), W = a(null), I = a(!1), O = a(!1), x = a(0), G = a(0), $ = a(!1), J = a(20), Q = a(!1), y = a([]), A = a([]), w = a([]), S = a([]), P = a({}), 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" }, ce = K(() => w.value.filter((e) => e.show !== !1)), X = K(() => S.value.map((e) => e.key).includes("import")), L = K(() => S.value.find((e) => e.key === "import") || {}); ie( () => _.buttons, (e) => { e && e.length && fe(e); }, { immediate: !0, deep: !0 } ), ie( () => _.columns, (e) => { ee(e || []); }, { deep: !0, immediate: !0 } ); function Y(e, t = "") { return !!(e && typeof e == "function"); } function Z(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && de[e.key] || ""; } function fe(e) { S.value = e.map((t) => (t.key === "remove" && (Q.value = !0), t)); } function me(e) { U(() => { D(), J.value = _.pSize, w.value = e.map((o) => ((o.template || o.isClick || o.dataIndex === "action" && !o.customRender) && !o.scopedSlots && (o.scopedSlots = { customRender: o.dataIndex }), (o.dataIndex === "action" || o.title === "操作") && (o.fixed = "right"), o)); }); const t = setTimeout(() => { const o = document.querySelector(".ant-table-cell.ant-table-cell-scrollbar"), i = document.querySelector(".ant-table-thead tr"); o && i && i.removeChild(o), clearTimeout(t); }, 100); } function ee(e = []) { me(e); } function z() { v.value && v.value.refresh(!0); } function te(e) { b("btnCallback", e.key, y.value); const t = Be[e.key]; typeof t == "function" ? t(e) : F(e); } function F(e) { if (e.selection !== !1 && !y.value.length) { window.$message.warn(`${window.$l("请选择要")}${window.$l(e.name)}${window.$l("的数据")}`); return; } if (Y(e.api, e.name, e.key)) { if (e.confirm) { window.$confirm({ title: `${window.$l(e.name)}`, content: () => Je( "div", { style: "color:red" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { $.value = !0, e.api(y.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), b("reset"); }).finally(() => { $.value = !1; }); } }); return; } $.value = !0, e.api(y.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), b("reset"); }).finally(() => { $.value = !1; }); } } function ne(e, t) { typeof e == "string" ? oe(e, t) : e.forEach((o) => { oe(o, t); }); } function oe(e, t) { const o = S.value.find((i) => i.key === e); if (!o) { console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`); return; } Object.keys(t).forEach((i) => { o[i] = t[i]; }); } function pe() { } function ve(e) { F(e); } function ye() { if (!X.value) { b("btnCallback", "import"); return; } I.value = !0; } function we(e) { Y(e.api, e.name, e.key) && ($.value = !0, e.api().then(() => { $.value = !1; })); } function he(e) { return _.loadData(M(M({}, e), P.value)); } function ke(e = [], t = 1) { const o = { filterMode: t, filterConditions: e }; e.forEach((i) => { ["equal", "includes"].includes(i.equals) && o[i.dataIndex] === void 0 && (o[i.dataIndex] = i.value); }), P.value = o, v.value && v.value.refresh(!0); } function $e() { P.value = {}, v.value && v.value.refresh(!0); } function ge(e) { w.value = e; } function Ce() { ee(_.columns || []); } function be(e, t) { b("tableColCallback", e, t); } function H(e) { return w.value.find((t) => t.dataIndex === e); } function Se(e) { const t = H(e); return !!(t && t.template); } function _e(e) { const t = H(e); return !!(t && t.isClick); } function Oe(e) { return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e; } function xe(e) { y.value = e; } function D() { U(() => { var e, t; x.value = (((t = (e = V.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, Re(); }); } function Re() { U(() => { var i, B; const t = ((i = q.value) == null ? void 0 : i.offsetHeight) || 0, o = ((B = N.value) == null ? void 0 : B.offsetHeight) || 0; G.value = x.value - t - 103 - o; }); } function Ie() { O.value = !O.value, D(); } function De() { b("reset"); } const Be = { add: pe, delete: ve, import: ye, export: we, reload: z, setStateBtn: ne, handAction: F }; return Ve(() => { }), qe(() => D()), r({ reload: z, spinning: $, selectedRowKeys: y, expandedRowKeys: A, renderColumns: w, renderButtons: S, setStateBtn: ne, btnCallback: te, table: v, importVisible: I, measureLayout: D }), (e, t) => { const o = Xe, i = h("SearchOutlined"), B = h("SettingOutlined"), Te = h("down-outlined"), Ae = h("up-outlined"), Pe = h("sync-outlined"), Le = Ye, ze = h("setting-filter"), Fe = h("setting-columns"), He = h("s-import-modal"), Me = Ne("action"); return l(), s("div", { class: "list-layout", ref_key: "layout", ref: V }, [ f("div", et, [ f("div", tt, C(u.title), 1), f("div", nt, [ (l(!0), s(se, null, je(S.value, (n) => (l(), s("span", { class: "item-btn", key: n.key }, [ ue((l(), R(o, { class: "btn", disabled: !!n.disabled, type: n.type || n.key === "add" ? "primary" : "default", onClick: (g) => te(n) }, { icon: k(() => [ Z(n) ? (l(), R(We(Z(n)), { key: 0 })) : c("", !0) ]), default: k(() => [ T(" " + C(e.$l(n.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [Me, n.action || n.key], [re, n.show !== !1] ]) ]))), 128)), e.$slots.otherBtns ? (l(), s("span", ot, [ p(e.$slots, "otherBtns", { selections: y.value }, void 0, !0) ])) : c("", !0), f("span", null, [ m(o, { class: "btn", onClick: t[0] || (t[0] = (n) => { var g; return (g = j.value) == null ? void 0 : g.show(w.value); }) }, { default: k(() => [ m(i), T(" " + C(e.$l("高级搜索")), 1) ]), _: 1 }), m(o, { class: "btn", onClick: t[1] || (t[1] = (n) => { var g; return (g = W.value) == null ? void 0 : g.show(); }) }, { default: k(() => [ m(B), T(" " + C(e.$l("高级表格")), 1) ]), _: 1 }) ]) ]) ]), f("div", { class: "list-layout-main", style: E({ height: x.value + "px" }) }, [ e.$slots.empty ? (l(), s("div", { key: 1, class: "layout-list-content", style: E({ height: x.value + "px" }) }, [ p(e.$slots, "empty", {}, void 0, !0) ], 4)) : (l(), s("div", { key: 0, class: "layout-list-content", style: E({ height: x.value + "px" }) }, [ e.$slots.filter || e.$slots.desc ? (l(), s("div", { key: 0, class: "list-filter-wrap", ref_key: "filters", ref: q }, [ e.$slots.filter ? (l(), s("div", lt, [ f("div", at, [ p(e.$slots, "filter", {}, void 0, !0) ]), e.$slots.filterMore ? (l(), s("a", { key: 0, class: "filter-more-btn", onClick: Ie }, [ T(C(O.value ? e.$l("收起") : e.$l("更多")) + " ", 1), O.value ? (l(), R(Ae, { key: 1, style: { "font-size": "12px" } })) : (l(), R(Te, { key: 0, style: { "font-size": "12px" } })) ])) : c("", !0), e.$slots.filter ? (l(), s("div", it, [ m(Le, { placement: "top", overlayStyle: { maxWidth: "500px" }, mouseEnterDelay: 1.5, mouseLeaveDelay: 0.5 }, { title: k(() => [ f("span", null, C(e.$l("条件重置")), 1) ]), default: k(() => [ m(o, { style: { "padding-bottom": "2px" }, onClick: De }, { icon: k(() => [ m(Pe) ]), _: 1 }) ]), _: 1 }) ])) : c("", !0) ])) : c("", !0), e.$slots.filterMore ? ue((l(), s("div", st, [ p(e.$slots, "filterMore", {}, void 0, !0) ], 512)), [ [re, O.value] ]) : c("", !0), e.$slots.desc ? (l(), s("div", ut, [ p(e.$slots, "desc", {}, void 0, !0) ])) : c("", !0) ], 512)) : c("", !0), f("div", rt, [ e.$slots.tabs ? (l(), s("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: N }, [ p(e.$slots, "tabs", {}, void 0, !0) ], 512)) : c("", !0), f("div", dt, [ m(Ge(Ze), { ref_key: "table", ref: v, size: "middle", scroll: { y: G.value, x: "100%" }, pageSize: J.value, rowKey: u.rowKey, columns: ce.value, data: he, "expanded-row-keys": A.value, "onUpdate:expandedRowKeys": t[2] || (t[2] = (n) => A.value = n), rowSelection: Q.value || u.isSelection ? { selectedRowKeys: y.value, onChange: xe } : null, showPagination: u.showPagination }, { bodyCell: k((n) => [ n.column ? (l(), s(se, { key: 0 }, [ Se(n.column.dataIndex) ? p(e.$slots, n.column.dataIndex, { text: n.text, record: n.record, index: n.index, item: H(n.column.dataIndex) }, void 0, !0, 0) : _e(n.column.dataIndex) ? (l(), s("a", { key: 1, onClick: (g) => be(n.column.dataIndex, n.record) }, C(Oe(n.text)), 9, ct)) : n.column.dataIndex === "action" ? p(e.$slots, "action", { record: n.record }, void 0, !0, 2) : c("", !0) ], 64)) : c("", !0) ]), _: 3 }, 8, ["scroll", "pageSize", "rowKey", "columns", "expanded-row-keys", "rowSelection", "showPagination"]) ]) ]) ], 4)) ], 4), m(ze, { ref_key: "filterRef", ref: j, columns: w.value, onSubmit: ke, onReset: $e }, null, 8, ["columns"]), m(Fe, { ref_key: "columnsRef", ref: W, pageCode: "demo", columns: w.value, onSave: ge, onReset: Ce }, null, 8, ["columns"]), f("div", ft, [ p(e.$slots, "other", {}, void 0, !0) ]), X.value ? (l(), R(He, { key: 0, ref: "importModalRef", "upload-url": L.value.importUploadUrl, value: I.value, "onUpdate:value": t[3] || (t[3] = (n) => I.value = n), columns: L.value.importColumns, apis: L.value.importApis, onReload: z }, null, 8, ["upload-url", "value", "columns", "apis"])) : c("", !0) ], 512); }; } }), wt = /* @__PURE__ */ Qe(mt, [["__scopeId", "data-v-bdd1580a"]]); export { wt as default };