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
| <template>
| <div :class="{'frame': true, editType: true}">
| <div v-if="editType==='inner'">
| <div v-if="title" class="title">{{ title }}</div>
| <slot></slot>
| <div :class="{'frame-footer': true, 'inner-footer': !!title, 'inner-footer-1': !title}">
| <slot name="footer"></slot>
| </div>
| </div>
| <el-dialog v-dialogDrag v-else :title="title" :top="top" :width="width" :visible.sync="isShowDialog" :before-close="onBeforeClose" class="editor-dialog" append-to-body @opened="opened">
| <slot></slot>
| <div class="frame-footer">
| <slot name="footer"></slot>
| </div>
| </el-dialog>
|
| </div>
| </template>
|
| <script>
| export default {
| name: "yrt-editor-frame",
| props: {
| // 编辑类型:inner、dialog
| editType: {
| type: String,
| default: "dialog"
| },
| // 显示对话框
| visible: {
| type: Boolean,
| default: false
| },
| // 对话框宽度
| width: {
| type: String,
| default: null
| },
| // 标题名称
| title: {
| type: String,
| default: null
| },
| // Dialog CSS 中的 margin-top 值
| top: {
| type: String,
| default: null
| },
| // 关闭前事件
| onBeforeClose: {
| type: Function,
| default: done => {
| done();
| }
| }
| },
| data() {
| return {};
| },
| computed: {
| // 是否显示dialog
| isShowDialog: {
| get: function() {
| return this.visible;
| },
| set: function(newValue) {
| this.$emit("update:visible", newValue); // 双向绑定prop.visible,通知父级组件变量值同步更新
| }
| }
| },
| methods: {
| opened() {
| this.$emit("opened");
| }
| }
| };
| </script>
|
| <style rel="stylesheet/scss" lang="scss" scoped>
| .frame {
| background-color: white;
| padding: 10px;
| padding-bottom: 20px;
| .title {
| padding: 10px;
| }
| &.editType {
| padding: 0px;
| }
| }
|
| .frame-footer {
| margin-top: 20px;
| /deep/ .dialog-footer {
| overflow: hidden;
| /deep/ .el-button--medium {
| padding: 10px 10px;
| font-size: 14px;
| border-radius: 4px;
| }
| }
| &.inner-footer {
| z-index: 100;
| position: fixed;
| bottom: 13px;
| right: 13px;
| background-color: white;
| }
| &.inner-footer-1 {
| z-index: 100;
| margin-bottom: 20px;
| margin-right: 20px;
| background-color: white;
| }
| }
| </style>
|
|