123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <div class="drawer-dialog">
- <el-drawer
- :custom-class="customClass"
- :show-close="showClose"
- :append-to-body="false"
- :visible.sync="drawerFlag"
- :direction="direction"
- :size="percent"
- :withHeader="withHeader"
- @before-close="beforeClose"
- @close="close"
- >
- <div class="el-container">
- <div class="el-header">
- <div slot="title">{{ title }}</div>
- </div>
- <div class="el-main">
- <slot></slot>
- </div>
- <div class="el-footer">
- <el-button class="el-btn el-save" @click="saveData">{{ confirmText }}</el-button>
- <el-button class="el-btn el-cancel" @click="close">{{ cancelText }}</el-button>
- </div>
- </div>
- </el-drawer>
- </div>
- </template>
- <script>
- import { Drawer, Button } from 'element-ui'
- export default {
- name: 'drawer-dialog',
- components: {
- [Drawer.name]: Drawer,
- [Button.name]: Button
- },
- props: {
- showDrawer: {
- type: Boolean,
- default: false
- },
- customClass: {
- type: String,
- default: ''
- },
- confirmText: {
- type: String,
- default: '保存设置'
- },
- cancelText: {
- type: String,
- default: '取消'
- },
- percent: {
- type: String,
- default: '42%'
- },
- direction: {
- type: String,
- default () {
- return 'rtl'
- }
- },
- // 控制是否显示 header 栏, 默认为 true, 当此项为 false 时, title attribute 和 title slot 均不生效
- withHeader: {
- type: Boolean,
- default: true
- },
- title: {
- type: String,
- default: ''
- },
- showClose: {
- type: Boolean,
- default: false
- }
- },
- model: {
- prop: 'showDrawer',
- event: 'change'
- },
- data () {
- return {
- drawerFlag: this.showDrawer
- }
- },
- watch: {
- showDrawer (val) {
- this.drawerFlag = val
- }
- },
- methods: {
- saveData () {
- this.$emit('saveData')
- },
- // 关闭回调
- close () {
- this.drawerFlag = false
- this.$emit('close', this.drawerFlag)
- },
- // 关闭前的回调,会暂停 Drawer 的关闭
- beforeClose () {
- this.$emit('beforeClose')
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .drawer-dialog{
- }
- ::v-deep .el-drawer__body{
- height: 100%;
- .el-container{
- display: flex;
- justify-content: space-between;
- flex-direction: column;
- height: 100%;
- }
- .el-main{
- flex: 1;
- overflow-y: scroll;
- padding: 0!important;
- }
- .el-footer {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 100%;
- width: -moz-available;
- width: -webkit-fill-available;
- height: 72px;
- background: #FFFFFF;
- box-shadow: 0px -8px 8px 0px rgba(0,0,0,0.05);
- .el-btn{
- padding: 7px 34px;
- min-width: 132px;
- height: 36px;
- border-radius: 6px;
- border: 1px solid #2CB7CA;
- color: #2CB7CA;
- &.el-cancel {
- margin-left: 40px;
- color: #686868;
- border: 1px solid #E0E0E0;
- }
- }
- }
- }
- </style>
|