Blame view

src/components/dialogBox/dialogBox.vue 2.96 KB
任超 committed
1
<template>
任超 committed
2 3
  <el-dialog :visible.sync="dialogVisible" v-if="dialogVisible" :width="width" :fullscreen="fullscreen" top="0"
    :append-to-body="appendToBody" :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
    },
任超 committed
33 34
    appendToBody: {
      type: Boolean,
任超 committed
35
      default: true
任超 committed
36
    },
任超 committed
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 65 66 67 68
    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,
    },
69 70 71
    btnDisabled: {
      type: Boolean,
      default: false
任超 committed
72
    }
任超 committed
73 74 75 76 77 78
  },
  data () {
    return {
      key: 0,
      dialogVisible: false,
      fullscreen: false,
任超 committed
79
      scrollerHeight: false,
任超 committed
80 81
    }
  },
任超 committed
82 83 84 85 86
  watch: {
    value (val) {
      this.dialogVisible = val
    }
  },
任超 committed
87
  methods: {
任超 committed
88
    handleFullscreen (val) {
任超 committed
89 90 91 92 93 94 95 96
      this.fullscreen = !this.fullscreen
      let height = document.getElementById('dialogBox').clientHeight
      if (!this.fullscreen) {
        this.scrollerHeight = false
      } else {
        this.scrollerHeight = (window.innerHeight - 180) + 'px'
      }
    },
任超 committed
97
    submitForm () {
98
      if (this.isButton) {
任超 committed
99 100
        this.$emit('submitForm');
      }
任超 committed
101
    },
任超 committed
102
    closeDialog () {
任超 committed
103
      this.key++
任超 committed
104
      this.$emit('input', false)
任超 committed
105
      this.$emit('closeDialog')
任超 committed
106 107 108 109 110
    }
  },
}
</script>
<style rel="stylesheet/scss" lang="scss" >
任超 committed
111
@import "~@/styles/mixin.scss";
任超 committed
112
@import "./dialogBox.scss";
任超 committed
113 114 115 116 117 118 119 120
</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
121
</style>