fix/approval-workflow (#1254)
Reviewed-on: daoyoucloud/tachybase#1254 Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
d44037ec24
commit
c8f99dd228
@ -70,7 +70,11 @@ export const CollectionApprovalTodos = {
|
||||
type: 'text',
|
||||
name: 'comment',
|
||||
interface: 'markdown',
|
||||
uiSchema: { type: 'string', 'x-component': 'Markdown', title: `{{t("Comment", { ns: "${NAMESPACE}" })}}` },
|
||||
uiSchema: {
|
||||
type: 'string',
|
||||
'x-component': 'Markdown',
|
||||
title: `{{t("Comment", { ns: "${NAMESPACE}" })}}`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'createdAt',
|
||||
|
@ -21,13 +21,15 @@ export const ApproverBlock = ({ value: srcID, onChange }) => {
|
||||
const { setFormValueChanged } = useContext(ContextApproverConfig) as any;
|
||||
const onChangeFunc = useCallback(
|
||||
(data) => {
|
||||
const flatSet = flatSchemaArray(
|
||||
data.toJSON(),
|
||||
(field) => field['x-decorator'] === 'ApprovalFormBlockProvider',
|
||||
).reduce((accSet, curr) => {
|
||||
flatSchemaArray(curr, (field) => field['x-component'] === 'Action').forEach((field) => {
|
||||
const arr = flatSchemaArray(data.toJSON(), (field) => field['x-decorator'] === 'ApprovalFormBlockProvider');
|
||||
|
||||
const flatSet = arr.reduce((accSet, curr) => {
|
||||
const currArr = flatSchemaArray(curr, (field) => field['x-component'] === 'Action');
|
||||
|
||||
for (const field of currArr) {
|
||||
accSet.add(Number.parseInt(field['x-action'], 10));
|
||||
});
|
||||
}
|
||||
|
||||
return accSet;
|
||||
}, new Set());
|
||||
|
||||
@ -57,7 +59,9 @@ export const ApproverBlock = ({ value: srcID, onChange }) => {
|
||||
};
|
||||
|
||||
await apiClient.resource('uiSchemas').insert({ values: schema });
|
||||
|
||||
onChange(id);
|
||||
|
||||
return schema;
|
||||
});
|
||||
|
||||
|
@ -26,6 +26,24 @@ const useStyles = createStyles(({ css }) => {
|
||||
};
|
||||
});
|
||||
|
||||
function getSchema({ styles }) {
|
||||
return {
|
||||
name: 'drawer',
|
||||
type: 'void',
|
||||
title: `{{t("Approver's interface", { ns: "${NAMESPACE}" })}}`,
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-component-props': {
|
||||
className: styles.container,
|
||||
},
|
||||
properties: {
|
||||
applyDetail: {
|
||||
type: 'string',
|
||||
'x-component': 'ApproverBlock',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// 审批人操作界面
|
||||
export const ApproverInterfaceComponent = () => {
|
||||
const context = useContext(SchemaComponentContext);
|
||||
@ -64,21 +82,3 @@ export const ApproverInterfaceComponent = () => {
|
||||
</ExtendCollectionsProvider>
|
||||
);
|
||||
};
|
||||
|
||||
function getSchema({ styles }) {
|
||||
return {
|
||||
name: 'drawer',
|
||||
type: 'void',
|
||||
title: `{{t("Approver's interface", { ns: "${NAMESPACE}" })}}`,
|
||||
'x-component': 'Action.Drawer',
|
||||
'x-component-props': {
|
||||
className: styles.container,
|
||||
},
|
||||
properties: {
|
||||
applyDetail: {
|
||||
type: 'string',
|
||||
'x-component': 'ApproverBlock',
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -197,8 +197,7 @@ export default class ApprovalInstruction extends Instruction {
|
||||
}, []);
|
||||
const processing = Boolean(distribution.find((item) => item.status !== APPROVAL_ACTION_STATUS.PENDING));
|
||||
const status =
|
||||
job.status ||
|
||||
(getNegotiationMode(negotiation).getStatus(distribution, assignees, negotiation) ?? JOB_STATUS.PENDING);
|
||||
getNegotiationMode(+negotiation).getStatus(distribution, assignees, negotiation) ?? JOB_STATUS.PENDING;
|
||||
const result = ApprovalJobStatusMap[status];
|
||||
processor.logger.debug(`approval resume job and next status: ${status}`);
|
||||
job.set({
|
||||
|
@ -53,6 +53,13 @@ const approvals = {
|
||||
context,
|
||||
});
|
||||
const instance = values.get();
|
||||
const summary = getSummary({
|
||||
summaryConfig: workflow.config.summary,
|
||||
data: {
|
||||
...instance,
|
||||
...data,
|
||||
},
|
||||
});
|
||||
Object.keys(model.associations).forEach((key) => {
|
||||
delete instance[key];
|
||||
});
|
||||
@ -63,10 +70,7 @@ const approvals = {
|
||||
dataKey: values[collection.filterTargetKey],
|
||||
workflowKey: workflow.key,
|
||||
applicantRoleName: context.state.currentRole,
|
||||
summary: getSummary({
|
||||
summaryConfig: workflow.config.summary,
|
||||
data: instance,
|
||||
}),
|
||||
summary,
|
||||
},
|
||||
});
|
||||
return actions.create(context, next);
|
||||
|
Loading…
Reference in New Issue
Block a user