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',
|
type: 'text',
|
||||||
name: 'comment',
|
name: 'comment',
|
||||||
interface: 'markdown',
|
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',
|
name: 'createdAt',
|
||||||
|
@ -21,13 +21,15 @@ export const ApproverBlock = ({ value: srcID, onChange }) => {
|
|||||||
const { setFormValueChanged } = useContext(ContextApproverConfig) as any;
|
const { setFormValueChanged } = useContext(ContextApproverConfig) as any;
|
||||||
const onChangeFunc = useCallback(
|
const onChangeFunc = useCallback(
|
||||||
(data) => {
|
(data) => {
|
||||||
const flatSet = flatSchemaArray(
|
const arr = flatSchemaArray(data.toJSON(), (field) => field['x-decorator'] === 'ApprovalFormBlockProvider');
|
||||||
data.toJSON(),
|
|
||||||
(field) => field['x-decorator'] === 'ApprovalFormBlockProvider',
|
const flatSet = arr.reduce((accSet, curr) => {
|
||||||
).reduce((accSet, curr) => {
|
const currArr = flatSchemaArray(curr, (field) => field['x-component'] === 'Action');
|
||||||
flatSchemaArray(curr, (field) => field['x-component'] === 'Action').forEach((field) => {
|
|
||||||
|
for (const field of currArr) {
|
||||||
accSet.add(Number.parseInt(field['x-action'], 10));
|
accSet.add(Number.parseInt(field['x-action'], 10));
|
||||||
});
|
}
|
||||||
|
|
||||||
return accSet;
|
return accSet;
|
||||||
}, new Set());
|
}, new Set());
|
||||||
|
|
||||||
@ -57,7 +59,9 @@ export const ApproverBlock = ({ value: srcID, onChange }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await apiClient.resource('uiSchemas').insert({ values: schema });
|
await apiClient.resource('uiSchemas').insert({ values: schema });
|
||||||
|
|
||||||
onChange(id);
|
onChange(id);
|
||||||
|
|
||||||
return schema;
|
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 = () => {
|
export const ApproverInterfaceComponent = () => {
|
||||||
const context = useContext(SchemaComponentContext);
|
const context = useContext(SchemaComponentContext);
|
||||||
@ -64,21 +82,3 @@ export const ApproverInterfaceComponent = () => {
|
|||||||
</ExtendCollectionsProvider>
|
</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 processing = Boolean(distribution.find((item) => item.status !== APPROVAL_ACTION_STATUS.PENDING));
|
||||||
const status =
|
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];
|
const result = ApprovalJobStatusMap[status];
|
||||||
processor.logger.debug(`approval resume job and next status: ${status}`);
|
processor.logger.debug(`approval resume job and next status: ${status}`);
|
||||||
job.set({
|
job.set({
|
||||||
|
@ -53,6 +53,13 @@ const approvals = {
|
|||||||
context,
|
context,
|
||||||
});
|
});
|
||||||
const instance = values.get();
|
const instance = values.get();
|
||||||
|
const summary = getSummary({
|
||||||
|
summaryConfig: workflow.config.summary,
|
||||||
|
data: {
|
||||||
|
...instance,
|
||||||
|
...data,
|
||||||
|
},
|
||||||
|
});
|
||||||
Object.keys(model.associations).forEach((key) => {
|
Object.keys(model.associations).forEach((key) => {
|
||||||
delete instance[key];
|
delete instance[key];
|
||||||
});
|
});
|
||||||
@ -63,10 +70,7 @@ const approvals = {
|
|||||||
dataKey: values[collection.filterTargetKey],
|
dataKey: values[collection.filterTargetKey],
|
||||||
workflowKey: workflow.key,
|
workflowKey: workflow.key,
|
||||||
applicantRoleName: context.state.currentRole,
|
applicantRoleName: context.state.currentRole,
|
||||||
summary: getSummary({
|
summary,
|
||||||
summaryConfig: workflow.config.summary,
|
|
||||||
data: instance,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return actions.create(context, next);
|
return actions.create(context, next);
|
||||||
|
Loading…
Reference in New Issue
Block a user