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
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
<template>
  <div class="testcase-template">
    <div
      :class="[
        {
          ['template-img-active']: itemActive
        },
        'template-img'
      ]"
      :style="itemStyle"
      @click.stop="setBoard"
    >
      <Icon class-name="svg-background"
        ><component
          :style="{ color: commonBackground.innerImageColor }"
          class="svg-icon svg-background"
          :is="iconBoardMap[mainIconClass]"
        ></component
      ></Icon>
    </div>
    <span class="demonstration">{{ template.name }}</span>
  </div>
</template>
 
<script setup lang="ts">
import Icon from '@/components/icon-custom/src/Icon.vue'
import { computed, toRefs } from 'vue'
import { hexColorToRGBA } from '@/views/chart/components/js/util'
import { iconBoardMap } from '@/components/icon-group/board-list'
 
const props = defineProps({
  template: {
    type: Object,
    default() {
      return {}
    }
  },
  commonBackground: {
    type: Object,
    required: true
  }
})
 
const { template, commonBackground } = toRefs(props)
const emits = defineEmits(['borderChange'])
 
const itemStyle = computed(() => {
  if (commonBackground.value.backgroundColorSelect) {
    return {
      'background-color': hexColorToRGBA(commonBackground.value.color, commonBackground.value.alpha)
    }
  } else {
    return {}
  }
})
 
const mainIconClass = computed(() => {
  return template.value.url.replace('board/', '').replace('.svg', '')
})
const itemActive = computed(() => {
  return commonBackground.value && commonBackground.value.innerImage === template.value.url
})
 
const setBoard = () => {
  commonBackground.value.innerImage = template.value.url
  emits('borderChange')
}
</script>
 
<style scoped lang="less">
.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: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
 
.template-img {
  position: relative;
  height: 70px;
  width: 110px;
  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>