2023西安数博会CIM演示-【前端】-Web
AdaKing88
2023-08-21 bc03b832caa49bbcd2674fe4cae3701b5059bf95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!--
 * @Description: 
 * @Author: 王旭
 * @Date: 2022-03-18 11:21:22
 * @LastEditTime: 2022-03-18 15:20:27
 * @LastEditors: 王旭
-->
<template>
  <el-card
    class="tree-card scrollbar box-card"
    :body-style="{ padding: '18px 0' }"
  >
    <div slot="header" class="header_box">
      <i class="title_circle"></i>
      <span>{{ title }}</span>
    </div>
    <el-tree
      :data="dataMenuTypes"
      :props="defaultProps"
      node-key="id"
      :default-expanded-keys="[4]"
      @node-click="handleNodeClick"
    >
      <span slot-scope="{ node, data }">
        <i :class="data.icon"></i>
        <span style="padding-left: 4px">{{ node.label }}</span>
      </span>
    </el-tree>
  </el-card>
</template>
 
<script>
import { mapState, mapMutations } from "vuex";
export default {
  //import引入的组件需要注入到对象中才能使用
  props: ["title"],
  components: {},
  data() {
    //这里存放数据
    return {
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  computed: {
    ...mapState(["dataMenuTypes"]),
  },
  //方法集合
  methods: {
    //   获取vuex中mutation里的方法
    ...mapMutations(["UP_REQUERT"]),
    handleNodeClick(data) {
      this.UP_REQUERT(data.datatype);
    },
  },
  created() {},
};
</script>
<style lang="less"  >
.el-tree-node.is-current > .el-tree-node__content {
  background-color: rgba(0, 166, 226, 0.6) !important;
}
//@import url(); 引入公共css类
.tree-card {
  overflow: auto;
  height: 98%;
  border-radius: 6px 6px 6px 6px;
  /deep/ .el-card__header {
    background: rgba(0, 166, 226, 0.6) !important;
    box-shadow: 0px 0px 4px 0px rgba(14, 22, 32, 0.2);
    border-radius: 6px 6px 0px 0px;
    height: 42px;
    font-size: 16px;
    font-weight: 600;
    border-bottom: 0;
    padding: 10px;
  }
  .header_box {
    display: flex;
    .title_circle {
      display: inline-block;
      width: 22px;
      height: 22px;
      background: linear-gradient(-30deg, #00a5e5, #0e1620);
      border-radius: 50%;
      margin-right: 8px;
    }
  }
}
</style>