diff --git a/comps/custom/Breadcrumb.tsx b/comps/custom/Breadcrumb.tsx index 38cf362..a0b9d63 100755 --- a/comps/custom/Breadcrumb.tsx +++ b/comps/custom/Breadcrumb.tsx @@ -15,11 +15,11 @@ type BreadcrumbProps = { className?: string; props?: any; value?: BreadItem[]; - item: any; + item?: any; }; export const Breadcrumb: FC = (_arg) => { - const { on_load } = _arg; + const { on_load, item } = _arg; const local = useLocal({ list: _arg.value || ([] as BreadItem[]), @@ -35,8 +35,8 @@ export const Breadcrumb: FC = (_arg) => { if (local.status === "init") { let should_load = true; - if (isEditor && breadcrumbData[_arg.item.id]) { - local.list = breadcrumbData[_arg.item.id]; + if (isEditor && item && breadcrumbData[item.id]) { + local.list = breadcrumbData[item.id]; local.status = "ready"; should_load = false; } @@ -44,7 +44,7 @@ export const Breadcrumb: FC = (_arg) => { if (should_load && typeof on_load === "function") { const callback = (res: any) => { local.list = res; - breadcrumbData[_arg.item.id] = res; + if (item) breadcrumbData[item.id] = res; local.status = "ready"; }; const res = on_load(); @@ -57,8 +57,10 @@ export const Breadcrumb: FC = (_arg) => { } } - if (isEditor && local.status !== "ready" && breadcrumbData[_arg.item.id]) { - local.list = breadcrumbData[_arg.item.id]; + if (isEditor && local.status !== "ready") { + if (item && breadcrumbData[item.id]) { + local.list = breadcrumbData[_arg.item.id]; + } local.status = "ready"; } diff --git a/comps/form/Form.tsx b/comps/form/Form.tsx index 860b54b..1f59e57 100755 --- a/comps/form/Form.tsx +++ b/comps/form/Form.tsx @@ -124,15 +124,9 @@ export const Form: FC = (props) => { ` )} > - {fm.status !== "init" && - fm.size.width > 0 && - childs.map((child, idx) => { - return ( - - {child} - - ); - })} + {fm.status !== "init" && fm.size.width > 0 && ( + {body} + )} diff --git a/comps/form/utils/init.tsx b/comps/form/utils/init.tsx index e8943d5..2125224 100755 --- a/comps/form/utils/init.tsx +++ b/comps/form/utils/init.tsx @@ -63,6 +63,9 @@ export const formInit = (fm: FMLocal, props: FMProps) => { } else { fm.data = res; } + if (!fm.data) { + fm.data = {}; + } if (isEditor) { const item_id = props.item.id; diff --git a/gen/gen_form/gen_form.ts b/gen/gen_form/gen_form.ts index 501e231..bf12ba0 100755 --- a/gen/gen_form/gen_form.ts +++ b/gen/gen_form/gen_form.ts @@ -60,6 +60,7 @@ export const gen_form = async (modify: (data: any) => void, data: any) => { result["body"] = data["body"]; result.body.content.childs = []; + console.log(fields); for (const item of fields.filter((e) => !e.is_pk)) { result.body.content.childs.push(await newField(item)); } diff --git a/gen/utils.ts b/gen/utils.ts index dbd6332..ae5343d 100755 --- a/gen/utils.ts +++ b/gen/utils.ts @@ -8,8 +8,10 @@ export const parseGenField = (fields: PropOptRaw) => { const result = [] as GFCol[]; for (const f of fields) { if (typeof f === "string") { - const field = JSON.parse(f); - result.push(field); + try { + const field = JSON.parse(f); + result.push(field); + } catch (e) {} } else { const field = JSON.parse(f.value); field.relation.fields = f.checked.map((e) => JSON.parse(e));