gyyg-components 0.3.10 → 0.3.11

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.11",
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,7 +18,6 @@
18
18
  @close="closeMethod"
19
19
  :destroy-on-close="destroyOnClose"
20
20
  :modal='modal'
21
- :style="'height:' + height"
22
21
  >
23
22
  <div slot="title" style="font-size: 16px; color: #303133;">
24
23
  <el-icon :class="titleIcon" style="color: #1890ff; font-size: 18px;margin-right: 5px;"></el-icon>
@@ -229,12 +228,16 @@ export default {
229
228
  }
230
229
  }
231
230
  }
232
- /deep/ .el-dialog {
233
- height: 100%;
234
- }
231
+
235
232
  .shan-maintenance-dialog {
236
233
  /deep/ .el-dialog {
237
234
  height: 90%;
238
235
  }
239
236
  }
237
+ /deep/ .el-dialog {
238
+ height: 100%;
239
+ }
240
+ /deep/ .el-dialog {
241
+ height: v-bind(height); /* 动态绑定 height */
242
+ }
240
243
  </style>
@@ -1,64 +1,71 @@
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;
22
+ console.log(disX, disY)
20
23
 
21
- // 获取到的值带px 正则匹配替换
22
- let styL = getStyle(dragDom, 'left')
23
- let styT = getStyle(dragDom, 'top')
24
+ // 获取初始位置样式
25
+ let styL = getStyle(dragDom, 'left');
26
+ let styT = getStyle(dragDom, 'top');
24
27
 
28
+ // 如果样式值包含百分比,则转换为像素值
25
29
  if (styL.includes('%')) {
26
- styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100)
27
- styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100)
30
+ styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100);
31
+ styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100);
28
32
  } else {
29
- styL = +styL.replace(/\px/g, '')
30
- styT = +styT.replace(/\px/g, '')
33
+ styL = +styL.replace(/\px/g, '');
34
+ styT = +styT.replace(/\px/g, '');
31
35
  }
32
36
 
33
37
  document.onmousemove = function(e) {
34
- // 通过事件委托,计算移动的距离
35
- let left = e.clientX - disX
36
- let top = e.clientY - disY
38
+ // 计算移动的距离
39
+ let left = e.clientX - disX;
40
+ let top = e.clientY - disY;
41
+ console.log(left, top)
37
42
 
38
- // 边界处理
39
- // if (-(left) > minDragDomLeft) {
40
- // left = -minDragDomLeft
41
- // } else if (left > maxDragDomLeft) {
42
- // left = maxDragDomLeft
43
- // }
43
+ // 获取屏幕宽高
44
+ const screenWidth = document.body.clientWidth;
45
+ const screenHeight = document.body.clientHeight;
44
46
 
45
- // if (-(top) > minDragDomTop) {
46
- // top = -minDragDomTop
47
- // } else if (top > maxDragDomTop) {
48
- // top = maxDragDomTop
49
- // }
47
+ // 获取对话框宽高
48
+ const dialogWidth = dragDom.offsetWidth;
49
+ const dialogHeight = dragDom.offsetHeight;
50
50
 
51
- // 移动当前元素
52
- dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`
51
+ // 边界限制逻辑
52
+ left = Math.max(0, Math.min(left + styL, screenWidth - dialogWidth));
53
+ top = Math.max(0, Math.min(top + styT, screenHeight - dialogHeight));
53
54
 
54
- // emit onDrag event
55
- vnode.child.$emit('dragDialog')
56
- }
55
+ // 更新对话框位置
56
+ dragDom.style.left = `${left}px`;
57
+ dragDom.style.top = `${top}px`;
58
+ console.log(left, top)
57
59
 
58
- document.onmouseup = function(e) {
59
- document.onmousemove = null
60
- document.onmouseup = null
61
- }
62
- }
60
+ // 触发拖拽事件
61
+ vnode.child.$emit('dragDialog');
62
+ };
63
+
64
+ document.onmouseup = function() {
65
+ // 清除事件监听
66
+ document.onmousemove = null;
67
+ document.onmouseup = null;
68
+ };
69
+ };
63
70
  }
64
- }
71
+ };