HomeAside.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <div id="main">
  3. <input id="search" :placeholder="lang.search">
  4. <el-tree :data="data" :props="defaultProps" :defaultExpandAll="true" @node-click="handleNodeClick" :class="node" />
  5. </div>
  6. </template>
  7. <script setup>
  8. import { useRouter } from 'vue-router'
  9. import { reactive, ref } from 'vue'
  10. import useGroupStore from '../stores/group'
  11. import lang from '../i18n/i18n';
  12. import { getCurrentInstance } from 'vue'
  13. const app = getCurrentInstance()
  14. const $http = app.appContext.config.globalProperties.$http
  15. const groupStore = useGroupStore()
  16. const router = useRouter()
  17. const data = ref([])
  18. $http.get('/api/group').then(res => {
  19. data.value = res.data
  20. })
  21. const handleNodeClick = function (data) {
  22. if (data.tag != null) {
  23. groupStore.name = data.label
  24. groupStore.tag = data.tag
  25. router.push({
  26. name: "list",
  27. })
  28. }
  29. }
  30. </script>
  31. <style scoped>
  32. #main {
  33. width: 243px;
  34. background-color: #F1F1F1;
  35. height: 100%;
  36. }
  37. #search {
  38. background-color: #D6E7F7;
  39. width: 100%;
  40. height: 40px;
  41. padding-left: 10px;
  42. border: none;
  43. outline: none;
  44. font-size: 16px;
  45. }
  46. .el-tree {
  47. background-color: #F1F1F1;
  48. }
  49. .add_group{
  50. font-size: 14px;
  51. text-align: left;
  52. padding-left: 15px;
  53. }
  54. </style>