zhangwencui
2026-11-02 822b68aef531a3a0ff1bb8aefc20ab4700bcdd55
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
import type { DictData } from "../../api/crm";
 
export const HRM_DICT = {
  gender: "system_user_sex", employeeStatus: "hrm_employee_status", contractType: "hrm_contract_type",
  contractTermType: "hrm_contract_term_type", contractStatus: "hrm_contract_status",
  leaveType: "hrm_leave_type", auditStatus: "hrm_audit_status", transferType: "hrm_transfer_type",
  resignationType: "hrm_resignation_type", handoverStatus: "hrm_handover_status",
} as const;
export function options(dicts: DictData[], type: string) { return dicts.filter(item => item.dictType === type && item.status !== 1).sort((a, b) => Number(a.sort || 0) - Number(b.sort || 0)); }
export function label(dicts: DictData[], type: string, value?: string | number, fallback = "--") { return dicts.find(item => item.dictType === type && String(item.value) === String(value))?.label || fallback; }
export function auditClass(status?: number) { return status === 20 ? "tag-on" : status === 30 || status === 40 ? "tag-danger" : status === 10 ? "tag-blue" : "tag-off"; }
export function displayDate(value?: string) { return value ? value.replace("T", " ").slice(0, 19) : "--"; }
export function isOwnApplication(row: { userId?: number; userName?: string; employeeName?: string }, user?: { id?: number; nickname?: string; username?: string } | null) {
  if (!user) return false;
  if (row.userId !== undefined && row.userId !== null) return Number(row.userId) === Number(user.id);
  const applicant = String(row.userName || row.employeeName || "").trim();
  return Boolean(applicant) && [user.nickname, user.username].some(name => String(name || "").trim() === applicant);
}
export function setDateTime(value: string | undefined, part: "date" | "time", next: string) {
  const current = value || ""; const date = current.slice(0, 10) || new Date().toISOString().slice(0, 10); const time = current.slice(11, 16) || "08:00";
  return `${part === "date" ? next : date} ${part === "time" ? next : time}:00`;
}
export const toast = (title: string) => uni.showToast({ title, icon: "none" });
export const money = (value?: number) => value === undefined || value === null ? "--" : `¥${Number(value).toFixed(2)}`;
export const dateTime = (value?: string) => value ? value.replace("T", " ").slice(0, 19) : "--";
export function confirm(content: string) {
  return new Promise<boolean>(resolve => uni.showModal({ title: "提示", content, success: result => resolve(result.confirm), fail: () => resolve(false) }));
}