import { ref as l, computed as X, watch as Y, onMounted as Ce, onActivated as Se, resolveComponent as $, resolveDirective as be, openBlock as a, createElementBlock as s, createElementVNode as u, toDisplayString as g, Fragment as Z, renderList as Oe, withDirectives as _e, createBlock as D, withCtx as C, createTextVNode as P, resolveDynamicComponent as xe, createCommentVNode as d, vShow as Re, renderSlot as c, createVNode as y, normalizeStyle as H, unref as Ie, nextTick as L, h as Be } from "vue"; import { useRoute as Te } from "vue-router"; import { n as Ae, B as De, aO as Pe } from "./index2.js"; const He = { class: "tools" }, Le = { class: "title" }, ze = { class: "btn-list" }, Ke = { key: 0, style: { "margin-left": "8px" } }, Ue = { class: "filter-content" }, Ve = { class: "filter" }, Me = { key: 0, class: "desc-wrap" }, Ne = { class: "table-content" }, Ee = { class: "table-container" }, Fe = ["onClick"], qe = { class: "other" }, je = /* @__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(v, { expose: ee, emit: te }) { const _ = v, k = te; Te(); const z = l(null), K = l(null), U = l(null), S = l(null), V = l(null), M = l(null), ne = l(null), b = l(!1), h = l(0), N = l(0), f = l(!1), E = l(20), F = l(!1), r = l([]), x = l([]), m = l([]), w = l([]), oe = { 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 = X(() => w.value.map((e) => e.key).includes("import")), R = X(() => w.value.find((e) => e.key === "import") || {}); Y( () => _.buttons, (e) => { e && e.length && le(e); }, { immediate: !0, deep: !0 } ), Y( () => _.columns, (e) => { ie(e || []); }, { deep: !0, immediate: !0 } ); function j(e, t = "") { return !!(e && typeof e == "function"); } function G(e) { return typeof e.icon == "string" ? e.icon : typeof e.icon == "boolean" && e.icon && oe[e.key] || ""; } function le(e) { w.value = e.map((t) => (t.key === "remove" && (F.value = !0), t)); } function ae(e) { L(() => { A(), E.value = _.pSize, m.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 ie(e = []) { ae(e); } function I() { S.value && S.value.refresh(!0); } function J(e) { k("btnCallback", e.key, r.value); const t = we[e.key]; typeof t == "function" ? t(e) : B(e); } function B(e) { if (e.selection !== !1 && !r.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: `${window.$l(e.name)}`, content: () => Be( "div", { style: "color:red" }, `${window.$l("确认要")}{${window.$l(e.name)}}${window.$l("数据吗?")}` ), onOk: () => { f.value = !0, e.api(r.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), k("reset"); }).finally(() => { f.value = !1; }); } }); return; } f.value = !0, e.api(r.value).then(() => { window.$message.success(`${window.$l(e.name)}${window.$l("成功")}`), k("reset"); }).finally(() => { f.value = !1; }); } } function Q(e, t) { typeof e == "string" ? W(e, t) : e.forEach((o) => { W(o, t); }); } function W(e, t) { const o = w.value.find((i) => i.key === e); if (!o) { console.error(`按钮(${e})未定义, 请确认该变更状态按钮是否设置正确`); return; } Object.keys(t).forEach((i) => { o[i] = t[i]; }); } function se() { } function ue(e) { B(e); } function re() { if (!q.value) { k("btnCallback", "import"); return; } b.value = !0; } function de(e) { j(e.api, e.name, e.key) && (f.value = !0, e.api().then(() => { f.value = !1; })); } function ce(e, t) { k("tableColCallback", e, t); } function T(e) { return m.value.find((t) => t.dataIndex === e); } function fe(e) { const t = T(e); return !!(t && t.template); } function me(e) { const t = T(e); return !!(t && t.isClick); } function pe(e) { return e == null ? "" : typeof e == "object" ? e.name === void 0 ? "" : e.name : e; } function ye(e) { r.value = e; } function A() { L(() => { var e, t; h.value = (((t = (e = z.value) == null ? void 0 : e.parentNode) == null ? void 0 : t.offsetHeight) || 0) - 76, ve(); }); } function ve() { L(() => { var i, O; const t = ((i = K.value) == null ? void 0 : i.offsetHeight) || 0, o = ((O = U.value) == null ? void 0 : O.offsetHeight) || 0; N.value = h.value - t - 103 - o; }); } const we = { add: se, delete: ue, import: re, export: de, reload: I, setStateBtn: Q, handAction: B }; return Ce(() => { }), Se(() => A()), ee({ reload: I, spinning: f, selectedRowKeys: r, expandedRowKeys: x, renderColumns: m, renderButtons: w, setStateBtn: Q, btnCallback: J, table: S, importVisible: b, measureLayout: A }), (e, t) => { const o = De, i = $("SearchOutlined"), O = $("SettingOutlined"), ke = $("setting-filter"), he = $("setting-columns"), $e = $("s-import-modal"), ge = be("action"); return a(), s("div", { class: "list-layout", ref_key: "layout", ref: z }, [ u("div", He, [ u("div", Le, g(v.title), 1), u("div", ze, [ (a(!0), s(Z, null, Oe(w.value, (n) => (a(), s("span", { class: "item-btn", key: n.key }, [ _e((a(), D(o, { class: "btn", disabled: !!n.disabled, type: n.type || n.key === "add" ? "primary" : "default", onClick: (p) => J(n) }, { icon: C(() => [ G(n) ? (a(), D(xe(G(n)), { key: 0 })) : d("", !0) ]), default: C(() => [ P(" " + g(e.$l(n.name)), 1) ]), _: 2 }, 1032, ["disabled", "type", "onClick"])), [ [ge, n.action || n.key], [Re, n.show !== !1] ]) ]))), 128)), e.$slots.otherBtns ? (a(), s("span", Ke, [ c(e.$slots, "otherBtns", { selections: r.value }, void 0, !0) ])) : d("", !0), u("span", null, [ y(o, { class: "btn", onClick: t[0] || (t[0] = (n) => { var p; return (p = V.value) == null ? void 0 : p.show(m.value); }) }, { default: C(() => [ y(i), P(" " + g(e.$l("高级搜索")), 1) ]), _: 1 }), y(o, { class: "btn", onClick: t[1] || (t[1] = (n) => { var p; return (p = M.value) == null ? void 0 : p.show(m.value); }) }, { default: C(() => [ y(O), P(" " + g(e.$l("高级表格")), 1) ]), _: 1 }) ]) ]) ]), u("div", { class: "list-layout-main", style: H({ height: h.value + "px" }) }, [ e.$slots.empty ? (a(), s("div", { key: 1, class: "layout-list-content", style: H({ height: h.value + "px" }) }, [ c(e.$slots, "empty", {}, void 0, !0) ], 4)) : (a(), s("div", { key: 0, class: "layout-list-content", style: H({ height: h.value + "px" }) }, [ e.$slots.filter || e.$slots.desc ? (a(), s("div", { key: 0, class: "list-filter-wrap", ref_key: "filters", ref: K }, [ u("div", Ue, [ u("div", Ve, [ c(e.$slots, "filter", {}, void 0, !0) ]) ]), e.$slots.desc ? (a(), s("div", Me, [ c(e.$slots, "desc", {}, void 0, !0) ])) : d("", !0) ], 512)) : d("", !0), u("div", Ne, [ e.$slots.tabs ? (a(), s("div", { key: 0, class: "tabs-wrap", ref_key: "tabs", ref: U }, [ c(e.$slots, "tabs", {}, void 0, !0) ], 512)) : d("", !0), u("div", Ee, [ y(Ie(Pe), { ref_key: "table", ref: S, size: "middle", scroll: { y: N.value, x: "100%" }, pageSize: E.value, rowKey: v.rowKey, columns: m.value, data: v.loadData, "expanded-row-keys": x.value, "onUpdate:expandedRowKeys": t[2] || (t[2] = (n) => x.value = n), rowSelection: F.value || v.isSelection ? { selectedRowKeys: r.value, onChange: ye } : null, showPagination: v.showPagination }, { bodyCell: C((n) => [ n.column ? (a(), s(Z, { key: 0 }, [ fe(n.column.dataIndex) ? c(e.$slots, n.column.dataIndex, { text: n.text, record: n.record, index: n.index, item: T(n.column.dataIndex) }, void 0, !0, 0) : me(n.column.dataIndex) ? (a(), s("a", { key: 1, onClick: (p) => ce(n.column.dataIndex, n.record) }, g(pe(n.text)), 9, Fe)) : n.column.dataIndex === "action" ? c(e.$slots, "action", { record: n.record }, void 0, !0, 2) : d("", !0) ], 64)) : d("", !0) ]), _: 3 }, 8, ["scroll", "pageSize", "rowKey", "columns", "data", "expanded-row-keys", "rowSelection", "showPagination"]) ]) ]) ], 4)) ], 4), y(ke, { ref_key: "filterRef", ref: V }, null, 512), y(he, { ref_key: "columnsRef", ref: M, pageCode: "demo", onReset: t[3] || (t[3] = (n = null) => { n && n(m.value); }) }, null, 512), u("div", qe, [ c(e.$slots, "other", {}, void 0, !0) ]), q.value ? (a(), D($e, { key: 0, ref_key: "importModalRef", ref: ne, "upload-url": R.value.importUploadUrl, value: b.value, "onUpdate:value": t[4] || (t[4] = (n) => b.value = n), columns: R.value.importColumns, apis: R.value.importApis, onReload: I }, null, 8, ["upload-url", "value", "columns", "apis"])) : d("", !0) ], 512); }; } }), We = /* @__PURE__ */ Ae(je, [["__scopeId", "data-v-48633fc5"]]); export { We as default };