popup.vue
1.75 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
<template>
<van-popup
:model-show="props.showPopup"
round
@close="close"
:close-on-click-overlay="true"
:position="props.position"
>
<div class="content-box">
<div class="btn-class">
<button class="cancel-btn" @click="cancel">取消</button>
<button
class="save-btn"
:class="isDisabled ? 'disabled' : ''"
@click="save"
v-preventReClick
>
{{ isDisabled ? "关闭" : "确定" }}
</button>
</div>
<slot></slot>
</div>
</van-popup>
</template>
<script>
import { defineComponent } from "vue";
export default defineComponent({
name: "PopupCom",
props: {
showPopup: {
type: Boolean,
default: false,
},
position: {
type: String,
},
isDisabled: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
const cancel = () => {
emit("btnCancel");
};
const close = () => {
emit("btnCancel");
};
const save = () => {
if (props.isDisabled) {
emit("btnCancel");
} else {
emit("btnSave");
}
};
return {
cancel,
save,
props,
close,
};
},
});
</script>
<style lang="scss">
.content-box {
display: flex;
align-items: center;
background: #fff;
flex-flow: column;
border-radius: 0 0 16px 16px;
overflow: hidden;
padding-bottom: 40px;
.btn-class {
padding: 15px;
box-sizing: border-box;
border-bottom: 1px solid #f0f2f5;
width: 100%;
display: flex;
justify-content: space-between;
font-size: 14px;
.cancel-btn {
color: #6c737a;
}
.save-btn {
color: var(--base-color);
}
.save-btn.disabled {
color: #6c737a;
}
}
}
</style>