index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="flex flex-center flex-justify-between">
  3. <div class="flex flex-center flex-justify-start">
  4. <el-button text type="primary" size="mini" @click="goBefore"
  5. >返回上一层
  6. </el-button>
  7. <el-divider direction="vertical" border-style="dashed" />
  8. <el-button text type="primary" size="mini" @click="goHome"
  9. >全部文件
  10. </el-button>
  11. <div v-if="data" class="flex flex-center">
  12. <el-icon>
  13. <ArrowRight />
  14. </el-icon>
  15. <el-button text type="primary" size="mini">{{ data.title }}</el-button>
  16. </div>
  17. </div>
  18. <el-tooltip content="刷新">
  19. <el-button
  20. icon="Refresh"
  21. circle
  22. v-if="refreshBtn"
  23. @click="this.$emit('refresh')"
  24. />
  25. </el-tooltip>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. next: {
  32. type: Object,
  33. default: {
  34. title: ''
  35. }
  36. },
  37. refreshBtn: {
  38. type: Boolean,
  39. default: false
  40. }
  41. },
  42. watch: {
  43. next: {
  44. handler(val) {
  45. console.log(val)
  46. if (Object.hasOwn(val, 'projectId')) {
  47. const item = {
  48. id: val.id,
  49. title: val.title,
  50. projectId: val.projectId,
  51. stageId: val.stageId,
  52. parentId: val.parentId,
  53. type: val.type,
  54. isAccess: val.isAccess
  55. }
  56. const tmp = this.list.find(ele => ele.id === item.id)
  57. if (tmp === undefined || tmp === null) {
  58. console.log(item.type)
  59. if (item.type === 2) {
  60. this.data = item
  61. this.list.push(item)
  62. }
  63. }
  64. }
  65. },
  66. immediate: false
  67. }
  68. },
  69. data() {
  70. return {
  71. list: [],
  72. data: null
  73. }
  74. },
  75. methods: {
  76. goHome() {
  77. this.list.length = 0
  78. this.data = null
  79. this.$emit('goHome')
  80. },
  81. goBefore() {
  82. this.list.pop()
  83. if (this.list.length > 0) {
  84. this.data = this.list[this.list.length - 1]
  85. this.$emit('before', this.data)
  86. } else {
  87. this.goHome()
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped></style>