forked from TencentBlueKing/bk-job
-
Notifications
You must be signed in to change notification settings - Fork 0
/
collapse-box.vue
100 lines (89 loc) · 2.3 KB
/
collapse-box.vue
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
<template>
<div class="ip-selector-view-collsapn">
<div
class="box-header"
@click="handleToggle">
<ip-selector-icon
class="arrow-flag"
:class="{ 'is-show': isShow }"
type="close" />
<div class="box-header-text">
<slot name="title" />
</div>
</div>
<div
v-show="isShow"
class="box-content">
<slot />
</div>
<div class="box-action">
<slot name="action" />
</div>
</div>
</template>
<script setup>
import { ref } from 'vue';
import IpSelectorIcon from '../../common/ip-selector-icon';
const props = defineProps({
name: {
type: String,
},
});
const isShow = ref(true);
const handleToggle = () => {
isShow.value = !isShow.value;
};
defineExpose({
toggle (lastStatus) {
if (lastStatus === undefined) {
handleToggle();
} else if (lastStatus === false) {
isShow.value = false;
} else if (lastStatus === true) {
isShow.value = true;
} else if (Array.isArray(lastStatus) && props.name && lastStatus.includes(props.name)) {
isShow.value = true;
}
},
});
</script>
<style lang="postcss" scoped>
.ip-selector-view-collsapn {
position: relative;
.box-header {
display: flex;
height: 42px;
padding: 0 16px;
font-size: 12px;
color: #63656e;
cursor: pointer;
align-items: center;
background: #eff1f5;
user-select: none;
.arrow-flag {
margin-right: 16px;
transform: rotateZ(0);
transition: all 0.15s;
&.is-show {
transform: rotateZ(90deg);
}
}
}
.box-header-text {
display: flex;
}
.box-content {
background: #fff;
}
.box-action {
position: absolute;
top: 0;
right: 12px;
display: flex;
align-items: center;
height: 42px;
margin-left: auto;
cursor: pointer;
}
}
</style>