utils.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. // 获取字典是否
  3. exports.getIsNot = function(value) {
  4. let isNot = '';
  5. // eslint-disable-next-line default-case
  6. switch (value) {
  7. case '0':
  8. isNot = '否';
  9. break;
  10. case '1':
  11. isNot = '是';
  12. break;
  13. case '2':
  14. isNot = '无资格';
  15. break;
  16. }
  17. return isNot;
  18. };
  19. // 获取两个时间差
  20. exports.begindateEnddateSum = function(begindate, enddate) {
  21. const sumDate = [];
  22. const startTime = getDate(begindate);
  23. const endTime = getDate(enddate);
  24. while (endTime.getTime() - startTime.getTime() >= 0) {
  25. const year = startTime.getFullYear();
  26. const month = startTime.getMonth().toString().length === 1 ? '0' + startTime.getMonth().toString() : startTime.getMonth();
  27. const day = startTime.getDate().toString().length === 1 ? '0' + startTime.getDate() : startTime.getDate();
  28. sumDate.push(year + '-' + month + '-' + day);
  29. startTime.setDate(startTime.getDate() + 1);
  30. }
  31. // console.log(sumDate);
  32. return sumDate;
  33. };
  34. function getDate(datestr) {
  35. const temp = datestr.split('-');
  36. // new Date()的月份入参实际都是当前值-1
  37. const date = new Date(temp[0], temp[1], temp[2]);
  38. return date;
  39. // const temp = datestr.split('-');
  40. // const date = new Date(temp[0], temp[1], temp[2]);
  41. // return date;
  42. }