wangrong
2026-08-30 761e5c5fa871959f60e15c971c8d83f2b53d0af5
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
  <div class="testcase-template">
    <div
      :class="[
        {
          ['template-img-active']: itemActive
        },
        'template-img'
      ]"
      :style="itemStyle"
      @click.stop="setBoard"
    >
      <Icon
        ><component
          class="svg-icon svg-background"
          :style="{ color: curComponent.commonBackground.innerImageColor }"
          :is="iconBoardMap[mainIconClass]"
        ></component
      ></Icon>
    </div>
    <span class="demonstration">{{ template.name }}</span>
  </div>
</template>
 
<script setup lang="ts">
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { hexColorToRGBA } from '@/views/chart/components/js/util'
import { storeToRefs } from 'pinia'
import { computed, toRefs } from 'vue'
const dvMainStore = dvMainStoreWithOut()
const { curComponent } = storeToRefs(dvMainStore)
import Icon from '@/components/icon-custom/src/Icon.vue'
import { iconBoardMap } from '@/components/icon-group/board-list'
 
const props = defineProps({
  template: {
    type: Object,
    default() {
      return {}
    }
  }
})
 
const { template } = toRefs(props)
 
const itemStyle = computed(() => {
  if (curComponent.value.commonBackground.backgroundColorSelect) {
    return {
      'background-color': hexColorToRGBA(
        curComponent.value.commonBackground.color,
        curComponent.value.commonBackground.alpha
      )
    }
  } else {
    return {}
  }
})
 
const mainIconClass = computed(() => {
  return template.value.url.replace('board/', '').replace('.svg', '')
})
 
const itemActive = computed(() => {
  return (
    curComponent.value &&
    curComponent.value.commonBackground &&
    curComponent.value.commonBackground.innerImage === template.value.url
  )
})
 
const setBoard = () => {
  curComponent.value.commonBackground.innerImage = template.value.url
}
</script>
 
<style scoped>
.testcase-template {
  display: inline-block;
  margin: 5px 0px;
  width: 90px;
}
 
.demonstration {
  display: block;
  font-size: 8px;
  color: gray;
  text-align: center;
  margin: 10px auto;
  width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.template-img {
  position: relative;
  height: 80px;
  width: 130px;
  margin: 0 auto;
  box-sizing: border-box;
  border-radius: 3px;
}
 
.template-img:hover {
  border: solid 1px #4b8fdf;
  border-radius: 3px;
  color: deepskyblue;
  cursor: pointer;
}
 
.template-img > i {
  display: none;
  float: right;
  color: gray;
  margin: 2px;
}
 
.template-img > i:hover {
  color: red;
}
 
.template-img:hover > .el-icon-error {
  display: inline;
}
 
.template-img:hover > .el-icon-edit {
  display: inline;
}
 
.template-img-active {
  border: solid 1px red;
  border-radius: 3px;
  color: deepskyblue;
}
 
.svg-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
}
:deep(.ed-row) {
  flex-direction: column;
}
</style>