index.vue 2.57 KB
<!-- 弹窗 -->
<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="isVisible"
      :show-close="showClose"
      :before-close="handleClose"
      :close-on-click-modal="false"
      :modal-append-to-body="false"
      :width="width"
      class="app-dialog"
    >
      <el-scrollbar v-if="hasScroll">
        <span slot="title">
          <span class="main-title"></span>
          <span class="dialog-sub-title">
            <slot name="sub-title"></slot>
          </span>
        </span>
        <slot></slot>
      </el-scrollbar>
      <template v-if="!hasScroll">
        <span slot="title">
          <span class="main-title"></span>
          <span class="dialog-sub-title">
            <slot name="sub-title"></slot>
          </span>
        </span>
        <slot></slot>
      </template>

      <div slot="footer">
        <slot name="btn-start"></slot>
        <el-button
          :type="typeName"
          v-if="!noClose"
          :size="btnSize"
          @click="handleClose"
        ></el-button>
        <el-button
          type="default"
          v-if="!noCancel"
          :size="btnSize"
          @click="handleClose"
        ></el-button>
        <el-button
          type="primary"
          v-if="!noBtnOk"
          :size="btnSize"
          @click="handleConfirm"
        ></el-button>
        <slot name="btn-middle"></slot>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'glsx-dialog',
  data() {
    return {}
  },
  props: {
    hasScroll: {
      type: Boolean,
      default: true
    },
    title: {
      type: String,
      default: ''
    },
    isVisible: {
      type: Boolean,
      default: false
    },
    showClose: {
      type: Boolean,
      default: false
    },
    btnCloseLabel: {
      type: String,
      default: '关闭'
    },
    btnOkLabel: {
      type: String,
      default: '确定'
    },
    btnCancelLabel: {
      type: String,
      default: '取消'
    },
    noBtnOk: {
      type: Boolean,
      default: false
    },
    noCancel: {
      type: Boolean,
      default: false
    },
    noClose: {
      type: Boolean,
      default: true
    },
    typeName: {
      type: String,
      default: 'default'
    },
    width: {
      type: String,
      default: '580px'
    },
    btnSize: {
      type: String,
      default: 'small'
    }
  },

  methods: {
    handleClose() {
      this.$emit('closeDialog')
    },
    handleConfirm() {
      this.$emit('confirmDialog')
    }
  }
}
</script>
<style lang="scss">
.dialog-sub-title {
  font-size: 12px;
  color: #666666;
}
</style>