fix: plugin-approval, submit approval or reject faild (#835)
Reviewed-on: daoyoucloud/tachybase#835 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
cc58ee4acc
commit
021c8a9a16
@ -254,7 +254,7 @@ export const BlockProvider = (props: {
|
||||
};
|
||||
|
||||
export const useBlockAssociationContext = () => {
|
||||
const { association } = useDataBlockProps();
|
||||
const { association } = useDataBlockProps() || {};
|
||||
return useContext(BlockAssociationContext) || association;
|
||||
};
|
||||
|
||||
|
@ -62,7 +62,7 @@ const InternalRemoteSelect = connect(
|
||||
|
||||
const operator = useMemo(() => {
|
||||
if (targetField?.interface) {
|
||||
return getInterface(targetField.interface)?.filterable?.operators[0].value || '$includes';
|
||||
return getInterface(targetField.interface)?.filterable?.operators?.[0]?.value || '$includes';
|
||||
}
|
||||
return '$includes';
|
||||
}, [targetField]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useAPIClient, useActionContext } from '@nocobase/client';
|
||||
import { useAPIClient, useActionContext, useRefreshActionProps } from '@nocobase/client';
|
||||
import { useField, useForm } from '@nocobase/schema';
|
||||
import { useContextApprovalAction } from '../Pd.ApprovalAction';
|
||||
import { useContextApprovalExecutions } from '../Pd.ApprovalExecutions';
|
||||
@ -10,26 +10,30 @@ export function useSubmit() {
|
||||
const approvalExecutions = useContextApprovalExecutions();
|
||||
const { status } = useContextApprovalAction();
|
||||
const { setVisible, setSubmitted } = useActionContext() as any;
|
||||
// TODO: 自动更新外层block, 提升交互体验
|
||||
// const { onClick: refreshAction } = useRefreshActionProps();
|
||||
return {
|
||||
run() {
|
||||
return async () => {
|
||||
try {
|
||||
if (form.values.status) return;
|
||||
await form.submit(), (field.data = field.data ?? {});
|
||||
field.data.loading = true;
|
||||
await api.resource('approvalRecords').submit({
|
||||
filterByTk: approvalExecutions.id,
|
||||
values: { ...form.values, status },
|
||||
});
|
||||
field.data.loading = false;
|
||||
await form.reset();
|
||||
setSubmitted(true);
|
||||
setVisible(false);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
field.data && (field.data.loading = false);
|
||||
run: async () => {
|
||||
try {
|
||||
if (form.values.status) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
await form.submit();
|
||||
field.data = field.data ?? {};
|
||||
field.data.loading = true;
|
||||
setVisible(false);
|
||||
await api.resource('approvalRecords').submit({
|
||||
filterByTk: approvalExecutions.id,
|
||||
values: { ...form.values, status },
|
||||
});
|
||||
field.data.loading = false;
|
||||
await form.reset();
|
||||
// refreshAction?.();
|
||||
setSubmitted?.(true);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
field.data && (field.data.loading = false);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user