mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +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 { setVisible } = useActionContext();
|
||||
const { selectedRows, options, collectionField } = useContext(RecordPickerContext);
|
||||
const { selectedRows, setSelectedRows } = useContext(RecordPickerContext);
|
||||
return {
|
||||
onClick() {
|
||||
const selectData = unionBy(selectedRows, options, collectionField?.targetKey || 'id');
|
||||
const data = field.value || [];
|
||||
field.value = uniqBy(data.concat(selectData), collectionField?.targetKey || 'id');
|
||||
selectedRows.map((v) => field.value.push(markRecordAsNew({ ...v })));
|
||||
field.onInput(field.value);
|
||||
setSelectedRows([]);
|
||||
setVisible(false);
|
||||
},
|
||||
};
|
||||
};
|
||||
const getFilter = () => {
|
||||
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 }] } : {};
|
||||
return filter;
|
||||
};
|
||||
|
@ -75,7 +75,6 @@ export function Result(props) {
|
||||
const fieldName = fieldPath.split('.')[0];
|
||||
const index = parseInt(fieldPath.split('.')?.[1]);
|
||||
const ctx = useContext(ActionContext);
|
||||
|
||||
useEffect(() => {
|
||||
setEditingValue(value);
|
||||
}, [value]);
|
||||
@ -85,7 +84,8 @@ export function Result(props) {
|
||||
if (
|
||||
(fieldSchema.name as string).indexOf('.') >= 0 ||
|
||||
!formBlockContext?.form ||
|
||||
formBlockContext.form?.readPretty
|
||||
formBlockContext.form?.readPretty ||
|
||||
fieldSchema['x-decorator'] !== 'FormItem'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user