<template>
  <el-dialog
    :title="title"
    :visible.sync="visible"
    :key="reload"
    :before-close="handleCancel"
    :width="width"
  >
    <!-- 表格主体部分 -->
    <slot></slot>
    <!-- 表格底部 -->
    <div slot="footer">
      <slot name="footer">
        <el-button @click="handleCancel" size="small">取消</el-button>
        <el-button @click="handleConfirm" type="primary" size="small">确定</el-button>
        </slot>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "",
    },
    reload: {
      type: Number,
      default: 0,
    },
    width: {
      type: String,
      default: "500px",
    },
  },
  mounted() {
    console.log("我被初始化了");
  },
  methods: {
    //   确定的回调
    handleConfirm() {
      this.$emit("confirm", false);
    },
    //   取消的回调
    handleCancel() {
      this.$emit("cancel", false);
    },
  },
};
</script>

<style></style>
