刘光辉
5 小时以前 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type { DmsVersionExtendedProperties } from '#/api/x/dms/fileCenter';
 
import { formatToDateTime } from '@jnpf/utils';
 
export interface DmsFilePropertyItem {
  extendedProperties?: DmsVersionExtendedProperties;
  documentName?: string;
  documentNo?: string;
  effectiveFrom?: string;
  effectiveTo?: string;
  fileName?: string;
  lastReviewedOn?: string;
  lifecycleStatus?: string;
  name?: string;
  nextReviewOn?: string;
  preparedBy?: string;
  preparedOn?: string;
  reviewCycleMonths?: number;
  versionLabel?: string;
  versionNo?: number;
}
 
export interface DmsLifecycleMeta {
  color: string;
  label: string;
}
 
const lifecycleMeta: Record<string, DmsLifecycleMeta> = {
  EFFECTIVE: { color: 'success', label: '已生效/执行中' },
  EXPIRED: { color: 'error', label: '已过期' },
  INVALIDATED: { color: 'default', label: '已失效' },
  OBSOLETE: { color: 'default', label: '已废止' },
  PENDING_EFFECTIVE: { color: 'processing', label: '待生效' },
  REVOKED: { color: 'warning', label: '已撤销' },
  SUPERSEDED: { color: 'default', label: '已被替代' },
};
 
export function filePropertyDate(value?: string) {
  return value ? formatToDateTime(value, 'YYYY-MM-DD') : '—';
}
 
export function filePropertyName(item?: DmsFilePropertyItem) {
  return item?.documentName || item?.name || item?.fileName || '—';
}
 
export function filePropertyVersion(item?: DmsFilePropertyItem) {
  if (item?.versionLabel) return item.versionLabel;
  return item?.versionNo === undefined || item.versionNo === null ? '—' : `v${item.versionNo}`;
}
 
export function filePropertyReview(item?: DmsFilePropertyItem) {
  const nextReview = filePropertyDate(item?.nextReviewOn);
  const interval = item?.reviewCycleMonths ? `每 ${item.reviewCycleMonths} 个月` : '';
  if (nextReview === '—') return interval || '—';
  return interval ? `${nextReview}(${interval})` : nextReview;
}
 
export function filePropertyLifecycle(status?: string): DmsLifecycleMeta {
  return lifecycleMeta[status || ''] || { color: 'default', label: '—' };
}
 
export function filePropertyPreparer(item?: DmsFilePropertyItem) {
  return item?.extendedProperties?.prepared_by_name?.trim() || item?.preparedBy?.trim() || '未记录';
}
 
export function filePropertyReviewers(item?: DmsFilePropertyItem) {
  const reviewers = item?.extendedProperties?.reviewers;
  if (!Array.isArray(reviewers) || !reviewers.length) return '未记录';
  return reviewers.map((reviewer) => reviewer.name?.trim() || reviewer.user_id?.trim() || '未记录').join('、');
}