taskItem.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <view class="task-item" @click="handleDetail">
  3. <view class="wk-list-item">
  4. <view :style="{backgroundColor: prioritColor}" class="badge" />
  5. <view class="item-top">
  6. <view
  7. :class="{over: isOver}"
  8. class="checkbox"
  9. @tap.stop="changeTaskStatus">
  10. <text v-if="isOver" class="icon wk wk-check" />
  11. </view>
  12. <view class="item-content">
  13. <view class="item-title" :class="{'over': isOver}">
  14. <view>{{ itemData.taskName || itemData.name }}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="item-bottom">
  19. <view v-if="itemData.stopTime" class="item-bottom-left">
  20. <image :src="$static('images/icon/time.png')" alt class="img-icon" />
  21. <text
  22. :style="{color: (itemData.status === 2 && !itemData.isEnd) ? 'red' : ''}">
  23. {{ itemData.stopTime | formatTime }} 截止
  24. </text>
  25. </view>
  26. <view v-if="showCreate" class="item-bottom-left">
  27. <text>
  28. {{ itemData.createTime | formatTime }} 创建
  29. </text>
  30. </view>
  31. <view class="item-bottom-right">
  32. <view v-if="itemData.relationCount" class="bottom-icon">
  33. <image :src="$static('images/oa/link.png')" alt class="img-icon" />
  34. <text>{{ itemData.relationCount }}</text>
  35. </view>
  36. <view v-if="itemData.childAllCount" class="bottom-icon">
  37. <image :src="$static('images/oa/organization.png')" alt class="img-icon" />
  38. <text>{{ itemData.childWCCount }}/{{ itemData.childAllCount }}</text>
  39. </view>
  40. <view v-if="itemData.fileCount" class="bottom-icon">
  41. <image :src="$static('images/oa/path.png')" alt class="img-icon" />
  42. <text>{{ itemData.fileCount }}</text>
  43. </view>
  44. <view v-if="itemData.commentCount" class="bottom-icon">
  45. <image :src="$static('images/oa/task-comment.png')" alt class="img-icon" />
  46. <text>{{ itemData.commentCount }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import moment from 'moment'
  55. export default {
  56. name: 'TaskItem',
  57. filters: {
  58. formatTime(date) {
  59. if (!date) return ''
  60. return moment(date).format('YYYY-MM-DD')
  61. }
  62. },
  63. props: {
  64. itemData: {
  65. type: Object,
  66. required: true,
  67. },
  68. index: {
  69. type: Number,
  70. default: 0
  71. }
  72. },
  73. data() {
  74. return {}
  75. },
  76. computed: {
  77. isOver() {
  78. return this.itemData.status === 5 // 1正在进行 2延期 5结束
  79. },
  80. prioritColor() {
  81. // 优先级列表
  82. const priorityData = [
  83. {id: 3, name: '高', color: '#E60000'},
  84. {id: 2, name: '中', color: '#FFA200'},
  85. {id: 1, name: '低', color: '#5DBC47'},
  86. {id: 0, name: '无', color: '#FFFFFF'},
  87. ]
  88. let findRes = priorityData.find(item => item.id === this.itemData.priority)
  89. if (findRes) return findRes.color
  90. return '#cccccc'
  91. },
  92. showCreate() {
  93. return !this.itemData.stopTime &&
  94. !this.itemData.relationCount &&
  95. !this.itemData.childAllCount &&
  96. !this.itemData.fileNum &&
  97. !this.itemData.commentCount
  98. }
  99. },
  100. methods: {
  101. /**
  102. * 转到任务详情
  103. */
  104. handleDetail() {
  105. this.$Router.navigateTo({
  106. url: '/pages_task/detail',
  107. query: {
  108. id: this.itemData.taskId
  109. }
  110. })
  111. },
  112. /**
  113. * 更改任务状态
  114. */
  115. changeTaskStatus() {
  116. this.$emit('status', {
  117. taskId: this.itemData.taskId,
  118. status: this.isOver ? 1 : 5,
  119. index: this.index
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped lang="scss">
  126. .task-item {
  127. position: relative;
  128. font-size: 24rpx;
  129. text-align: left;
  130. border-radius: 0;
  131. .wk-list-item::after {
  132. left: 0;
  133. width: 100%;
  134. }
  135. .item-top {
  136. display: flex;
  137. align-items: center;
  138. .checkbox {
  139. width: 40rpx;
  140. height: 40rpx;
  141. margin-right: 25rpx;
  142. border: 1rpx solid #ccc;
  143. border-radius: 6rpx;
  144. overflow: hidden;
  145. @include center;
  146. .icon {
  147. font-size: 28rpx;
  148. line-height: 1;
  149. color: white;
  150. }
  151. &.over {
  152. background-color: $theme-color;
  153. border-color: $theme-color;
  154. }
  155. }
  156. .item-content {
  157. display: flex;
  158. flex: 1;
  159. overflow: hidden;
  160. align-items: center;
  161. .item-title {
  162. flex: 1;
  163. color: $dark;
  164. font-size: 32rpx;
  165. overflow: hidden;
  166. margin-right: 20rpx;
  167. div {
  168. @include ellipsis;
  169. }
  170. }
  171. .over {
  172. text-decoration: line-through;
  173. color: $gray;
  174. }
  175. }
  176. }
  177. .item-bottom {
  178. padding-left: 60rpx;
  179. padding-top: 15rpx;
  180. display: flex;
  181. align-items: center;
  182. justify-content: space-between;
  183. font-size: 26rpx;
  184. color: $light;
  185. .item-bottom-left {
  186. @include left;
  187. }
  188. .item-bottom-right {
  189. flex: 1;
  190. @include left;
  191. .bottom-icon {
  192. margin-left: 18rpx;
  193. @include center;
  194. }
  195. }
  196. .img-icon {
  197. width: 26rpx;
  198. height: 26rpx;
  199. margin-right: 10rpx;
  200. }
  201. }
  202. .badge {
  203. position: absolute;
  204. top: 0;
  205. left: 0;
  206. width: 10rpx;
  207. height: 100%;
  208. border-top-left-radius: 10rpx;
  209. border-bottom-left-radius: 10rpx;
  210. overflow: hidden;
  211. }
  212. }
  213. </style>