feat(approval): v2 (#1476)
Reviewed-on: daoyoucloud/tachybase#1476 Reviewed-by: sealday <zhanglin@daoyoucloud.com> Co-authored-by: bai.zixv <bai.zixv@foxmail.com> Co-committed-by: bai.zixv <bai.zixv@foxmail.com>
This commit is contained in:
parent
ba75073ec0
commit
d34b1fba36
@ -66,7 +66,6 @@ export const ApproverInterfaceComponent = () => {
|
|||||||
value={{
|
value={{
|
||||||
...context,
|
...context,
|
||||||
refresh: () => setId(uid()),
|
refresh: () => setId(uid()),
|
||||||
designable: !workflow.executed,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RecordProvider record={{}} parent={false}>
|
<RecordProvider record={{}} parent={false}>
|
||||||
|
@ -37,7 +37,8 @@ export function ApprovalFormBlockDecorator(props) {
|
|||||||
return createForm({
|
return createForm({
|
||||||
initialValues: omitApproval,
|
initialValues: omitApproval,
|
||||||
pattern:
|
pattern:
|
||||||
!workflow?.enabled || execution?.status || job?.status || omitApproval?.status == null
|
// NOTE: 为了让过期版本也能走完正常流程, 去除 !workflow?.enabled 条件
|
||||||
|
execution?.status || job?.status || omitApproval?.status == null
|
||||||
? 'disabled'
|
? 'disabled'
|
||||||
: omitApproval.status || data.data?.id !== omitApproval.userId
|
: omitApproval.status || data.data?.id !== omitApproval.userId
|
||||||
? 'readPretty'
|
? 'readPretty'
|
||||||
|
@ -13,16 +13,7 @@ export const WorkflowColumn = observer(
|
|||||||
if (value?.enabled) {
|
if (value?.enabled) {
|
||||||
return title;
|
return title;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return <span title={t('Disabled')}>{`${title}*`}</span>;
|
||||||
<span
|
|
||||||
className={css`
|
|
||||||
text-decoration: line-through;
|
|
||||||
`}
|
|
||||||
title={t('Disabled')}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ displayName: 'WorkflowColumn' },
|
{ displayName: 'WorkflowColumn' },
|
||||||
|
@ -13,16 +13,7 @@ export const ColumnWorkflow = observer(
|
|||||||
if (value?.enabled) {
|
if (value?.enabled) {
|
||||||
return title;
|
return title;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return <span title={t('Disabled')}>{`${title}*`}</span>;
|
||||||
<span
|
|
||||||
className={css`
|
|
||||||
text-decoration: line-through;
|
|
||||||
`}
|
|
||||||
title={t('Disabled')}
|
|
||||||
>
|
|
||||||
{title}
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ displayName: 'ColumnWorkflow' },
|
{ displayName: 'ColumnWorkflow' },
|
||||||
|
@ -3,7 +3,7 @@ import { UiSchemaRepository } from '@tachybase/plugin-ui-schema-storage';
|
|||||||
import { JOB_STATUS } from '../../constants';
|
import { JOB_STATUS } from '../../constants';
|
||||||
import Instruction from '../../instructions';
|
import Instruction from '../../instructions';
|
||||||
import { COLLECTION_NAME_APPROVAL_CARBON_COPY } from '../common/constants';
|
import { COLLECTION_NAME_APPROVAL_CARBON_COPY } from '../common/constants';
|
||||||
import { APPROVAL_STATUS } from './constants';
|
import { APPROVAL_STATUS } from './constants/status';
|
||||||
import { parsePerson } from './tools';
|
import { parsePerson } from './tools';
|
||||||
|
|
||||||
export default class ApprovalCarbonCopyInstruction extends Instruction {
|
export default class ApprovalCarbonCopyInstruction extends Instruction {
|
||||||
|
@ -6,7 +6,7 @@ import { JOB_STATUS } from '../../constants';
|
|||||||
import Instruction from '../../instructions';
|
import Instruction from '../../instructions';
|
||||||
import { toJSON } from '../../utils';
|
import { toJSON } from '../../utils';
|
||||||
import ApprovalTrigger from './ApprovalTrigger';
|
import ApprovalTrigger from './ApprovalTrigger';
|
||||||
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from './constants';
|
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from './constants/status';
|
||||||
|
|
||||||
const NEGOTIATION_MODE = {
|
const NEGOTIATION_MODE = {
|
||||||
SINGLE: Symbol('single'),
|
SINGLE: Symbol('single'),
|
||||||
|
@ -8,7 +8,7 @@ import { BelongsTo, HasOne, Op } from 'sequelize';
|
|||||||
import { EXECUTION_STATUS, JOB_STATUS } from '../../constants';
|
import { EXECUTION_STATUS, JOB_STATUS } from '../../constants';
|
||||||
import Trigger from '../../triggers';
|
import Trigger from '../../triggers';
|
||||||
import { toJSON } from '../../utils';
|
import { toJSON } from '../../utils';
|
||||||
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from './constants';
|
import { APPROVAL_ACTION_STATUS, APPROVAL_STATUS } from './constants/status';
|
||||||
import { getSummary } from './tools';
|
import { getSummary } from './tools';
|
||||||
|
|
||||||
const ExecutionStatusMap = {
|
const ExecutionStatusMap = {
|
||||||
|
@ -2,7 +2,7 @@ import actions from '@tachybase/actions';
|
|||||||
import { Op } from '@tachybase/database';
|
import { Op } from '@tachybase/database';
|
||||||
|
|
||||||
import { COLLECTION_WORKFLOWS_NAME } from '../../common/constants';
|
import { COLLECTION_WORKFLOWS_NAME } from '../../common/constants';
|
||||||
import { APPROVAL_STATUS } from '../constants';
|
import { APPROVAL_STATUS } from '../constants/status';
|
||||||
import { findUniqueObjects } from '../utils';
|
import { findUniqueObjects } from '../utils';
|
||||||
|
|
||||||
export const approvalCarbonCopy = {
|
export const approvalCarbonCopy = {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import actions, { utils } from '@tachybase/actions';
|
import actions, { utils } from '@tachybase/actions';
|
||||||
|
|
||||||
import { PluginWorkflow } from '../../..';
|
import { PluginWorkflow } from '../../..';
|
||||||
import { APPROVAL_ACTION_STATUS } from '../constants';
|
import { ERROR_CODE_MAP } from '../constants/error-code';
|
||||||
|
import { APPROVAL_ACTION_STATUS } from '../constants/status';
|
||||||
|
|
||||||
export const approvalRecords = {
|
export const approvalRecords = {
|
||||||
async listCentralized(context, next) {
|
async listCentralized(context, next) {
|
||||||
@ -38,15 +39,24 @@ export const approvalRecords = {
|
|||||||
if (!approvalRecord) {
|
if (!approvalRecord) {
|
||||||
return context.throw(404);
|
return context.throw(404);
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
!approvalRecord.workflow.enabled ||
|
// NOTE: 为了更改设定, 让切换版本后, 已经在进程中的审批流程也可以执行下去. 所以这里先注释掉.
|
||||||
approvalRecord.execution.status ||
|
// 原设定是, 切换版本后, 已经在流程中的, 置为未处理状态, 然后禁止继续执行.
|
||||||
approvalRecord.job.status ||
|
switch (true) {
|
||||||
approvalRecord.status !== APPROVAL_ACTION_STATUS.PENDING ||
|
// case !approvalRecord.workflow.enabled:
|
||||||
(!needUpdateRecord && !(approvalRecord.node.config.actions ?? []).includes(status))
|
// return context.throw(400, ERROR_CODE_MAP['not_enable_workflow']);
|
||||||
) {
|
case approvalRecord.execution.status:
|
||||||
return context.throw(400);
|
return context.throw(400, ERROR_CODE_MAP['execution_finished']);
|
||||||
|
case approvalRecord.job.status:
|
||||||
|
return context.throw(400, ERROR_CODE_MAP['job_finished']);
|
||||||
|
case approvalRecord.status !== APPROVAL_ACTION_STATUS.PENDING:
|
||||||
|
return context.throw(400, ERROR_CODE_MAP['not_approval_pending']);
|
||||||
|
case !needUpdateRecord && !(approvalRecord.node.config.actions ?? []).includes(status):
|
||||||
|
return context.throw(400, ERROR_CODE_MAP['not_need_update']);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
await approvalRecord.update({
|
await approvalRecord.update({
|
||||||
status: status,
|
status: status,
|
||||||
comment: data.comment,
|
comment: data.comment,
|
||||||
|
@ -3,7 +3,7 @@ import { parseCollectionName } from '@tachybase/data-source-manager';
|
|||||||
import { traverseJSON } from '@tachybase/database';
|
import { traverseJSON } from '@tachybase/database';
|
||||||
|
|
||||||
import { EXECUTION_STATUS, JOB_STATUS, PluginWorkflow } from '../../..';
|
import { EXECUTION_STATUS, JOB_STATUS, PluginWorkflow } from '../../..';
|
||||||
import { APPROVAL_STATUS } from '../constants';
|
import { APPROVAL_STATUS } from '../constants/status';
|
||||||
import { getSummary } from '../tools';
|
import { getSummary } from '../tools';
|
||||||
import { getAssociationName, jsonParse } from '../utils';
|
import { getAssociationName, jsonParse } from '../utils';
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
export const ERROR_CODE_MAP = {
|
||||||
|
['not_enable_workflow']: {
|
||||||
|
code: 9000,
|
||||||
|
message: 'not_enable_workflow',
|
||||||
|
},
|
||||||
|
['execution_finished']: {
|
||||||
|
code: 9001,
|
||||||
|
message: 'execution_finished',
|
||||||
|
},
|
||||||
|
['job_finished']: {
|
||||||
|
code: 9002,
|
||||||
|
message: 'job_finished',
|
||||||
|
},
|
||||||
|
['not_approval_pending']: {
|
||||||
|
code: 9003,
|
||||||
|
message: 'not_approval_pending',
|
||||||
|
},
|
||||||
|
['not_need_update']: {
|
||||||
|
code: 9004,
|
||||||
|
message: 'not_need_update',
|
||||||
|
},
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user