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