|
|
@@ -1,5 +1,5 @@
|
|
|
-import { ApprovalWay, IProcessAccount, ProcessStatus } from '@sc/types';
|
|
|
-import { isArray } from 'lodash';
|
|
|
+import { ApprovalWay, IProcessAccount, ProcessStatus, IProcess } from '@sc/types';
|
|
|
+import { isArray, isEmpty } from 'lodash';
|
|
|
|
|
|
// 获取流程某个环节审批状态
|
|
|
export const getProcessStatus = (approvalWay: ApprovalWay, accounts: IProcessAccount[] | IProcessAccount) => {
|
|
|
@@ -41,4 +41,41 @@ export const getProcessStatus = (approvalWay: ApprovalWay, accounts: IProcessAcc
|
|
|
return ProcessStatus.WAITING;
|
|
|
};
|
|
|
|
|
|
-export const a = 1;
|
|
|
+// 获取当前的流程
|
|
|
+export const getCurrentProcess = (processes: IProcess[]) => {
|
|
|
+ if (isEmpty(processes)) {
|
|
|
+ return undefined;
|
|
|
+ }
|
|
|
+ for (let i = 0; i < processes.length; i += 1) {
|
|
|
+ const {
|
|
|
+ participantInfo: { approvalWay, accounts },
|
|
|
+ } = processes[i];
|
|
|
+ // 上报审批
|
|
|
+ // if (approvalWay === ApprovalWay.REPORT) {
|
|
|
+ // continue;
|
|
|
+ // }
|
|
|
+ // 指定用户
|
|
|
+ if (approvalWay === ApprovalWay.ACCOUNT) {
|
|
|
+ const { status } = accounts[0];
|
|
|
+ if (status === ProcessStatus.ACTIVATING) {
|
|
|
+ return processes[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 会签 或者 依次审批
|
|
|
+ if (approvalWay === ApprovalWay.JOINTLYSIGN || approvalWay === ApprovalWay.ORDERAPPROVAL) {
|
|
|
+ if (
|
|
|
+ accounts.every(account => account.status !== ProcessStatus.FAILED) &&
|
|
|
+ accounts.some(account => account.status === ProcessStatus.ACTIVATING)
|
|
|
+ ) {
|
|
|
+ return processes[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 或签
|
|
|
+ if (approvalWay === ApprovalWay.ORSIGN) {
|
|
|
+ if (accounts.every(account => account.status === ProcessStatus.ACTIVATING)) {
|
|
|
+ return processes[i];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return undefined;
|
|
|
+};
|