<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    :class="['ps-dialog__wrapper', $slots.footer && 'have-footer', size]"
    :destroy-on-close="true"
    :before-close="closeDrawer"
    :append-to-body="appendToBody"
    :close-on-click-modal="true"
  >
    <div class="ps-dialog">
      <div :class="['ps-dialog--body', $slots.footer && 'have-footer']">
        <el-scrollbar style="height: 100%">
          <div class="ps-dialog--body__con">
            <slot>

            </slot>
          </div>
        </el-scrollbar>
      </div>
      <div
        class="ps-dialog--footer"
        v-if="$slots.footer"
      >
        <slot name="footer">

        </slot>
      </div>
    </div>
  </el-dialog>
</template>

<script>
export default {
  name: "PsDialog",
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: null,
    },
    // small | large
    size: {
      type: String,
      default: null,
    },
    appendToBody: {
      type: Boolean,
      default: false
    },
    id: { type: String, default: "" }
  },
  watch: {
    visible: {
      handler(val) {
        this.dialogVisible = val
      },
      immediate: true
    }
  },
  data() {
    return {
      dialogVisible: false,
    };
  },
  created() {
  },
  mounted() {
  },
  methods: {
    closeDrawer() {
      this.dialogVisible = false
      this.$emit('update:visible', false)
      this.$emit('close', false)
    }
  },
};
</script>

<style></style>
