VisualWidgetSelect.vue
1.42 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
<script lang="ts" setup>
import { Card } from 'ant-design-vue';
const props = defineProps({
controlId: {
type: String,
required: true,
},
checkedId: {
type: String,
required: true,
},
});
const emit = defineEmits(['change']);
const handleClick = () => {
emit('change', props.controlId);
};
</script>
<template>
<Card
:style="{ borderColor: props.controlId === props.checkedId ? '#3079FF' : '#fff' }"
hoverable
bordered
class="w-60 h-60 border-2 widget-select !bg-light-50 cursor-pointer"
@click="handleClick"
>
<div class="widget-container">
<slot></slot>
</div>
<Card.Meta>
<template #description> 选择 </template>
</Card.Meta>
</Card>
</template>
<style scoped>
.widget-select {
box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
border-width: 2px;
}
.widget-select:deep(.ant-card-body) {
/* height: 240px; */
width: 240px;
padding: 0;
box-sizing: border-box;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.widget-select:deep(.ant-card-meta) {
border-top: 1px solid #f0f0f0;
width: 100%;
height: 40px;
text-align: center;
line-height: 40px;
margin: 0;
}
.widget-select .widget-container {
width: 240px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
}
</style>