timeline.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div :class="[!bgmargin ? 'qz-timeline-bg' : 'qz-timeline-bgOne']">
  3. <div class="qz-timeline-layout">
  4. <div v-for="(item, index) in list" ref="ss" :key="'item' + index">
  5. <div class="qz-timeline-name" :class="[index === key ? 'qz-time-color1' : 'qz-time-color']">{{ item }}</div>
  6. <span class="circular" :class="[index === key ? 'qz-time-code1' : 'qz-time-code']" @click="qz_click_code({value: index, name: item})" />
  7. <div class="qz-timeline-divider" />
  8. </div>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. data: { type: Array, required: true },
  16. num: { type: Number, default: 0 },
  17. bgmargin: { type: Boolean, default: false }
  18. },
  19. data() {
  20. return {
  21. list: [],
  22. key: this.num
  23. }
  24. },
  25. watch: {
  26. data: {
  27. handler(newV) {
  28. if (!newV) return
  29. this.list = newV
  30. },
  31. deep: true,
  32. immediate: true
  33. },
  34. num: {
  35. handler(newV) {
  36. this.key = newV
  37. document.getElementById('index').scrollLeft += 500
  38. // this.$refs.ss.scrollLeft = 300
  39. },
  40. deep: true
  41. }
  42. },
  43. methods: {
  44. // 初始化
  45. timeline_init() {
  46. this.list = this.list.map(item => ({
  47. ...item,
  48. show: false
  49. }))
  50. },
  51. // 点击节点
  52. qz_click_code(val) {
  53. this.key = val.value
  54. this.$emit('update', val)
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="less" scoped>
  60. .qz-timeline-bgOne {
  61. min-width: max-content;
  62. margin: 0 30px 18px;
  63. text-align: center;
  64. padding-right: 30px;
  65. }
  66. .qz-timeline-bg {
  67. min-width: max-content;
  68. margin: 29px 30px 30px;
  69. text-align: center;
  70. padding-right: 30px;
  71. }
  72. .qz-timeline-layout {
  73. display: flex;
  74. justify-content: center;
  75. }
  76. .qz-timeline-divider {
  77. content: '';
  78. min-width: 100px;
  79. border: 1px solid #E5E5E5;
  80. }
  81. .qz-timeline-name {
  82. padding: 0 10px;
  83. font-weight: 400;
  84. font-size: 12px;
  85. color: #444444;
  86. position: relative;
  87. top: 12px;
  88. }
  89. .circular {
  90. width: 10px;
  91. height: 10px;
  92. margin: 0 8px;
  93. display: inline-block;
  94. border: 1px solid #60AEFF;
  95. border-radius: 50%;
  96. position: relative;
  97. top: 12px;
  98. cursor: pointer;
  99. }
  100. .qz-time-code {
  101. background: #FFF;
  102. }
  103. .qz-time-code1 {
  104. background: #60AEFF;
  105. }
  106. .qz-time-color {
  107. color: #444;
  108. }
  109. .qz-time-color1 {
  110. color: #60AEFF;
  111. }
  112. </style>