workorder-item.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="workorder-card" @tap="handleClick">
  3. <view class="edit-icon">
  4. <u-icon name="edit-pen" color="#1b77f0" size="18"></u-icon>
  5. </view>
  6. <view class="content">
  7. <u-image :src="imgSrc" width="160rpx" height="190rpx" radius="8" mode="aspectFill"></u-image>
  8. <view class="details">
  9. <view class="row">
  10. <text class="label">快递单号:</text>
  11. <text class="value">{{ item.waybillCode || '-' }}</text>
  12. </view>
  13. <view class="row">
  14. <text class="label">任务类型:</text>
  15. <text class="value">{{ item.taskTypeName || item.taskType || '-' }}</text>
  16. </view>
  17. <view class="row">
  18. <text class="label">创建时间:</text>
  19. <text class="value">{{ item.createTime || '-' }}</text>
  20. </view>
  21. <view class="row" v-if="showDuration">
  22. <text class="label danger">处理时长:</text>
  23. <text class="value danger">{{ durationText }}</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script setup name="workorderItem">
  30. import { computed } from 'vue'
  31. const emit = defineEmits(['click'])
  32. const props = defineProps({
  33. item: {
  34. type: Object,
  35. default: () => ({})
  36. },
  37. showDuration: {
  38. type: Boolean,
  39. default: false
  40. }
  41. })
  42. const imgSrc = computed(() => {
  43. return props.item.imageUrl || props.item.imgPath || '/static/img/book.png'
  44. })
  45. const durationText = computed(() => {
  46. const sec = Number(props.item.waitingTime ?? props.item.duration ?? props.item.durationSec ?? 0)
  47. const s = Math.max(0, Math.floor(sec))
  48. const h = Math.floor(s / 3600)
  49. const m = Math.floor((s % 3600) / 60)
  50. const ss = s % 60
  51. return `${h}小时${m}分${ss}秒`
  52. })
  53. const handleClick = () => {
  54. emit('click', props.item)
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .workorder-card {
  59. background: #ffffff;
  60. border-radius: 12rpx;
  61. padding: 20rpx;
  62. box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.04);
  63. position: relative;
  64. }
  65. .edit-icon {
  66. position: absolute;
  67. right: 16rpx;
  68. top: 16rpx;
  69. }
  70. .content {
  71. display: flex;
  72. gap: 20rpx;
  73. align-items: flex-start;
  74. }
  75. .details {
  76. flex: 1;
  77. }
  78. .row {
  79. display: flex;
  80. align-items: baseline;
  81. margin-bottom: 10rpx;
  82. }
  83. .label {
  84. font-size: 28rpx;
  85. color: #666666;
  86. }
  87. .value {
  88. font-size: 28rpx;
  89. color: #333333;
  90. }
  91. .danger {
  92. color: #ff4d4f;
  93. font-weight: 500;
  94. }
  95. </style>