<template>
  <el-dialog
    :visible.sync="visible"
    :width="width"
    :show-close="false"
    :close-on-click-modal="false"
    :append-to-body="appendToBody"
    @closed="close"
    :fullscreen="fullscreen"
  >
    <div slot="title" class="hearders">
      <div class="leftTitle">{{ title }}</div>
      <div class="rightBoxs">
        <i class="el-icon-full-screen full_style" @click="fullscreen = !fullscreen"></i>
        <img
          src="@/assets/images/Close@2x.png"
          alt=""
          @click="visible = false"
        />
      </div>
    </div>
    <slot></slot>
    <div slot="footer" class="dialog-footer" v-if="isShowFooter">
      <slot name="slotBtn"></slot>
      <el-button :loading="disabledBtn" @click="visible = false">{{
        cancelName
      }}</el-button>
      <el-button
        v-if="confirmStatus"
        :loading="disabledBtn"
        type="primary"
        @click="confirmBtn"
        >{{ confirmName }}</el-button
      >
      <slot name="slotBtnRight"></slot>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "BaseDialog",
  props: {
    title: {
      type: String,
      default: "",
    },
    isShow: {
      type: Boolean,
      default: false,
    },
    width: {
      type: String,
      default: "600px",
    },
    cancelName: {
      type: String,
      default: "取 消",
    },
    confirmName: {
      type: String,
      default: "确 定",
    },
    isShowFooter: {
      type: Boolean,
      default: true,
    },
    appendToBody: {
      type: Boolean,
      default: false,
    },
    disabledBtn: {
      type: Boolean,
      default: false,
    },
    confirmStatus: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      fullscreen:false,
    };
  },
  methods: {
    confirmBtn() {
      this.$emit("submit");
    },
    close() {
      this.$emit("close");
    },
  },
  computed: {
    visible: {
      get() {
        return this.isShow;
      },
      set(val) {
        this.$emit("update:isShow", false);
      },
    },
  },

  watch: {
    visible(val) {
      if (val === false) {
        this.fullscreen = false
      } else {
        this.$emit("open");
      }
    },
  },
};
</script>

<style scoped lang="scss">
/deep/.el-dialog {
  border-radius: 8px;
  .el-dialog__header {
    padding: 0;
    .hearders {
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0px 18px 0px 20px;
      border-bottom: 1px solid #e2e2e2;
      .leftTitle {
        font-size: 14px;
        font-weight: bold;
        color: #2f4378;
      }
      .rightBoxs {
        display: flex;
        align-items: center;
        img {
          width: 14px;
          height: 14px;
          margin-left: 13px;
          cursor: pointer;
        }
      }
    }
  }
  .el-dialog__footer {
    padding: 0;
    .dialog-footer {
      padding: 0px 40px;
      height: 70px;
      border-top: 1px solid #e2e2e2;
      display: flex;
      align-items: center;
      justify-content: flex-end;
    }
  }
}
/deep/.el-button {
  border-radius: 8px;
}
.full_style {
  cursor: pointer;
  color:#6e6e6e;
}
</style>
