田源
2024-09-20 3c6c92b68a1b113b5450554db750ebe1d8bd26bb
Source/plt-web/plt-web-ui/src/util/func.js
@@ -4,6 +4,28 @@
import CryptoJS from 'crypto-js'
export default class func {
  /**
   * 单选表格行
   * 时间戳格式化
   */
  static formattedDate(val) {
    // 创建一个 Date 对象
    const date = new Date(val);
    // 格式化时间的辅助函数
    const formatNumber = (number) => String(number).padStart(2, '0');
    // 提取并格式化年、月、日、小时、分钟和秒
    const year = date.getFullYear();
    const month = formatNumber(date.getMonth() + 1); // 月份从0开始,需要+1
    const day = formatNumber(date.getDate());
    const hours = formatNumber(date.getHours());
    const minutes = formatNumber(date.getMinutes());
    const seconds = formatNumber(date.getSeconds());
    // 格式化为 YYYY-MM-DD HH:MM:SS
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  }
  /**
   * 单选表格行
@@ -223,7 +245,7 @@
      padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}
  }
  /**
   * HmacMD5加密
@@ -233,7 +255,7 @@
   * @constructor
   */
  static HmacMD5(message, key) {
    const encrypted = CryptoJS.HmacMD5(message,key);
    const encrypted = CryptoJS.HmacMD5(message, key);
    return encrypted.toString();
  }