mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 06:59:26 +08:00
fix: data filtering and formula field value errors after subtable record selection (#4547)
* fix: data filter issue after selecting records in subtable * fix: bug * fix: bug * fix: bug * fix: bug
This commit is contained in:
parent
1b1930b328
commit
e842cd4cab
@ -99,20 +99,19 @@ export const SubTable: any = observer(
|
|||||||
};
|
};
|
||||||
const usePickActionProps = () => {
|
const usePickActionProps = () => {
|
||||||
const { setVisible } = useActionContext();
|
const { setVisible } = useActionContext();
|
||||||
const { selectedRows, options, collectionField } = useContext(RecordPickerContext);
|
const { selectedRows, setSelectedRows } = useContext(RecordPickerContext);
|
||||||
return {
|
return {
|
||||||
onClick() {
|
onClick() {
|
||||||
const selectData = unionBy(selectedRows, options, collectionField?.targetKey || 'id');
|
selectedRows.map((v) => field.value.push(markRecordAsNew({ ...v })));
|
||||||
const data = field.value || [];
|
|
||||||
field.value = uniqBy(data.concat(selectData), collectionField?.targetKey || 'id');
|
|
||||||
field.onInput(field.value);
|
field.onInput(field.value);
|
||||||
|
setSelectedRows([]);
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
const getFilter = () => {
|
const getFilter = () => {
|
||||||
const targetKey = collectionField?.targetKey || 'id';
|
const targetKey = collectionField?.targetKey || 'id';
|
||||||
const list = options.map((option) => option[targetKey]).filter(Boolean);
|
const list = (field.value || []).map((option) => option[targetKey]).filter(Boolean);
|
||||||
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
const filter = list.length ? { $and: [{ [`${targetKey}.$ne`]: list }] } : {};
|
||||||
return filter;
|
return filter;
|
||||||
};
|
};
|
||||||
|
@ -75,7 +75,6 @@ export function Result(props) {
|
|||||||
const fieldName = fieldPath.split('.')[0];
|
const fieldName = fieldPath.split('.')[0];
|
||||||
const index = parseInt(fieldPath.split('.')?.[1]);
|
const index = parseInt(fieldPath.split('.')?.[1]);
|
||||||
const ctx = useContext(ActionContext);
|
const ctx = useContext(ActionContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEditingValue(value);
|
setEditingValue(value);
|
||||||
}, [value]);
|
}, [value]);
|
||||||
@ -85,7 +84,8 @@ export function Result(props) {
|
|||||||
if (
|
if (
|
||||||
(fieldSchema.name as string).indexOf('.') >= 0 ||
|
(fieldSchema.name as string).indexOf('.') >= 0 ||
|
||||||
!formBlockContext?.form ||
|
!formBlockContext?.form ||
|
||||||
formBlockContext.form?.readPretty
|
formBlockContext.form?.readPretty ||
|
||||||
|
fieldSchema['x-decorator'] !== 'FormItem'
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user