index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 v-if="refreshBtn" text type="primary" size="mini">{{
  16. data.title
  17. }}</el-button>
  18. </div>
  19. </div>
  20. <el-button icon="Refresh" circle />
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. next: {
  27. type: Object,
  28. default: {
  29. title: ''
  30. }
  31. },
  32. refreshBtn: {
  33. type: Boolean,
  34. default: false
  35. }
  36. },
  37. watch: {
  38. next: {
  39. handler(val) {
  40. console.log(val)
  41. if (Object.hasOwn(val, 'projectId')) {
  42. const item = {
  43. id: val.id,
  44. title: val.title,
  45. projectId: val.projectId,
  46. stageId: val.stageId,
  47. parentId: val.parentId,
  48. type: val.type,
  49. isAccess: val.isAccess
  50. }
  51. const tmp = this.list.find(ele => ele.id === item.id)
  52. if (tmp === undefined || tmp === null) {
  53. console.log(item.type)
  54. if (item.type === 2) {
  55. this.data = item
  56. this.list.push(item)
  57. }
  58. }
  59. }
  60. },
  61. immediate: false
  62. }
  63. },
  64. data() {
  65. return {
  66. list: [],
  67. data: null
  68. }
  69. },
  70. methods: {
  71. goHome() {
  72. this.list.length = 0
  73. this.data = null
  74. this.$emit('goHome')
  75. },
  76. goBefore() {
  77. this.list.pop()
  78. if (this.list.length > 0) {
  79. this.data = this.list[this.list.length - 1]
  80. this.$emit('before', this.data)
  81. } else {
  82. this.goHome()
  83. }
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped></style>