@yqg/permission 1.1.0-beta.0 → 1.1.1-beta.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/dist/{apply-modal-SzDVxN-2.js → apply-modal-CXHxB881.js} +906 -906
- package/dist/{checkbox-item-BlnmEaiY.js → checkbox-item-B19NWjP3.js} +946 -966
- package/dist/{index-DFUPlAqp.js → index-CtHcMKbX.js} +2105 -2075
- package/dist/index.js +2 -2
- package/dist/index.umd.cjs +71 -71
- package/dist/{yqg-permission-Cfoxcf-d.js → yqg-permission-B-6y_a6O.js} +750 -756
- package/package.json +1 -1
- package/src/App.vue +4 -11
- package/src/components/apply-modal.vue +9 -19
- package/src/components/checkbox-item.vue +6 -21
- package/src/components/success-modal.vue +10 -4
- package/src/components/yqg-permission.vue +27 -23
- package/src/i18n/en-US.ts +1 -6
- package/src/i18n/zh-CH.ts +0 -2
- package/src/typings/index.d.ts +0 -4
- package/src/vite-env.d.ts +1 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -8,14 +8,7 @@ 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(['
|
|
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']);
|
|
11
|
+
const permissions = reactive(['PPDL.0801-test2.XIUGAI.test5', 'PPDL.0801-test2.XIUGAI.test4', 'PPDL.0801-test2.XIUGAI.test6']);
|
|
19
12
|
// const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
|
|
20
13
|
const changeColor = () => {
|
|
21
14
|
color.value = color.value === '#f00' ? '#1677ff' : '#f00';
|
|
@@ -38,11 +31,11 @@ const changeLocale = () => {
|
|
|
38
31
|
<!-- 05184 -->
|
|
39
32
|
<yqg-permission
|
|
40
33
|
:permissions="permissions"
|
|
41
|
-
workNumber="
|
|
42
|
-
businessCode="
|
|
34
|
+
workNumber="H00408"
|
|
35
|
+
businessCode="PPDL"
|
|
43
36
|
:color="color"
|
|
44
37
|
:locale="locale"
|
|
45
|
-
@
|
|
38
|
+
@success="() => {console.log('成功')}"
|
|
46
39
|
>
|
|
47
40
|
</yqg-permission>
|
|
48
41
|
</div>
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
width="800px"
|
|
6
6
|
@ok="handleOk"
|
|
7
7
|
:okText="t('submit')"
|
|
8
|
-
:maskClosable="false"
|
|
9
8
|
:ok-button-props="{ loading: loading }"
|
|
10
9
|
:cancelText="t('cancel')">
|
|
11
10
|
<Form
|
|
@@ -35,14 +34,14 @@
|
|
|
35
34
|
|
|
36
35
|
<FormItem
|
|
37
36
|
name="applyReason"
|
|
38
|
-
:label="t('applyReason')"
|
|
37
|
+
:label="t('applyReason')"
|
|
39
38
|
:rules="[{
|
|
40
|
-
required: true, message: t('reasonPlaceholder')
|
|
39
|
+
required: true, message: t('reasonPlaceholder')
|
|
41
40
|
}, {
|
|
42
|
-
max: 300, message: t('maxLengthTips', {length: 300})
|
|
41
|
+
max: 300, message: t('maxLengthTips', {length: 300})
|
|
43
42
|
}]">
|
|
44
43
|
<Textarea
|
|
45
|
-
v-model:value
|
|
44
|
+
v-model:value="formState.applyReason"
|
|
46
45
|
show-count
|
|
47
46
|
:maxlength="300"
|
|
48
47
|
:placeholder="t('applyReasonPlaceholder')"
|
|
@@ -113,7 +112,7 @@
|
|
|
113
112
|
},
|
|
114
113
|
|
|
115
114
|
});
|
|
116
|
-
const emit = defineEmits(['
|
|
115
|
+
const emit = defineEmits(['onSuccess']);
|
|
117
116
|
const open = defineModel({
|
|
118
117
|
required: true,
|
|
119
118
|
default: false,
|
|
@@ -142,7 +141,6 @@
|
|
|
142
141
|
} else {
|
|
143
142
|
formState.applyReason += `、${item}`;
|
|
144
143
|
}
|
|
145
|
-
formRef.value.validateFields(['applyReason']);
|
|
146
144
|
}
|
|
147
145
|
|
|
148
146
|
const handleOk = async() => {
|
|
@@ -156,8 +154,8 @@
|
|
|
156
154
|
const url = res?.body?.oaFlowUrl;
|
|
157
155
|
open.value = false;
|
|
158
156
|
loading.value = false;
|
|
159
|
-
|
|
160
|
-
successModal.value?.countDown(url, () => emit('onSuccess'));
|
|
157
|
+
|
|
158
|
+
successModal.value?.countDown(url, () => emit('onSuccess'));
|
|
161
159
|
})
|
|
162
160
|
};
|
|
163
161
|
|
|
@@ -172,8 +170,8 @@
|
|
|
172
170
|
}
|
|
173
171
|
|
|
174
172
|
const onChangeHandler = throttle(async () => {
|
|
175
|
-
if (formState.roleIds.length >
|
|
176
|
-
return;
|
|
173
|
+
if (formState.roleIds.length > 5) {
|
|
174
|
+
return message.warning(t('maxCountTips', {count: 5}));
|
|
177
175
|
}
|
|
178
176
|
|
|
179
177
|
if (!formState.roleIds.length) {
|
|
@@ -186,14 +184,6 @@
|
|
|
186
184
|
stepNodes.value = res?.body?.nodes || [];
|
|
187
185
|
}, 0)
|
|
188
186
|
|
|
189
|
-
watch(() => formState.roleIds, (val) => {
|
|
190
|
-
// 写到watch里避免闪烁
|
|
191
|
-
if (val.length > 1) {
|
|
192
|
-
formState.roleIds.pop();
|
|
193
|
-
message.warning(t('maxCountTips', {count: 5}));
|
|
194
|
-
}
|
|
195
|
-
})
|
|
196
|
-
|
|
197
187
|
watch(() => open.value, (cur) => {
|
|
198
188
|
if (cur) {
|
|
199
189
|
formRef.value?.resetFields();
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="crane-checkbox-line">
|
|
3
|
-
<Checkbox
|
|
4
|
-
:value="item.roleId"
|
|
5
|
-
:disabled="['OWNER', 'PENDING', 'NO'].includes(props.item.businessApplyType)"
|
|
6
|
-
@change="onCheck">
|
|
3
|
+
<Checkbox :value="item.roleId" :disabled="disabled" @change="onCheck">
|
|
7
4
|
<div class="crane-flex-center crane-checkbox-label">
|
|
8
5
|
<Tag
|
|
9
6
|
v-if="item.securityLevel"
|
|
@@ -22,26 +19,12 @@
|
|
|
22
19
|
<span class="crane-text-overflow">{{ item.name }}</span>
|
|
23
20
|
</Popover>
|
|
24
21
|
<Tag
|
|
25
|
-
v-if="item.businessApplyType
|
|
22
|
+
v-if="item.businessApplyType"
|
|
26
23
|
:bordered="false"
|
|
27
24
|
class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
|
|
28
|
-
:class="
|
|
25
|
+
:class="item.businessApplyType !== StatusTypePending ? 'crane-disabled-color' : ''">
|
|
29
26
|
{{ statusMap[item.businessApplyType] }}
|
|
30
27
|
</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
|
-
|
|
45
28
|
</div>
|
|
46
29
|
</Checkbox>
|
|
47
30
|
|
|
@@ -64,7 +47,7 @@
|
|
|
64
47
|
</span>
|
|
65
48
|
</Popover>
|
|
66
49
|
|
|
67
|
-
<span v-
|
|
50
|
+
<span v-show="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
|
|
68
51
|
{{t('availableTime')}}:
|
|
69
52
|
<Select
|
|
70
53
|
v-model:value="validTime"
|
|
@@ -115,6 +98,8 @@
|
|
|
115
98
|
});
|
|
116
99
|
const timeStatusOptions = formatOptions('availiables');
|
|
117
100
|
const statusMap = t('status');
|
|
101
|
+
const StatusTypePending = 'PENDING';
|
|
102
|
+
const disabled = ['NO', 'PENDING'].includes(props.item.businessApplyType);
|
|
118
103
|
const validTime = ref('');
|
|
119
104
|
|
|
120
105
|
//1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
|
|
@@ -21,13 +21,19 @@
|
|
|
21
21
|
onOk: () => {
|
|
22
22
|
window.open(url);
|
|
23
23
|
modal1.destroy();
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
if (callback) {
|
|
25
|
+
callback();
|
|
26
|
+
} else {
|
|
27
|
+
location.reload();
|
|
28
|
+
}
|
|
26
29
|
},
|
|
27
30
|
onCancel: () => {
|
|
28
31
|
modal1.destroy();
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
if (callback) {
|
|
33
|
+
callback();
|
|
34
|
+
} else {
|
|
35
|
+
location.reload();
|
|
36
|
+
}
|
|
31
37
|
},
|
|
32
38
|
});
|
|
33
39
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ConfigProvider
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
v-if="allPermissions.length"
|
|
4
|
+
prefixCls="yqg-permission"
|
|
5
|
+
:theme="{
|
|
6
6
|
token: {
|
|
7
7
|
colorPrimary: props.color,
|
|
8
|
-
}}"
|
|
8
|
+
}}"
|
|
9
|
+
>
|
|
9
10
|
<div class="crane-wraper">
|
|
10
11
|
<template v-if="type==='text'">
|
|
11
12
|
<TypographyLink @click="showModal">{{t('permissionApply')}}</TypographyLink>
|
|
@@ -18,7 +19,7 @@
|
|
|
18
19
|
<template v-else>
|
|
19
20
|
|
|
20
21
|
<!-- 可申请 -->
|
|
21
|
-
<template v-if="curStatus.status ===
|
|
22
|
+
<template v-if="curStatus.status === STATUS_MAP.DEFAULT">
|
|
22
23
|
<img
|
|
23
24
|
:src="curStatus.imageUrl"
|
|
24
25
|
height="200"
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
</div>
|
|
33
34
|
</template>
|
|
34
35
|
<!-- 审批中 -->
|
|
35
|
-
<template v-if="curStatus.status ===
|
|
36
|
+
<template v-if="curStatus.status === STATUS_MAP.PENDING">
|
|
36
37
|
<img
|
|
37
38
|
:src="curStatus.imageUrl"
|
|
38
39
|
height="200"
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
</div>
|
|
53
54
|
</template>
|
|
54
55
|
<!-- 不可申请 -->
|
|
55
|
-
<div v-if="curStatus.status ===
|
|
56
|
+
<div v-if="curStatus.status === STATUS_MAP.NO" class="crane-wraper">
|
|
56
57
|
<img
|
|
57
58
|
:src="curStatus.imageUrl"
|
|
58
59
|
height="200"
|
|
@@ -76,27 +77,31 @@
|
|
|
76
77
|
:permissionList="permissionList"
|
|
77
78
|
:workNumber="workNumber"
|
|
78
79
|
:businessCode="businessCode"
|
|
79
|
-
@onSuccess="
|
|
80
|
-
@onSubmit="getPermissions">
|
|
80
|
+
@onSuccess="getPermissions">
|
|
81
81
|
</ApplyModal>
|
|
82
82
|
|
|
83
83
|
</ConfigProvider>
|
|
84
84
|
</template>
|
|
85
85
|
<script lang="ts" setup>
|
|
86
|
-
import { ref, defineAsyncComponent, computed, watchEffect, watch} from 'vue';
|
|
87
|
-
import {Button, ConfigProvider, TypographyLink, Popover } from 'ant-design-vue';
|
|
86
|
+
import { ref, defineAsyncComponent, computed, watchEffect, watch } from 'vue';
|
|
87
|
+
import {Button, ConfigProvider, TypographyLink, Popover, message } from 'ant-design-vue';
|
|
88
88
|
import applyUrl from '@/assets/applying.png';
|
|
89
89
|
import noauthority from '@/assets/noauthority.png';
|
|
90
90
|
import Http from '../axios/index';
|
|
91
91
|
import t from '../utils';
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
);
|
|
95
|
-
const statusMap = {
|
|
92
|
+
|
|
93
|
+
const STATUS_MAP = {
|
|
96
94
|
DEFAULT: 'DEFAULT',
|
|
97
95
|
PENDING: 'PENDING',
|
|
98
96
|
NO: 'NO',
|
|
99
|
-
}
|
|
97
|
+
} as const;
|
|
98
|
+
|
|
99
|
+
// 重置 message 类名,避免被全局样式覆盖
|
|
100
|
+
message.config({prefixCls: 'yqg-permission-message'});
|
|
101
|
+
|
|
102
|
+
const ApplyModal = defineAsyncComponent(() =>
|
|
103
|
+
import('./apply-modal.vue')
|
|
104
|
+
);
|
|
100
105
|
|
|
101
106
|
const props = defineProps({
|
|
102
107
|
workNumber: {
|
|
@@ -155,7 +160,7 @@
|
|
|
155
160
|
flattenData(data);
|
|
156
161
|
// 需要排序,规则:businessApplyType 为 null 在前面, PENDING. OWNER 在中间, NO 在后面
|
|
157
162
|
// 然后再根据 L1, L2, L3 排序
|
|
158
|
-
const sort = [ null, '
|
|
163
|
+
const sort = [ null, 'PENDING', 'OWNER', 'NO'];
|
|
159
164
|
const levelSort = ['L1', 'L2', 'L3'];
|
|
160
165
|
arr.sort((a, b) => {
|
|
161
166
|
return sort.indexOf(a.businessApplyType) - sort.indexOf(b.businessApplyType) || levelSort.indexOf(a.securityLevel) - levelSort.indexOf(b.securityLevel);
|
|
@@ -170,13 +175,13 @@
|
|
|
170
175
|
status: '',
|
|
171
176
|
};
|
|
172
177
|
}
|
|
173
|
-
const current = data.find((per) => per.businessApplyType ===
|
|
174
|
-
const cannotApply = data.every((per) => per.businessApplyType ===
|
|
178
|
+
const current = data.find((per) => per.businessApplyType === STATUS_MAP.PENDING);
|
|
179
|
+
const cannotApply = data.every((per) => per.businessApplyType === STATUS_MAP.NO);
|
|
175
180
|
if (current) {
|
|
176
181
|
curApproving.value = current;
|
|
177
182
|
return {
|
|
178
183
|
imageUrl: applyUrl,
|
|
179
|
-
status:
|
|
184
|
+
status: STATUS_MAP.PENDING,
|
|
180
185
|
tips: t('status.PENDING'),
|
|
181
186
|
url: current.oaFlowUrl,
|
|
182
187
|
};
|
|
@@ -185,18 +190,17 @@
|
|
|
185
190
|
if (cannotApply) {
|
|
186
191
|
return {
|
|
187
192
|
imageUrl: noauthority,
|
|
188
|
-
status:
|
|
193
|
+
status: STATUS_MAP.NO,
|
|
189
194
|
tips: data[0].admin?.map((item) => `${item.name}(${item.departmentName})`)?.join('、'),
|
|
190
195
|
};
|
|
191
196
|
};
|
|
192
197
|
return {
|
|
193
198
|
imageUrl: noauthority,
|
|
194
|
-
status:
|
|
199
|
+
status: STATUS_MAP.DEFAULT,
|
|
195
200
|
}
|
|
196
201
|
};
|
|
197
202
|
|
|
198
203
|
const goViewApproval = () => {
|
|
199
|
-
console.log(curApproving.value)
|
|
200
204
|
if (curApproving.value?.oaFlowUrl) {
|
|
201
205
|
window.open(curApproving.value.oaFlowUrl);
|
|
202
206
|
}
|
package/src/i18n/en-US.ts
CHANGED
|
@@ -28,10 +28,6 @@ export default {
|
|
|
28
28
|
availableTime: '有效期',
|
|
29
29
|
selectPlaceholder: '请选择权限点',
|
|
30
30
|
reasonPlaceholder: '请输入申请理由',
|
|
31
|
-
maxCountTips: '一次最多只可申请{count}个权限',
|
|
32
|
-
maxLengthTips: '最多{length}个字符',
|
|
33
|
-
lastDays: '{count}天后到期',
|
|
34
|
-
taday: '今天到期',
|
|
35
31
|
availiables: {
|
|
36
32
|
SEVEN_DAYS: '7天',
|
|
37
33
|
THIRTY_DAYS: '30天',
|
|
@@ -47,8 +43,7 @@ export default {
|
|
|
47
43
|
status: {
|
|
48
44
|
PENDING: '审批中',
|
|
49
45
|
NO: '不可申请',
|
|
50
|
-
OWNER: '
|
|
51
|
-
TEMP_OWNER: '临时拥有',
|
|
46
|
+
OWNER: '已拥有',
|
|
52
47
|
},
|
|
53
48
|
operationType: {
|
|
54
49
|
QUERY: '查询',
|
package/src/i18n/zh-CH.ts
CHANGED
package/src/typings/index.d.ts
CHANGED
|
@@ -26,7 +26,6 @@ declare type PermissionType = {
|
|
|
26
26
|
businessApplyType: StatusType;
|
|
27
27
|
oaFlowUrl?: string;
|
|
28
28
|
children?: PermissionListType;
|
|
29
|
-
ownStatusVO: any;
|
|
30
29
|
admin?: any[];
|
|
31
30
|
};
|
|
32
31
|
declare type PermissionListType = PermissionType[];
|
|
@@ -53,6 +52,3 @@ declare type formStateType = {
|
|
|
53
52
|
submitWorkNumber: string,
|
|
54
53
|
|
|
55
54
|
};
|
|
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" />
|