dangsn
2024-12-03 f31d6505363fa191fb715976826369484c26cf16
Source/plt-web/plt-web-ui/src/util/func.js
@@ -5,6 +5,53 @@
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}`;
  }
  /**
   * 单选表格行
   * row 当前行数据
   * CrudRef 表格ref绑定值
   * lastIndex 判断二次点击index是否和第一次点击一致
   * setLastIndex 更新lastIndex值
   * setSelectList 将下拉框保存数组置空
   */
  static rowClickHandler(row, CrudRef, lastIndex, setLastIndex, setSelectList) {
    /*if (lastIndex === row.$index) {
      setSelectList();
      CrudRef.clearSelection();
    } else {
      setSelectList();
      CrudRef.clearSelection();
      CrudRef.toggleRowSelection(row);
    }*/
    setSelectList();
    CrudRef.toggleSelection();
    CrudRef.toggleRowSelection(row);//选中当前行
    setLastIndex(row.$index);
  }
  /**
   * 不为空
   * @param val
   * @returns {boolean}
@@ -45,7 +92,11 @@
   */
  static isEmptyObject(obj) {
    return Object.keys(obj).length === 0;
    if(obj){
      return Object.keys(obj).length === 0;
    }else {
      return true;
    }
  }
  /**
@@ -200,7 +251,7 @@
      padding: CryptoJS.pad.Pkcs7
    });
    return encrypted.toString();
}
  }
  /**
   * HmacMD5加密
@@ -210,7 +261,7 @@
   * @constructor
   */
  static HmacMD5(message, key) {
    const encrypted = CryptoJS.HmacMD5(message,key);
    const encrypted = CryptoJS.HmacMD5(message, key);
    return encrypted.toString();
  }