<template>
  <el-drawer
    :title="title"
    :visible.sync="drawerVisible"
    :class="['ps-drawer__wrapper', size]"
    :destroy-on-close="true"
    :before-close="closeDrawer"
    :wrapperClosable="true"
    :append-to-body="appendToBody"
  >
    <div class="ps-drawer">
      <div class="ps-drawer--body">
        <el-scrollbar style="height: 100%">
          <div class="ps-drawer--body__con">
            <slot name="body">

            </slot>
          </div>
        </el-scrollbar>
      </div>
      <div class="ps-drawer--footer">
        <slot name="footer">

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

<script>
export default {
  name: "PsDrawer",
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: null,
    },
    size: {
      type: String,
      default: null,
    },
    id: { type: String, default: "" },
    appendToBody: {
      type: Boolean,
      default: false
    },
  },
  watch: {
    visible: {
      handler(val) {
        this.drawerVisible = val
      },
      immediate: true
    }
  },
  data() {
    return {
      drawerVisible: false,
      isLoading: false,
    };
  },
  created() {

  },
  mounted() {
  },
  methods: {
    closeDrawer() {
      console.log('------------------')
      this.drawerVisible = false
      this.$emit('update:visible', false)
      this.$emit('close', false)
    }
  },
};
</script>

<style></style>
