刘光辉
4 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const APPROVAL_EVENT_TYPES = new Set(['audit', 'reject']);
 
export function isApprovalOpinionRequired(properties: any, eventType: string) {
  return APPROVAL_EVENT_TYPES.has(eventType) && !!properties?.hasOpinion && !!properties?.opinionRequired;
}
 
export function hasApprovalOpinion(opinion: unknown) {
  return hasValue(opinion);
}
 
export function hasValue(value: unknown) {
  if (typeof value === 'string') return value.trim().length > 0;
  if (Array.isArray(value)) return value.length > 0;
  return value !== null && value !== undefined;
}
 
export function shouldOpenApprovalDrawer(values: unknown, properties: any, eventType: string, approvalForm: any) {
  if (values) return false;
  if (properties?.hasSign && !hasValue(approvalForm?.signImg)) return true;
  const hasApprovalFormInput =
    hasApprovalOpinion(approvalForm?.handleOpinion) || hasValue(approvalForm?.fileList) || approvalForm?.approvalField?.some((item) => hasValue(item.value));
  if (hasApprovalFormInput) return false;
  return isApprovalOpinionRequired(properties, eventType) || properties?.hasFile || properties?.hasApprovalField;
}