index.vue 2.42 KB
<template>
  <div class="dialog_page">
    <el-dialog ref="glsxDialogCom" :title="title" :visible.sync="show" :width="width" :append-to-body="appendtobody" :show-close="showClose" custom-class="glsx_dialog" :close-on-press-escape="false" :close-on-click-modal="false" @close="onCancel" @opened="onDialogOpened">
      <div slot="title" class="test" v-if="slotInfo.title">
        <slot name="title" />
      </div>
      <div class="dialog_content">
        <slot />
      </div>
      <div class="dialog_footer" v-show="hasFooter">
        <slot name="footer"></slot>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "GlsxDialog",
  props: {
    show: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
      default: "提示",
    },
    width: {
      type: String,
      default: "46%",
    },
    cancel: {
      required: false,
      type: Function,
    },
    confirm: {
      required: false,
      type: Function,
    },
    usefooter: {
      required: false,
      type: Boolean,
      default: false,
    },
    appendtobody: {
      required: false,
      type: Boolean,
      default: false,
    },
    value: {
      type: Boolean,
      default: false,
    },
    showClose: {
      required: false,
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      hasFooter: false,
      hasTitle: false,
      slotInfo: {},
    };
  },
  created() {
    let o = this.$slots;
    this.hasFooter = o.footer;
    this.hasTitle = o.title;
    this.slotInfo = o;
  },
  mounted: function () {
    //this.$refs.glsxDialogCom.rendered = true;
  },
  methods: {
    /**
     * 取消关闭弹框
     */
    onCancel: function () {
      // 兼容以前的页面
      this.$emit("close");
      //this.$emit("input", false);
    },

    /**
     * 确定
     */
    onConfirm: function () {},

    //
    onDialogOpened() {},
  },
};
</script>

<style lang="scss">
.glsx_dialog {
  .el-dialog__header {
    border-bottom: 1px solid #ddd !important;
    padding-top: 10px;
    font-size: 14px;
  }
  .el-dialog__headerbtn {
    top: 10px;
    right: 10px;
  }
  .el-dialog__body {
    padding: 0;
  }
  .el-dialog__footer {
    border-top: 1px solid #ddd;
  }
}
</style>
<style lang="scss" scoped>
.dialog_content {
  max-height: 600px;
  overflow-y: auto;
  padding: 20px;
}
.dialog_footer {
  padding: 10px 15px;
  border-top: 1px solid #e1e1e1;
  text-align: right;
}
</style>