<!--
 * @Author: guanxiaoyan guanxiaoyan@pb-station.com
 * @Deion:
 * @Date: 2023-12-06 18:22:03
 * @LastEditors: guanxiaoyan guanxiaoyan@pb-station.com
 * @LastEditTime: 2023-12-13 16:56:02
 * @FilePath: /followUp-admin/src/components/Popup/index.vue
-->
<template>
  <el-dialog :title="fullTitle" :visible.sync="visible" :width="width" append-to-body center
    v-bind="$attrs" v-on="$listeners">
    <slot></slot>
    <div slot="footer">
      <slot name="footer"></slot>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    title: String,
    width: {
      type: String,
      default: "600px",
    },
    isCrud: {
      type: Boolean,
      default: true,
    },
  },
  computed: {
    fullTitle() {
      if (!this.isCrud) return this.title;
      console.log("openParams", this.openParams);
      return (this.openParams && this.openParams.id ? "编辑" : "新增") + this.title;
    },
  },
  data() {
    return {
      visible: false,
      openParams: null,
    };
  },

  methods: {
    open(params = null) {
      this.visible = true;
      this.openParams = params;
    },

    close() {
      this.visible = false;
    },
  },
};
</script>
