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