@yqg/permission 1.3.2-alpha.0 → 1.3.2-alpha.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-CSpYfIii.js → apply-modal-BNdUCpv3.js} +995 -957
- package/dist/{category-selector-RZIDDDzv.js → category-selector-DN93T2dR.js} +4 -4
- package/dist/{index-BmkUdNAO.js → index-C8n_Swh6.js} +1 -1
- package/dist/{index-PEBPXz6I.js → index-wZrMoTve.js} +3 -3
- package/dist/index.js +2 -2
- package/dist/{permission-item-Cblf9DpJ.js → permission-item-BSOmY3P3.js} +277 -274
- package/dist/{yqg-permission-TXUFbfxZ.js → yqg-permission-80IS5NzA.js} +1993 -1982
- package/dist/yqg-permission.umd.js +44 -44
- package/package.json +1 -1
- package/src/App.vue +2 -7
- package/src/axios/index.ts +1 -1
- package/src/components/apply-modal.vue +43 -10
- package/src/components/permission-item.vue +11 -5
- package/src/components/yqg-permission.vue +10 -5
- package/src/hooks/useFormat.ts +18 -5
- package/src/i18n/en-US.ts +2 -1
- package/src/i18n/in-ID.ts +2 -1
- package/src/i18n/zh-CH.ts +2 -1
- package/src/typings/index.d.ts +1 -0
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -9,12 +9,7 @@ const color = ref<string>('#1677ff');
|
|
|
9
9
|
const locale = ref<LocaleType>('zh-CN');
|
|
10
10
|
|
|
11
11
|
const permissions = reactive([
|
|
12
|
-
'
|
|
13
|
-
'CRANE.EMPLOYEE.QUERY',
|
|
14
|
-
'CRANE.EMPLOYEE.DETAIL_QUERY',
|
|
15
|
-
'CRANE.EMPLOYEE.ATTRIBUTE_CREATE',
|
|
16
|
-
'CRANE.EMPLOYEE.ROLE_ASSIGN',
|
|
17
|
-
'CRANE.EMPLOYEE.DEPARTMENT_ROLE.ATTRIBUTE_ROLE_CREATE',
|
|
12
|
+
'yewei0313.REAQS.DEPAWED_ANQ2.QUERY',
|
|
18
13
|
]);
|
|
19
14
|
// const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
|
|
20
15
|
const changeColor = () => {
|
|
@@ -36,7 +31,7 @@ const changeLocale = () => {
|
|
|
36
31
|
<!-- 03541 -->
|
|
37
32
|
<!-- 02124 -->
|
|
38
33
|
<!-- 05184 -->
|
|
39
|
-
<yqg-permission :permissions="permissions" workNumber="
|
|
34
|
+
<yqg-permission :permissions="permissions" workNumber="03817" :color="color" :locale="locale"
|
|
40
35
|
@onSuccess="() => {console.log('成功')}">
|
|
41
36
|
</yqg-permission>
|
|
42
37
|
</div>
|
package/src/axios/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ type apiType = {
|
|
|
9
9
|
export default {
|
|
10
10
|
getPermissions: (params: any) => axios.get(`${urlPrefix}/permission/apply`, {params}),
|
|
11
11
|
|
|
12
|
-
getFlowPreview: (params: any)=> axios.post(`${urlPrefix}/permission/apply/oa/flow/submit/preview`, params),
|
|
12
|
+
getFlowPreview: (params: any) => axios.post(`${urlPrefix}/permission/apply/oa/flow/submit/preview`, params),
|
|
13
13
|
|
|
14
14
|
submitApply: (params: any) => axios.post(`${urlPrefix}/permission/apply/oa/flow/submit`, params),
|
|
15
15
|
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Modal v-model:open="open"
|
|
3
|
-
|
|
2
|
+
<Modal v-model:open="open" width="1100px" :maskClosable="false">
|
|
3
|
+
<template #footer>
|
|
4
|
+
<Button @click="open = false" v-show="!isAllChecked && permissionList.length">{{ t('cancel') }}</Button>
|
|
5
|
+
<Button type="primary" @click="handleOk" :loading="loading">{{ t('submit') }}</Button>
|
|
6
|
+
</template>
|
|
7
|
+
<template #title>
|
|
8
|
+
<span>{{ t('permissionApply') }}</span>
|
|
9
|
+
<span v-show="isAllChecked && permissionList.length" class="crane-permission-title-tips">{{ t('isAllOwnTips') }}</span>
|
|
10
|
+
</template>
|
|
4
11
|
<Form ref="formRef" :model="formState" :labelCol="{ span: 4 }" :wrapperCol="{ span: 19 }">
|
|
5
12
|
<FormItem :label="t('applyPermission')" name="features"
|
|
6
13
|
:rules="[{ required: true, message: t('selectPlaceholder') }]">
|
|
@@ -30,8 +37,8 @@
|
|
|
30
37
|
max: 300, message: t('maxLengthTips', { length: 300 }), trigger: ['change', 'blur']
|
|
31
38
|
}]">
|
|
32
39
|
<Textarea v-model:value.trim="formState.applyReason" :placeholder="t('applyReasonPlaceholder')"
|
|
33
|
-
:auto-size="{ minRows: 4, maxRows: 4 }">
|
|
34
|
-
|
|
40
|
+
:auto-size="{ minRows: 4, maxRows: 4 }" :disabled="isAllChecked || !permissionList.length">
|
|
41
|
+
</Textarea>
|
|
35
42
|
<span class="reason-tips" style="font-size: 12px">
|
|
36
43
|
{{ t('applyReasonTips') }}
|
|
37
44
|
</span>
|
|
@@ -64,7 +71,8 @@ import {
|
|
|
64
71
|
Textarea,
|
|
65
72
|
message,
|
|
66
73
|
Tree,
|
|
67
|
-
Spin
|
|
74
|
+
Spin,
|
|
75
|
+
Button
|
|
68
76
|
} from 'ant-design-vue';
|
|
69
77
|
import SuccessModal from './success-modal.vue';
|
|
70
78
|
import ApprovalSteps from './approval-steps.vue';
|
|
@@ -94,6 +102,14 @@ const props = defineProps({
|
|
|
94
102
|
spining: {
|
|
95
103
|
type: Boolean,
|
|
96
104
|
default: false
|
|
105
|
+
},
|
|
106
|
+
defaultCheckedIds: {
|
|
107
|
+
type: Array as PropType<string[]>,
|
|
108
|
+
default: () => []
|
|
109
|
+
},
|
|
110
|
+
isAllChecked: {
|
|
111
|
+
type: Boolean,
|
|
112
|
+
default: false
|
|
97
113
|
}
|
|
98
114
|
|
|
99
115
|
});
|
|
@@ -130,6 +146,10 @@ const getValidTimeOptions = async () => {
|
|
|
130
146
|
|
|
131
147
|
getValidTimeOptions();
|
|
132
148
|
const handleOk = async () => {
|
|
149
|
+
if (props.isAllChecked || !permissionList.value.length) {
|
|
150
|
+
open.value = false;
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
133
153
|
await Promise.all([formRef.value.validate(), categoryRef.value?.validate()])
|
|
134
154
|
loading.value = true;
|
|
135
155
|
const params = getParams();
|
|
@@ -161,7 +181,7 @@ const getParams = () => {
|
|
|
161
181
|
|
|
162
182
|
});
|
|
163
183
|
deepTree(permissionList.value, (item: any) => {
|
|
164
|
-
if (!item.children && formState.features.includes(item.feature)) {
|
|
184
|
+
if (!item.children && formState.features.includes(item.feature) && !item.disabled) {
|
|
165
185
|
roleVoList.push({
|
|
166
186
|
roleId: item.roleId,
|
|
167
187
|
validTime: item.validTime
|
|
@@ -188,20 +208,22 @@ const onChangeTime = throttle(async () => {
|
|
|
188
208
|
if (params.roleVoList.length === 0) {
|
|
189
209
|
stepNodes.value = [];
|
|
190
210
|
return;
|
|
191
|
-
}
|
|
211
|
+
};
|
|
212
|
+
|
|
192
213
|
let res = await Http.getFlowPreview(params);
|
|
193
214
|
stepNodes.value = res?.body?.nodes || [];
|
|
194
|
-
},
|
|
215
|
+
}, 1)
|
|
195
216
|
const onCheck = (checkedIds: any, info: any) => {
|
|
196
217
|
// 如果选择的是子节点,判断是否超过5个,超过的话,删除当前选的节点,并给予提示
|
|
197
218
|
// 如果选择的是父节点,判断是否超过5个,超过的话,从当前选择的父节点的叶子节点中删除多出的个数,并给予提示
|
|
198
219
|
let total = 0;
|
|
199
220
|
let curTotal = 0;
|
|
221
|
+
|
|
200
222
|
deepTree(permissionList.value, (item: any) => {
|
|
201
|
-
if (!item.children && checkedIds.includes(item.feature)) {
|
|
223
|
+
if (!item.children && checkedIds.includes(item.feature) && !item.disabled) {
|
|
202
224
|
total += 1;
|
|
203
225
|
}
|
|
204
|
-
if (!item.children && formState.features.includes(item.feature)) {
|
|
226
|
+
if (!item.children && formState.features.includes(item.feature) && !item.disabled) {
|
|
205
227
|
curTotal += 1;
|
|
206
228
|
}
|
|
207
229
|
if (!item.children && !formState.features.includes(item.feature)) {
|
|
@@ -257,6 +279,10 @@ watch(() => props.permissionList, (cur) => {
|
|
|
257
279
|
})
|
|
258
280
|
})
|
|
259
281
|
|
|
282
|
+
watch(() => props.defaultCheckedIds, (cur) => {
|
|
283
|
+
formState.features = cur.concat(formState.features);
|
|
284
|
+
}, { immediate: true })
|
|
285
|
+
|
|
260
286
|
watch(() => open.value, (cur) => {
|
|
261
287
|
if (cur) {
|
|
262
288
|
formRef.value?.resetFields();
|
|
@@ -267,6 +293,13 @@ watch(() => open.value, (cur) => {
|
|
|
267
293
|
</script>
|
|
268
294
|
|
|
269
295
|
<style scoped>
|
|
296
|
+
.crane-permission-title-tips {
|
|
297
|
+
color: #FF4D4F;
|
|
298
|
+
font-size: 14px;
|
|
299
|
+
margin-left: 8px;
|
|
300
|
+
font-weight: 400;
|
|
301
|
+
}
|
|
302
|
+
|
|
270
303
|
:deep(.yqg-permission-tree-list) {
|
|
271
304
|
margin-top: 4px;
|
|
272
305
|
}
|
|
@@ -34,10 +34,11 @@
|
|
|
34
34
|
|
|
35
35
|
<Popover v-if="item.relatedCompleteNames?.length">
|
|
36
36
|
<template #content>
|
|
37
|
-
<div
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
<div class="crane-department-wraper">
|
|
38
|
+
<div>
|
|
39
|
+
{{ t('adaptDepartment') }}:
|
|
40
|
+
</div>
|
|
41
|
+
<div v-for="item in item.relatedCompleteNames">{{ item }}</div>
|
|
41
42
|
</div>
|
|
42
43
|
</template>
|
|
43
44
|
<div class="crane-flex-center crane-margin-left-4">
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
</Popover>
|
|
68
69
|
|
|
69
70
|
<!-- 选择框 -->
|
|
70
|
-
<span v-if="checkedKeys.includes(item.feature)" class="crane-weak-color crane-margin-left-12">
|
|
71
|
+
<span v-if="checkedKeys.includes(item.feature) && !item.disabled" class="crane-weak-color crane-margin-left-12">
|
|
71
72
|
{{ t('availableTime') }}:
|
|
72
73
|
<Select v-model:value="item.validTime" style="width: 100px"
|
|
73
74
|
:disabled="item.businessApplyType === OWNER_STATUS"
|
|
@@ -145,6 +146,11 @@ const onChangeTimeHandler = () => {
|
|
|
145
146
|
|
|
146
147
|
</script>
|
|
147
148
|
<style scoped>
|
|
149
|
+
.crane-department-wraper {
|
|
150
|
+
max-width: 600px;
|
|
151
|
+
max-height: 300px;
|
|
152
|
+
overflow-y: scroll;
|
|
153
|
+
}
|
|
148
154
|
.crane-flex-center {
|
|
149
155
|
display: flex;
|
|
150
156
|
align-items: center;
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</div>
|
|
43
43
|
<div>
|
|
44
44
|
<Button class="crane-margin-right10" @click="goViewApproval">{{ t('viewApprovalDetail')
|
|
45
|
-
|
|
45
|
+
}}</Button>
|
|
46
46
|
<Button type="primary" @click="showModal">+ {{ t('applyMore') }}</Button>
|
|
47
47
|
</div>
|
|
48
48
|
</template>
|
|
@@ -63,7 +63,8 @@
|
|
|
63
63
|
</div>
|
|
64
64
|
|
|
65
65
|
<ApplyModal v-model="open" :permissionList="permissionList" :spining="loading" :workNumber="workNumber"
|
|
66
|
-
@onSuccess="() => emit('onSuccess')"
|
|
66
|
+
:defaultCheckedIds="defaultCheckedIds" :isAllChecked="isAllChecked" @onSuccess="() => emit('onSuccess')"
|
|
67
|
+
@onSubmit="getPermissions">
|
|
67
68
|
</ApplyModal>
|
|
68
69
|
|
|
69
70
|
</ConfigProvider>
|
|
@@ -130,6 +131,8 @@ const props = defineProps({
|
|
|
130
131
|
const open = ref(false);
|
|
131
132
|
const curApproving = ref<PermissionType>();
|
|
132
133
|
const loading = ref(false);
|
|
134
|
+
const defaultCheckedIds = ref<string[]>([]);
|
|
135
|
+
const isAllChecked = ref(false);
|
|
133
136
|
let permissionList = ref<PermissionListType>([]);
|
|
134
137
|
let curStatus = ref<Record<string, any>>({
|
|
135
138
|
imageUrl: noauthority,
|
|
@@ -163,7 +166,10 @@ const getPermissions = async () => {
|
|
|
163
166
|
|
|
164
167
|
loading.value = true;
|
|
165
168
|
const res = await Http.getPermissions(params);
|
|
166
|
-
|
|
169
|
+
const datalist = useFormat(res.body || []);
|
|
170
|
+
permissionList.value = datalist.data;
|
|
171
|
+
defaultCheckedIds.value = datalist.checkList;
|
|
172
|
+
isAllChecked.value = datalist.isAllChecked;
|
|
167
173
|
curStatus.value = useStatus(permissionList.value, curApproving);
|
|
168
174
|
loading.value = false;
|
|
169
175
|
};
|
|
@@ -202,5 +208,4 @@ watch(() => props.locale, (cur, pre) => {
|
|
|
202
208
|
.crane-margin-right10 {
|
|
203
209
|
margin-right: 10px;
|
|
204
210
|
}
|
|
205
|
-
</style>
|
|
206
|
-
../hooks/useSort../hooks/useFormat
|
|
211
|
+
</style>
|
package/src/hooks/useFormat.ts
CHANGED
|
@@ -9,6 +9,8 @@ const StatusType = {
|
|
|
9
9
|
TEMP_OWNER: 'TEMP_OWNER'
|
|
10
10
|
}
|
|
11
11
|
export default function useFormat(tree: PermissionListType) {
|
|
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
23
|
node.categoryVOS = (node.categoryVOS || []).filter((item: any) => item.configWay !== Category.AUTO);
|
|
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
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
applyPermission: 'Apply for Permission',
|
|
4
4
|
applyReason: 'Application Reason',
|
|
5
5
|
approvalProcess: 'Approval Process',
|
|
6
|
+
isAllOwnTips: 'The current page already has permission or is under approval, no need to apply',
|
|
6
7
|
applyReasonPlaceholder: 'Please describe the reason for application and usage scenarios in as much detail as possible. Avoid simply stating "work requirements" to prevent delays in the approval process.',
|
|
7
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!',
|
|
8
9
|
cancel: 'Cancel',
|
|
@@ -31,7 +32,7 @@ export default {
|
|
|
31
32
|
maxLengthTips: 'Maximum {length} characters',
|
|
32
33
|
today: 'Expires today',
|
|
33
34
|
clickToApply: 'Click to apply for permission',
|
|
34
|
-
noPermissionTips: '
|
|
35
|
+
noPermissionTips: 'There are no permission points under this menu, no need to apply',
|
|
35
36
|
lastDays: '{count} days',
|
|
36
37
|
categoryTips: 'Your current data scope is as follows:',
|
|
37
38
|
empty: 'Empty',
|
package/src/i18n/in-ID.ts
CHANGED
|
@@ -3,6 +3,7 @@ export default {
|
|
|
3
3
|
applyPermission: 'Ajukan Izin',
|
|
4
4
|
applyReason: 'Alasan Pengajuan',
|
|
5
5
|
approvalProcess: 'Proses Persetujuan',
|
|
6
|
+
isAllOwnTips: 'Halaman saat ini sudah memiliki izin atau sedang dalam proses persetujuan, tidak perlu mengajukan permohonan',
|
|
6
7
|
applyReasonPlaceholder: 'Harap jelaskan alasan pengajuan dan skenario penggunaan selengkap mungkin. Hindari hanya menyebutkan "kebutuhan kerja" untuk mencegah penundaan dalam proses persetujuan.',
|
|
7
8
|
applyReasonTips: 'Contoh: Karena kebutuhan proyek XX, perlu melihat/mengoperasikan skenario/masalah XXXX, yang melibatkan penggunaan izin XXX, oleh karena itu mengajukan permohonan ini!',
|
|
8
9
|
cancel: 'Batal',
|
|
@@ -31,7 +32,7 @@ export default {
|
|
|
31
32
|
maxLengthTips: 'Maksimal {length} karakter',
|
|
32
33
|
today: 'Kadaluarsa hari ini',
|
|
33
34
|
clickToApply: 'Klik untuk mengajukan izin',
|
|
34
|
-
noPermissionTips: 'Tidak ada titik izin di menu ini',
|
|
35
|
+
noPermissionTips: 'Tidak ada titik izin di menu ini, tidak perlu mengajukan permohonan',
|
|
35
36
|
lastDays: '{count} hari',
|
|
36
37
|
categoryTips: 'Cakupan data Anda saat ini adalah sebagai berikut:',
|
|
37
38
|
empty: 'Kosong',
|
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,7 +32,7 @@ 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: '空',
|