yaozc
2023-02-21 744ddc3550c2bdbe61f7326e4ab7c00dfa3ac51f
eladmin-web-master/src/components/Crud/crud.js
@@ -560,6 +560,20 @@
      }
    },
    /**
     * 月日格式化
     * @param {Object} timestamp 时间戳
     */
    toMonthDay(timestamp) {
      if (timestamp == null) {
        return
      } else {
        const system = new Date(timestamp)
        const month = system.getMonth() + 1 < 10 ? '0' + (system.getMonth() + 1) : system.getMonth() + 1
        const date = system.getDate() < 10 ? '0' + system.getDate() : system.getDate()
        return month + '-' + date
      }
    },
    /**
     * 时间格式化
     * @param {Object} timestamp
     */
@@ -590,6 +604,15 @@
      if (cents < 10) { cents = '0' + cents }
      for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3)) }
      return (((sign) ? '' : '-') + num + '.' + cents)
    },
    /**
     * 最大两位小数格式
     * @param {Object} num
     */
    toMaxTwoDecimalPlaces(num) {
      const numList = num.toString().split('.')
      num = numList.length > 1 ? numList[1].length > 1 ? num.toFixed(2) : num : num
      return num
    }
  }
  const crud = Object.assign({}, data)