@yqg/permission 1.3.0 → 1.3.1-1.bate.1
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/dist/{apply-modal-Ct9rKeUf.js → apply-modal-BFzYTq8s.js} +3886 -4164
- package/dist/{category-selector-BnUMBDty.js → category-selector-3bIJ-OEr.js} +153 -149
- package/dist/{index-XvlOgi6s.js → index-Cnz2SLUX.js} +1828 -1836
- package/dist/{index-CAVNFmBo.js → index-qdB6FW1K.js} +4 -4
- package/dist/index.js +2 -2
- package/dist/permission-item-C6tr81T4.js +1252 -0
- package/dist/{yqg-permission-BrOMv4sA.js → yqg-permission-BPhYJ3ps.js} +3738 -3696
- package/dist/yqg-permission.umd.js +65 -65
- package/package.json +9 -10
- package/src/App.vue +8 -12
- package/src/axios/index.ts +1 -1
- package/src/components/apply-modal.vue +160 -73
- package/src/components/approval-steps.vue +39 -40
- package/src/components/category-selector.vue +15 -8
- package/src/components/permission-item.vue +49 -37
- package/src/components/success-modal.vue +45 -45
- package/src/components/yqg-permission.vue +169 -144
- package/src/hooks/useCategory.ts +1 -1
- package/src/hooks/useFormat.ts +20 -7
- package/src/i18n/en-US.ts +50 -50
- package/src/i18n/in-ID.ts +57 -0
- package/src/i18n/index.ts +5 -2
- package/src/i18n/zh-CH.ts +2 -9
- package/src/style/reset.css +3 -0
- package/src/typings/index.d.ts +1 -0
- package/src/utils/index.ts +16 -2
- package/tsconfig.app.json +8 -8
- package/dist/permission-item-2JurQrn-.js +0 -1250
package/src/hooks/useFormat.ts
CHANGED
|
@@ -8,7 +8,9 @@ const StatusType = {
|
|
|
8
8
|
OWNER: 'OWNER',
|
|
9
9
|
TEMP_OWNER: 'TEMP_OWNER'
|
|
10
10
|
}
|
|
11
|
-
export default function useFormat(tree: PermissionListType) {
|
|
11
|
+
export default function useFormat(tree: PermissionListType, needOmitCategoryIds: number[] = []) {
|
|
12
|
+
const checkList: string[] = [];
|
|
13
|
+
let allCount: number = 0;
|
|
12
14
|
function sortTree(
|
|
13
15
|
tree: PermissionListType,
|
|
14
16
|
sortMap: Map<string | null, number>,
|
|
@@ -16,26 +18,33 @@ export default function useFormat(tree: PermissionListType) {
|
|
|
16
18
|
) {
|
|
17
19
|
return tree.map((node) => {
|
|
18
20
|
node.key = node.feature;
|
|
19
|
-
|
|
21
|
+
allCount++;
|
|
20
22
|
if (!node.children || node.children.length === 0) {
|
|
21
|
-
node.categoryVOS = (node.categoryVOS || []).filter((item: any) => item.configWay !== Category.AUTO);
|
|
23
|
+
node.categoryVOS = (node.categoryVOS || []).filter((item: any) => (item.configWay !== Category.AUTO) && !needOmitCategoryIds.includes(item.id));
|
|
22
24
|
|
|
23
|
-
if ([StatusType.NO
|
|
25
|
+
if ([StatusType.NO].includes(node.businessApplyType)) {
|
|
24
26
|
node.disabled = true;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
if ([StatusType.OWNER].includes(node.businessApplyType) && !node.categoryVOS.length) {
|
|
29
|
+
if (([StatusType.OWNER].includes(node.businessApplyType) && !node.categoryVOS.length) || [StatusType.PENDING].includes(node.businessApplyType)) {
|
|
28
30
|
node.disabled = true;
|
|
31
|
+
checkList.push(node.feature);
|
|
29
32
|
}
|
|
30
33
|
} else {
|
|
31
34
|
// 递归对子节点进行排序
|
|
32
35
|
node.children = sortTree(node.children, sortMap, levelSortMap);
|
|
33
36
|
|
|
37
|
+
// 如果所有子节点都在 checkList 中,那么当前节点也加入 checkList
|
|
38
|
+
if (node.children.every((child) => checkList.includes(child.feature))) {
|
|
39
|
+
checkList.push(node.feature);
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
// 检查所有子节点是否 `disabled === true`
|
|
35
43
|
if (node.children.every((child) => child.disabled)) {
|
|
36
44
|
node.disabled = true;
|
|
37
45
|
}
|
|
38
|
-
}
|
|
46
|
+
};
|
|
47
|
+
|
|
39
48
|
|
|
40
49
|
return node;
|
|
41
50
|
}).sort((a, b) => {
|
|
@@ -51,6 +60,10 @@ export default function useFormat(tree: PermissionListType) {
|
|
|
51
60
|
const sortMap = new Map(sort.map((value, index) => [value, index]));
|
|
52
61
|
const levelSortMap = new Map(levelSort.map((value, index) => [value, index]));
|
|
53
62
|
|
|
54
|
-
return
|
|
63
|
+
return {
|
|
64
|
+
data: sortTree(tree, sortMap, levelSortMap),
|
|
65
|
+
checkList,
|
|
66
|
+
isAllChecked: allCount === checkList.length
|
|
67
|
+
};
|
|
55
68
|
}
|
|
56
69
|
|
package/src/i18n/en-US.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
permissionApply: '
|
|
3
|
-
applyPermission: '
|
|
4
|
-
applyReason: '
|
|
5
|
-
approvalProcess: '
|
|
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
|
-
},
|
|
2
|
+
permissionApply: 'Permission Application',
|
|
3
|
+
applyPermission: 'Apply for Permission',
|
|
4
|
+
applyReason: 'Application Reason',
|
|
5
|
+
approvalProcess: 'Approval Process',
|
|
6
|
+
isAllOwnTips: 'The current page already has permission or is under approval, no need to apply',
|
|
7
|
+
applyReasonPlaceholder: 'Please describe your reason and usage scenario in detail. Avoid vague explanations like "work needs" to prevent delays in approval.',
|
|
8
|
+
applyReasonTips: 'Example: Due to requirements of XX project, need to view/operate XXXX scenario/issue, which involves the use of XXX permission, hence submitting this application!',
|
|
9
|
+
cancel: 'Cancel',
|
|
10
|
+
submit: 'Confirm',
|
|
11
|
+
close: 'Close',
|
|
12
|
+
viewApprovalDetail: 'View Approval Details',
|
|
13
|
+
applyMore: 'Continue applying for other permissions',
|
|
14
|
+
successTips: 'Application submitted. Relevant permissions will be granted upon approval.',
|
|
15
|
+
resoultTitle: 'Operation Result Feedback',
|
|
16
|
+
start: 'Start',
|
|
17
|
+
end: 'End',
|
|
18
|
+
noNeed: 'No Approval Required',
|
|
19
|
+
adaptDepartment: 'Applicable Department',
|
|
20
|
+
noApprovalProcess: 'No approval process required',
|
|
21
|
+
excessTips: 'You can apply for up to {number} permissions at a time',
|
|
22
|
+
unavailableTips: 'You currently don\'t have permission to view/operate this page. Please click the button below to apply.',
|
|
23
|
+
appliedTips: 'Permission request submitted, currently {status}...',
|
|
24
|
+
unapplyTips: 'You don’t have permission to view or operate this page. There are no available permissions to apply for.',
|
|
25
|
+
callManager: 'If needed, please contact the system administrator',
|
|
26
|
+
manager: 'System Administrator',
|
|
27
|
+
availableTime: 'Validity Period',
|
|
28
|
+
selectPlaceholder: 'Please select permission points',
|
|
29
|
+
reasonPlaceholder: 'Please enter your reason for applying',
|
|
30
|
+
pleaseChoose: 'Please select',
|
|
31
|
+
maxCountTips: 'You can apply for up to {count} permissions at a time',
|
|
32
|
+
maxLengthTips: 'Up to {length} characters',
|
|
33
|
+
today: 'Expires today',
|
|
34
|
+
clickToApply: 'Click to apply for permission',
|
|
35
|
+
noPermissionTips: 'There are no permission points under this menu, no need to apply',
|
|
36
|
+
lastDays: '{count} days',
|
|
37
|
+
categoryTips: 'Your current data scope:',
|
|
38
|
+
empty: 'None',
|
|
39
|
+
category: 'Data Permission',
|
|
40
|
+
categotySelectTips: 'The selected permissions include data scope settings. Please apply for or update the scope based on your actual needs.',
|
|
41
|
+
categoryChangeTips: 'Please verify whether full access to "{category}" is necessary for your role. Be sure to explain the use case clearly in your application to avoid rejection.',
|
|
42
42
|
levels: {
|
|
43
|
-
L1: '
|
|
44
|
-
L2: '
|
|
45
|
-
L3: '
|
|
43
|
+
L1: 'Low',
|
|
44
|
+
L2: 'Medium',
|
|
45
|
+
L3: 'High',
|
|
46
46
|
},
|
|
47
47
|
status: {
|
|
48
|
-
PENDING: '
|
|
49
|
-
NO: '
|
|
50
|
-
OWNER: '
|
|
51
|
-
TEMP_OWNER: '
|
|
48
|
+
PENDING: 'Under review',
|
|
49
|
+
NO: 'Not applicable for application',
|
|
50
|
+
OWNER: 'Permanent permission',
|
|
51
|
+
TEMP_OWNER: 'Temporary permission',
|
|
52
52
|
},
|
|
53
53
|
operationType: {
|
|
54
|
-
QUERY: '
|
|
55
|
-
MANAGE: '
|
|
54
|
+
QUERY: 'Query',
|
|
55
|
+
MANAGE: 'Action',
|
|
56
56
|
}
|
|
57
|
-
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
permissionApply: 'Aplikasi Izin',
|
|
3
|
+
applyPermission: 'Ajukan Permohonan Izin',
|
|
4
|
+
applyReason: 'Alasan Permohonan',
|
|
5
|
+
approvalProcess: 'Proses Persetujuan',
|
|
6
|
+
isAllOwnTips: 'Halaman ini sudah memiliki izin atau sedang dalam proses persetujuan, tidak perlu mengajukan permohonan',
|
|
7
|
+
applyReasonPlaceholder: 'Harap jelaskan alasan dan skenario penggunaan secara detail. Hindari penjelasan yang tidak jelas seperti "kebutuhan kerja" untuk mencegah penundaan persetujuan.',
|
|
8
|
+
applyReasonTips: 'Contoh: Karena kebutuhan proyek XX, perlu melihat/mengoperasikan skenario/masalah XXXX, yang melibatkan penggunaan izin XXX, oleh karena itu mengajukan permohonan ini!',
|
|
9
|
+
cancel: 'Batal',
|
|
10
|
+
submit: 'Konfirmasi',
|
|
11
|
+
close: 'Tutup',
|
|
12
|
+
viewApprovalDetail: 'Lihat Detail Persetujuan',
|
|
13
|
+
applyMore: 'Lanjutkan mengajukan izin lainnya',
|
|
14
|
+
successTips: 'Permohonan telah diajukan. Izin terkait akan diberikan setelah disetujui.',
|
|
15
|
+
resoultTitle: 'Umpan Balik Hasil Operasi',
|
|
16
|
+
start: 'Mulai',
|
|
17
|
+
end: 'Selesai',
|
|
18
|
+
noNeed: 'Tidak Perlu Persetujuan',
|
|
19
|
+
adaptDepartment: 'Departemen yang Berlaku',
|
|
20
|
+
noApprovalProcess: 'Tidak perlu proses persetujuan',
|
|
21
|
+
excessTips: 'Anda dapat mengajukan hingga {number} izin sekaligus',
|
|
22
|
+
unavailableTips: 'Anda saat ini tidak memiliki izin untuk melihat/mengoperasikan halaman ini. Silakan klik tombol di bawah untuk mengajukan permohonan.',
|
|
23
|
+
appliedTips: 'Permohonan izin telah diajukan, saat ini {status}...',
|
|
24
|
+
unapplyTips: 'Anda tidak memiliki izin untuk melihat atau mengoperasikan halaman ini. Tidak ada izin yang tersedia untuk diajukan.',
|
|
25
|
+
callManager: 'Jika diperlukan, silakan hubungi administrator sistem',
|
|
26
|
+
manager: 'Administrator Sistem',
|
|
27
|
+
availableTime: 'Masa Berlaku',
|
|
28
|
+
selectPlaceholder: 'Silakan pilih titik izin',
|
|
29
|
+
reasonPlaceholder: 'Silakan masukkan alasan permohonan Anda',
|
|
30
|
+
pleaseChoose: 'Silakan pilih',
|
|
31
|
+
maxCountTips: 'Anda dapat mengajukan hingga {count} izin sekaligus',
|
|
32
|
+
maxLengthTips: 'Maksimal {length} karakter',
|
|
33
|
+
today: 'Kadaluarsa hari ini',
|
|
34
|
+
clickToApply: 'Klik untuk mengajukan izin',
|
|
35
|
+
noPermissionTips: 'Tidak ada titik izin di bawah menu ini, tidak perlu mengajukan permohonan',
|
|
36
|
+
lastDays: '{count} hari',
|
|
37
|
+
categoryTips: 'Cakupan data Anda saat ini:',
|
|
38
|
+
empty: 'Tidak ada',
|
|
39
|
+
category: 'Izin Data',
|
|
40
|
+
categotySelectTips: 'Izin yang dipilih termasuk pengaturan cakupan data. Silakan ajukan atau perbarui cakupan berdasarkan kebutuhan aktual Anda.',
|
|
41
|
+
categoryChangeTips: 'Harap verifikasi apakah akses penuh ke "{category}" diperlukan untuk peran Anda. Pastikan untuk menjelaskan kasus penggunaan secara jelas dalam permohonan Anda untuk menghindari penolakan.',
|
|
42
|
+
levels: {
|
|
43
|
+
L1: 'Rendah',
|
|
44
|
+
L2: 'Sedang',
|
|
45
|
+
L3: 'Tinggi',
|
|
46
|
+
},
|
|
47
|
+
status: {
|
|
48
|
+
PENDING: 'Dalam tinjauan',
|
|
49
|
+
NO: 'Tidak berlaku untuk aplikasi',
|
|
50
|
+
OWNER: 'Izin permanen',
|
|
51
|
+
TEMP_OWNER: 'Izin sementara',
|
|
52
|
+
},
|
|
53
|
+
operationType: {
|
|
54
|
+
QUERY: 'Kueri',
|
|
55
|
+
MANAGE: 'Aksi',
|
|
56
|
+
}
|
|
57
|
+
};
|
package/src/i18n/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import enUS from './en-US';
|
|
2
2
|
import zhCH from './zh-CH';
|
|
3
|
+
// import inID from './in-ID';
|
|
3
4
|
|
|
4
5
|
const language: {
|
|
5
6
|
[key: string]: any;
|
|
6
7
|
} = {
|
|
7
|
-
'zh
|
|
8
|
-
'en
|
|
8
|
+
'zh': zhCH,
|
|
9
|
+
'en': enUS,
|
|
10
|
+
// 'id': inID,
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
|
|
11
14
|
export default language;
|
package/src/i18n/zh-CH.ts
CHANGED
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
applyPermission: '申请权限',
|
|
4
4
|
applyReason: '申请理由',
|
|
5
5
|
approvalProcess: '审批流程',
|
|
6
|
+
isAllOwnTips: '当前页面权限已拥有或审批中,无需申请',
|
|
6
7
|
applyReasonPlaceholder: '请尽可能详细说明申请原因和使用场景,不要只填写“工作需要”之类的理由,以免影响你获取权限的审批时间。',
|
|
7
8
|
applyReasonTips: '示例:由于XX项目需要,需要查看/操作XXXX场景/问题,涉及到XXX权限的使用,因此提交申请!',
|
|
8
9
|
cancel: '取消',
|
|
@@ -31,21 +32,13 @@ export default {
|
|
|
31
32
|
maxLengthTips: '最多{length}个字符',
|
|
32
33
|
today: '今天到期',
|
|
33
34
|
clickToApply: '点击申请权限',
|
|
34
|
-
noPermissionTips: '
|
|
35
|
+
noPermissionTips: '该菜单下暂无权限点,无需申请',
|
|
35
36
|
lastDays: '{count}天',
|
|
36
37
|
categoryTips: '当前您所拥有的数据范围如下:',
|
|
37
38
|
empty: '空',
|
|
38
39
|
category: '数据权限',
|
|
39
40
|
categotySelectTips: '上方选中的权限包含数据权限,请根据实际工作需要申请/更改数据范围。',
|
|
40
41
|
categoryChangeTips: '提醒:您选择的数据权限范围较大!请确认实际工作场景是否需要全量「{category}」权限,并在申请理由中写明,避免审批不通过!',
|
|
41
|
-
availiables: {
|
|
42
|
-
SEVEN_DAYS: '7天',
|
|
43
|
-
THIRTY_DAYS: '30天',
|
|
44
|
-
SIXTY_DAYS: '60天',
|
|
45
|
-
NINETY_DAYS: '90天',
|
|
46
|
-
ONE_YEARS: '1年',
|
|
47
|
-
FOREVER: '永久有效',
|
|
48
|
-
},
|
|
49
42
|
levels: {
|
|
50
43
|
L1: '低',
|
|
51
44
|
L2: '中',
|
package/src/typings/index.d.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import language from '../i18n';
|
|
2
2
|
|
|
3
|
+
const localkey = 'yqg_permission_sdk_locale';
|
|
4
|
+
|
|
3
5
|
type optionsType = {
|
|
4
6
|
[key: string]: any;
|
|
5
7
|
};
|
|
6
8
|
const t = (key: string, options?: optionsType) => {
|
|
7
9
|
// key的格式为:'xxx.xxx.xxx'//国际化todo
|
|
8
|
-
const en = localStorage.getItem(
|
|
10
|
+
const en = localStorage.getItem(localkey) || 'en';
|
|
9
11
|
const keys = key.split('.');
|
|
10
|
-
let result = language[en as string] || language['en
|
|
12
|
+
let result = language[en as string] || language['en'];
|
|
11
13
|
for (let i = 0; i < keys.length; i++) {
|
|
12
14
|
result = result[keys[i]];
|
|
13
15
|
}
|
|
@@ -54,3 +56,15 @@ export const deepTree = (tree: any[], fn: (item:any) => void) => {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
export default t;
|
|
59
|
+
|
|
60
|
+
export const setLocale = (locale: string) => {
|
|
61
|
+
let finalLocale = '';
|
|
62
|
+
if (locale.startsWith('zh')) {
|
|
63
|
+
finalLocale = 'zh';
|
|
64
|
+
} else if (locale.startsWith('en')) {
|
|
65
|
+
finalLocale = 'en';
|
|
66
|
+
} else if (locale.startsWith('id') || locale.startsWith('in')) {
|
|
67
|
+
finalLocale = 'id';
|
|
68
|
+
}
|
|
69
|
+
localStorage.setItem(localkey, finalLocale);
|
|
70
|
+
}
|
package/tsconfig.app.json
CHANGED
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"composite": true,
|
|
24
24
|
"include": [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
"src/**/*.ts",
|
|
26
|
+
"src/**/*.d.ts",
|
|
27
|
+
"src/**/*.tsx",
|
|
28
|
+
"src/**/*.vue",
|
|
29
29
|
"src/i18n/zh-CH.js"
|
|
30
30
|
],
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
"exclude": [
|
|
32
|
+
"node_modules",
|
|
33
|
+
"vite.config.ts" // 如果不需要解析 vite.config.ts
|
|
34
|
+
],
|
|
35
35
|
}
|