config.js 582 B

12345678910111213141516171819202122232425
  1. export const GetPercent = (num, total)=> {
  2. /// <summary>
  3. /// 求百分比
  4. /// </summary>
  5. /// <param name="num">当前数</param>
  6. /// <param name="total">总数</param>
  7. num = parseFloat(num);
  8. total = parseFloat(total);
  9. if (isNaN(num) || isNaN(total)) {
  10. return "-";
  11. }
  12. return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00)+"%";
  13. }
  14. export const GetMax = (arr)=> {
  15. let max = 1;
  16. if(arr ==undefined)
  17. return 1;
  18. arr.forEach(v => {
  19. if (max<v) {
  20. max = v;
  21. }
  22. })
  23. return max;
  24. }