riku
2024-10-30 d4e7c11e06b643c9353444c839cec40c25945219
src/components/SideList.vue
@@ -11,24 +11,26 @@
    empty-text="暂无记录"
  >
    <template #default="{ node, data }">
      <div
        :class="
          data.selected
            ? 'selected-tree-node custom-tree-node'
            : 'custom-tree-node'
        "
      >
        <el-icon v-if="data.type == 2" color="var(--el-color-success)"
          ><SuccessFilled
        /></el-icon>
        <el-icon v-else-if="data.type == 1" color="var(--el-color-warning)"
          ><WarningFilled
        /></el-icon>
        <el-icon v-else-if="data.type == 0" color="var(--el-color-danger)"
          ><WarningFilled
        /></el-icon>
        <div>{{ node.label }}</div>
      </div>
      <slot :node="node" :data="data">
        <div
          :class="
            data.selected
              ? 'selected-tree-node custom-tree-node'
              : 'custom-tree-node'
          "
        >
          <el-icon v-if="data.type == 2" color="var(--el-color-success)"
            ><SuccessFilled
          /></el-icon>
          <el-icon v-else-if="data.type == 1" color="var(--el-color-warning)"
            ><WarningFilled
          /></el-icon>
          <el-icon v-else-if="data.type == 0" color="var(--el-color-danger)"
            ><WarningFilled
          /></el-icon>
          <div>{{ node.label }}</div>
        </div>
      </slot>
    </template>
  </el-tree>
</template>
@@ -43,20 +45,20 @@
          type: 0,
          title: 'title',
          categoly: '2022-10-10',
          data: {},
        },
      ],
          data: {}
        }
      ]
    },
    loading: Boolean,
    loading: Boolean
  },
  emits: ['itemClick'],
  data() {
    return {
      defaultProps: {
        children: 'children',
        label: 'title',
        label: 'title'
      },
      isLoading: this.loading,
      isLoading: this.loading
    };
  },
  computed: {
@@ -75,7 +77,7 @@
      for (const [key, value] of itemMap) {
        const i = {
          title: key,
          children: [],
          children: []
        };
        value.forEach((v) => {
          i.children.push(v);
@@ -92,11 +94,11 @@
        }
      });
      return list;
    },
    }
  },
  watch: {
    loading(nValue) {
      this.isLoading = nValue
      this.isLoading = nValue;
    },
    //当数据第一次更新时
    dataList(nValue) {
@@ -117,7 +119,7 @@
        }
        this.isLoading = false;
      }
    },
    }
  },
  methods: {
    handleNodeClick(data) {
@@ -131,8 +133,8 @@
      if (data.children == undefined) {
        this.$emit('itemClick', data);
      }
    },
  },
    }
  }
};
</script>