task-card.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <view class="task-card">
  3. <view @click="handleClick">
  4. <view class="task-card__header">
  5. <view class="task-card__title">{{dataSource.task_type}}</view>
  6. <view class="task-card__name">处理人:{{dataSource.operator_user}}</view>
  7. </view>
  8. <view class="task-card__content">
  9. <view class="content__header">
  10. <view class="content__title">{{dataSource.start_time}} → {{dataSource.last_time}}</view>
  11. <view class="content__tag" v-if="dataSource.task_status!=='已完成'"
  12. :class="{warn:dataSource.is_overdue}">
  13. {{dataSource.is_overdue?`已逾期${dataSource.diff_day || 0}天`:`距离结束${dataSource.diff_day||0}天`}}
  14. </view>
  15. <view class="content__tag warn" v-if="dataSource.task_status==='已完成' && dataSource.is_overdue">
  16. {{dataSource.is_overdue&&`已逾期${dataSource.diff_day || 0}天`}}
  17. </view>
  18. </view>
  19. <view class="content__desc">
  20. {{dataSource.tesk_msg}}
  21. </view>
  22. </view>
  23. </view>
  24. <view class="task-card__actions" v-if="type==='action'">
  25. <view class="start-btn" v-if="dataSource.task_status === '待处理'">
  26. <u-button text="接收任务" size="mini" type="primary" @click="handleReceiveClick"></u-button>
  27. </view>
  28. <template v-if="dataSource.task_status === '处理中'">
  29. <view class="actions__list">
  30. <view class="actions__item ">
  31. <view class="actions__icon">
  32. <image src="@/static/image/task/icon/progress.png" mode="aspectFit" class="img"></image>
  33. </view>
  34. <view class="actions__text">{{dataSource.clock_in_count||0}}次</view>
  35. </view>
  36. <view class="actions__item middle">
  37. <view class="actions__icon">
  38. <image src="@/static/image/task/icon/tool.png" mode="aspectFit" class="img"></image>
  39. </view>
  40. <view class="actions__text">
  41. {{dataSource.walk_length/1000>=1?`${Math.ceil(dataSource.walk_length/1000)}km`:`${dataSource.walk_length}m`}}
  42. </view>
  43. </view>
  44. <view class="actions__item right">
  45. <view class="actions__icon">
  46. <image src="@/static/image/task/icon/area.png" mode="aspectFit" class="img"></image>
  47. </view>
  48. <view class="actions__text">{{dataSource.walk_area}} ㎡</view>
  49. </view>
  50. </view>
  51. <view class="actions__btns">
  52. <view class="actions__btn blocked" v-if="dataSource.walk_status === TASK_WALK_TYPE.IS_READY"
  53. @click="handleBtnClick(TASK_ACTION_TYPE.START)">
  54. <view class="actions__btn-icon">
  55. <image src="@/static/image/task/icon/play.svg" mode="aspectFit" class="img"></image>
  56. </view>
  57. <view class="actions__btn-text">开始</view>
  58. </view>
  59. <template v-else>
  60. <view class="actions__btn" @click="handleBtnClick(TASK_ACTION_TYPE.PAUSE)"
  61. v-if="dataSource.walk_status === TASK_WALK_TYPE.IS_RECORDING">
  62. <view class="actions__btn-icon">
  63. <image src="@/static/image/task/icon/pause.svg" mode="aspectFit" class="img">
  64. </image>
  65. </view>
  66. <view class="actions__btn-text">暂停</view>
  67. </view>
  68. <view class="actions__btn" @click="handleBtnClick(TASK_ACTION_TYPE.RESTART)"
  69. v-if="dataSource.walk_status === TASK_WALK_TYPE.IS_PAUSED">
  70. <view class="actions__btn-icon">
  71. <image src="@/static/image/task/icon/play.svg" mode="aspectFit" class="img">
  72. </image>
  73. </view>
  74. <view class="actions__btn-text">重新开始</view>
  75. </view>
  76. <view class="actions__btn" @click="handleBtnClick(TASK_ACTION_TYPE.CLOCK)">
  77. <view class="actions__btn-icon">
  78. <image src="@/static/image/task/icon/clockin.svg" mode="aspectFit" class="img">
  79. </image>
  80. </view>
  81. <view class="actions__btn-text">打卡</view>
  82. </view>
  83. <view class="actions__btn" @click="handleBtnClick(TASK_ACTION_TYPE.FINISHED)">
  84. <view class="actions__btn-icon">
  85. <image src="@/static/image/task/icon/finished.svg" mode="aspectFit" class="img">
  86. </image>
  87. </view>
  88. <view class="actions__btn-text">完成</view>
  89. </view>
  90. </template>
  91. </view>
  92. <view class="actions__tips" v-if="dataSource.walk_status === TASK_WALK_TYPE.IS_RECORDING">
  93. (任务轨迹监测中,如需暂停请点击暂停任务…)</view>
  94. </template>
  95. </view>
  96. <view class="task-card__footer" v-else>
  97. <view class="task-card__decoration-title">
  98. 任务派发人:{{dataSource.owner_user}}
  99. </view>
  100. <view class="task-card__decoration-title">
  101. 任务监督人:{{dataSource.supervisor_user}}
  102. </view>
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import {
  108. TASK_ACTION_TYPE,
  109. TASK_WALK_TYPE
  110. } from '@/util/constants.js';
  111. export default {
  112. props: {
  113. type: {
  114. type: String,
  115. default: 'action'
  116. },
  117. status: {
  118. type: Number,
  119. default: 1
  120. },
  121. dataSource: {
  122. type: Object,
  123. default: () => ({})
  124. }
  125. },
  126. data() {
  127. return {
  128. TASK_ACTION_TYPE,
  129. TASK_WALK_TYPE
  130. }
  131. },
  132. mounted() {
  133. console.warn(this.dataSource, 'mounted 1121331331ddd')
  134. },
  135. methods: {
  136. handleClick() {
  137. this.$emit('click', this.dataSource.task_id);
  138. },
  139. handleBtnClick(type) {
  140. this.$emit('btntap', type, this.dataSource.task_id);
  141. },
  142. handleReceiveClick() {
  143. this.$emit('confirm', this.dataSource.task_id);
  144. },
  145. handleResetRecordLocation() {
  146. this.$emit('checkRecordStatus', this.dataSource.task_id)
  147. }
  148. }
  149. }
  150. </script>
  151. <style scoped lang="scss">
  152. .task-card {
  153. background-color: #fff;
  154. border-radius: 16rpx;
  155. padding: 16rpx;
  156. margin-bottom: 24rpx;
  157. &__header {
  158. display: flex;
  159. align-items: center;
  160. justify-content: space-between;
  161. }
  162. &__title {
  163. flex: 1 1 auto;
  164. font-size: 14px;
  165. color: #333;
  166. line-height: 20px;
  167. margin-right: 100rpx;
  168. padding-bottom: 10rpx;
  169. @include hairline-bottom(rgba(151, 151, 151, 0.09));
  170. }
  171. &__name {
  172. flex: 0 0 auto;
  173. font-size: 12px;
  174. line-height: 20px;
  175. color: #1B76FF;
  176. }
  177. &__content {
  178. padding: 10rpx 16rpx;
  179. }
  180. .content {
  181. &__header {
  182. display: flex;
  183. align-items: center;
  184. }
  185. &__title {
  186. font-size: 12px;
  187. line-height: 18px;
  188. color: #1B76FF;
  189. margin-right: 20rpx;
  190. }
  191. &__tag {
  192. padding: 0 12rpx;
  193. color: #1B76FF;
  194. font-size: 12px;
  195. line-height: 14px;
  196. border-radius: 8rpx;
  197. border: 1px solid #1B76FF;
  198. &.warn {
  199. color: #F33E43;
  200. border: 1px solid #F33E43;
  201. }
  202. }
  203. &__desc {
  204. padding: 10rpx 0;
  205. color: #656565;
  206. font-size: 12px;
  207. line-height: 18px;
  208. margin-bottom: 10rpx;
  209. @include line(2);
  210. }
  211. }
  212. &__actions {
  213. padding: 0 20rpx;
  214. overflow: hidden;
  215. .start-btn {
  216. display: inline-block;
  217. float: right;
  218. }
  219. .actions {
  220. &__list {
  221. display: flex;
  222. align-items: center;
  223. padding: 20rpx 0;
  224. border-bottom: 1px solid rgba(2, 2, 2, 0.3);
  225. }
  226. &__item {
  227. flex: 1 1 auto;
  228. height: 50rpx;
  229. display: flex;
  230. align-items: center;
  231. @include hairline-right(rgba(0, 0, 0, 0.3));
  232. &.middle {
  233. justify-content: center;
  234. }
  235. &.right {
  236. justify-content: flex-end;
  237. }
  238. &:last-child {
  239. @include hairline-right(transparent);
  240. }
  241. }
  242. &__icon {
  243. width: 32rpx;
  244. height: 32rpx;
  245. margin-right: 36rpx;
  246. .img {
  247. width: 100%;
  248. height: 100%;
  249. }
  250. }
  251. &__btns {
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. padding: 24rpx 0;
  256. }
  257. &__btn {
  258. display: flex;
  259. align-items: center;
  260. padding: 10rpx 20rpx;
  261. border-radius: 8rpx;
  262. background-color: #F8F8F8;
  263. &.blocked {
  264. flex: 1;
  265. justify-content: center;
  266. }
  267. &-icon {
  268. width: 40rpx;
  269. height: 40rpx;
  270. overflow: hidden;
  271. .img {
  272. width: 100%;
  273. height: 100%;
  274. }
  275. }
  276. &-text {
  277. min-width: 88rpx;
  278. text-align: center;
  279. font-size: 12px;
  280. line-height: 18px;
  281. color: #555555;
  282. }
  283. }
  284. &__tips {
  285. font-size: 12px;
  286. line-height: 14px;
  287. color: #1B76FF;
  288. margin-bottom: 8rpx;
  289. }
  290. }
  291. }
  292. &__footer {
  293. display: flex;
  294. justify-content: space-between;
  295. align-items: center;
  296. padding: 20rpx 16rpx;
  297. }
  298. &__decoration-title {
  299. position: relative;
  300. padding-left: 24rpx;
  301. font-size: 12px;
  302. line-height: 36rpx;
  303. height: 36rpx;
  304. color: #656565;
  305. &::before {
  306. content: '';
  307. position: absolute;
  308. left: 0;
  309. top: 50%;
  310. width: 8rpx;
  311. height: 30rpx;
  312. transform: translateY(-50%);
  313. background-color: #1B76FF;
  314. border-radius: 8rpx;
  315. }
  316. }
  317. }
  318. </style>