@yqg/permission 1.0.5-beta.0 → 1.0.5
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-CzowWeBJ.js → apply-modal-BPixNFpD.js} +237 -231
- package/dist/{checkbox-item-zQ0rw1If.js → checkbox-item-DZpRo3sl.js} +965 -943
- package/dist/{index-DA6ClyIX.js → index-CSrTBn_D.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/index.umd.cjs +53 -53
- package/dist/{yqg-permission-BrJJoGxC.js → yqg-permission-Ki1ZjjJV.js} +670 -662
- package/package.json +1 -1
- package/src/App.vue +11 -4
- package/src/components/apply-modal.vue +18 -8
- package/src/components/checkbox-item.vue +21 -6
- package/src/components/success-modal.vue +6 -6
- package/src/components/yqg-permission.vue +5 -2
- package/src/i18n/en-US.ts +6 -1
- package/src/i18n/zh-CH.ts +2 -0
- package/src/typings/index.d.ts +4 -0
- package/src/vite-env.d.ts +1 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -8,7 +8,14 @@ type LocaleType = 'zh-CN' | 'en-US' | 'id-ID' | 'fil-PH';
|
|
|
8
8
|
const color = ref<string>('#1677ff');
|
|
9
9
|
const locale = ref<LocaleType>('zh-CN');
|
|
10
10
|
|
|
11
|
-
const permissions = reactive(['
|
|
11
|
+
const permissions = reactive(['CRANE.ROLE.QUERY',
|
|
12
|
+
'CRANE.ROLE.CREATE',
|
|
13
|
+
'CRANE.ROLE.UPDATE',
|
|
14
|
+
'CRANE.ROLE.DELETE',
|
|
15
|
+
'CRANE.ROLE.PERMISSION_ASSIGN',
|
|
16
|
+
'CRANE.ROLE.EMPLOYEE_ASSIGN',
|
|
17
|
+
'CRANE.ROLE.DETAIL_QUERY',
|
|
18
|
+
'CRANE.ROLE.EXPORT']);
|
|
12
19
|
// const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
|
|
13
20
|
const changeColor = () => {
|
|
14
21
|
color.value = color.value === '#f00' ? '#1677ff' : '#f00';
|
|
@@ -31,11 +38,11 @@ const changeLocale = () => {
|
|
|
31
38
|
<!-- 05184 -->
|
|
32
39
|
<yqg-permission
|
|
33
40
|
:permissions="permissions"
|
|
34
|
-
workNumber="
|
|
35
|
-
businessCode="
|
|
41
|
+
workNumber="05181"
|
|
42
|
+
businessCode="CRANE"
|
|
36
43
|
:color="color"
|
|
37
44
|
:locale="locale"
|
|
38
|
-
@
|
|
45
|
+
@onSuccess="() => {console.log('成功')}"
|
|
39
46
|
>
|
|
40
47
|
</yqg-permission>
|
|
41
48
|
</div>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
width="800px"
|
|
6
6
|
@ok="handleOk"
|
|
7
7
|
:okText="t('submit')"
|
|
8
|
+
:maskClosable="false"
|
|
8
9
|
:ok-button-props="{ loading: loading }"
|
|
9
10
|
:cancelText="t('cancel')">
|
|
10
11
|
<Form
|
|
@@ -34,14 +35,14 @@
|
|
|
34
35
|
|
|
35
36
|
<FormItem
|
|
36
37
|
name="applyReason"
|
|
37
|
-
:label="t('applyReason')"
|
|
38
|
+
:label="t('applyReason')"
|
|
38
39
|
:rules="[{
|
|
39
|
-
required: true, message: t('reasonPlaceholder')
|
|
40
|
+
required: true, message: t('reasonPlaceholder'), trigger: ['change', 'blur']
|
|
40
41
|
}, {
|
|
41
|
-
max: 300, message: t('maxLengthTips', {length: 300})
|
|
42
|
+
max: 300, message: t('maxLengthTips', {length: 300}), trigger: ['change', 'blur']
|
|
42
43
|
}]">
|
|
43
44
|
<Textarea
|
|
44
|
-
v-model:value="formState.applyReason"
|
|
45
|
+
v-model:value.trim="formState.applyReason"
|
|
45
46
|
show-count
|
|
46
47
|
:maxlength="300"
|
|
47
48
|
:placeholder="t('applyReasonPlaceholder')"
|
|
@@ -112,7 +113,7 @@
|
|
|
112
113
|
},
|
|
113
114
|
|
|
114
115
|
});
|
|
115
|
-
const emit = defineEmits(['onSuccess']);
|
|
116
|
+
const emit = defineEmits(['onSubmit', 'onSuccess']);
|
|
116
117
|
const open = defineModel({
|
|
117
118
|
required: true,
|
|
118
119
|
default: false,
|
|
@@ -141,6 +142,7 @@
|
|
|
141
142
|
} else {
|
|
142
143
|
formState.applyReason += `、${item}`;
|
|
143
144
|
}
|
|
145
|
+
formRef.value.validateFields(['applyReason']);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
const handleOk = async() => {
|
|
@@ -154,8 +156,8 @@
|
|
|
154
156
|
const url = res?.body?.oaFlowUrl;
|
|
155
157
|
open.value = false;
|
|
156
158
|
loading.value = false;
|
|
157
|
-
|
|
158
|
-
successModal.value?.countDown(url, () => emit('onSuccess'));
|
|
159
|
+
emit('onSubmit');
|
|
160
|
+
successModal.value?.countDown(url, () => emit('onSuccess'));
|
|
159
161
|
})
|
|
160
162
|
};
|
|
161
163
|
|
|
@@ -171,7 +173,7 @@
|
|
|
171
173
|
|
|
172
174
|
const onChangeHandler = throttle(async () => {
|
|
173
175
|
if (formState.roleIds.length > 5) {
|
|
174
|
-
return
|
|
176
|
+
return;
|
|
175
177
|
}
|
|
176
178
|
|
|
177
179
|
if (!formState.roleIds.length) {
|
|
@@ -184,6 +186,14 @@
|
|
|
184
186
|
stepNodes.value = res?.body?.nodes || [];
|
|
185
187
|
}, 0)
|
|
186
188
|
|
|
189
|
+
watch(() => formState.roleIds, (val) => {
|
|
190
|
+
// 写到watch里避免闪烁
|
|
191
|
+
if (val.length > 5) {
|
|
192
|
+
formState.roleIds.pop();
|
|
193
|
+
message.warning(t('maxCountTips', {count: 5}));
|
|
194
|
+
}
|
|
195
|
+
})
|
|
196
|
+
|
|
187
197
|
watch(() => open.value, (cur) => {
|
|
188
198
|
if (cur) {
|
|
189
199
|
formRef.value?.resetFields();
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="crane-checkbox-line">
|
|
3
|
-
<Checkbox
|
|
3
|
+
<Checkbox
|
|
4
|
+
:value="item.roleId"
|
|
5
|
+
:disabled="['OWNER', 'PENDING', 'NO'].includes(props.item.businessApplyType)"
|
|
6
|
+
@change="onCheck">
|
|
4
7
|
<div class="crane-flex-center crane-checkbox-label">
|
|
5
8
|
<Tag
|
|
6
9
|
v-if="item.securityLevel"
|
|
@@ -19,12 +22,26 @@
|
|
|
19
22
|
<span class="crane-text-overflow">{{ item.name }}</span>
|
|
20
23
|
</Popover>
|
|
21
24
|
<Tag
|
|
22
|
-
v-if="item.businessApplyType"
|
|
25
|
+
v-if="item.businessApplyType && item.businessApplyType !== 'TEMP_OWNER'"
|
|
23
26
|
:bordered="false"
|
|
24
27
|
class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
|
|
25
|
-
:class="item.businessApplyType
|
|
28
|
+
:class="['PENDING', 'TEMP_OWNER'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
|
|
26
29
|
{{ statusMap[item.businessApplyType] }}
|
|
27
30
|
</Tag>
|
|
31
|
+
<Popover>
|
|
32
|
+
<template #content>
|
|
33
|
+
<span v-if="item?.ownStatusVO?.dayDiff>0">{{t('lastDays', {count: item?.ownStatusVO?.dayDiff})}}</span>
|
|
34
|
+
<span v-else>{{ t('taday') }}</span>
|
|
35
|
+
</template>
|
|
36
|
+
<Tag
|
|
37
|
+
v-if="item.businessApplyType === 'TEMP_OWNER'"
|
|
38
|
+
:bordered="false"
|
|
39
|
+
class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
|
|
40
|
+
:class="['PENDING'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
|
|
41
|
+
{{ statusMap[item.businessApplyType] }}
|
|
42
|
+
</Tag>
|
|
43
|
+
</Popover>
|
|
44
|
+
|
|
28
45
|
</div>
|
|
29
46
|
</Checkbox>
|
|
30
47
|
|
|
@@ -47,7 +64,7 @@
|
|
|
47
64
|
</span>
|
|
48
65
|
</Popover>
|
|
49
66
|
|
|
50
|
-
<span v-
|
|
67
|
+
<span v-if="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
|
|
51
68
|
{{t('availableTime')}}:
|
|
52
69
|
<Select
|
|
53
70
|
v-model:value="validTime"
|
|
@@ -98,8 +115,6 @@
|
|
|
98
115
|
});
|
|
99
116
|
const timeStatusOptions = formatOptions('availiables');
|
|
100
117
|
const statusMap = t('status');
|
|
101
|
-
const StatusTypePending = 'PENDING';
|
|
102
|
-
const disabled = ['NO', 'PENDING'].includes(props.item.businessApplyType);
|
|
103
118
|
const validTime = ref('');
|
|
104
119
|
|
|
105
120
|
//1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
onOk: () => {
|
|
22
22
|
window.open(url);
|
|
23
23
|
modal1.destroy();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
callback && callback();
|
|
25
|
+
window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
|
|
26
|
+
if (!window.YQG_PERMISSION_CALLBACK && !callback) {
|
|
27
27
|
location.reload();
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
onCancel: () => {
|
|
31
31
|
modal1.destroy();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
callback && callback();
|
|
33
|
+
window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
|
|
34
|
+
if (!window.YQG_PERMISSION_CALLBACK && !callback) {
|
|
35
35
|
location.reload();
|
|
36
36
|
}
|
|
37
37
|
},
|
|
@@ -76,7 +76,8 @@
|
|
|
76
76
|
:permissionList="permissionList"
|
|
77
77
|
:workNumber="workNumber"
|
|
78
78
|
:businessCode="businessCode"
|
|
79
|
-
@onSuccess="
|
|
79
|
+
@onSuccess="() => emit('onSuccess')"
|
|
80
|
+
@onSubmit="getPermissions">
|
|
80
81
|
</ApplyModal>
|
|
81
82
|
|
|
82
83
|
</ConfigProvider>
|
|
@@ -154,7 +155,7 @@
|
|
|
154
155
|
flattenData(data);
|
|
155
156
|
// 需要排序,规则:businessApplyType 为 null 在前面, PENDING. OWNER 在中间, NO 在后面
|
|
156
157
|
// 然后再根据 L1, L2, L3 排序
|
|
157
|
-
const sort = [ null, 'PENDING', 'OWNER', 'NO'];
|
|
158
|
+
const sort = [ null, 'TEMP_OWNER', 'PENDING', 'OWNER', 'NO'];
|
|
158
159
|
const levelSort = ['L1', 'L2', 'L3'];
|
|
159
160
|
arr.sort((a, b) => {
|
|
160
161
|
return sort.indexOf(a.businessApplyType) - sort.indexOf(b.businessApplyType) || levelSort.indexOf(a.securityLevel) - levelSort.indexOf(b.securityLevel);
|
|
@@ -195,6 +196,7 @@
|
|
|
195
196
|
};
|
|
196
197
|
|
|
197
198
|
const goViewApproval = () => {
|
|
199
|
+
console.log(curApproving.value)
|
|
198
200
|
if (curApproving.value?.oaFlowUrl) {
|
|
199
201
|
window.open(curApproving.value.oaFlowUrl);
|
|
200
202
|
}
|
|
@@ -215,6 +217,7 @@
|
|
|
215
217
|
};
|
|
216
218
|
|
|
217
219
|
const showModal = () => {
|
|
220
|
+
getPermissions();
|
|
218
221
|
open.value = !open.value;
|
|
219
222
|
};
|
|
220
223
|
|
package/src/i18n/en-US.ts
CHANGED
|
@@ -28,6 +28,10 @@ export default {
|
|
|
28
28
|
availableTime: '有效期',
|
|
29
29
|
selectPlaceholder: '请选择权限点',
|
|
30
30
|
reasonPlaceholder: '请输入申请理由',
|
|
31
|
+
maxCountTips: '一次最多只可申请{count}个权限',
|
|
32
|
+
maxLengthTips: '最多{length}个字符',
|
|
33
|
+
lastDays: '{count}天后到期',
|
|
34
|
+
taday: '今天到期',
|
|
31
35
|
availiables: {
|
|
32
36
|
SEVEN_DAYS: '7天',
|
|
33
37
|
THIRTY_DAYS: '30天',
|
|
@@ -43,7 +47,8 @@ export default {
|
|
|
43
47
|
status: {
|
|
44
48
|
PENDING: '审批中',
|
|
45
49
|
NO: '不可申请',
|
|
46
|
-
OWNER: '
|
|
50
|
+
OWNER: '永久拥有',
|
|
51
|
+
TEMP_OWNER: '临时拥有',
|
|
47
52
|
},
|
|
48
53
|
operationType: {
|
|
49
54
|
QUERY: '查询',
|
package/src/i18n/zh-CH.ts
CHANGED
package/src/typings/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ declare type PermissionType = {
|
|
|
26
26
|
businessApplyType: StatusType;
|
|
27
27
|
oaFlowUrl?: string;
|
|
28
28
|
children?: PermissionListType;
|
|
29
|
+
ownStatusVO: any;
|
|
29
30
|
admin?: any[];
|
|
30
31
|
};
|
|
31
32
|
declare type PermissionListType = PermissionType[];
|
|
@@ -52,3 +53,6 @@ declare type formStateType = {
|
|
|
52
53
|
submitWorkNumber: string,
|
|
53
54
|
|
|
54
55
|
};
|
|
56
|
+
declare interface Window {
|
|
57
|
+
YQG_PERMISSION_CALLBACK?: () => void;
|
|
58
|
+
}
|
package/src/vite-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
1
|
+
/// <reference types="vite/client" />
|