refactor(frontend): 重构前端第二版
This commit is contained in:
1 parent
2631f78b00
commit
4b562cfa82
205 files changed
+15399
-12015
No files matched your search
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* 请假:假种标签、时长/是否展示、余额数字格式化。
|
||||
*/
|
||||
import { LEAVE_TYPES } from '../constants/leave';
|
||||
import { isLeaveTypeByDay } from './leaveDateTime';
|
||||
|
||||
export function getLeaveTypeLabel(val: string): string {
|
||||
const item = LEAVE_TYPES.find((x) => x.value === val);
|
||||
return item ? item.label : val;
|
||||
}
|
||||
|
||||
export function formatDurationLabel(
|
||||
hours: number,
|
||||
leaveType: string | undefined,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
if (!hours) return `0 ${isLeaveTypeByDay(leaveType || '') ? t('chat.dayUnit') : t('chat.hourUnit')}`;
|
||||
if (isLeaveTypeByDay(leaveType || '')) {
|
||||
const days = Math.round(hours / 8);
|
||||
return `${days} ${t('chat.dayUnit')}`;
|
||||
}
|
||||
return `${hours} ${t('chat.hourUnit')}`;
|
||||
}
|
||||
|
||||
export function formatYesNoLabel(value: 0 | 1 | null): string {
|
||||
if (value === 0) return '是';
|
||||
if (value === 1) return '否';
|
||||
return '未选择';
|
||||
}
|
||||
|
||||
export function formatLeaveBalanceNumber(value: unknown, t: (key: string) => string): string {
|
||||
if (value === null || value === undefined) return t('chat.noData');
|
||||
const num = Number(value);
|
||||
if (Number.isNaN(num)) return String(value);
|
||||
return Number.isInteger(num) ? String(num) : num.toFixed(2);
|
||||
}
|
||||
Reference in new issue
Block a user