<template>
  <el-dialog
    :custom-class="customClass"
    :title="title"
    :visible="dialogShow"
    :append-to-body="appendToBody"
    :modal-append-to-body="modalAppendToBody"
    :close-on-click-modal="closeOnClickModal"
    :destroy-on-close="destroyOnClose"
    :lock-scroll="lockScroll"
    :width="width"
    @close="close"
  >
    <slot />
    <span slot="footer" v-if="buttons">
      <el-button size="small" v-if="cancelButton" @click="cancel" type="info" plain 
        >{{cancelText}}</el-button
      >
      <el-button type="primary" size="small" v-if="confirmButton" @click="confirm">{{confirmText}}</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: "ZrDialog",
  props: {
    title: {
      type: String,
      default: "提示",
    },
    destroyOnClose: {
      type: Boolean,
      default: false,
    },
    dialogShow: {
      type: Boolean,
      default: false,
    },
    width: {
      type: String,
      default: "40%",
    },
    appendToBody: {
      type: Boolean,
      default: false,
    },
    modalAppendToBody: {
      type: Boolean,
      default: false,
    },
    closeOnClickModal: {
      type: Boolean,
      default: true,
    },
    customClass:{
      type: String,
      default: "customClass",
    },
    buttons: {
      type: Boolean,
      default: true,
    },
    cancelButton: {
      type: Boolean,
      default: true,
    },
    confirmButton: {
      type: Boolean,
      default: true,
    },
    lockScroll:{
      type: Boolean,
      default: true,
    },
    cancelText: {
      type: String,
      default: "取 消",
    },
    confirmText: {
      type: String,
      default: "确 定",
    },
  },
  data() {
    return {};
  },
  methods: {
    close() {
      this.$emit("close");
      this.$emit("update:dialogShow", false);
    },
    confirm() {
      this.$emit("confirm");
    },
    cancel() {
      this.$emit("cancel");
      this.close();
    },
  },
};
</script>

<style lang="scss" scoped></style>
