gyyg-components 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gyyg-components",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -163,6 +163,7 @@ export default {
163
163
 
164
164
  /deep/ .el-descriptions__body .el-descriptions__table .el-descriptions-item__cell {
165
165
  white-space: pre-wrap;
166
+ vertical-align: top;
166
167
  }
167
168
 
168
169
  /deep/ .el-progress-bar {
@@ -18,14 +18,23 @@
18
18
  @close="closeMethod"
19
19
  :destroy-on-close="destroyOnClose"
20
20
  :modal='modal'
21
- :style="'height:' + height"
21
+ ref="dialog"
22
22
  >
23
- <div slot="title" style="font-size: 16px; color: #303133;">
24
- <el-icon :class="titleIcon" style="color: #1890ff; font-size: 18px;margin-right: 5px;"></el-icon>
23
+ <div
24
+ slot="title"
25
+ style="font-size: 16px; color: #303133;"
26
+ >
27
+ <el-icon
28
+ :class="titleIcon"
29
+ style="color: #1890ff; font-size: 18px;margin-right: 5px;"
30
+ ></el-icon>
25
31
  <span>{{ title }}</span>
26
32
  </div>
27
33
  <slot name="body" />
28
- <div v-if="footer" slot="footer">
34
+ <div
35
+ v-if="footer"
36
+ slot="footer"
37
+ >
29
38
  <slot name="footer" />
30
39
  </div>
31
40
  </el-dialog>
@@ -78,7 +87,7 @@ export default {
78
87
  type: Boolean
79
88
  },
80
89
  //是否需要遮罩层
81
- modal:{
90
+ modal: {
82
91
  default: true,
83
92
  type: Boolean
84
93
  },
@@ -107,16 +116,24 @@ export default {
107
116
  },
108
117
  computed: {
109
118
  customClass() {
110
- let className = this.dialogClass;
119
+ let className = this.height !== 'auto' ? 'haveHeight-dialog' : this.dialogClass;
111
120
  return className;
112
121
  },
113
122
  },
123
+
114
124
  created() {
115
125
  this.type === "fullscreen" && (this.fullscreen = true);
116
126
  },
117
127
  methods: {
118
128
  open() {
119
129
  this.visible = true;
130
+ console.log(this.height)
131
+ if(this.height !== 'auto' && this.height) {
132
+ this.$nextTick(() => {
133
+ this.$refs.dialog.$el.firstElementChild.style.height = this.height;
134
+ });
135
+ }
136
+
120
137
  },
121
138
  close() {
122
139
  this.visible = false;
@@ -135,18 +152,21 @@ export default {
135
152
  .base-dialog {
136
153
  text-align: left;
137
154
  }
155
+
138
156
  /deep/.el-dialog__wrapper {
139
157
  overflow: hidden;
140
158
  display: flex;
141
159
  justify-content: center;
142
160
  align-items: center;
143
161
  margin: auto 0;
162
+
144
163
  .el-dialog {
145
164
  display: flex;
146
165
  flex-direction: column;
147
166
  border-radius: 8px;
148
167
  margin: 0;
149
168
  margin-top: 0 !important;
169
+
150
170
  .el-dialog__header {
151
171
  text-align: left;
152
172
  background-color: #efefef;
@@ -201,6 +221,7 @@ export default {
201
221
  }
202
222
 
203
223
  .custom-table {
224
+
204
225
  // 取消表格下边线
205
226
  tbody tr:last-child td {
206
227
  border-bottom: none !important;
@@ -220,6 +241,7 @@ export default {
220
241
  .el-dialog__body {
221
242
  padding: 10px;
222
243
  }
244
+
223
245
  .el-dialog__footer {
224
246
  padding: 10px;
225
247
  border: none;
@@ -229,12 +251,14 @@ export default {
229
251
  }
230
252
  }
231
253
  }
254
+
255
+ .shan-maintenance-dialog {
256
+ /deep/ .el-dialog {
257
+ height: 90%;
258
+ }
259
+ }
260
+
232
261
  /deep/ .el-dialog {
233
262
  height: 100%;
234
263
  }
235
- .shan-maintenance-dialog {
236
- /deep/ .el-dialog {
237
- height: 90%;
238
- }
239
- }
240
264
  </style>
@@ -1,64 +1,68 @@
1
1
  export default {
2
2
  bind(el, binding, vnode) {
3
- const dialogHeaderEl = el.querySelector('.el-dialog__header')
4
- const dragDom = el.querySelector('.el-dialog')
5
- dialogHeaderEl.style.cssText += ';cursor:move;'
3
+ const dialogHeaderEl = el.querySelector('.el-dialog__header');
4
+ const dragDom = el.querySelector('.el-dialog');
5
+
6
+ // 设置鼠标样式为可移动
7
+ dialogHeaderEl.style.cssText += ';cursor:move;';
6
8
 
7
- // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
9
+ // 获取元素样式兼容方法
8
10
  const getStyle = (function() {
9
11
  if (window.document.currentStyle) {
10
- return (dom, attr) => dom.currentStyle[attr]
12
+ return (dom, attr) => dom.currentStyle[attr];
11
13
  } else {
12
- return (dom, attr) => getComputedStyle(dom, false)[attr]
14
+ return (dom, attr) => getComputedStyle(dom, false)[attr];
13
15
  }
14
- })()
16
+ })();
15
17
 
16
18
  dialogHeaderEl.onmousedown = (e) => {
17
- // 鼠标按下,计算当前元素距离可视区的距离
18
- const disX = e.clientX - dialogHeaderEl.offsetLeft
19
- const disY = e.clientY - dialogHeaderEl.offsetTop
19
+ // 鼠标按下时,计算当前元素距离可视区的距离
20
+ const disX = e.clientX - dialogHeaderEl.offsetLeft;
21
+ const disY = e.clientY - dialogHeaderEl.offsetTop;
20
22
 
21
- // 获取到的值带px 正则匹配替换
22
- let styL = getStyle(dragDom, 'left')
23
- let styT = getStyle(dragDom, 'top')
23
+ // 获取初始位置样式
24
+ let styL = getStyle(dragDom, 'left');
25
+ let styT = getStyle(dragDom, 'top');
24
26
 
27
+ // 如果样式值包含百分比,则转换为像素值
25
28
  if (styL.includes('%')) {
26
- styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100)
27
- styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100)
29
+ styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100);
30
+ styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100);
28
31
  } else {
29
- styL = +styL.replace(/\px/g, '')
30
- styT = +styT.replace(/\px/g, '')
32
+ styL = +styL.replace(/\px/g, '');
33
+ styT = +styT.replace(/\px/g, '');
31
34
  }
32
35
 
33
36
  document.onmousemove = function(e) {
34
- // 通过事件委托,计算移动的距离
35
- let left = e.clientX - disX
36
- let top = e.clientY - disY
37
+ // 计算移动的距离
38
+ let left = e.clientX - disX;
39
+ let top = e.clientY - disY;
40
+ console.log(left, top)
37
41
 
38
- // 边界处理
39
- // if (-(left) > minDragDomLeft) {
40
- // left = -minDragDomLeft
41
- // } else if (left > maxDragDomLeft) {
42
- // left = maxDragDomLeft
43
- // }
42
+ // 获取屏幕宽高
43
+ const screenWidth = document.body.clientWidth;
44
+ const screenHeight = document.body.clientHeight;
44
45
 
45
- // if (-(top) > minDragDomTop) {
46
- // top = -minDragDomTop
47
- // } else if (top > maxDragDomTop) {
48
- // top = maxDragDomTop
49
- // }
46
+ // 获取对话框宽高
47
+ const dialogWidth = dragDom.offsetWidth;
48
+ const dialogHeight = dragDom.offsetHeight;
50
49
 
51
- // 移动当前元素
52
- dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`
50
+ // 边界限制逻辑
51
+ left = Math.max(0, Math.min(left + styL, screenWidth - dialogWidth));
52
+ top = Math.max(0, Math.min(top + styT, screenHeight - dialogHeight));
53
53
 
54
- // emit onDrag event
55
- vnode.child.$emit('dragDialog')
56
- }
54
+ // 更新对话框位置
55
+ dragDom.style.left = `${left}px`;
56
+ dragDom.style.top = `${top}px`;
57
+ // 触发拖拽事件
58
+ vnode.child.$emit('dragDialog');
59
+ };
57
60
 
58
- document.onmouseup = function(e) {
59
- document.onmousemove = null
60
- document.onmouseup = null
61
- }
62
- }
61
+ document.onmouseup = function() {
62
+ // 清除事件监听
63
+ document.onmousemove = null;
64
+ document.onmouseup = null;
65
+ };
66
+ };
63
67
  }
64
- }
68
+ };
@@ -19,9 +19,7 @@
19
19
  console.log(el.parentNode);
20
20
  el.parentNode && el.parentNode.removeChild(el)
21
21
  }
22
- } else {
23
- throw new Error(`请设置操作权限标签值`)
24
- }
22
+ }
25
23
  }
26
24
  })
27
25