Blame view

src/components/inspection/communityInspectionTree.vue 1.79 KB
e0196f8a   wuxw   开发完成admin下巡检任务
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
  <template>
    <div class="community-inspection-tree">
      <el-card class="box-card">
        <el-tree
          ref="tree"
          :data="treeData"
          node-key="id"
          :props="defaultProps"
          :highlight-current="true"
          :expand-on-click-node="false"
          @node-click="handleNodeClick"
        ></el-tree>
      </el-card>
    </div>
  </template>
  
  <script>
  import { queryCommunityInspectionTree } from '@/api/inspection/adminInspectionTaskApi'
  
  export default {
    name: 'CommunityInspectionTree',
    data() {
      return {
        treeData: [],
        defaultProps: {
          children: 'children',
          label: 'text'
        }
      }
    },
    mounted() {
      this.loadTreeData()
    },
    methods: {
      async loadTreeData() {
        try {
          const response = await queryCommunityInspectionTree({ hc: 1.8 })
          this.treeData = response.data || []
        } catch (error) {
          console.error('Failed to load tree data:', error)
        }
      },
      handleNodeClick(data, node) {
        console.log(node)
        const params = {
          communityId: '',
          inspectionPlanId: '',
          staffId: ''
        }
  
        if (data.id.startsWith('c_')) {
          params.communityId = data.original.communityId
          params.communityName = data.original.communityName
        } else if (data.id.startsWith('p_')) {
          params.communityId = data.original.communityId
          params.inspectionPlanId = data.original.inspectionPlanId
        } else if (data.id.startsWith('s_')) {
          params.communityId = data.original.communityId
          params.inspectionPlanId = data.original.inspectionPlanId
          params.staffId = data.original.staffId
        }
  
        this.$emit('notifyQuery', params)
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .community-inspection-tree {
    .box-card {
      border-radius: 4px;
    }
  }
  </style>