wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
  <el-col>
    <el-row style="display: inherit; margin-top: 5px">
      <el-row>
        <el-input
          v-model="state.templateFilterText"
          :placeholder="t('visualization.filter_keywords')"
          size="small"
          clearable
          prefix-icon="el-icon-search"
        />
      </el-row>
      <el-row style="display: inherit; margin-top: 5px">
        <el-tree
          ref="templateTree"
          :default-expanded-keys="state.defaultExpandedKeys"
          :data="templateList"
          node-key="id"
          :expand-on-click-node="true"
          :filter-node-method="filterNode"
          :highlight-current="true"
          @node-click="nodeClick"
        >
          <template #default="{ data }">
            <span class="custom-tree-node">
              <span class="custom-label">
                <el-icon style="font-size: 18px" v-if="data.nodeType === 'folder'">
                  <Icon name="dv-folder"><dvFolder class="svg-icon" /></Icon>
                </el-icon>
                <el-icon style="font-size: 18px" v-else-if="data.dvType === 'dashboard'">
                  <Icon name="dv-dashboard-spine"><dvDashboardSpine class="svg-icon" /></Icon>
                </el-icon>
                <el-icon class="icon-screen-new" style="font-size: 18px" v-else>
                  <Icon name="icon_operation-analysis_outlined"
                    ><icon_operationAnalysis_outlined class="svg-icon"
                  /></Icon>
                </el-icon>
                <span :title="data.name" class="custom-name">{{ data.name }}</span>
              </span>
            </span>
          </template>
        </el-tree>
      </el-row>
    </el-row>
  </el-col>
</template>
 
<script setup lang="ts">
import dvFolder from '@/assets/svg/dv-folder.svg'
import dvDashboardSpine from '@/assets/svg/dv-dashboard-spine.svg'
import icon_operationAnalysis_outlined from '@/assets/svg/icon_operation-analysis_outlined.svg'
import { findOne } from '@/api/template'
import { useI18n } from '@/hooks/web/useI18n'
import { reactive } from 'vue'
const { t } = useI18n()
const emits = defineEmits(['showCurrentTemplateInfo'])
 
defineProps({
  curCanvasType: {
    type: String,
    required: true
  },
  templateList: {
    type: Array,
    default: function () {
      return []
    }
  }
})
 
const state = reactive({
  templateFilterText: '',
  defaultExpandedKeys: [],
  currentTemplateShowList: []
})
 
const filterNode = (value, data) => {
  if (!value) return true
  return data.label.indexOf(value) !== -1
}
 
const nodeClick = data => {
  if (data.nodeType === 'template') {
    findOne(data.id).then(res => {
      emits('showCurrentTemplateInfo', res.data)
    })
  }
}
</script>
 
<style scoped lang="less">
.custom-label {
  display: flex;
  flex: 1 1 0%;
  width: 0px;
}
 
.custom-name {
  margin-left: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.custom-tree-node {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  padding-right: 8px;
}
</style>