index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div>
  3. <a-breadcrumb style="padding: 5px;">
  4. <span>{{ $t('cloudenv.text_374') + ": " }}</span>
  5. <a-breadcrumb-item v-for="(item, index) in navs" :key="item.id">
  6. <template v-if="index === lastIndex">
  7. <span class="monitor-overview-breadcrumb-span">{{ locationTitle(item.location) }}</span>
  8. </template>
  9. <template v-else>
  10. <a class="monitor-overview-breadcrumb-link" @click="changeNav(index)">{{ item.location }}</a>
  11. </template>
  12. </a-breadcrumb-item>
  13. </a-breadcrumb>
  14. <div
  15. v-if="this.total > 1"
  16. class="col-3"
  17. :style="{ fontSize: '20px', padding: '5px'}">
  18. <a-icon type="arrow-left" class="anticon anticon-arrow-left monitor-overview-breadcrumb-link" :style="{ cursor: 'pointer', }" @click="changeNav(navs.length-2)" />
  19. <span :style="{ paddingLeft: '5px' }">{{ navs[navs.length-1].name }}</span>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'OverviewNav',
  26. props: {
  27. items: {
  28. type: Array,
  29. /* { id: res_uuid, name: res_name, location: xxx } */
  30. default: () => { return [] },
  31. },
  32. },
  33. data () {
  34. const navs = [...this.items]
  35. return {
  36. navs: navs,
  37. }
  38. },
  39. computed: {
  40. total () {
  41. return this.navs ? this.navs.length : 0
  42. },
  43. lastIndex () {
  44. return this.total > 0 ? this.total - 1 : 0
  45. },
  46. },
  47. watch: {
  48. items: {
  49. deep: true,
  50. handler: function (val, oldVal) {
  51. this.$nextTick(() => {
  52. this.navs = [...val]
  53. })
  54. },
  55. },
  56. },
  57. methods: {
  58. locationTitle: function (base) {
  59. return this.$t('monitor.overview.location', [base])
  60. },
  61. changeNav (i) {
  62. this.navs = this.navs.slice(0, i + 1)
  63. console.log(this.navs)
  64. this.$emit('change', this.navs[i])
  65. },
  66. },
  67. }
  68. </script>
  69. <style lang="less" scoped>
  70. @import '../../../../../../src/styles/less/theme';
  71. .monitor-overview-breadcrumb-span {
  72. color: @text-color-secondary !important;
  73. }
  74. .monitor-overview-breadcrumb-link {
  75. color: @primary-color !important;
  76. }
  77. </style>