OnDutyToday.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="on-duty-today">
  3. <div class="on-duty-today__inner">
  4. <div class="on-duty-today__list">
  5. <div class="on-duty-today__item">
  6. <div class="on-duty-today__itemHeader">{{todayBeOnDuty.total || 0}}</div>
  7. <div class="on-duty-today__itemBody">总单数</div>
  8. </div>
  9. <div class="on-duty-today__item">
  10. <div class="on-duty-today__itemHeader">{{todayBeOnDuty.price || 0}}</div>
  11. <div class="on-duty-today__itemBody">总费用(元)</div>
  12. </div>
  13. <div class="on-duty-today__item">
  14. <div class="on-duty-today__itemHeader">{{todayBeOnDuty.avg_response | formatHourMinute}}</div>
  15. <div class="on-duty-today__itemBody">平均接单时间</div>
  16. </div>
  17. <div class="on-duty-today__item">
  18. <div class="on-duty-today__itemHeader">{{todayBeOnDuty.avg_handle | formatHourMinute}}</div>
  19. <div class="on-duty-today__itemBody">平均解决时间</div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import { post, timerCommon } from './../http/http'
  27. export default {
  28. name: 'OnDutyToday',
  29. inject: ['parentDutyId', 'hosId', 'dutyId'],
  30. data () {
  31. return {
  32. sign: 'lastWeek',
  33. timer: null,
  34. todayBeOnDuty: {} // 头部总当班人数
  35. }
  36. },
  37. methods: {
  38. // 获取数据
  39. async getData () {
  40. this.$emit('signEmit', this.sign)
  41. let startTime
  42. let endTime
  43. if (this.sign === 'lastWeek') {
  44. startTime = this.$moment().subtract(1, 'week').startOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  45. endTime = this.$moment().subtract(1, 'week').endOf('week').add(1, 'day').format('YYYY-MM-DD HH:mm:ss')
  46. } else if (this.sign === 'lastMonth') {
  47. startTime = this.$moment().subtract(1, 'month').startOf('month').format('YYYY-MM-DD HH:mm:ss')
  48. endTime = this.$moment().subtract(1, 'month').endOf('month').format('YYYY-MM-DD HH:mm:ss')
  49. }
  50. const result = await post(
  51. '/itsm/report/index',
  52. {
  53. parentDutyId: this.parentDutyId,
  54. hosId: this.hosId,
  55. dutyId: this.dutyId,
  56. startDate: startTime,
  57. endDate: endTime,
  58. type: 'itsmSummary'
  59. }
  60. )
  61. this.todayBeOnDuty = result.data ? result.data[0] : {}
  62. this.polling()
  63. },
  64. // 轮询请求
  65. polling () {
  66. clearTimeout(this.timer)
  67. this.timer = setTimeout(() => {
  68. if (this.sign === 'lastWeek') {
  69. this.sign = 'lastMonth'
  70. } else if (this.sign === 'lastMonth') {
  71. this.sign = 'lastWeek'
  72. }
  73. this.getData()
  74. }, timerCommon)
  75. }
  76. },
  77. mounted () {
  78. this.getData()
  79. },
  80. beforeDestroy () {
  81. clearTimeout(this.timer)
  82. }
  83. }
  84. </script>
  85. <style lang="less">
  86. .on-duty-today {
  87. overflow: hidden;
  88. height: 2.6625rem;
  89. .on-duty-today__inner {
  90. height: 100%;
  91. .on-duty-today__list {
  92. display: flex;
  93. justify-content: space-between;
  94. height: 100%;
  95. .on-duty-today__item {
  96. text-align: center;
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. margin-right: .4rem;
  101. &:first-child {
  102. margin-left: .4rem;
  103. }
  104. &:last-child {
  105. margin-right: .4rem;
  106. }
  107. .on-duty-today__itemHeader{
  108. font-size: .65rem;
  109. color: #00D5EA;
  110. font-weight: bold;
  111. }
  112. .on-duty-today__itemBody{
  113. font-size: .2rem;
  114. color: #FFFFFF;
  115. margin-top: .1rem;
  116. }
  117. }
  118. }
  119. }
  120. }
  121. </style>