index.vue
4.13 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<template>
<div class="go-content-layers-list-item" :class="{ hover, select, 'list-mini': selectText }">
<div class="go-flex-center item-content">
<n-image
class="list-img"
object-fit="contain"
preview-disabled
:src="imageInfo"
:fallback-src="requireErrorImg()"
></n-image>
<n-ellipsis style="margin-right: auto">
<span class="list-text">
{{ t(props.componentData.chartConfig.title) }}
</span>
</n-ellipsis>
<div class="list-layers">
<layers-status :isGroup="isGroup" :hover="hover" :status="status"></layers-status>
</div>
</div>
<div :class="{ 'select-modal': select }"></div>
</div>
</template>
<script setup lang="ts">
import { computed, PropType, ref } from 'vue'
import { requireErrorImg } from '@/utils'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { LayerModeEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
import { fetchImages } from '@/packages'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
import { LayersStatus } from '../LayersStatus/index'
const props = defineProps({
componentData: {
type: Object as PropType<CreateComponentType | CreateComponentGroupType>,
required: true
},
isGroup: {
type: Boolean,
default: false
},
layerMode: {
type: String as PropType<LayerModeEnum>,
default: LayerModeEnum.THUMBNAIL
}
})
const t = window['$t']
// 全局颜色
const designStore = useDesignStore()
const chartEditStore = useChartEditStore()
const imageInfo = ref('')
// 获取图片
const fetchImageUrl = async () => {
const threeModelImageUrl = props.componentData.chartConfig?.threeModelImageUrl
imageInfo.value = threeModelImageUrl ? threeModelImageUrl : await fetchImages(props.componentData.chartConfig)
}
fetchImageUrl()
// 颜色
const themeColor = computed(() => {
return designStore.getAppTheme
})
// 计算当前选中目标
const select = computed(() => {
const id = props.componentData.id
return chartEditStore.getTargetChart.selectId.find((e: string) => e === id)
})
// 悬浮对象
const hover = computed(() => {
return props.componentData.id === chartEditStore.getTargetChart.hoverId
})
// 组件状态 隐藏/锁定
const status = computed(() => {
return props.componentData.status
})
// 是否选中文本
const selectText = computed(() => {
return props.layerMode === LayerModeEnum.TEXT
})
</script>
<style lang="scss" scoped>
$centerHeight: 52px;
$centerMiniHeight: 28px;
$textSize: 10px;
@include go(content-layers-list-item) {
position: relative;
height: $centerHeight;
width: 90%;
margin: 5px 5%;
margin-bottom: 5px;
border-radius: 5px;
cursor: pointer;
border: 1px solid rgba(0, 0, 0, 0);
@extend .go-transition-quick;
&.hover,
&:hover {
@include fetch-bg-color('background-color4');
}
&:hover {
@include deep() {
.icon-item {
opacity: 1;
}
}
}
.select-modal,
.item-content {
position: absolute;
top: 0;
left: 0;
}
.item-content {
z-index: 1;
padding: 6px 5px;
justify-content: start !important;
width: calc(100% - 10px);
height: calc(100% - 10px);
}
.select-modal {
width: 100%;
height: 100%;
opacity: 0.3;
background-color: v-bind('themeColor');
}
.list-img {
flex-shrink: 0;
height: $centerHeight;
border-radius: 5px;
overflow: hidden;
border: none !important;
padding: 2px;
@include hover-border-color('hover-border-color');
}
.list-text {
position: absolute;
z-index: 99;
left: 70px;
top: 20px;
padding-left: 6px;
width: 60px;
font-size: $textSize;
overflow: hidden;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
}
.list-layers {
position: absolute;
z-index: 99;
left: 140px;
top: 15px;
}
/* 选中样式 */
&.select {
border: 1px solid v-bind('themeColor');
background-color: rgba(0, 0, 0, 0);
}
// mini样式
&.list-mini {
height: $centerMiniHeight;
}
}
</style>