Blame view

src/components/car/CommunityParkingTree.vue 1.46 KB
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
  <template>
    <el-card class="tree-card">
      <el-tree
        ref="parkingTree"
        :data="treeData"
        node-key="id"
        :props="defaultProps"
        :highlight-current="true"
        :expand-on-click-node="false"
        @node-click="handleNodeClick"
      />
    </el-card>
  </template>
  
  <script>
  import { queryCommunityParkingTree } from '@/api/car/adminCarApi'
  
  export default {
    name: 'CommunityParkingTree',
    data() {
      return {
        treeData: [],
        defaultProps: {
          children: 'children',
          label: 'text'
        }
      }
    },
    methods: {
      async initTree() {
        try {
          const { data } = await queryCommunityParkingTree({ hc: 1.8 })
          this.treeData = data
        
        } catch (error) {
          this.$message.error(this.$t('adminCar.tree.fetchError'))
        }
      },
      handleNodeClick(data, node) {
        console.log(node)
        if (data.id.startsWith('c_')) {
          this.$emit('selectCommunity', {
            communityName: data.communityName,
            communityId: data.communityId
          })
        } else if (data.id.startsWith('p_')) {
          this.$emit('selectParkingArea', {
            paNum: data.num,
            paId: data.paId
          })
        } else if (data.id.startsWith('l_')) {
          this.$emit('selectLeaseType', {
            leaseTypeName: data.leaseTypeName,
            leaseType: data.leaseType
          })
        }
      },
      open() {
        this.initTree()
      }
    }
  }
  </script>
  
  <style scoped>
  .tree-card {
    height: 100%;
  }
  </style>