detail.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="havedone-container">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="流程详情" @clickLeft="back" background-color="#157A2C" color="#fff"></uni-nav-bar>
  4. <view class="list-wrapper">
  5. <rxl-timeline>
  6. <rxl-timeline-item v-for="(item, index) in tasks" :key="index" :color="getTimelineItemIcon(item)" :timestamp="item.createTime">
  7. <template #body>
  8. <p style="font-weight: 700;display: block;">{{item.taskDefinitionKey?'流程节点':'发起人'}}:{{ item.name }}</p>
  9. <view style="{ padding: '10px';display: flex;flex-direction: column; }">
  10. <span>
  11. <label v-if="item.assigneeUser"
  12. style="font-weight: normal;display: flex;flex-direction: row;">
  13. 审批人:{{ item.assigneeUser.nickname }}
  14. <u-tag style="margin-left: 10rpx;" type="info" :text="item.assigneeUser.deptName"
  15. size="mini"></u-tag>
  16. </label>
  17. </span>
  18. <span>
  19. <label v-if="item.endTime" style="font-weight: normal">审批时间:</label>
  20. <label v-if="item.endTime" style="color: #8a909c; font-weight: normal">
  21. {{ item.endTime }}</label>
  22. </span>
  23. <span>
  24. <label v-if="item.durationInMillis" style=" font-weight: normal">耗时:</label>
  25. <label v-if="item.durationInMillis" style="color: #8a909c; font-weight: normal">
  26. {{ getDateStar(item.durationInMillis) }}
  27. </label>
  28. </span>
  29. <p v-if="item.reason">
  30. <u-tag :type="getTimelineItemType(item)" :text="item.reason"></u-tag>
  31. </p>
  32. </view>
  33. </template>
  34. </rxl-timeline-item>
  35. </rxl-timeline>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. getTaskListByProcessinstanceid
  42. } from '@/api/wt/index.js'
  43. import {
  44. getDates
  45. } from '@/utils/utils.js'
  46. export default {
  47. components: {},
  48. data() {
  49. return {
  50. tasks: []
  51. }
  52. },
  53. onLoad(processInstanceId) {
  54. this.getInfo(processInstanceId)
  55. },
  56. methods: {
  57. getChildren(data) {
  58. const arr = [];
  59. (data || []).forEach((item) => {
  60. if (item.children && item.children.length > 0) {
  61. arr.push(...this.getChildren(item.children));
  62. }
  63. arr.push(item);
  64. });
  65. return arr;
  66. },
  67. async getInfo(processInstanceId) {
  68. // 审批记录
  69. let data = await getTaskListByProcessinstanceid(processInstanceId)
  70. // 移除已取消的审批
  71. data.forEach((task) => {
  72. // if (task.result !== 4) {
  73. // this.tasks.push(task);
  74. this.tasks.push(...this.getChildren([task]));
  75. // }
  76. });
  77. // 排序,将未完成的排在前面,已完成的排在后面;
  78. this.tasks.sort((a, b) => {
  79. // 有已完成的情况,按照完成时间倒序
  80. if (a.endTime && b.endTime) {
  81. return b.endTime - a.endTime;
  82. } else if (a.endTime) {
  83. return 1;
  84. } else if (b.endTime) {
  85. return -1;
  86. // 都是未完成,按照创建时间倒序
  87. } else {
  88. return b.createTime - a.createTime;
  89. }
  90. });
  91. // 需要审核的记录
  92. let userInfo = wx.getStorageSync("userInfo");
  93. this.tasks.forEach((task) => {
  94. if (task.result !== 1 && task.result !== 6) {
  95. // 只有待处理才需要
  96. return;
  97. }
  98. if (!task.assigneeUser || task.assigneeUser.id !== userInfo.userId) {
  99. // 自己不是处理人
  100. return;
  101. }
  102. });
  103. console.log('tasks~~~~', this.tasks)
  104. },
  105. getTimelineItemIcon(item) {
  106. if (item.result === 1) {
  107. return '';
  108. }
  109. if (item.result === 2) {
  110. return 'green';
  111. }
  112. return '';
  113. },
  114. getTimelineItemType(item) {
  115. if (item.result === 1) {
  116. return 'waiting';
  117. }
  118. if (item.result === 2) {
  119. return 'success';
  120. }
  121. if (item.result === 3) {
  122. return 'cancel';
  123. }
  124. if (item.result === 4) {
  125. return 'info';
  126. }
  127. if (item.result === 5) {
  128. return 'warn';
  129. }
  130. if (item.result === 6) {
  131. return 'default';
  132. }
  133. return '';
  134. },
  135. getDateStar(ms) {
  136. return getDates(ms);
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. </style>