fix
This commit is contained in:
parent
fc8d54816a
commit
dff267ebdd
|
|
@ -5,6 +5,7 @@ import { FormHook } from "../form-old/utils/utils";
|
||||||
import { editorFormData } from "./utils/ed-data";
|
import { editorFormData } from "./utils/ed-data";
|
||||||
import { PropTypeText } from "./field/type/TypeText";
|
import { PropTypeText } from "./field/type/TypeText";
|
||||||
import { PropTypeRelation } from "./field/type/TypeRelation";
|
import { PropTypeRelation } from "./field/type/TypeRelation";
|
||||||
|
import { getProp } from "../../..";
|
||||||
|
|
||||||
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;
|
||||||
|
|
@ -164,3 +165,34 @@ export const formType = (active: { item_id: string }, meta: any) => {
|
||||||
};
|
};
|
||||||
}`;
|
}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const fieldType = (item: any, meta: any, fm: FMLocal) => {
|
||||||
|
const m = meta[item.id];
|
||||||
|
if (m) {
|
||||||
|
const name = getProp(m.item, "name");
|
||||||
|
const field = fm.fields[name];
|
||||||
|
const def = fm.field_def[name];
|
||||||
|
return `
|
||||||
|
const field = null as unknown as {
|
||||||
|
status: "init" | "loading" | "ready";
|
||||||
|
name: "${name}";
|
||||||
|
type: "${field.type}";
|
||||||
|
label: any;
|
||||||
|
desc: any;
|
||||||
|
prefix: any;
|
||||||
|
suffix: any;
|
||||||
|
width: any;
|
||||||
|
required: boolean;
|
||||||
|
focused: boolean;
|
||||||
|
disabled: boolean;
|
||||||
|
required_msg: any;
|
||||||
|
col?: GFCol;
|
||||||
|
Child: () => ReactNode;
|
||||||
|
input: Record<string, any> & {
|
||||||
|
render: () => void;
|
||||||
|
};
|
||||||
|
prop?: any;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useLocal } from "@/utils/use-local";
|
import { useLocal } from "@/utils/use-local";
|
||||||
import { FMLocal, FieldInternal, FieldProp } from "../typings";
|
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
import { FieldInternal, FieldProp } from "../typings";
|
||||||
|
|
||||||
export const useField = (arg: FieldProp) => {
|
export const useField = (arg: FieldProp) => {
|
||||||
const field = useLocal<FieldInternal<typeof arg.type>>({
|
const field = useLocal<FieldInternal<typeof arg.type>>({
|
||||||
|
|
@ -32,7 +32,7 @@ export const useField = (arg: FieldProp) => {
|
||||||
const fm = arg.fm;
|
const fm = arg.fm;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (field.status === "init") {
|
if (field.status === "init" || !fm.fields[arg.name]) {
|
||||||
field.status = "ready";
|
field.status = "ready";
|
||||||
fm.fields[arg.name] = field;
|
fm.fields[arg.name] = field;
|
||||||
field.render();
|
field.render();
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ export type MDLocalInternal = {
|
||||||
export type MDRef = { PassProp: any; child: any };
|
export type MDRef = { PassProp: any; child: any };
|
||||||
export type MDLocal = MDLocalInternal & { render: (force?: boolean) => void };
|
export type MDLocal = MDLocalInternal & { render: (force?: boolean) => void };
|
||||||
|
|
||||||
export const MasterDetailType = `{
|
export const MasterDetailType = `const md = {
|
||||||
name: string;
|
name: string;
|
||||||
breadcrumb: {
|
breadcrumb: {
|
||||||
label: React.ReactNode;
|
label: React.ReactNode;
|
||||||
|
|
|
||||||
1
data.ts
1
data.ts
|
|
@ -3,6 +3,7 @@ export { FieldTypeRelation } from "./comps/form/field/type/TypeRelation";
|
||||||
export { Form } from "@/comps/form/Form";
|
export { Form } from "@/comps/form/Form";
|
||||||
export { Field } from "@/comps/form/field/Field";
|
export { Field } from "@/comps/form/field/Field";
|
||||||
export { formType } from "@/comps/form/typings";
|
export { formType } from "@/comps/form/typings";
|
||||||
|
export { fieldType } from "@/comps/form/typings";
|
||||||
export { TableList } from "@/comps/list/TableList";
|
export { TableList } from "@/comps/list/TableList";
|
||||||
export { TableListType } from "@/comps/list/typings";
|
export { TableListType } from "@/comps/list/typings";
|
||||||
export { MasterDetail } from "@/comps/md/MasterDetail";
|
export { MasterDetail } from "@/comps/md/MasterDetail";
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ export const gen_relation = async (modify: (data: any) => void, data: any) => {
|
||||||
alert("Failed to generate! Primary Key not found. ");
|
alert("Failed to generate! Primary Key not found. ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pk) {
|
if (pk) {
|
||||||
const code = {} as any;
|
const code = {} as any;
|
||||||
if (data["on_load"]) {
|
if (data["on_load"]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue