DateUtils.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // import dd from '@/static/dd.js'
  2. export function editDDtitle(text) {
  3. // dd.ready(function() {
  4. // dd.biz.navigation.setTitle({
  5. // title: text, // 替换为你想要设置的导航栏文字
  6. // });
  7. // });
  8. }
  9. export function addColor(list) {
  10. let arr = [{
  11. color: 'rgba(41,212,175,1)',
  12. bgcColor: 'rgba(41,212,175,0.5)'
  13. },
  14. {
  15. color: 'rgba(204,115,237,1)',
  16. bgcColor: 'rgba(204,115,237,0.5)'
  17. },
  18. {
  19. color: 'rgba(254,127,126,1)',
  20. bgcColor: 'rgba(254,127,126,0.5)'
  21. },
  22. {
  23. color: 'rgba(102,195,255,1)',
  24. bgcColor: 'rgba(102,195,255,0.5)'
  25. }
  26. ]
  27. list.forEach((item, index) => {
  28. item.honor.forEach((item1, index1) => {
  29. let num = index1 % 4
  30. item1.color = arr[num].color
  31. item1.bgcColor = arr[num].bgcColor
  32. })
  33. })
  34. return list
  35. }
  36. export function addText(list) {
  37. let obj = {
  38. 0: '#FE6B6B',
  39. 1: '#43B3FF',
  40. 2: '#05CCA1',
  41. 3: '#BF57EA'
  42. }
  43. let obj1 = {
  44. 0: '未提交',
  45. 1: '已提交',
  46. 2: '已批改',
  47. 3: '线上提交'
  48. }
  49. list.forEach(item => {
  50. item.color = obj[item.status]
  51. item.text = obj1[item.status]
  52. })
  53. return list
  54. }
  55. export function toChinesNum(num) {
  56. let changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
  57. let unit = ['', '十', '百', '千', '万']
  58. num = parseInt(num)
  59. let getWan = (temp) => {
  60. let strArr = temp.toString().split('').reverse()
  61. let newNum = ''
  62. let newArr = []
  63. strArr.forEach((item, index) => {
  64. newArr.unshift(item === '0' ? changeNum[item] : changeNum[item] + unit[index])
  65. })
  66. let numArr = []
  67. newArr.forEach((m, n) => {
  68. if (m !== '零') numArr.push(n)
  69. })
  70. if (newArr.length > 1) {
  71. newArr.forEach((m, n) => {
  72. if (newArr[newArr.length - 1] === '零') {
  73. if (n <= numArr[numArr.length - 1]) {
  74. newNum += m
  75. }
  76. } else {
  77. newNum += m
  78. }
  79. })
  80. } else {
  81. newNum = newArr[0]
  82. }
  83. return newNum
  84. }
  85. let overWan = Math.floor(num / 10000)
  86. let noWan = num % 10000
  87. if (noWan.toString().length < 4) {
  88. noWan = '0' + noWan
  89. }
  90. return overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num)
  91. }