index.vue
3.94 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<template>
<el-dialog id="baseDialog"
top="15vh"
:close-on-click-modal="false"
:close-on-press-escape="true"
:title="dialogConfig.title"
:width="dialogConfig.width"
:visible.sync="visible"
:show-close="config.showClose"
class="noborder"
:append-to-body="config.appendToBody">
<slot />
<div slot="footer"
v-if="config.isShowFooter">
<el-button type="primary"
@click="confirmBtn"
:loading="$store.state.d2admin.loading.value || btnLoding">
{{ config.confirm_name }}
</el-button>
<el-button v-preventReClick
@click="visible = false">
{{ config.cancel_name }}
</el-button>
</div>
</el-dialog>
</template>
<script>
export default {
name: 'BaseDialog',
directives: {
// 函数节流 监控输入框 提高性能
throttle: {
// 指令的定义
inserted: function (el, obj) {
let timerId = null
let flag = true
el.addEventListener('click', function () {
if (!flag) return
flag = false
timerId && clearTimeout(timerId)
timerId = setTimeout(function () {
flag = true
// 调用绑定在v-throttle上的方法search
obj.value()
}, 1000)
})
}
}
},
props: {
dialogConfig: {
required: false,
type: Object,
default: function () {
return {
title: '提示',
width: '480px'
}
}
},
config: {
required: false,
type: Object,
default: function () {
return {
showClose: true,
appendToBody: false, // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
isShowFooter: true,
cancel_name: '取 消',
confirm_name: '确 定'
}
}
},
isShow: {
// 弹窗是否展示
type: Boolean,
default: false
},
btnLoding: {
// 手动设置确定按钮loding
type: Boolean,
default: false
}
// width: {
// //弹窗宽度
// type: String,
// default: '',
// },
// cancel_name: {
// //取消按钮名称
// type: String,
// default: '取 消',
// },
// confirm_name: {
// //确定按钮名称
// type: String,
// default: '确 定',
// },
// isShowFooter: {
// //是否自定底部
// type: Boolean,
// default: true,
// },
// closeClick: {
// type: Boolean,
// default: false,
// },
// appendToBody: {
// // 是否将自身插入至 body 元素,有嵌套的弹窗时一定要设置
// type: Boolean,
// default: false,
// },
},
data() {
return {}
},
computed: {
visible: {
get() {
return this.isShow
},
set(val) {
this.$emit('update:isShow', false)
}
}
},
methods: {
confirmBtn() {
// 触发保存
this.$emit('handleClick')
}
},
created() {
// console.log('baseDialog')
},
mounted() { }
}
</script>
<style scoped lang="scss">
::v-deep .el-dialog {
// height: 90vh;
border-radius: 6px;
// padding: 0;
overflow: hidden;
.el-dialog__header {
border-bottom: solid 1px #e6e6e6;
border-radius: 6px 6px 0px 0px;
padding: 18px 20px 18px 25px;
.el-dialog__title {
// color: #212121;
color: #333333;
font-family: PingFangSC-Medium;
font-size: 20px;
font-weight: 600;
// font-weight: 16px;
}
.el-dialog__close {
color: #666;
font-weight: 600;
font-size: 20px;
}
}
.el-dialog__body {
box-sizing: border-box;
// padding-left: 25px;
padding: 15px 20px 30px;
color: #333;
max-height: calc(100% - 121px);
// height: calc(100% - 121px);
}
.roleTitle {
margin-right: 40px;
}
}
</style>