Blame view

src/components/dialogBox/dialogBox.vue 2.86 KB
任超 committed
1
<template>
2 3
  <el-dialog :visible.sync="dialogVisible" :width="width" :fullscreen="fullscreen" top="0" :append-to-body="true"
    :lock-scroll="true" :close-on-click-modal="false" @close="closeDialog" :key="key"
任超 committed
4 5
    :custom-class="isMain ? 'mainCenter dialogBox' : 'contentCenter dialogBox'" :destroy-on-close="true" ref="dialogBox"
    id="dialogBox">
任超 committed
6 7
    <div slot="title">
      <div class="dialog_title">
8
        <b>{{ title }}</b>
任超 committed
9 10 11 12
        <div v-if="isFullscreen" class="dialog_full">
          <i class="el-icon-rank" v-if="fullscreen" @click="handleFullscreen"></i>
          <i class="el-icon-full-screen" v-else @click="handleFullscreen" />
        </div>
任超 committed
13 14
      </div>
    </div>
任超 committed
15
    <div class="dialogBox-content" :style="{ height: scrollerHeight ? scrollerHeight : 'auto' }">
任超 committed
16 17
      <slot></slot>
    </div>
任超 committed
18 19
    <div slot="footer" class="dialog_footer" v-if="isButton">
      <el-button @click="closeDialog" v-if="isReset">取消</el-button>
20 21
      <el-button type="primary" plain @click="submitForm" v-if="isSave" :disabled="btnDisabled" :loading="saveloding">
        {{ saveButton }}</el-button>
任超 committed
22 23 24 25 26 27
    </div>
  </el-dialog>
</template>
<script>
export default {
  props: {
任超 committed
28 29
    value: { type: Boolean, default: false },
    isMain: {
任超 committed
30
      type: Boolean,
31
      default: false
任超 committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
    },
    isButton: {
      type: Boolean,
      default: true,
    },
    width: {
      type: String,
      default: '70%',
    },
    title: {
      type: String,
      default: '',
    },
    isFullscreen: {
      type: Boolean,
      default: true,
    },
    isSave: {
      type: Boolean,
      default: true,
    },
    saveButton: {
      type: String,
      default: '提交',
    },
    isReset: {
      type: Boolean,
      default: true,
    },
    saveloding: {
      type: Boolean,
      default: false,
    },
65 66 67
    btnDisabled: {
      type: Boolean,
      default: false
任超 committed
68
    }
任超 committed
69 70 71 72 73 74
  },
  data () {
    return {
      key: 0,
      dialogVisible: false,
      fullscreen: false,
任超 committed
75
      scrollerHeight: false,
任超 committed
76 77
    }
  },
任超 committed
78 79 80 81 82
  watch: {
    value (val) {
      this.dialogVisible = val
    }
  },
任超 committed
83
  methods: {
任超 committed
84
    handleFullscreen (val) {
任超 committed
85 86 87 88 89 90 91 92
      this.fullscreen = !this.fullscreen
      let height = document.getElementById('dialogBox').clientHeight
      if (!this.fullscreen) {
        this.scrollerHeight = false
      } else {
        this.scrollerHeight = (window.innerHeight - 180) + 'px'
      }
    },
任超 committed
93
    submitForm () {
94
      if (this.isButton) {
任超 committed
95 96
        this.$emit('submitForm');
      }
任超 committed
97
    },
任超 committed
98
    closeDialog () {
任超 committed
99
      this.key++
任超 committed
100
      this.$emit('input', false)
任超 committed
101
      this.$emit('closeDialog')
任超 committed
102 103 104 105 106
    }
  },
}
</script>
<style rel="stylesheet/scss" lang="scss" >
任超 committed
107
@import "~@/styles/mixin.scss";
任超 committed
108
@import "./dialogBox.scss";
任超 committed
109 110 111 112 113 114 115 116
</style>
<style rel="stylesheet/scss" scoped lang="scss" >
/deep/.is-fullscreen {
  position: absolute;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
}
任超 committed
117
</style>