<template>
  <el-card shadow="hover">
    <div class="flex flex-justify-between flex-center mb-10">
      <div class="font-16 bold-500 flex-justify-start flex">
        {{ title }}
      </div>
      <el-button
        type="primary"
        icon="Edit"
        v-if="editBtn"
        size="small"
        @click="change"
        >{{ btnText }}</el-button
      >
    </div>
    <el-divider />
    <slot></slot>
  </el-card>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: ''
    },
    editBtn: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      btnText: '编 辑'
    }
  },
  methods: {
    change() {
      if (this.btnText == '保 存') {
        this.$emit('save')
      }
      this.btnText = this.btnText === '编 辑' ? '保 存' : '编 辑'
      this.$emit('change', this.btnText === '编 辑')
    }
  }
}
</script>

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