fix relation
This commit is contained in:
parent
ad39b108c5
commit
0ddd31fecc
|
|
@ -85,16 +85,14 @@ export const TypeDropdown: FC<{
|
||||||
<Typeahead
|
<Typeahead
|
||||||
value={Array.isArray(value) ? value : [value]}
|
value={Array.isArray(value) ? value : [value]}
|
||||||
onSelect={({ search, item }) => {
|
onSelect={({ search, item }) => {
|
||||||
console.log(search, item);
|
|
||||||
if (item) {
|
if (item) {
|
||||||
const result = arg.opt_set_value({
|
arg.opt_set_value({
|
||||||
fm,
|
fm,
|
||||||
name: field.name,
|
name: field.name,
|
||||||
type: field.type,
|
type: field.type,
|
||||||
options: local.options,
|
options: local.options,
|
||||||
selected: [item.value],
|
selected: [item.value],
|
||||||
});
|
});
|
||||||
console.log(item, result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return item?.value || search;
|
return item?.value || search;
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ export const newField = async (
|
||||||
const res = generateSelect(fields);
|
const res = generateSelect(fields);
|
||||||
const load = on_load_rel({
|
const load = on_load_rel({
|
||||||
pk: res.pk,
|
pk: res.pk,
|
||||||
table: arg.name,
|
table: arg.relation.to.table,
|
||||||
select: res.select,
|
select: res.select,
|
||||||
pks: {},
|
pks: {},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export const generateField = async (
|
||||||
) as any;
|
) as any;
|
||||||
const pk = fields.find((e: any) => get(e, "is_pk")) as any;
|
const pk = fields.find((e: any) => get(e, "is_pk")) as any;
|
||||||
const pk_master = master.relation.fields.find((e: any) => get(e, "is_pk"));
|
const pk_master = master.relation.fields.find((e: any) => get(e, "is_pk"));
|
||||||
|
|
||||||
const load = on_load_rel({
|
const load = on_load_rel({
|
||||||
pk: generateSelect(parseGenField(master.value.checked)).pk,
|
pk: generateSelect(parseGenField(master.value.checked)).pk,
|
||||||
table: master?.name,
|
table: master?.name,
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export const genRelMany = (prop: {
|
||||||
// select master
|
// select master
|
||||||
if (master) {
|
if (master) {
|
||||||
const select = generateSelect(master.relation.fields);
|
const select = generateSelect(master.relation.fields);
|
||||||
|
|
||||||
result.on_load = on_load_rel({
|
result.on_load = on_load_rel({
|
||||||
pk: select.pk,
|
pk: select.pk,
|
||||||
table: master.name,
|
table: master.name,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ async (opt) => {
|
||||||
raw_id = md.selected[pk];
|
raw_id = md.selected[pk];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (parseInt(raw_id)) raw_id = parseInt(raw_id);
|
|
||||||
|
|
||||||
${opt?.before_load ? opt.before_load : `let id = raw_id`}
|
${opt?.before_load ? opt.before_load : `let id = raw_id`}
|
||||||
let item = {};
|
let item = {};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue