fix
This commit is contained in:
parent
d4a8c9932b
commit
ee154438c1
|
|
@ -160,7 +160,10 @@ export const Form: FC<FMProps> = (props) => {
|
||||||
if (!ref.current.el) {
|
if (!ref.current.el) {
|
||||||
ref.current.el = el;
|
ref.current.el = el;
|
||||||
ref.current.rob.observe(el);
|
ref.current.rob.observe(el);
|
||||||
|
if (fm.status === "ready") {
|
||||||
fm.status = "resizing";
|
fm.status = "resizing";
|
||||||
|
fm.render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ export const TypeDropdown: FC<{
|
||||||
loaded: false,
|
loaded: false,
|
||||||
options: [] as { value: string; label: string; data: any }[],
|
options: [] as { value: string; label: string; data: any }[],
|
||||||
});
|
});
|
||||||
|
|
||||||
let value =
|
let value =
|
||||||
typeof arg.opt_get_value === "function"
|
typeof arg.opt_get_value === "function"
|
||||||
? arg.opt_get_value({
|
? arg.opt_get_value({
|
||||||
|
|
@ -22,6 +23,7 @@ export const TypeDropdown: FC<{
|
||||||
type: field.type,
|
type: field.type,
|
||||||
})
|
})
|
||||||
: fm.data[field.name];
|
: fm.data[field.name];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof arg.on_load === "function") {
|
if (typeof arg.on_load === "function") {
|
||||||
const options = arg.on_load({ field });
|
const options = arg.on_load({ field });
|
||||||
|
|
@ -44,6 +46,7 @@ export const TypeDropdown: FC<{
|
||||||
local.options = res;
|
local.options = res;
|
||||||
}
|
}
|
||||||
local.render();
|
local.render();
|
||||||
|
|
||||||
value =
|
value =
|
||||||
typeof arg.opt_get_value === "function"
|
typeof arg.opt_get_value === "function"
|
||||||
? arg.opt_get_value({
|
? arg.opt_get_value({
|
||||||
|
|
@ -53,9 +56,9 @@ export const TypeDropdown: FC<{
|
||||||
type: field.type,
|
type: field.type,
|
||||||
})
|
})
|
||||||
: fm.data[field.name];
|
: fm.data[field.name];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
field.type === "single-option" &&
|
field.type === "single-option" &&
|
||||||
field.required &&
|
|
||||||
!value &&
|
!value &&
|
||||||
local.options.length > 0
|
local.options.length > 0
|
||||||
) {
|
) {
|
||||||
|
|
@ -86,6 +89,7 @@ export const TypeDropdown: FC<{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
let popupClassName = "";
|
let popupClassName = "";
|
||||||
|
|
||||||
if (arg.__props) {
|
if (arg.__props) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { GFCol, parseGenField } from "../utils";
|
||||||
import { newField } from "./new_field";
|
import { newField } from "./new_field";
|
||||||
import { on_submit } from "./on_submit";
|
import { on_submit } from "./on_submit";
|
||||||
|
|
||||||
export const gen_form = async (modify: (data: any) => void, data: any) => {
|
export const gen_form = async (modify: (data: any) => void, data: any, is_md?: boolean) => {
|
||||||
const table = JSON.parse(data.gen_table.value);
|
const table = JSON.parse(data.gen_table.value);
|
||||||
const raw_fields = JSON.parse(data.gen_fields.value) as (
|
const raw_fields = JSON.parse(data.gen_fields.value) as (
|
||||||
| string
|
| string
|
||||||
|
|
@ -43,7 +43,13 @@ export const gen_form = async (modify: (data: any) => void, data: any) => {
|
||||||
const code = {} as any;
|
const code = {} as any;
|
||||||
if (data["on_load"]) {
|
if (data["on_load"]) {
|
||||||
result["on_load"] = data["on_load"];
|
result["on_load"] = data["on_load"];
|
||||||
result["on_load"].value = on_load({ pk: pk.name, pks, select, table });
|
result["on_load"].value = on_load({
|
||||||
|
pk: pk.name,
|
||||||
|
pks,
|
||||||
|
select,
|
||||||
|
table,
|
||||||
|
opt: is_md ? { is_md: true } : undefined,
|
||||||
|
});
|
||||||
code.on_load = result["on_load"].value;
|
code.on_load = result["on_load"].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ type Init = { submit: () => Promise<boolean>; reload: () => void; fm:any }
|
||||||
|
|
||||||
const data = childs[0].component.props;
|
const data = childs[0].component.props;
|
||||||
const modify = async (props: any) => {};
|
const modify = async (props: any) => {};
|
||||||
await gen_form(modify, data);
|
await gen_form(modify, data, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ export const FormatValue: FC<{
|
||||||
|
|
||||||
const fields = fields_map.get(gf);
|
const fields = fields_map.get(gf);
|
||||||
const field = fields?.find((e) => e.name === name);
|
const field = fields?.find((e) => e.name === name);
|
||||||
|
|
||||||
|
if (typeof value === "boolean") return <>{value ? "Yes" : "No"}</>;
|
||||||
|
|
||||||
if (mode === "money") {
|
if (mode === "money") {
|
||||||
if (!value || isEmptyString(value)) return "-";
|
if (!value || isEmptyString(value)) return "-";
|
||||||
return formatMoney(Number(value) || 0);
|
return formatMoney(Number(value) || 0);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue