ShowHandler.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="show-data-box">
  3. <div v-if="showData.enable">
  4. <div class="data-box" style="display: flex; align-items: center; justify-content: center;">
  5. <div v-if="taskStatusList.completedTaskList.length > 0" class="data-complated green-color"
  6. style="margin-right: 5px;" @click="openDialog('completed')">
  7. <el-tooltip :content="'已完成:' + taskStatusList.completedTaskList.length + '人'" effect="dark"
  8. placement="right">
  9. <div>
  10. <i class="el-icon-check"></i> {{ taskStatusList.completedTaskList.length }}人
  11. </div>
  12. </el-tooltip>
  13. </div>
  14. <div v-if="taskStatusList.createdTaskList.length > 0" class="orange-color"
  15. @click="openDialog('created')">
  16. <el-tooltip :content="'进行中:' + taskStatusList.createdTaskList.length + '人'" effect="dark"
  17. placement="right">
  18. <div>
  19. <i class="el-icon-reading"></i> {{ taskStatusList.createdTaskList.length }}人
  20. </div>
  21. </el-tooltip>
  22. </div>
  23. <div v-if="!taskStatusList.completedTaskList.length > 0 && !taskStatusList.createdTaskList.length > 0"
  24. class="gray-color">
  25. 未开始
  26. </div>
  27. </div>
  28. </div>
  29. <el-tooltip v-else content="未开启" effect="dark" placement="right">
  30. <el-switch v-model="showData.enable" disabled></el-switch>
  31. </el-tooltip>
  32. <ShowHanderDialog v-if="dialogVisible" v-model="dialogVisible" :dialogTitle="dialogTitle" :showData="showData" :status="status" />
  33. </div>
  34. </template>
  35. <script>
  36. import ShowHanderDialog from "./ShowHanderDialog.vue"
  37. export default {
  38. components: {
  39. ShowHanderDialog
  40. },
  41. props: {
  42. showData: {
  43. type: Object,
  44. default: () => { }
  45. }
  46. },
  47. watch: {
  48. showData(v) {
  49. }
  50. },
  51. data() {
  52. return {
  53. dialogVisible: false,
  54. dialogTitle: "已完成",
  55. status: "completed"
  56. }
  57. },
  58. computed: {
  59. taskStatusList() {
  60. let completedTaskList = [], createdTaskList = [];
  61. if (this.showData.children && this.showData.children.length > 0) {
  62. this.showData.children.forEach(child => {
  63. if (child.tasks && child.tasks.length > 0) {
  64. child.tasks.forEach(task => {
  65. if (task.state === 'completed') {
  66. completedTaskList.push(task)
  67. } else {
  68. createdTaskList.push(task)
  69. }
  70. })
  71. }
  72. })
  73. }
  74. else {
  75. let { tasks } = this.showData
  76. if (tasks && tasks.length > 0) {
  77. tasks.forEach(task => {
  78. if (task.state === 'completed') {
  79. completedTaskList.push(task)
  80. } else {
  81. createdTaskList.push(task)
  82. }
  83. })
  84. }
  85. }
  86. return {
  87. completedTaskList,
  88. createdTaskList
  89. }
  90. },
  91. handleShowData() {
  92. if (this.showData.children && this.showData.children.length > 0) {
  93. this.showData.children.forEach(children => {
  94. // 指定人员
  95. if (children.assigneeType === 'user') {
  96. let tasks = children.tasks;
  97. let assigneeIds = children.assigneeIds;
  98. let diff = []; // 找出未处理的指定人
  99. if (assigneeIds && assigneeIds.length > 0) {
  100. if (tasks && tasks.length > 0) {
  101. assigneeIds.forEach(assigneeId => {
  102. tasks.forEach(task => {
  103. if (assigneeId !== task.assignee) {
  104. diff.push(assigneeId)
  105. }
  106. })
  107. })
  108. }
  109. return diff
  110. } else {
  111. return diff
  112. }
  113. }
  114. })
  115. }
  116. else {
  117. }
  118. }
  119. },
  120. filters: {
  121. },
  122. methods: {
  123. openDialog(status) {
  124. if (status === 'created') {
  125. this.status = 'created'
  126. this.dialogTitle = '进行中'
  127. } else {
  128. this.status = 'completed'
  129. this.dialogTitle = '已完成'
  130. }
  131. this.dialogVisible = true
  132. }
  133. }
  134. }
  135. </script>
  136. <style scoped lang="scss">
  137. .green-color {
  138. color: #67c23a;
  139. }
  140. .orange-color {
  141. color: #e6a23c;
  142. }
  143. .gray-color {
  144. color: #ccc;
  145. }
  146. .show-data-box {
  147. // width: 100%;
  148. // height: 100%;
  149. .item-list {
  150. .item {
  151. display: flex;
  152. flex-direction: column;
  153. align-items: center;
  154. justify-content: center;
  155. .value-box {
  156. margin-bottom: 5px;
  157. display: flex;
  158. span {
  159. padding: 3px 6px;
  160. border-radius: 20px;
  161. white-space: nowrap;
  162. box-sizing: border-box;
  163. }
  164. }
  165. }
  166. }
  167. }
  168. </style>