materials.vue
3.07 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
<template>
<section class="select-material">
<div class="current-material" @click="onDropdown">
<div class="description">
<div class="name" v-text="selecteditem" />
</div>
<div class="dropIcon">
<img width="16" :src="selectIcon" alt="" />
</div>
</div>
<div class="selectitems" v-show="isSelectitemsVisible" @mouseleave="onMouseout">
<div v-for="item in items" :key="item" :index="item.key" class="selectitem" @click="onSelect(item.key)">
<div class="description">
<div class="name" v-text="item.key" />
</div>
</div>
</div>
</section>
</template>
<script setup>
import DROPDOWNICON from '@/views/assets/images/application-field/materials/dropdown.png';
import DROPUPICON from '@/views/assets/images/application-field/materials/dropup.png';
import { ref } from 'vue';
import { storeToRefs } from 'pinia';
import { useMaterialsStore } from '@/views/stores/applications/useMaterialsStore';
const store = useMaterialsStore();
const { items, handleSelect } = store;
const { selecteditem } = storeToRefs(store);
const isSelectitemsVisible = ref(false);
const selectIcon = ref(DROPDOWNICON);
const onSelect = (key) => {
handleSelect(key);
isSelectitemsVisible.value = false;
selectIcon.value = DROPDOWNICON;
};
const onDropdown = () => {
isSelectitemsVisible.value = !isSelectitemsVisible.value;
selectIcon.value = isSelectitemsVisible.value ? DROPUPICON : DROPDOWNICON;
};
const onMouseout = () => {
isSelectitemsVisible.value = false;
selectIcon.value = DROPDOWNICON;
};
</script>
<style lang="less">
.select-material {
width: 100%;
height: calc(35px * 943 / 1008);
border: 1.5px solid @color-button-active-background;
border-radius: 8px;
font-weight: 300;
.current-material,
.selectitem {
display: flex;
align-items: center;
width: 100%;
height: calc(35px * 943 / 1008);
cursor: pointer;
.icon {
width: 56px;
}
.description {
width: 165px;
margin-left: 12px;
display: flex;
flex-direction: column;
justify-content: center;
.name {
font-size: 15px;
}
.size {
font-size: 14px;
color: #c0c1c2;
}
}
.dropIcon {
width: 16px;
}
img {
cursor: pointer;
.image {
width: 48px;
height: 72px;
}
}
&:hover {
background-color: @header-machine-hover-color;
color: @main-color;
}
}
.selectitems {
position: absolute;
width: 100%;
background-color: #fff;
border: 1px solid #eef0f2;
border-radius: 0 0 8px 8px;
height: calc(35px * 943 / 1008 * 5);
overflow-y: auto;
overflow-x: hidden;
z-index: 100;
width: 202px;
}
}
</style>