rxl-timeline-item.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="timeline-item">
  3. <view class="left-line">
  4. <slot name="icon">
  5. <view @click="iconClick" class="timeline-item-icon"
  6. :style="{'backgroundColor':color,'width':size+'px','height':size+'px'}">
  7. </view>
  8. </slot>
  9. <view v-if="showTail" class="timeline-item-tail"></view>
  10. </view>
  11. <view class="timeline-item-wrapper">
  12. <view class="time" @click="timeClick" :style="{'height':size+'px','lineHeight':(size>40?40:size)+'px'}">
  13. {{timestamp}}
  14. </view>
  15. <view class="item-body" @click="bodyClick">
  16. <view class="title" v-if="title!=''">
  17. {{title}}
  18. </view>
  19. <view class="desc" v-if="desc!=''">
  20. {{desc}}
  21. </view>
  22. <slot name="body"></slot>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. /**
  29. *
  30. * @description 时间线
  31. * @property {Boolean} showTail 显示节点连接线
  32. * @property {String} timestamp 时间
  33. * @property {String} color 节点颜色
  34. * @property {String} title 标题
  35. * @property {String} desc 描述
  36. * @property {Number} size 节点大小(单位px,最大40)
  37. * @event {Function()} onIconClick 时间线图标点击事件
  38. * @event {Function()} onTimeClick 时间线时间点击事件
  39. * @event {Function()} onBodyClick 时间线内容点击事件
  40. */
  41. export default {
  42. name: "rxl-timeline-item",
  43. data() {
  44. return {}
  45. },
  46. props: {
  47. showTail: {
  48. type: Boolean,
  49. default: true
  50. },
  51. timestamp: {
  52. type: String,
  53. default: function() {
  54. return ""
  55. }
  56. },
  57. color: {
  58. type: String,
  59. default: function() {
  60. return null
  61. }
  62. },
  63. title: {
  64. type: String,
  65. default: function() {
  66. return ""
  67. }
  68. },
  69. desc: {
  70. type: String,
  71. default: function() {
  72. return ""
  73. }
  74. },
  75. size: {
  76. type: Number,
  77. default: function() {
  78. return 16
  79. }
  80. }
  81. },
  82. methods: {
  83. iconClick: function() {
  84. this.$emit("onIconClick")
  85. },
  86. timeClick: function() {
  87. this.$emit("onTimeClick")
  88. },
  89. bodyClick: function() {
  90. this.$emit("onBodyClick")
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .timeline-item {
  97. position: relative;
  98. padding-bottom: 20px;
  99. .left-line {
  100. position: absolute;
  101. height: 100%;
  102. display: flex;
  103. justify-content: flex-start;
  104. width: 40px;
  105. flex-direction: column;
  106. align-items: center;
  107. .timeline-item-tail {
  108. height: 100%;
  109. width: 2px;
  110. background-color: #e4e7ed;
  111. }
  112. .timeline-item-icon {
  113. background-color: #e4e7ed;
  114. border-radius: 50%;
  115. width: 12px;
  116. height: 12px;
  117. max-width: 40px;
  118. max-height: 40px;
  119. z-index: 10;
  120. }
  121. }
  122. .timeline-item-wrapper {
  123. position: relative;
  124. padding-left: 44px;
  125. .time {
  126. color: #606060;
  127. font-size: 26rpx;
  128. max-height: 40px;
  129. }
  130. .item-body {
  131. // background-color: #f6f7f8;
  132. // padding: 20rpx;
  133. margin-top: 30rpx;
  134. border-radius: 20rpx;
  135. // border-color: rgba(242, 242, 242, 1);
  136. // padding-inline-start: 30rpx;
  137. margin-right: 40rpx;
  138. .title {
  139. color: #199ED8;
  140. font-size: 32rpx;
  141. font-weight: 500;
  142. .title-text {
  143. display: inline-block;
  144. vertical-align: middle;
  145. padding-left: 10rpx;
  146. }
  147. }
  148. .desc {
  149. padding-inline-start: 30rpx;
  150. padding-top: 10rpx;
  151. color: #7f7f7f;
  152. font-size: 30rpx;
  153. }
  154. }
  155. }
  156. }
  157. </style>