石广澎
2023-10-20 4cb068fb1d51129be7199cbd83fb0ef1f97915e2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
65
66
67
68
69
70
71
72
<template>
  <!--动画-->
  <transition name="el-fade-in">
    <el-dialog
      :title="title"
      :width="width"
      :modal="false"
      :visible.sync="visible"
      top="150px"
      :append-to-body="false"
      :destroy-on-close="true"
      @close="close"
    >
      <div v-loading="loading">
        <slot/>
      </div>
      <div v-if="$slots.footer" slot="footer">
        <slot name="footer"/>
      </div>
    </el-dialog>
  </transition>
</template>
 
<script>
export default {
  props: {
    loading: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    width: {
      type: String,
      default: '50%'
    }
  },
  data() {
    return {
      visible: true
    }
  },
  mounted() {
    try {
      window.onresize = function () {
        document.querySelectorAll('.cus-dialog').forEach(v => {
          v.style.width = document.querySelector('.app-main').clientWidth + 'px'
          v.style.height = '100%'
        })
      }
      window.onresize()
    } catch (e) {
      console.error(e)
    }
  },
  methods: {
    close() {
      this.visible = false
      this.$emit('close')
    }
  }
}
</script>
 
<style scoped>
>>> .el-dialog__body {
  overflow-y: auto;
  max-height: calc(100vh - 140px);
}
</style>