tree.vue 1.9 KB

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