Files
UserclassFront/public/code/confirm.vue
T
2026-08-12 17:19:37 +08:00

64 lines
1.6 KiB
Vue

<template>
<Modal v-model="modal" @on-visible-change="showChange" :title="title || '提示'">
<Alert type="warning" class="mb-1" show-icon>
<Icon type="ios-bulb-outline" :class="{ 'mt-5': !info }" slot="icon" :size="28"></Icon>
<div v-if="msg" :class="['message-box', info ? '' : 'mt-10 mb-10 ml-10']">{{ msg }}</div>
<span v-if="info" slot="desc">{{ info }}</span>
</Alert>
<div slot="footer">
<Button type="primary" @click="ok">确定</Button>
<Button @click="cancle">取消</Button>
</div>
</Modal>
</template>
<script>
export default {
props: {
title: String,
msg: String,
info: String,
onOk: Function,
onCancel: Function,
},
data() {
return {
modal: false,
};
},
mounted() {
this.$nextTick(() => {
this.modal = true;
});
},
methods: {
ok() {
this.modal = false;
typeof this.onOk === "function" && this.onOk();
},
cancle() {
this.modal = false;
typeof this.onCancel === "function" && this.onCancel();
},
showChange(state) {
if (!state) this.destroy();
},
destroy() {
setTimeout(() => {
document.body.removeChild(this.$el);
}, 300);
},
},
};
</script>
<style scoped>
.my-confirwm {
margin-bottom: 0;
}
.message-box {
font-size: 16px;
color: #17233d;
display: block;
}
</style>