@yqg/permission 1.1.2-bate.0 → 1.2.0
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/README.md +4 -3
- package/dist/apply-modal-BBqMmKS2.js +8742 -0
- package/dist/checkbox-item-CFWhXmMU.js +4991 -0
- package/dist/{index-DFUPlAqp.js → index-BAGvIeoy.js} +42 -40
- package/dist/index.js +2 -2
- package/dist/index.umd.cjs +69 -81
- package/dist/{yqg-permission-Cfoxcf-d.js → yqg-permission-Bxzu3bMl.js} +6622 -8594
- package/dist_/345/211/257/346/234/254/apply-modal-Bgd3UWf-.js +8739 -0
- package/dist_/345/211/257/346/234/254/card.png +0 -0
- package/{dist/checkbox-item-BlnmEaiY.js → dist_/345/211/257/346/234/254/checkbox-item-DiIgFuBE.js} +1938 -1647
- package/dist_/345/211/257/346/234/254/dialog.png +0 -0
- package/dist_/345/211/257/346/234/254/image.png +0 -0
- package/dist_/345/211/257/346/234/254/index-CUS1Jydp.js +6164 -0
- package/dist_/345/211/257/346/234/254/index.js +5 -0
- package/dist_/345/211/257/346/234/254/index.umd.cjs +259 -0
- package/dist_/345/211/257/346/234/254/yqg-permission-ChMRXqi6.js +14944 -0
- package/package.json +7 -8
- package/src/App.vue +20 -22
- package/src/assets/apply.png +0 -0
- package/src/assets/applyicon.png +0 -0
- package/src/axios/index.ts +1 -1
- package/src/components/apply-modal.vue +10 -32
- package/src/components/checkbox-item.vue +32 -27
- package/src/components/success-modal.vue +7 -1
- package/src/components/yqg-permission.vue +97 -47
- package/src/hooks/useDragable.ts +136 -0
- package/src/i18n/en-US.ts +21 -21
- package/src/i18n/zh-CH.ts +5 -5
- package/src/typings/index.d.ts +2 -0
- package/vite.config.ts +1 -1
- package/dist/apply-modal-SzDVxN-2.js +0 -6844
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// useDraggable.js
|
|
2
|
+
|
|
3
|
+
import { ref, onBeforeUnmount, watch, onMounted } from 'vue';
|
|
4
|
+
|
|
5
|
+
export default function useDraggable(props: { top: any }, showModal: () => void) {
|
|
6
|
+
const currentTop = ref(0);
|
|
7
|
+
const isDragging = ref(false); // 是否正在拖拽
|
|
8
|
+
const startX = ref(0); // 鼠标按下时的X坐标
|
|
9
|
+
const initialX = ref(0); // 元素初始X坐标
|
|
10
|
+
const initialY = ref(0);
|
|
11
|
+
const dragElement = ref<any>(null);
|
|
12
|
+
|
|
13
|
+
watch(() => props.top, (newVal) => {
|
|
14
|
+
console.log('newVal', newVal);
|
|
15
|
+
currentTop.value = newVal;
|
|
16
|
+
}, { immediate: true });
|
|
17
|
+
|
|
18
|
+
// 获取元素的初始位置
|
|
19
|
+
const getPosition = (el: HTMLElement) => {
|
|
20
|
+
const rect = el.getBoundingClientRect();
|
|
21
|
+
return {
|
|
22
|
+
x: rect.left,
|
|
23
|
+
y: rect.top
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// 限制拖拽元素在屏幕内
|
|
28
|
+
const constrainToScreen = (clientX: number, clientY: number, el: HTMLElement) => {
|
|
29
|
+
const { innerWidth, innerHeight } = window;
|
|
30
|
+
const elRect = el.getBoundingClientRect();
|
|
31
|
+
|
|
32
|
+
const constrainedX = Math.min(Math.max(clientX, 0), innerWidth - elRect.width);
|
|
33
|
+
const constrainedY = Math.min(Math.max(clientY, 0), innerHeight - elRect.height);
|
|
34
|
+
|
|
35
|
+
return { x: constrainedX, y: constrainedY };
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// 鼠标移动时的处理函数
|
|
39
|
+
const onMouseMove = (e: MouseEvent, el: HTMLElement) => {
|
|
40
|
+
if (!isDragging.value) return;
|
|
41
|
+
|
|
42
|
+
// 移动的时候yqg-permission-tooltip隐藏
|
|
43
|
+
const tooltip = document.querySelector('.yqg-permission-tooltip') as HTMLElement;
|
|
44
|
+
if (tooltip) {
|
|
45
|
+
tooltip.style.display = 'none';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { clientX, clientY } = e;
|
|
49
|
+
const { x, y } = constrainToScreen(clientX - startX.value + initialX.value, clientY - currentTop.value + initialY.value, el);
|
|
50
|
+
|
|
51
|
+
el.style.left = `${x}px`;
|
|
52
|
+
el.style.top = `${y}px`;
|
|
53
|
+
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// 鼠标松开时的处理函数
|
|
57
|
+
const onMouseUp = (e: MouseEvent, el: HTMLElement) => {
|
|
58
|
+
if (!isDragging.value) return;
|
|
59
|
+
|
|
60
|
+
// 阻止点击事件触发
|
|
61
|
+
e.preventDefault(); // 阻止默认行为
|
|
62
|
+
e.stopPropagation(); // 阻止事件冒泡
|
|
63
|
+
|
|
64
|
+
// // 获取元素当前的位置
|
|
65
|
+
const { x: currentX, y: currentY } = getPosition(el);
|
|
66
|
+
if ( Math.abs(currentY - initialY.value) < 10 && Math.abs(currentX - initialX.value) < 10) {
|
|
67
|
+
showModal();
|
|
68
|
+
// 卸载拖拽
|
|
69
|
+
isDragging.value = false;
|
|
70
|
+
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
isDragging.value = false;
|
|
76
|
+
const { clientY } = e;
|
|
77
|
+
|
|
78
|
+
// 在鼠标松开时设置x为初始位置,y为鼠标当前位置
|
|
79
|
+
const { x, y } = constrainToScreen(initialX.value, clientY - currentTop.value + initialY.value, el);
|
|
80
|
+
el.style.transition = 'all 0.3s';
|
|
81
|
+
el.style.left = `${x}px`;
|
|
82
|
+
el.style.top = `${y}px`;
|
|
83
|
+
|
|
84
|
+
// 清除事件监听
|
|
85
|
+
document.removeEventListener('mousemove', (e) => onMouseMove(e, el));
|
|
86
|
+
document.removeEventListener('mouseup', (e) => onMouseUp(e, el));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// 鼠标按下时的处理函数
|
|
90
|
+
const onMouseDown = (e: MouseEvent, el: HTMLElement) => {
|
|
91
|
+
isDragging.value = true;
|
|
92
|
+
|
|
93
|
+
// 阻止点击事件触发
|
|
94
|
+
e.preventDefault(); // 阻止默认行为
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
|
|
97
|
+
// 获取鼠标按下时的位置
|
|
98
|
+
startX.value = e.clientX;
|
|
99
|
+
currentTop.value = e.clientY;
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
// 获取元素的初始位置
|
|
103
|
+
const { x, y } = getPosition(el);
|
|
104
|
+
initialX.value = x;
|
|
105
|
+
initialY.value = y;
|
|
106
|
+
el.style.transition = 'none';
|
|
107
|
+
|
|
108
|
+
// 添加鼠标移动和鼠标松开事件监听
|
|
109
|
+
document.addEventListener('mousemove', (e) => onMouseMove(e, el));
|
|
110
|
+
document.addEventListener('mouseup', (e) => onMouseUp(e, el));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// 返回拖拽的绑定方法
|
|
114
|
+
const bindDraggable = () => {
|
|
115
|
+
onMounted(() => {
|
|
116
|
+
const el = dragElement.value?.$el;
|
|
117
|
+
if (el) {
|
|
118
|
+
el.addEventListener('mousedown', (e: MouseEvent) => onMouseDown(e, el));
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
onBeforeUnmount(() => {
|
|
123
|
+
const el = dragElement.value?.$el;
|
|
124
|
+
if (el) {
|
|
125
|
+
el.removeEventListener('mousedown', (e: MouseEvent) => onMouseDown(e, el));
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
bindDraggable();
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
currentTop,
|
|
134
|
+
dragElement,
|
|
135
|
+
};
|
|
136
|
+
}
|
package/src/i18n/en-US.ts
CHANGED
|
@@ -3,35 +3,35 @@ export default {
|
|
|
3
3
|
applyPermission: '申请权限',
|
|
4
4
|
applyReason: '申请理由',
|
|
5
5
|
approvalProcess: '审批流程',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
applyReason3: '数据查询与分析',
|
|
9
|
-
applyReasonPlaceholder: '请尽可能详细描述申请理由',
|
|
6
|
+
applyReasonPlaceholder: '请尽可能详细说明申请原因和使用场景,不要只填写“工作需要”之类的理由,以免影响你获取权限的审批时间。',
|
|
7
|
+
applyReasonTips: '示例:由于XX项目需要,需要查看/操作XXXX场景/问题,涉及到XXX权限的使用,因此提交申请!',
|
|
10
8
|
cancel: '取消',
|
|
11
9
|
submit: '确定',
|
|
12
10
|
close: '关闭',
|
|
13
11
|
viewApprovalDetail: '查看审批详情',
|
|
14
|
-
|
|
12
|
+
applyMore: '继续申请其他权限',
|
|
15
13
|
successTips: '已提交申请,审批通过后可拥有相关权限',
|
|
16
14
|
resoultTitle: '操作结果反馈',
|
|
17
15
|
start: '发起',
|
|
18
16
|
end: '结束',
|
|
19
|
-
|
|
17
|
+
noNeed: '无需审批',
|
|
20
18
|
adaptDepartment: '适用部门',
|
|
21
|
-
|
|
19
|
+
noApprovalProcess: '无审批流程',
|
|
22
20
|
excessTips: '一次最多可申请{number}个权限',
|
|
23
|
-
unavailableTips: '
|
|
21
|
+
unavailableTips: '您暂无权限查看/操作该页面,请点击下方按钮进行申请',
|
|
24
22
|
appliedTips: '权限已申请,正在{status}...',
|
|
25
23
|
unapplyTips: '您暂无权限查看/操作该页面,且该页面中没有您可以申请的权限,',
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
callManager: '如有需要请联系系统管理员',
|
|
25
|
+
manager: '系统管理员',
|
|
28
26
|
availableTime: '有效期',
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
selectPlaceholder: '请选择权限点',
|
|
28
|
+
reasonPlaceholder: '请输入申请理由',
|
|
29
|
+
maxCountTips: '一次最多只可申请{count}个权限',
|
|
30
|
+
maxLengthTips: '最多{length}个字符',
|
|
31
|
+
lastDays: '{count}天后到期',
|
|
32
|
+
taday: '今天到期',
|
|
33
|
+
clickToApply: '点击申请权限',
|
|
34
|
+
noPermissionTips: '该菜单下暂无权限点',
|
|
35
35
|
availiables: {
|
|
36
36
|
SEVEN_DAYS: '7天',
|
|
37
37
|
THIRTY_DAYS: '30天',
|
|
@@ -48,10 +48,10 @@ export default {
|
|
|
48
48
|
PENDING: '审批中',
|
|
49
49
|
NO: '不可申请',
|
|
50
50
|
OWNER: '永久拥有',
|
|
51
|
-
|
|
51
|
+
TEMP_OWNER: '临时拥有',
|
|
52
52
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
operationType: {
|
|
54
|
+
QUERY: '查询',
|
|
55
|
+
MANAGE: '操作',
|
|
56
|
+
}
|
|
57
57
|
};
|
package/src/i18n/zh-CH.ts
CHANGED
|
@@ -3,10 +3,8 @@ export default {
|
|
|
3
3
|
applyPermission: '申请权限',
|
|
4
4
|
applyReason: '申请理由',
|
|
5
5
|
approvalProcess: '审批流程',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
applyReason3: '数据查询与分析',
|
|
9
|
-
applyReasonPlaceholder: '请尽可能详细描述申请理由',
|
|
6
|
+
applyReasonPlaceholder: '请尽可能详细说明申请原因和使用场景,不要只填写“工作需要”之类的理由,以免影响你获取权限的审批时间。',
|
|
7
|
+
applyReasonTips: '示例:由于XX项目需要,需要查看/操作XXXX场景/问题,涉及到XXX权限的使用,因此提交申请!',
|
|
10
8
|
cancel: '取消',
|
|
11
9
|
submit: '确定',
|
|
12
10
|
close: '关闭',
|
|
@@ -20,7 +18,7 @@ export default {
|
|
|
20
18
|
adaptDepartment: '适用部门',
|
|
21
19
|
noApprovalProcess: '无审批流程',
|
|
22
20
|
excessTips: '一次最多可申请{number}个权限',
|
|
23
|
-
unavailableTips: '
|
|
21
|
+
unavailableTips: '您暂无权限查看/操作该页面,请点击下方按钮进行申请',
|
|
24
22
|
appliedTips: '权限已申请,正在{status}...',
|
|
25
23
|
unapplyTips: '您暂无权限查看/操作该页面,且该页面中没有您可以申请的权限,',
|
|
26
24
|
callManager: '如有需要请联系系统管理员',
|
|
@@ -32,6 +30,8 @@ export default {
|
|
|
32
30
|
maxLengthTips: '最多{length}个字符',
|
|
33
31
|
lastDays: '{count}天后到期',
|
|
34
32
|
taday: '今天到期',
|
|
33
|
+
clickToApply: '点击申请权限',
|
|
34
|
+
noPermissionTips: '该菜单下暂无权限点',
|
|
35
35
|
availiables: {
|
|
36
36
|
SEVEN_DAYS: '7天',
|
|
37
37
|
THIRTY_DAYS: '30天',
|
package/src/typings/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ declare type PermissionType = {
|
|
|
21
21
|
operationType: string;
|
|
22
22
|
securityLevel: LevelType;
|
|
23
23
|
relatedDepartments?: any[];
|
|
24
|
+
relatedCompleteNames: string[];
|
|
24
25
|
relatedDepartmentIds?: number[];
|
|
25
26
|
curDepartmentId?: number;
|
|
26
27
|
businessApplyType: StatusType;
|
|
@@ -35,6 +36,7 @@ declare type LevelMapType = {
|
|
|
35
36
|
[key in LevelType]: {
|
|
36
37
|
color: string;
|
|
37
38
|
text: string;
|
|
39
|
+
background: string;
|
|
38
40
|
};
|
|
39
41
|
};
|
|
40
42
|
|