Blame view

src/components/Dialog/index.vue 3.85 KB
xiaomiao committed
1
<template>
任超 committed
2 3 4
  <el-dialog :title="title" :visible.sync="visible" :width="width" :append-to-body="appendToBody" :modal="modal"
    :close-on-click-modal="false" :fullscreen="fullscreen" :destroy-on-close="destroyOnClose"
    :modal-append-to-body="modalAppendToBody" :class="customClass" @close="close" class="dialog">
xiaomiao committed
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
    <slot name="content" />
    <span slot="footer" class="dialog-footer">
      <slot name="footer" />
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: '',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    customClass: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: '新增'
    },
    appendToBody: {
      // Dialog 自身是否插入至 body 元素上。嵌套的 Dialog 必须指定该属性并赋值为 true
      type: Boolean,
      default: true
    },
    modalAppendToBody: {
      // 遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Dialog 的父元素上
      type: Boolean,
      default: true
    },
    modal: {
      // 是否需要遮罩层
      type: Boolean,
      default: true
    },
    fullscreen: {
      // 是否全屏
      type: Boolean,
      default: false
    },
    destroyOnClose: {
      // 关闭时销毁 Dialog 中的元素
      type: Boolean,
      default: false
    },
    width: {
      type: String,
      default: '30%'
    }
  },
任超 committed
58
  data () {
xiaomiao committed
59 60 61 62
    return {}
  },
  computed: {
    visible: {
任超 committed
63
      get () {
xiaomiao committed
64 65
        return this.show
      },
任超 committed
66
      set (val) {
xiaomiao committed
67 68 69 70 71
        this.$emit('update:show', val) // visible 改变的时候通知父组件
      }
    }
  },
  methods: {
任超 committed
72
    close () {
xiaomiao committed
73 74 75 76 77 78 79 80
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" scoped>
.dialog {
任超 committed
81 82 83 84
  /deep/.el-dialog {
    overflow: hidden;
    background: url("~@/image/dialogBg.png") no-repeat !important;
    background-size: 100% 100% !important;
xiaomiao committed
85
  }
任超 committed
86

xiaomiao committed
87 88 89 90 91
  .el-dialog__header {
    padding: 0;
    height: 56px;
    line-height: 56px;
    border-bottom: none;
任超 committed
92

xiaomiao committed
93 94 95
    .el-dialog__title {
      font-weight: 400;
    }
任超 committed
96

xiaomiao committed
97 98 99 100 101 102 103 104 105 106 107
    .el-dialog__title:before {
      display: inline-block;
      content: '';
      width: 4px;
      height: 16px;
      background: #3aa3f8;
      margin-left: 12px;
      margin-right: 8px;
      position: relative;
      top: 2px;
    }
任超 committed
108

xiaomiao committed
109 110 111 112 113 114
    .el-dialog__headerbtn {
      position: absolute;
      // top: 2%;
      right: 12px;
    }
  }
任超 committed
115

xiaomiao committed
116 117 118 119 120
  .el-dialog__body {
    margin: 0px 12px;
    padding: 48px 24px;
    background: #fff;
    border: 1px solid #dfe7f3;
任超 committed
121

xiaomiao committed
122 123 124 125
    .el-button {
      padding: 8px 16px;
      border: none;
    }
任超 committed
126

xiaomiao committed
127 128 129 130 131
    .el-form {
      .el-checkbox {
        line-height: 32px;
        height: 32px;
      }
任超 committed
132

xiaomiao committed
133 134 135
      .form-item-mb0 {
        margin-bottom: 0 !important;
      }
任超 committed
136

xiaomiao committed
137 138
      .el-form-item {
        margin-bottom: 24px;
任超 committed
139

xiaomiao committed
140 141 142 143 144 145 146 147 148
        .el-form-item__label {
          height: 32px;
          line-height: 32px;
          vertical-align: middle;
        }

        .el-form-item__content {
          // height: 32px;
          line-height: 32px;
任超 committed
149

xiaomiao committed
150 151 152 153 154 155
          // date 组件有图标
          .has-icon.el-date-editor {
            .el-input__inner {
              padding-left: 32px;
            }
          }
任超 committed
156

xiaomiao committed
157 158 159 160 161 162
          .el-input__inner {
            padding: 0 8px;
            height: 32px;
            line-height: 32px;
            text-align: left;
          }
任超 committed
163

xiaomiao committed
164 165 166
          .el-textarea__inner {
            padding: 8px 8px;
          }
任超 committed
167

xiaomiao committed
168 169 170 171 172 173 174
          .el-input .el-input__icon {
            font-size: 14px;
            color: #747e8c;
          }
        }
      }
    }
任超 committed
175

xiaomiao committed
176 177 178 179 180 181 182 183 184 185 186 187 188
    .el-select,
    .el-cascader,
    .el-date-editor {
      width: 100%;
      line-height: 32px;
    }
  }

  .el-dialog__footer {
    padding: 0 12px;
    height: 56px;
    line-height: 56px;
    border: none;
任超 committed
189

xiaomiao committed
190 191 192 193
    .el-button {
      padding: 8px 16px;
      border: none;
    }
任超 committed
194 195

    .el-button+.el-button {
xiaomiao committed
196 197 198 199 200
      margin-left: 12px;
    }
  }
}
</style>