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('、');
|
}
|