WXL (wul)
6 天以前 19c62799136bb984e968fcb6b0a4d2371d018270
src/utils/ruoyi.js
@@ -50,18 +50,17 @@
  return time_str;
}
// 出院/入院天数计算
export function Daycount(dateString1, dateString2){
// 将日期字符串转换为日期对象
var date1 = new Date(dateString1);
var date2 = new Date(dateString2);
// 计算时间差(毫秒)
var timeDifference = date2 - date1;
// 将时间差转换为天数
var daysDifference = Math.ceil(timeDifference / (1000 * 3600 * 24));
return daysDifference;
export function daysBetween(dateString) {
  // 将输入的日期字符串转换为Date对象
  var startDate = new Date(dateString);
  // 获取当前日期
  var currentDate = new Date();
  // 计算两个日期之间的时间差(毫秒)
  var differenceInTime = currentDate - startDate;
  // 将时间差转换为天数
  var differenceInDays = differenceInTime / (1000 * 3600 * 24);
  // 返回天数,四舍五入到最接近的整数
  return Math.round(differenceInDays);
}
// 过滤器
export function formatTime(val) {
@@ -182,6 +181,19 @@
  }
  return source;
}
// 脱敏方法
export function desensitization(str, type) {
  // 脱敏处理
  if (!str) return "";
  switch (type) {
    case "phone":
      return str.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
    case "idCard":
      return str.replace(/(\d{4})\d{10}(\w{4})/, "$1**********$2");
    default:
      return str;
  }
}
/**
 * 构造树型结构数据