slice-modal.vue
3.61 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
<template>
<section class="slice-button">
<span class="button-big" @click="onSlice" v-text="$t('slice')" />
</section>
<section class="slice-modal" v-show="isSliceModalVisible">
<Card :title="$t('slice')" customClass="slice-modal-card">
<template v-slot:extend>
<el-icon class="icon" :size="24" @click="onCloseModal">
<Close />
</el-icon>
</template>
<template v-slot:component>
<div class="content">
<SliceCanvas />
</div>
<div class="footer">
<span class="button-hollow" @click="onCloseModal" v-text="$t('cancel')" />
<span class="button-big" v-text="$t('apply')" @click="onApply" />
</div>
</template>
</Card>
</section>
</template>
<script setup>
import { nextTick } from 'vue';
import { storeToRefs } from 'pinia';
import Card from '@/components/simple-card.vue';
import { useSliceModalStore } from '@/views/stores/useSliceModalStore';
import { Close } from '@element-plus/icons-vue';
import SliceCanvas from './slice-canvas.vue';
const store = useSliceModalStore();
const { isSliceModalVisible } = storeToRefs(store);
const { setIsVisible, apply } = store;
const onSlice = () => {
setIsVisible(true);
};
const onCloseModal = () => {
setIsVisible(false);
nextTick(() => {
const b = document.getElementsByClassName('el-slider__button-wrapper');
const popperDom = document.getElementsByClassName('el-popper');
if (popperDom) {
const canvas = document.getElementById('viewer-editor');
const rect = canvas.getBoundingClientRect();
for (let i = 0; i < popperDom.length; i++) {
const element = b[i].getBoundingClientRect();
popperDom[i].style['transform'] = `translate(${
element.right - rect.width - element.width * 0.75 - 15
}px,${element.top - element.height * 0.25}px)`;
}
}
});
};
const onApply = () => {
apply();
};
</script>
<style lang="less">
.slice-button {
position: absolute;
right: 62px;
bottom: 40px;
.button-big {
width: 200px;
height: 70px;
font-size: 18px;
}
}
.slice-modal-card {
position: absolute;
background-color: #fff;
box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.2);
border: 1px solid #cdd1d5;
top: 44px;
z-index: 200;
.content {
display: flex;
flex-direction: row;
min-height: 566px;
height: calc(100vh - 44px - 63px - 79px);
justify-content: center;
}
.footer {
display: flex;
-webkit-box-align: center;
align-items: center;
-webkit-box-pack: end;
justify-content: flex-end;
flex: 0 0 auto;
border-top: 1px solid rgb(222, 225, 229);
padding: 16px;
gap: 10px;
}
}
</style>
<style lang="less">
.slice-modal-card.card {
max-width: 100vw;
min-height: 634px;
width: 100vw !important;
height: calc(100% - 44px) !important;
padding: 0px !important;
.icon {
cursor: pointer;
&:hover {
background-color: rgb(246, 247, 248);
}
&:active {
background-color: #eef0f2;
}
}
.header {
padding: 22px !important;
margin-bottom: 0px !important;
border-bottom: 1px solid #f0f1f4;
.title {
margin: 0px;
font-size: 20px;
line-height: 34px;
font-weight: 700;
}
}
}
</style>