This commit is contained in:
rizky 2024-03-30 00:41:09 -07:00
parent 6d05d76522
commit 6c17b8711d
2 changed files with 20 additions and 2 deletions

View File

@ -10,6 +10,7 @@ type TableListProp = {
PassProp: any;
name: string;
on_load: () => Promise<any[]>;
mode: "table" | "list" | "grid";
};
export const TableList: FC<TableListProp> = ({
@ -17,6 +18,7 @@ export const TableList: FC<TableListProp> = ({
on_load,
child,
PassProp,
mode,
}) => {
const local = useLocal({
el: null as null | HTMLDivElement,
@ -50,11 +52,20 @@ export const TableList: FC<TableListProp> = ({
}
}, [on_load]);
const childs = get(
const raw_childs = get(
child,
"props.meta.item.component.props.child.content.childs"
);
let childs: any[] = [];
const mode_child = raw_childs.find((e: any) => e.name === mode);
if (mode_child && mode_child.childs) {
childs = mode_child.childs;
}
console.log(raw_childs);
const columns: ColumnOrColumnGroup<any>[] = [];
for (const child of childs) {
const key = getProp(child, "name");

View File

@ -53,6 +53,13 @@ export const gen_table_list = (
if (data["child"]) {
result["child"] = data["child"];
result["child"].content.childs = result["child"].content.childs.filter(
(e: any) => {
return e.name !== arg.mode;
}
);
result["child"].content.childs = [
createItem({
name: arg.mode,
@ -67,9 +74,9 @@ export const gen_table_list = (
},
],
}),
...result["child"].content.childs,
];
}
console.log(result["child"]);
if (data["selected"]) {
result["selected"] = data["selected"];