移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

78 line
1.7 KiB

  1. export function selectDictLabel(datas, value) {
  2. var actions = [];
  3. Object.keys(datas).some((key) => {
  4. if (datas[key].dictValue == ('' + value)) {
  5. actions.push(datas[key].dictLabel);
  6. return true;
  7. }
  8. })
  9. return actions.join('');
  10. }
  11. //回退
  12. export function onClickLeft(){
  13. history.back(-1);
  14. }
  15. export function getNowFormatDate(time) {
  16. var date;
  17. if (!time){
  18. date = new Date();
  19. }else{
  20. date = time;
  21. }
  22. var seperator1 = "-";
  23. var seperator2 = ":";
  24. var month = date.getMonth() + 1;
  25. var day = date.getDate();
  26. var hours = date.getHours();
  27. var minutes = date.getMinutes();
  28. var seconds = date.getSeconds();
  29. if (month >= 1 && month <= 9) {
  30. month = "0" + month;
  31. }
  32. if (day >= 0 && day <= 9) {
  33. day = "0" + day;
  34. }
  35. if (hours >= 0 && hours <= 9) {
  36. hours = "0" + hours;
  37. }
  38. if (minutes >= 0 && minutes <= 9) {
  39. minutes = "0" + minutes;
  40. }
  41. if (seconds >= 0 && seconds <= 9) {
  42. seconds = "0" + seconds;
  43. }
  44. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + day + " " + hours + seperator2 + minutes + seperator2 + seconds;
  45. return currentdate;
  46. }
  47. export function format(time, format) {
  48. var t = new Date(time);
  49. var tf = function (i) { return (i < 10 ? '0' : '') + i };
  50. return format.replace(/yyyy|MM|dd|HH|mm|ss/g, function (a) {
  51. switch (a) {
  52. case 'yyyy':
  53. return tf(t.getFullYear());
  54. break;
  55. case 'MM':
  56. return tf(t.getMonth() + 1);
  57. break;
  58. case 'mm':
  59. return tf(t.getMinutes());
  60. break;
  61. case 'dd':
  62. return tf(t.getDate());
  63. break;
  64. case 'HH':
  65. return tf(t.getHours());
  66. break;
  67. case 'ss':
  68. return tf(t.getSeconds());
  69. break;
  70. }
  71. })
  72. }