UNPKG

@aplus-frontend/ui

Version:

93 lines (92 loc) 2.14 kB
import "../index.mjs"; import { merge as i, cloneDeep as F } from "lodash-unified"; import { ref as R } from "vue"; import { useKeepAliveFlag as w } from "./useKeepAliveFlag.mjs"; import { useTableRefresh as V } from "./useTableRefresh.mjs"; function W(a) { const r = R(null), { isShowRowSelection: c = !0, clearSelectionOnRequest: f = !0, transformSearchFormValues: o, api: s, tableRefresh: d = !0, virtual: m, clearDataOnDeactivated: p = !0, ...h } = a || {}; let l = null; const n = () => { r.value?.rowSelection?.clearAll(); }; V({ ...b(d), apTableRef: r }); const u = () => { r.value?.submitWith(!0); }, v = () => { r.value?.reset(); }, { isDeactivated: S } = w({ afterDeactivated: u }); return [i( { // scroll,tableLayout,columnResizable设置表格可拖动 scroll: { x: "100%", y: "100%" }, columnResizable: !0, request: s ? async (e) => { if (S() && p) return { data: [], total: 0 }; l = e.sort; const t = o ? o(e) : e; if (!s) throw new Error("api is not defined"); const { records: g, total: A } = await s(t); return f && n(), { data: g, total: A }; } : void 0, rowSelection: c ? { fixed: "left", columnWidth: 38 } : void 0, ref(e) { r.value = e; }, virtual: i( { oSize: 20, y: 20 }, m ), // 新UI规范,需要都添加分割线 card: !0 }, h ), { reload: u, reset: v, getSearchFormValues: (e = !0) => { const t = r.value?.getSearchFormValues(!!e) || {}; return o ? o(t) : t; }, getApGridInstance: () => r.value, getSearchFormValuesAndSorted: (e = !0) => { const t = r.value?.getSearchFormValues(!!e) || {}; return t.sort = l && F(l), o ? o(t) : t; }, clearSelection: n }]; } function b(a) { return a === !0 ? {} : a === !1 ? { refreshBefore: () => !1 } : a; } export { W as usePageListApGrid };