index.vue 1.8 KB

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