index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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" :key="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. },
  38. deep: true
  39. }
  40. },
  41. methods: {
  42. // 初始化
  43. timeline_init() {
  44. this.list = this.list.map(item => ({
  45. ...item,
  46. show: false
  47. }))
  48. },
  49. // 点击节点
  50. qz_click_code(val) {
  51. this.key = val.value
  52. this.$emit('update', val)
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. .qz-timeline-bgOne {
  59. min-width: max-content;
  60. margin: 0 30px 18px;
  61. text-align: center;
  62. padding-right: 30px;
  63. }
  64. .qz-timeline-bg {
  65. min-width: max-content;
  66. margin: 29px 30px 30px;
  67. text-align: center;
  68. padding-right: 30px;
  69. }
  70. .qz-timeline-layout {
  71. display: flex;
  72. justify-content: center;
  73. }
  74. .qz-timeline-divider {
  75. content: '';
  76. min-width: 100px;
  77. border: 1px solid #E5E5E5;
  78. }
  79. .qz-timeline-name {
  80. font-weight: 400;
  81. font-size: 12px;
  82. color: #444444;
  83. position: relative;
  84. top: 12px;
  85. }
  86. .circular {
  87. width: 10px;
  88. height: 10px;
  89. margin: 0 8px;
  90. display: inline-block;
  91. border: 1px solid #60AEFF;
  92. border-radius: 50%;
  93. position: relative;
  94. top: 12px;
  95. cursor: pointer;
  96. }
  97. .qz-time-code {
  98. background: #FFF;
  99. }
  100. .qz-time-code1 {
  101. background: #60AEFF;
  102. }
  103. .qz-time-color {
  104. color: #444;
  105. }
  106. .qz-time-color1 {
  107. color: #60AEFF;
  108. }
  109. </style>