<template>
  <div class="modal" v-if="isVisible">
    <div class="modal-content">
      <header class="modal-header">
        <slot name="header">默认标题</slot>
      </header>
      <main class="modal-body">
        <slot>默认内容</slot>
      </main>
      <footer class="modal-footer">
        <el-button type="info" @click="closeModal">关闭</el-button>
        <el-button type="primary" @click="getSubmit">提交</el-button>
      </footer>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      isVisible: {
        type: Boolean,
        default: false
      }
    },
    methods: {
      closeModal() {
        this.$emit('closeModal', false);
      },
      getSubmit() {
        this.$emit('getSubmit')
      }
    }
  };
</script>

<style scoped>
  .modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2024;
  }

  .modal-content {
    background-color: white;
    padding: 20px;
    border-radius: 5px;
    min-width: 240px;
  }

  .modal-header {
    font-size: 17px;
    font-weight: 600;
    text-align: left;
  }

  .modal-footer {
    text-align: right;
  }

  .modal-body {
    padding: 15px 0px 20px 0px;
  }

  .modal-footer button {
    padding: 10px 15px;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
</style>
