rxl-timeline-item.vue 3.3 KB

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