184 lines
3.7 KiB
Vue
Raw Normal View History

<template>
<div v-if="visible" class="confirm-dialog-overlay" @click="handleOverlayClick">
<div class="confirm-dialog" @click.stop>
<!-- 标题栏 -->
<div class="dialog-header">
<div class="header-title">{{ title }}</div>
<div class="close-btn" @click="handleCancel">
<el-icon><Close /></el-icon>
</div>
</div>
<!-- 提示内容 -->
<div class="dialog-content">
<p class="confirm-message">{{ message }}</p>
</div>
<!-- 按钮区域 -->
<div class="dialog-footer">
<el-button class="btn-cancel" @click="handleCancel">
{{ cancelText }}
</el-button>
<el-button type="primary" class="btn-confirm" @click="handleConfirm">
{{ confirmText }}
</el-button>
</div>
</div>
</div>
</template>
<script setup>
import { Close } from "@element-plus/icons-vue";
const props = defineProps({
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: "提示",
},
message: {
type: String,
default: "",
},
confirmText: {
type: String,
default: "确定",
},
cancelText: {
type: String,
default: "取消",
},
});
const emit = defineEmits(["update:visible", "confirm", "cancel"]);
// 确认
const handleConfirm = () => {
emit("confirm");
emit("update:visible", false);
};
// 取消
const handleCancel = () => {
emit("cancel");
emit("update:visible", false);
};
// 点击遮罩关闭
const handleOverlayClick = () => {
handleCancel();
};
</script>
<style lang="scss" scoped>
.confirm-dialog-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.6);
display: flex;
align-items: center;
justify-content: center;
z-index: 2200;
}
.confirm-dialog {
width: 360px;
background: linear-gradient(135deg, rgba(20, 50, 90, 0.95) 0%, rgba(10, 30, 60, 0.98) 100%);
border: 1px solid rgba(64, 169, 255, 0.3);
border-radius: 8px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
overflow: hidden;
}
// 标题栏
.dialog-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px 16px;
background: linear-gradient(90deg, rgba(64, 169, 255, 0.15) 0%, rgba(64, 169, 255, 0.05) 100%);
border-bottom: 1px solid rgba(64, 169, 255, 0.2);
.header-title {
font-size: 16px;
font-weight: 600;
color: #fff;
}
.close-btn {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
color: rgba(255, 255, 255, 0.6);
cursor: pointer;
font-size: 16px;
transition: color 0.3s;
&:hover {
color: #fff;
}
}
}
// 内容区域
.dialog-content {
padding: 24px 20px;
text-align: center;
.confirm-message {
font-size: 14px;
color: rgba(255, 255, 255, 0.9);
line-height: 1.6;
margin: 0;
}
}
// 按钮区域
.dialog-footer {
display: flex;
justify-content: center;
gap: 16px;
padding: 0 20px 20px;
.btn-cancel {
min-width: 80px;
height: 32px;
background-color: transparent;
border: 1px solid rgba(64, 169, 255, 0.4);
color: rgba(255, 255, 255, 0.8);
font-size: 13px;
border-radius: 4px;
transition: all 0.3s;
&:hover {
background-color: rgba(64, 169, 255, 0.1);
border-color: rgba(64, 169, 255, 0.6);
color: #fff;
}
}
.btn-confirm {
min-width: 80px;
height: 32px;
background: linear-gradient(135deg, #40a9ff 0%, #1890ff 100%);
border: none;
color: #fff;
font-size: 13px;
border-radius: 4px;
transition: all 0.3s;
&:hover {
background: linear-gradient(135deg, #69c0ff 0%, #40a9ff 100%);
}
}
}
</style>