tree.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="list">
  3. <view class="item" v-for="(item,index) in list" :key="index" @click.stop="open(index,item),click(index,item)">
  4. <view class="info">
  5. <view class="name">
  6. <!-- <uni-icons v-if="!item.children" style="margin-right: 30rpx;" type="eye" color="#009FE8"></uni-icons> {{item.name}} <text v-if="item.children" style="margin-left: 10rpx;">({{item.children.length}})</text> -->
  7. <uni-icons v-if="!item.children" style="margin-right: 30rpx;" type="eye" color="#009FE8"></uni-icons> {{item.name}}
  8. </view>
  9. <view v-if="item.children && body_index != index" style="position: absolute;right: 20px;">
  10. <uni-icons type="arrowright"></uni-icons>
  11. </view>
  12. <view v-if="item.children && body_index == index" style="position: absolute;right: 20px;">
  13. <uni-icons type="arrowdown"></uni-icons>
  14. </view>
  15. </view>
  16. <view class="body" v-if="body_index == index">
  17. <tree :list="item.children"></tree>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import tree from "@/components/tree/tree.vue"
  24. export default {
  25. name: "tree",
  26. components: {
  27. tree
  28. },
  29. props: [
  30. "list"
  31. ],
  32. data() {
  33. return {
  34. body_index: 9999,
  35. };
  36. },
  37. methods: {
  38. open(index, item) {
  39. if (this.body_index == index) {
  40. this.body_index = 99999
  41. } else {
  42. this.body_index = index
  43. }
  44. },
  45. click(index, item) {
  46. if (!this.list[index].children) {
  47. uni.navigateTo({
  48. url: "./video-block/video-block?mine_id=" + item.mine_id + "&name=" + item.name +
  49. "&parent_id=" + item.parent_id,
  50. })
  51. }
  52. },
  53. }
  54. }
  55. </script>
  56. <style lang="scss">
  57. .list {
  58. margin-left: 25rpx;
  59. .item {
  60. margin-bottom: 20rpx;
  61. border-radius: 10rpx;
  62. background-color: #FFFFFF;
  63. .info {
  64. display: flex;
  65. align-items: center;
  66. height: 90rpx;
  67. box-sizing: border-box;
  68. padding: 10rpx 0;
  69. border-bottom: 2rpx solid #f0f0f0;
  70. .name {
  71. margin-left: 25rpx;
  72. }
  73. }
  74. }
  75. }
  76. </style>