fix typings form
This commit is contained in:
parent
6146b39454
commit
9beea0b93e
|
|
@ -1,6 +1,7 @@
|
||||||
import { GFCol } from "lib/gen/utils";
|
import { GFCol } from "lib/gen/utils";
|
||||||
import { FC, ReactElement, ReactNode } from "react";
|
import { FC, ReactElement, ReactNode } from "react";
|
||||||
import { editorFormData } from "./utils/ed-data";
|
import { editorFormData } from "./utils/ed-data";
|
||||||
|
import get from "lodash.get";
|
||||||
|
|
||||||
export type FMProps = {
|
export type FMProps = {
|
||||||
on_init: (arg: { fm: FMLocal; submit: any; reload: any }) => any;
|
on_init: (arg: { fm: FMLocal; submit: any; reload: any }) => any;
|
||||||
|
|
@ -216,12 +217,22 @@ export const formType = (active: { item_id: string }, meta: any) => {
|
||||||
const cache = editorFormData[m.parent.id];
|
const cache = editorFormData[m.parent.id];
|
||||||
if (cache && cache.data) {
|
if (cache && cache.data) {
|
||||||
data = JSON.stringify(cache.data);
|
data = JSON.stringify(cache.data);
|
||||||
|
} else {
|
||||||
|
const cur = get(m, "script.scope.fm.data");
|
||||||
|
if (!!cur && Object.keys(cur).length > 0) {
|
||||||
|
data = JSON.stringify(cur);
|
||||||
|
} else {
|
||||||
|
const fields = get(m, "script.scope.fm.fields");
|
||||||
|
if (!!fields) {
|
||||||
|
data = `null as {${Object.keys(fields)
|
||||||
|
.map((e) => `"${e}": any `)
|
||||||
|
.join(",")}}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(data, cache);
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
const ___data = ${data} ;
|
const ___data = ${data} ;
|
||||||
const fm = null as unknown as {
|
const fm = null as unknown as {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue