index.vue 1.52 KB
<!-- 弹窗 -->
<template>
  <div>
    <el-dialog
      :title="title"
      :visible.sync="isVisible"
      :show-close="showClose"
      :before-close="handleClose"
      :close-on-click-modal="false"
      :width="width"
    >
      <span slot="title">
        {{title}}
        <span class="dialog-sub-title">
          <slot name="sub-title"></slot>
        </span>
      </span>
      <slot></slot>
      <div slot="footer">
        <slot name="btn-start"></slot>
        <el-button
          type="primary"
          :size="btn_size"
          @click="handleConfirm"
        >{{btnOkLabel}}</el-button>
        <el-button
          v-if="!noCancel"
          :size="btn_size"
          @click="handleClose"
        >取消</el-button>
        <slot name="btn-middle"></slot>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'glsx-dialog',
  data() {
    return {
    }
  },
  props: {
    title: {
      type: String,
      default: ''
    },
    isVisible: {
      type: Boolean,
      default: false
    },
    showClose: {
      type: Boolean,
      default: true
    },
    btnOkLabel: {
      type: String,
      default: '确定'
    },
    noCancel: {
      type: Boolean,
      default: false
    },
    width: {
      type: String,
      default: '580px'
    }
  },

  methods: {
    handleClose() {
      this.$emit('closeDialog')
    },
    handleConfirm() {
      this.$emit('confirmDialog')
    }
  }
}

</script>
<style scoped>
.dialog-sub-title {
  font-size: 12px;
  color: #666666;
}
</style>