UNPKG

@aplus-frontend/ui

Version:

83 lines (82 loc) 1.96 kB
import { isFunction as g, merge as v, cloneDeep as b } from "lodash-unified"; import { ref as A } from "vue"; import { warning as F } from "../../utils/warning.mjs"; import { useKeepAliveFlag as w } from "./useKeepAliveFlag.mjs"; function k(u) { const r = A(null), { isShowRowSelection: f = !0, clearSelectionOnRequest: m = !0, transformSearchFormValues: o, api: a, tableRefresh: s = !1, ...p } = u || {}; let l = null; const c = () => { r.value?.rowSelection?.clearAll(); }, d = async (e) => { l = e.sort; const t = o ? o(e) : e; try { if (!a) throw new Error("api is not defined"); const { records: n, total: S } = await a(t); return m && c(), { data: n, total: S }; } catch (n) { return F(!1, n), { data: [], total: 0 }; } }; w({ afterActivated() { (g(s) ? s() : s) && i(); } }); const h = v( { // scroll,tableLayout,columnResizable设置表格可拖动 scroll: { x: "100%", y: "100%" }, tableLayout: "fixed", columnResizable: !0, // 表格header吸顶效果 class: "ap-table--sticky", request: a ? d : void 0, rowSelection: f ? { mode: "internal", fixed: "left", columnWidth: 50 } : void 0, ref(e) { r.value = e; }, // 新UI规范,需要都添加分割线 card: !0 }, p ), i = () => { r.value?.submit(); }; return [h, { reload: i, reset: () => { r.value?.reset(); }, getSearchFormValues: (e) => { const t = r.value?.getSearchFormValues(e) || {}; return o ? o(t) : t; }, getApTableInstance: () => r.value, getSearchFormValuesAndSorted: (e) => { const t = r.value?.getSearchFormValues(e) || {}; return t.sort = l && b(l), o ? o(t) : t; }, clearSelection: c }]; } export { k as usePageListApTable };