<template>
  <el-dialog v-model="dialogVisible" :title="props.title" :width="props.width" @close="close">
    <slot></slot>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="Confirm">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { ElMessageBox } from "element-plus";

let props = defineProps({
  title: {
    type: String,
    default: "Dialog",
  },
  width: {
    type: String,
    default: "30%",
  },
});
const emit = defineEmits(["confirm", "close"]);
const dialogVisible = ref(false);

function open() {
  dialogVisible.value = true;
}

function Confirm() {
  emit("confirm");
}
function close() {
  dialogVisible.value = false;
  emit("close");
}
defineExpose({ open, close });
</script>
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
