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

<script>
export default {
  props: {
    btnDisabled: {
      type: Boolean,
      default: false,
    },
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "",
    },
    reload: {
      type: Number,
      default: 0,
    },
    width: {
      type: String,
      default: "500px",
    },
    fullscreen: {
      type: Boolean,
      default: false,
    },
    modal: {
      type: Boolean,
      default: true,
    },
    destroy: {
      type: Boolean,
      default: false
    }
  },
  data(){
    return{
      BtnDisabled: false,
    }
  },
  mounted() {
  },
  watch:{
    btnDisabled(val){
      this.BtnDisabled =val
    }
  },
  methods: {
    //   确定的回调
    handleConfirm() {
    this.BtnDisabled = false;
    this.$emit("confirm", false);      
    // this.BtnDisabled = this.btnDisabled;
    },
    //   取消的回调
    handleCancel() {
      this.$emit("cancel", false);
    },
  },
};
</script>

<style></style>
