gyyg-components 0.3.11 → 0.3.13

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.11",
3
+ "version": "0.3.13",
4
4
  "private": false,
5
5
  "main": "lib/gyyg-components.umd.js",
6
6
  "scripts": {
@@ -18,13 +18,23 @@
18
18
  @close="closeMethod"
19
19
  :destroy-on-close="destroyOnClose"
20
20
  :modal='modal'
21
+ ref="dialog"
21
22
  >
22
- <div slot="title" style="font-size: 16px; color: #303133;">
23
- <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>
24
31
  <span>{{ title }}</span>
25
32
  </div>
26
33
  <slot name="body" />
27
- <div v-if="footer" slot="footer">
34
+ <div
35
+ v-if="footer"
36
+ slot="footer"
37
+ >
28
38
  <slot name="footer" />
29
39
  </div>
30
40
  </el-dialog>
@@ -77,7 +87,7 @@ export default {
77
87
  type: Boolean
78
88
  },
79
89
  //是否需要遮罩层
80
- modal:{
90
+ modal: {
81
91
  default: true,
82
92
  type: Boolean
83
93
  },
@@ -106,16 +116,24 @@ export default {
106
116
  },
107
117
  computed: {
108
118
  customClass() {
109
- let className = this.dialogClass;
119
+ let className = this.height !== 'auto' ? 'haveHeight-dialog' : this.dialogClass;
110
120
  return className;
111
121
  },
112
122
  },
123
+
113
124
  created() {
114
125
  this.type === "fullscreen" && (this.fullscreen = true);
115
126
  },
116
127
  methods: {
117
128
  open() {
118
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
+
119
137
  },
120
138
  close() {
121
139
  this.visible = false;
@@ -134,18 +152,21 @@ export default {
134
152
  .base-dialog {
135
153
  text-align: left;
136
154
  }
155
+
137
156
  /deep/.el-dialog__wrapper {
138
157
  overflow: hidden;
139
158
  display: flex;
140
159
  justify-content: center;
141
160
  align-items: center;
142
161
  margin: auto 0;
162
+
143
163
  .el-dialog {
144
164
  display: flex;
145
165
  flex-direction: column;
146
166
  border-radius: 8px;
147
167
  margin: 0;
148
168
  margin-top: 0 !important;
169
+
149
170
  .el-dialog__header {
150
171
  text-align: left;
151
172
  background-color: #efefef;
@@ -200,6 +221,7 @@ export default {
200
221
  }
201
222
 
202
223
  .custom-table {
224
+
203
225
  // 取消表格下边线
204
226
  tbody tr:last-child td {
205
227
  border-bottom: none !important;
@@ -219,6 +241,7 @@ export default {
219
241
  .el-dialog__body {
220
242
  padding: 10px;
221
243
  }
244
+
222
245
  .el-dialog__footer {
223
246
  padding: 10px;
224
247
  border: none;
@@ -230,14 +253,12 @@ export default {
230
253
  }
231
254
 
232
255
  .shan-maintenance-dialog {
233
- /deep/ .el-dialog {
234
- height: 90%;
235
- }
256
+ /deep/ .el-dialog {
257
+ height: 90%;
258
+ }
236
259
  }
260
+
237
261
  /deep/ .el-dialog {
238
262
  height: 100%;
239
263
  }
240
- /deep/ .el-dialog {
241
- height: v-bind(height); /* 动态绑定 height */
242
- }
243
264
  </style>
@@ -2,7 +2,7 @@ export default {
2
2
  bind(el, binding, vnode) {
3
3
  const dialogHeaderEl = el.querySelector('.el-dialog__header');
4
4
  const dragDom = el.querySelector('.el-dialog');
5
-
5
+
6
6
  // 设置鼠标样式为可移动
7
7
  dialogHeaderEl.style.cssText += ';cursor:move;';
8
8
 
@@ -15,11 +15,19 @@ export default {
15
15
  }
16
16
  })();
17
17
 
18
+ let isMouseDown = false; // 标记鼠标是否按下
19
+
20
+ // 监听鼠标进入页面时的状态
21
+ document.addEventListener('mouseenter', () => {
22
+ isMouseDown = false; // 确保初始状态为未按下
23
+ });
24
+
18
25
  dialogHeaderEl.onmousedown = (e) => {
26
+ isMouseDown = true; // 鼠标按下时设置为 true
27
+
19
28
  // 鼠标按下时,计算当前元素距离可视区的距离
20
29
  const disX = e.clientX - dialogHeaderEl.offsetLeft;
21
30
  const disY = e.clientY - dialogHeaderEl.offsetTop;
22
- console.log(disX, disY)
23
31
 
24
32
  // 获取初始位置样式
25
33
  let styL = getStyle(dragDom, 'left');
@@ -34,38 +42,46 @@ export default {
34
42
  styT = +styT.replace(/\px/g, '');
35
43
  }
36
44
 
37
- document.onmousemove = function(e) {
38
- // 计算移动的距离
39
- let left = e.clientX - disX;
40
- let top = e.clientY - disY;
41
- console.log(left, top)
45
+ const onMouseMove = (e) => {
46
+ if (!isMouseDown) return; // 如果鼠标未按下,直接返回
42
47
 
43
- // 获取屏幕宽高
44
- const screenWidth = document.body.clientWidth;
45
- const screenHeight = document.body.clientHeight;
48
+ requestAnimationFrame(() => {
49
+ // 计算移动的距离
50
+ let left = e.clientX - disX;
51
+ let top = e.clientY - disY;
46
52
 
47
- // 获取对话框宽高
48
- const dialogWidth = dragDom.offsetWidth;
49
- const dialogHeight = dragDom.offsetHeight;
53
+ // 获取屏幕宽高
54
+ const screenWidth = document.body.clientWidth;
55
+ const screenHeight = document.body.clientHeight;
50
56
 
51
- // 边界限制逻辑
52
- left = Math.max(0, Math.min(left + styL, screenWidth - dialogWidth));
53
- top = Math.max(0, Math.min(top + styT, screenHeight - dialogHeight));
57
+ // 获取对话框宽高
58
+ const dialogWidth = dragDom.offsetWidth;
59
+ const dialogHeight = dragDom.offsetHeight;
54
60
 
55
- // 更新对话框位置
56
- dragDom.style.left = `${left}px`;
57
- dragDom.style.top = `${top}px`;
58
- console.log(left, top)
61
+ // 边界限制逻辑
62
+ left = Math.max(0, Math.min(left + styL, screenWidth - dialogWidth));
63
+ top = Math.max(0, Math.min(top + styT, screenHeight - dialogHeight));
59
64
 
60
- // 触发拖拽事件
61
- vnode.child.$emit('dragDialog');
65
+ // 更新对话框位置
66
+ dragDom.style.left = `${left}px`;
67
+ dragDom.style.top = `${top}px`;
68
+
69
+ // 触发拖拽事件
70
+ vnode.child.$emit('dragDialog');
71
+ });
62
72
  };
63
73
 
64
- document.onmouseup = function() {
74
+ const onMouseUp = () => {
75
+ isMouseDown = false; // 鼠标松开时设置为 false
76
+
65
77
  // 清除事件监听
66
- document.onmousemove = null;
67
- document.onmouseup = null;
78
+ document.removeEventListener('mousemove', onMouseMove);
79
+ document.removeEventListener('mouseup', onMouseUp);
68
80
  };
81
+
82
+ // 绑定事件监听
83
+ document.addEventListener('mousemove', onMouseMove);
84
+ document.addEventListener('mouseup', onMouseUp); // 在 document 上监听 mouseup
69
85
  };
70
- }
86
+ },
71
87
  };
@@ -6,22 +6,20 @@
6
6
  Vue.directive('hasPermi', {
7
7
  inserted(el, binding, vnode) {
8
8
  const { value } = binding
9
- console.log('value',value)
10
9
  const all_permission = "*:*:*";
11
10
  const permissions = localStorage.getItem('authorities').split(',')//用户拥有的权限
12
11
  if (value && value instanceof Array && value.length > 0) {
13
- const permissionFlag = value//
14
-
12
+ const permissionFlag = value.join().split(',')//
13
+ console.log(permissionFlag)
15
14
  const hasPermissions = permissions.some(permission => {
16
15
  return all_permission === permission || permissionFlag.includes(permission)
17
16
  })
17
+ console.log(hasPermissions)
18
18
  if (!hasPermissions) {
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