util.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * 处理流程图数据
  3. * @param list 数据来源
  4. * @param stepList 流程数据列表
  5. */
  6. export function dealStepData (list, stepList) {
  7. if (list) {
  8. stepList.push({
  9. icon: 'el-icon-location',
  10. title: '开始'
  11. })
  12. list.forEach((item) => {
  13. stepList.push({
  14. // icon: item.approvalState === '0' ? 'el-icon-location' : 'el-icon-location-outline',
  15. icon: 'el-icon-location',
  16. title: item.stepName
  17. // description: formatStepDesc(item.processLogInfoList)
  18. })
  19. })
  20. stepList.push({
  21. icon: 'el-icon-location',
  22. title: '结束'
  23. })
  24. }
  25. }
  26. /**
  27. * 处理流程图日志数据
  28. * @param list 数据来源
  29. * @param stepLogList 流程日志数据
  30. */
  31. export function dealStepLogs (list, stepLogList) {
  32. if (!list) return
  33. list.forEach((item) => {
  34. stepLogList.push(item)
  35. })
  36. }
  37. export function formatStepDesc (lst) {
  38. if (!lst) return ''
  39. let str = ''
  40. lst.forEach((item) => {
  41. str = str + '\n' + item.assigneeName + ' ' + item.createTime + ' ' + item.approvalState
  42. })
  43. return str
  44. }
  45. /**
  46. * 获取文件后缀
  47. */
  48. export function getFileExt (fileName) {
  49. if (!fileName) return ''
  50. return fileName.split('.').pop().toLowerCase()
  51. }
  52. export function checkStr (currentStr, strList) {
  53. if (!currentStr || !strList) return false
  54. let list = strList.split(',')
  55. let index = list.findIndex(item => item === currentStr)
  56. // console.log('strList: ' + strList)
  57. // console.log('currentUser: ' + currentStr)
  58. // console.log('index: ' + index)
  59. return index > -1
  60. }
  61. /**
  62. * 日期处理:字符串转日期
  63. */
  64. export function strToDate (str) {
  65. if (!str) return null
  66. return dateToString(Date.parse(str))
  67. }
  68. export function dateToString (date) {
  69. let date1 = new Date(date)
  70. const year = date1.getFullYear() + ''
  71. let month = (date1.getMonth() + 1) + ''
  72. let day = (date1.getDate()) + ''
  73. if (month.length === 1) {
  74. month = '0' + month
  75. }
  76. if (day.length === 1) {
  77. day = '0' + day
  78. }
  79. return year + '-' + month + '-' + day
  80. }
  81. /**
  82. * 日期(带时间)转字符串
  83. */
  84. export function dateTimeToString (date) {
  85. let date1 = new Date(date)
  86. const year = date1.getFullYear() + ''
  87. let month = (date1.getMonth() + 1) + ''
  88. let day = (date1.getDate()) + ''
  89. let h = date1.getHours() + ''
  90. let m = date1.getMinutes() + ''
  91. let s = date1.getSeconds() + ''
  92. if (month.length === 1) {
  93. month = '0' + month
  94. }
  95. if (day.length === 1) {
  96. day = '0' + day
  97. }
  98. if (h.length === 1) {
  99. h = '0' + h
  100. }
  101. if (m.length === 1) {
  102. m = '0' + m
  103. }
  104. if (s.length === 1) {
  105. s = '0' + s
  106. }
  107. return year + '-' + month + '-' + day + ' ' + h + ':' + m + ':' + s
  108. }