@yqg/permission 1.1.0-beta.0 → 1.1.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 +3 -1
- package/vite.config.ts +1 -1
- package/dist/apply-modal-SzDVxN-2.js +0 -6844
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yqg/permission",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,23 +13,22 @@
|
|
|
13
13
|
"dev": "vite",
|
|
14
14
|
"preview": "vite preview"
|
|
15
15
|
},
|
|
16
|
-
"
|
|
16
|
+
"devDependencies": {
|
|
17
17
|
"@ant-design/icons-vue": "^7.0.1",
|
|
18
18
|
"@commitlint/cli": "^19.5.0",
|
|
19
19
|
"@commitlint/config-conventional": "^19.5.0",
|
|
20
|
-
"
|
|
21
|
-
"axios": "^1.7.7",
|
|
22
|
-
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
23
|
-
"vue": "^3.5.12"
|
|
24
|
-
},
|
|
25
|
-
"devDependencies": {
|
|
20
|
+
"@types/vue": "^2.0.0",
|
|
26
21
|
"@typescript-eslint/parser": "^8.13.0",
|
|
27
22
|
"@vitejs/plugin-vue": "^5.1.4",
|
|
23
|
+
"ant-design-vue": "4.x",
|
|
24
|
+
"axios": "^1.7.7",
|
|
28
25
|
"eslint": "^9.14.0",
|
|
29
26
|
"husky": "^9",
|
|
30
27
|
"lint-staged": "^13.2.0",
|
|
31
28
|
"typescript": "~5.5.4",
|
|
32
29
|
"vite": "^5.4.9",
|
|
30
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
31
|
+
"vue": "^3.5.12",
|
|
33
32
|
"vue-tsc": "^2.1.8"
|
|
34
33
|
}
|
|
35
34
|
}
|
package/src/App.vue
CHANGED
|
@@ -8,18 +8,20 @@ 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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
const permissions = reactive([
|
|
12
|
+
'CRANE.ROLE.QUERY',
|
|
13
|
+
'CRANE.ROLE.CREATE',
|
|
14
|
+
'CRANE.ROLE.UPDATE',
|
|
15
|
+
'CRANE.ROLE.DELETE',
|
|
16
|
+
'CRANE.ROLE.PERMISSION_ASSIGN',
|
|
17
|
+
'CRANE.ROLE.EMPLOYEE_ASSIGN',
|
|
18
|
+
'CRANE.ROLE.DETAIL_QUERY',
|
|
19
|
+
'CRANE.ROLE.EXPORT'
|
|
20
|
+
]);
|
|
19
21
|
// const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
|
|
20
22
|
const changeColor = () => {
|
|
21
23
|
color.value = color.value === '#f00' ? '#1677ff' : '#f00';
|
|
22
|
-
}
|
|
24
|
+
}
|
|
23
25
|
const changeLocale = () => {
|
|
24
26
|
locale.value = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN';
|
|
25
27
|
}
|
|
@@ -36,44 +38,40 @@ const changeLocale = () => {
|
|
|
36
38
|
<!-- 03541 -->
|
|
37
39
|
<!-- 02124 -->
|
|
38
40
|
<!-- 05184 -->
|
|
39
|
-
<yqg-permission
|
|
41
|
+
<yqg-permission
|
|
40
42
|
:permissions="permissions"
|
|
41
|
-
workNumber="
|
|
42
|
-
businessCode="CRANE"
|
|
43
|
+
workNumber="05184"
|
|
43
44
|
:color="color"
|
|
44
45
|
:locale="locale"
|
|
45
46
|
@onSuccess="() => {console.log('成功')}"
|
|
46
47
|
>
|
|
47
48
|
</yqg-permission>
|
|
48
49
|
</div>
|
|
49
|
-
|
|
50
|
+
<data class="case-card">
|
|
50
51
|
<div>2:文字组件</div>
|
|
51
|
-
<yqg-permission
|
|
52
|
-
:permissions="
|
|
53
|
-
businessCode="CRANE"
|
|
52
|
+
<yqg-permission
|
|
53
|
+
:permissions="['ddd']"
|
|
54
54
|
:color="color"
|
|
55
55
|
workNumber="02124"
|
|
56
56
|
type="text"
|
|
57
57
|
>
|
|
58
58
|
</yqg-permission>
|
|
59
59
|
</data>
|
|
60
|
-
-->
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
|
|
63
62
|
<!-- <div class="case-card">
|
|
64
63
|
<div>3:自定义</div>
|
|
65
|
-
<yqg-permission
|
|
64
|
+
<yqg-permission
|
|
66
65
|
:permissions="permissions"
|
|
67
|
-
businessCode="CRANE"
|
|
68
66
|
:color="color"
|
|
69
67
|
workNumber="02124"
|
|
70
|
-
locale="zh-CN"
|
|
68
|
+
locale="zh-CN"
|
|
71
69
|
type="custom"
|
|
72
70
|
>
|
|
73
71
|
<div style="color: red;" slot="custom">自定义按钮</div>
|
|
74
72
|
</yqg-permission>
|
|
75
73
|
</div> -->
|
|
76
|
-
|
|
74
|
+
|
|
77
75
|
</div>
|
|
78
76
|
|
|
79
77
|
</template>
|
|
Binary file
|
|
Binary file
|
package/src/axios/index.ts
CHANGED
|
@@ -18,7 +18,11 @@
|
|
|
18
18
|
:label="t('applyPermission')"
|
|
19
19
|
name="roleIds"
|
|
20
20
|
:rules="[{ required: true, message: t('selectPlaceholder')}]">
|
|
21
|
+
<span v-if="!permissionList.length">
|
|
22
|
+
{{t('noPermissionTips')}}
|
|
23
|
+
</span>
|
|
21
24
|
<CheckboxGroup
|
|
25
|
+
v-else
|
|
22
26
|
v-model:value="formState.roleIds"
|
|
23
27
|
style="display: block;"
|
|
24
28
|
@change="onChangeHandler"
|
|
@@ -43,19 +47,12 @@
|
|
|
43
47
|
}]">
|
|
44
48
|
<Textarea
|
|
45
49
|
v-model:value.trim="formState.applyReason"
|
|
46
|
-
show-count
|
|
47
|
-
:maxlength="300"
|
|
48
50
|
:placeholder="t('applyReasonPlaceholder')"
|
|
49
|
-
:auto-size="{ minRows:
|
|
51
|
+
:auto-size="{ minRows: 4, maxRows: 4 }">
|
|
50
52
|
</Textarea>
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
style="cursor: pointer;"
|
|
55
|
-
v-for="item in reasons"
|
|
56
|
-
@click="addReasonHandler(item)"
|
|
57
|
-
:key="item">{{ item }}</Tag>
|
|
58
|
-
</div>
|
|
53
|
+
<span class="reason-tips" style="font-size: 12px">
|
|
54
|
+
{{t('applyReasonTips')}}
|
|
55
|
+
</span>
|
|
59
56
|
</FormItem>
|
|
60
57
|
|
|
61
58
|
<FormItem :label="t('approvalProcess')">
|
|
@@ -82,7 +79,6 @@
|
|
|
82
79
|
FormItem,
|
|
83
80
|
CheckboxGroup,
|
|
84
81
|
Textarea,
|
|
85
|
-
Tag,
|
|
86
82
|
message
|
|
87
83
|
} from 'ant-design-vue';
|
|
88
84
|
import SuccessModal from './success-modal.vue';
|
|
@@ -92,12 +88,6 @@
|
|
|
92
88
|
import('./checkbox-item.vue')
|
|
93
89
|
);
|
|
94
90
|
|
|
95
|
-
const reasons = [
|
|
96
|
-
t('applyReason1'),
|
|
97
|
-
t('applyReason2'),
|
|
98
|
-
t('applyReason3'),
|
|
99
|
-
]
|
|
100
|
-
|
|
101
91
|
const props = defineProps({
|
|
102
92
|
permissionList: {
|
|
103
93
|
type: Array as () => PermissionType[],
|
|
@@ -132,18 +122,6 @@
|
|
|
132
122
|
applyReason: '',
|
|
133
123
|
submitWorkNumber: submitWorkNumber.value,
|
|
134
124
|
});
|
|
135
|
-
|
|
136
|
-
const addReasonHandler = (item: string) => {
|
|
137
|
-
if (formState.applyReason.includes(item)) {
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (!formState.applyReason || formState.applyReason.endsWith('、')) {
|
|
141
|
-
formState.applyReason += item;
|
|
142
|
-
} else {
|
|
143
|
-
formState.applyReason += `、${item}`;
|
|
144
|
-
}
|
|
145
|
-
formRef.value.validateFields(['applyReason']);
|
|
146
|
-
}
|
|
147
125
|
|
|
148
126
|
const handleOk = async() => {
|
|
149
127
|
if (formState.roleIds.length > 5) {
|
|
@@ -172,7 +150,7 @@
|
|
|
172
150
|
}
|
|
173
151
|
|
|
174
152
|
const onChangeHandler = throttle(async () => {
|
|
175
|
-
if (formState.roleIds.length >
|
|
153
|
+
if (formState.roleIds.length > 5) {
|
|
176
154
|
return;
|
|
177
155
|
}
|
|
178
156
|
|
|
@@ -188,7 +166,7 @@
|
|
|
188
166
|
|
|
189
167
|
watch(() => formState.roleIds, (val) => {
|
|
190
168
|
// 写到watch里避免闪烁
|
|
191
|
-
if (val.length >
|
|
169
|
+
if (val.length > 5) {
|
|
192
170
|
formState.roleIds.pop();
|
|
193
171
|
message.warning(t('maxCountTips', {count: 5}));
|
|
194
172
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="crane-checkbox-line">
|
|
3
|
-
<Checkbox
|
|
3
|
+
<Checkbox
|
|
4
4
|
:value="item.roleId"
|
|
5
5
|
:disabled="['OWNER', 'PENDING', 'NO'].includes(props.item.businessApplyType)"
|
|
6
6
|
@change="onCheck">
|
|
7
7
|
<div class="crane-flex-center crane-checkbox-label">
|
|
8
8
|
<Tag
|
|
9
|
-
v-if="item.securityLevel"
|
|
10
|
-
:bordered="false"
|
|
11
|
-
:
|
|
9
|
+
v-if="item.securityLevel"
|
|
10
|
+
:bordered="false"
|
|
11
|
+
:style="{color: levelMap[item.securityLevel].color, background: levelMap[item.securityLevel].background}"
|
|
12
12
|
class="crane-tag-position">
|
|
13
13
|
{{ levelMap[item.securityLevel].text }}
|
|
14
14
|
</Tag>
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
<span>{{t(`operationType.${item.operationType}`)}}|
|
|
17
17
|
</span>
|
|
18
18
|
<Popover>
|
|
19
19
|
<template #content>
|
|
20
|
-
{{ item.name }}
|
|
20
|
+
<div style="max-width: 400px;">{{ item.name }}</div>
|
|
21
21
|
</template>
|
|
22
22
|
<span class="crane-text-overflow">{{ item.name }}</span>
|
|
23
23
|
</Popover>
|
|
24
24
|
<Tag
|
|
25
|
-
v-if="item.businessApplyType && item.businessApplyType !== 'TEMP_OWNER'"
|
|
26
|
-
:bordered="false"
|
|
25
|
+
v-if="item.businessApplyType && item.businessApplyType !== 'TEMP_OWNER'"
|
|
26
|
+
:bordered="false"
|
|
27
27
|
class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
|
|
28
28
|
:class="['PENDING', 'TEMP_OWNER'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
|
|
29
29
|
{{ statusMap[item.businessApplyType] }}
|
|
@@ -34,33 +34,35 @@
|
|
|
34
34
|
<span v-else>{{ t('taday') }}</span>
|
|
35
35
|
</template>
|
|
36
36
|
<Tag
|
|
37
|
-
v-if="item.businessApplyType === 'TEMP_OWNER'"
|
|
38
|
-
:bordered="false"
|
|
37
|
+
v-if="item.businessApplyType === 'TEMP_OWNER'"
|
|
38
|
+
:bordered="false"
|
|
39
39
|
class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
|
|
40
40
|
:class="['PENDING'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
|
|
41
41
|
{{ statusMap[item.businessApplyType] }}
|
|
42
42
|
</Tag>
|
|
43
43
|
</Popover>
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
</div>
|
|
46
46
|
</Checkbox>
|
|
47
47
|
|
|
48
48
|
<Popover v-if="item.desc">
|
|
49
49
|
<template #content>
|
|
50
|
-
{{ item.desc }}
|
|
50
|
+
<div style="max-width: 400px;">{{ item.desc }}</div>
|
|
51
51
|
</template>
|
|
52
52
|
<QuestionCircleOutlined class=" crane-week-color"/>
|
|
53
53
|
</Popover>
|
|
54
54
|
|
|
55
|
-
<Popover v-if="item.
|
|
55
|
+
<Popover v-if="item.relatedCompleteNames?.length">
|
|
56
56
|
<template #content>
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
<div style="max-width: 400px;">
|
|
58
|
+
{{t('adaptDepartment')}}:{{ item.relatedCompleteNames.map((item: any) => {
|
|
59
|
+
return item;
|
|
59
60
|
}).join('、') }}
|
|
61
|
+
</div>
|
|
60
62
|
</template>
|
|
61
63
|
<span class="crane-flex-center crane-margin-left-4">
|
|
62
64
|
<img :src="departmentImg" height="14" width="14">
|
|
63
|
-
<span class="crane-week-color crane-margin-left-4">{{ item.
|
|
65
|
+
<span class="crane-week-color crane-margin-left-4">{{ item.relatedCompleteNames.length }}</span>
|
|
64
66
|
</span>
|
|
65
67
|
</Popover>
|
|
66
68
|
|
|
@@ -86,16 +88,19 @@
|
|
|
86
88
|
|
|
87
89
|
const levelMap:LevelMapType = {
|
|
88
90
|
L1: {
|
|
89
|
-
color: '
|
|
90
|
-
text: t('levels.L1')
|
|
91
|
+
color: '#1AA83B',
|
|
92
|
+
text: t('levels.L1'),
|
|
93
|
+
background: '#E3F9E9',
|
|
91
94
|
},
|
|
92
95
|
L2: {
|
|
93
|
-
color: '
|
|
94
|
-
text: t('levels.L2')
|
|
95
|
-
|
|
96
|
+
color: '#F37D1C',
|
|
97
|
+
text: t('levels.L2'),
|
|
98
|
+
background: '#FFE4BA'
|
|
99
|
+
},
|
|
96
100
|
L3: {
|
|
97
|
-
color: '
|
|
98
|
-
text: t('levels.L3')
|
|
101
|
+
color: '#F2494B',
|
|
102
|
+
text: t('levels.L3'),
|
|
103
|
+
background: '#FDCDC5'
|
|
99
104
|
},
|
|
100
105
|
};
|
|
101
106
|
|
|
@@ -153,7 +158,7 @@
|
|
|
153
158
|
}
|
|
154
159
|
.crane-checkbox-line {
|
|
155
160
|
margin-bottom: 12px;
|
|
156
|
-
display: flex;
|
|
161
|
+
display: flex;
|
|
157
162
|
align-items: center;
|
|
158
163
|
}
|
|
159
164
|
.crane-checkbox-line:last-child {
|
|
@@ -164,8 +169,8 @@
|
|
|
164
169
|
}
|
|
165
170
|
.crane-tag-position {
|
|
166
171
|
margin-right: 4px;
|
|
167
|
-
font-size: 10px;
|
|
168
|
-
padding: 2px 4px;
|
|
172
|
+
font-size: 10px;
|
|
173
|
+
padding: 2px 4px;
|
|
169
174
|
line-height: 12px;
|
|
170
175
|
font-weight: 500;
|
|
171
176
|
}
|
|
@@ -192,5 +197,5 @@
|
|
|
192
197
|
overflow: hidden;
|
|
193
198
|
text-overflow: ellipsis
|
|
194
199
|
}
|
|
195
|
-
|
|
200
|
+
|
|
196
201
|
</style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<contextHolder></contextHolder>
|
|
2
|
+
<contextHolder></contextHolder>
|
|
3
3
|
</template>
|
|
4
4
|
<script lang="ts" setup>
|
|
5
5
|
import { createVNode } from 'vue';
|
|
@@ -23,11 +23,17 @@
|
|
|
23
23
|
modal1.destroy();
|
|
24
24
|
callback && callback();
|
|
25
25
|
window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
|
|
26
|
+
if (!window.YQG_PERMISSION_CALLBACK && !callback) {
|
|
27
|
+
location.reload();
|
|
28
|
+
}
|
|
26
29
|
},
|
|
27
30
|
onCancel: () => {
|
|
28
31
|
modal1.destroy();
|
|
29
32
|
callback && callback();
|
|
30
33
|
window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
|
|
34
|
+
if (!window.YQG_PERMISSION_CALLBACK && !callback) {
|
|
35
|
+
location.reload();
|
|
36
|
+
}
|
|
31
37
|
},
|
|
32
38
|
});
|
|
33
39
|
|
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<ConfigProvider
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
prefixCls="yqg-permission"
|
|
4
|
+
:theme="{
|
|
5
|
+
token: {
|
|
6
|
+
colorPrimary: props.color,
|
|
7
|
+
}
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
9
10
|
<div class="crane-wraper">
|
|
10
|
-
<template v-if="type
|
|
11
|
-
<
|
|
11
|
+
<template v-if="[COM_TYPE.FLOATBUTTON, COM_TYPE.TEXT].includes(type)">
|
|
12
|
+
<FloatButton
|
|
13
|
+
ref="dragElement"
|
|
14
|
+
type="primary"
|
|
15
|
+
:tooltip="t('clickToApply')"
|
|
16
|
+
:style="{
|
|
17
|
+
right: RIGHT_DEFAULT,
|
|
18
|
+
top: currentTop,
|
|
19
|
+
}"
|
|
20
|
+
>
|
|
21
|
+
<template #icon>
|
|
22
|
+
<img :src="applyIconUrl" height="20" width="20"/>
|
|
23
|
+
</template>
|
|
24
|
+
</FloatButton>
|
|
12
25
|
</template>
|
|
13
|
-
<template v-else-if="type===
|
|
26
|
+
<template v-else-if="type===COM_TYPE.CUSTOM">
|
|
14
27
|
<div @click="showModal">
|
|
15
|
-
<slot name="custom"
|
|
28
|
+
<slot name="custom"/>
|
|
16
29
|
</div>
|
|
17
30
|
</template>
|
|
18
31
|
<template v-else>
|
|
19
|
-
|
|
20
32
|
<!-- 可申请 -->
|
|
21
|
-
<template v-if="curStatus.status ===
|
|
33
|
+
<template v-if="curStatus.status === STATUS_MAP.DEFAULT">
|
|
22
34
|
<img
|
|
23
35
|
:src="curStatus.imageUrl"
|
|
24
36
|
height="200"
|
|
@@ -32,7 +44,7 @@
|
|
|
32
44
|
</div>
|
|
33
45
|
</template>
|
|
34
46
|
<!-- 审批中 -->
|
|
35
|
-
<template v-if="curStatus.status ===
|
|
47
|
+
<template v-if="curStatus.status === STATUS_MAP.PENDING">
|
|
36
48
|
<img
|
|
37
49
|
:src="curStatus.imageUrl"
|
|
38
50
|
height="200"
|
|
@@ -52,7 +64,7 @@
|
|
|
52
64
|
</div>
|
|
53
65
|
</template>
|
|
54
66
|
<!-- 不可申请 -->
|
|
55
|
-
<div v-if="curStatus.status ===
|
|
67
|
+
<div v-if="curStatus.status === STATUS_MAP.NO" class="crane-wraper">
|
|
56
68
|
<img
|
|
57
69
|
:src="curStatus.imageUrl"
|
|
58
70
|
height="200"
|
|
@@ -83,20 +95,35 @@
|
|
|
83
95
|
</ConfigProvider>
|
|
84
96
|
</template>
|
|
85
97
|
<script lang="ts" setup>
|
|
86
|
-
import { ref, defineAsyncComponent, computed, watchEffect, watch} from 'vue';
|
|
87
|
-
import {Button, ConfigProvider,
|
|
98
|
+
import { ref, defineAsyncComponent, computed, watchEffect, watch } from 'vue';
|
|
99
|
+
import { Button, ConfigProvider, Popover , message, FloatButton} from 'ant-design-vue';
|
|
88
100
|
import applyUrl from '@/assets/applying.png';
|
|
101
|
+
import applyIconUrl from '@/assets/applyicon.png';
|
|
89
102
|
import noauthority from '@/assets/noauthority.png';
|
|
90
103
|
import Http from '../axios/index';
|
|
91
104
|
import t from '../utils';
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const statusMap = {
|
|
105
|
+
import useDraggable from '../hooks/useDragable';
|
|
106
|
+
|
|
107
|
+
const STATUS_MAP = {
|
|
96
108
|
DEFAULT: 'DEFAULT',
|
|
97
109
|
PENDING: 'PENDING',
|
|
98
110
|
NO: 'NO',
|
|
99
|
-
}
|
|
111
|
+
} as const;
|
|
112
|
+
|
|
113
|
+
const COM_TYPE = {
|
|
114
|
+
FLOATBUTTON: 'floatButton',
|
|
115
|
+
DEFAULT: 'default',
|
|
116
|
+
TEXT: 'text',
|
|
117
|
+
CUSTOM: 'custom',
|
|
118
|
+
};
|
|
119
|
+
const RIGHT_DEFAULT = '10px';
|
|
120
|
+
|
|
121
|
+
// 重置 message 类名,避免被全局样式覆盖
|
|
122
|
+
message.config({prefixCls: 'yqg-permission-message'});
|
|
123
|
+
|
|
124
|
+
const ApplyModal = defineAsyncComponent(() =>import('./apply-modal.vue'));
|
|
125
|
+
|
|
126
|
+
const emit = defineEmits(['onSuccess']);
|
|
100
127
|
|
|
101
128
|
const props = defineProps({
|
|
102
129
|
workNumber: {
|
|
@@ -107,10 +134,6 @@
|
|
|
107
134
|
type: [String, Array<String>],
|
|
108
135
|
default: []
|
|
109
136
|
},
|
|
110
|
-
businessCode: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: ''
|
|
113
|
-
},
|
|
114
137
|
locale: {
|
|
115
138
|
type: String,
|
|
116
139
|
default: 'zh-CN'
|
|
@@ -123,9 +146,12 @@
|
|
|
123
146
|
type: String,
|
|
124
147
|
default: 'default'
|
|
125
148
|
},
|
|
149
|
+
top: {
|
|
150
|
+
type: String,
|
|
151
|
+
default: '100px'
|
|
152
|
+
}
|
|
126
153
|
});
|
|
127
|
-
|
|
128
|
-
|
|
154
|
+
|
|
129
155
|
const open = ref(false);
|
|
130
156
|
const curApproving = ref<PermissionType>();
|
|
131
157
|
let permissionList = ref<PermissionListType>([]);
|
|
@@ -133,18 +159,27 @@
|
|
|
133
159
|
imageUrl: noauthority,
|
|
134
160
|
status: '',
|
|
135
161
|
})
|
|
162
|
+
|
|
136
163
|
const allPermissions = computed(() => {
|
|
164
|
+
permissionList.value = [];
|
|
137
165
|
if (Array.isArray(props.permissions)) {
|
|
138
|
-
return props.permissions;
|
|
139
|
-
} else {
|
|
140
|
-
return props.permissions.split(',');
|
|
166
|
+
return props.permissions.filter((item) => item.trim());
|
|
141
167
|
}
|
|
168
|
+
return props.permissions?.split(',')?.filter((item) => item.trim()) || [];
|
|
142
169
|
});
|
|
143
170
|
|
|
171
|
+
const businessCode = computed(() => {
|
|
172
|
+
const code = allPermissions.value[0] || '';
|
|
173
|
+
if (!code) return '';
|
|
174
|
+
|
|
175
|
+
return code.split('.')[0];
|
|
176
|
+
})
|
|
177
|
+
|
|
144
178
|
const formatPermissionsData = (data: PermissionListType) => {
|
|
145
179
|
const arr:PermissionListType = [];
|
|
146
180
|
const flattenData = (list: PermissionListType) => {
|
|
147
181
|
list.forEach((item) => {
|
|
182
|
+
item.name = item.name.replace(/^[^.]+\./, '');
|
|
148
183
|
if (item.children) {
|
|
149
184
|
flattenData(item.children);
|
|
150
185
|
} else {
|
|
@@ -153,13 +188,19 @@
|
|
|
153
188
|
})
|
|
154
189
|
};
|
|
155
190
|
flattenData(data);
|
|
191
|
+
|
|
156
192
|
// 需要排序,规则:businessApplyType 为 null 在前面, PENDING. OWNER 在中间, NO 在后面
|
|
157
193
|
// 然后再根据 L1, L2, L3 排序
|
|
158
194
|
const sort = [ null, 'TEMP_OWNER', 'PENDING', 'OWNER', 'NO'];
|
|
159
195
|
const levelSort = ['L1', 'L2', 'L3'];
|
|
196
|
+
const sortMap = new Map(sort.map((value, index) => [value, index]));
|
|
197
|
+
const levelSortMap = new Map(levelSort.map((value, index) => [value, index]));
|
|
198
|
+
|
|
160
199
|
arr.sort((a, b) => {
|
|
161
|
-
return
|
|
200
|
+
return (sortMap.get(a.businessApplyType) ?? 0) - (sortMap.get(b.businessApplyType) ?? 0)
|
|
201
|
+
|| (levelSortMap.get(a.securityLevel) ?? 0) - (levelSortMap.get(b.securityLevel) ?? 0);
|
|
162
202
|
});
|
|
203
|
+
|
|
163
204
|
return arr;
|
|
164
205
|
}
|
|
165
206
|
|
|
@@ -167,16 +208,18 @@
|
|
|
167
208
|
if (!data.length) {
|
|
168
209
|
return {
|
|
169
210
|
imageUrl: noauthority,
|
|
170
|
-
status: ''
|
|
211
|
+
status: ''
|
|
171
212
|
};
|
|
172
213
|
}
|
|
173
|
-
|
|
174
|
-
const
|
|
214
|
+
|
|
215
|
+
const current = data.find((per) => per.businessApplyType === STATUS_MAP.PENDING);
|
|
216
|
+
const cannotApply = data.every((per) => per.businessApplyType === STATUS_MAP.NO);
|
|
217
|
+
|
|
175
218
|
if (current) {
|
|
176
219
|
curApproving.value = current;
|
|
177
220
|
return {
|
|
178
221
|
imageUrl: applyUrl,
|
|
179
|
-
status:
|
|
222
|
+
status: STATUS_MAP.PENDING,
|
|
180
223
|
tips: t('status.PENDING'),
|
|
181
224
|
url: current.oaFlowUrl,
|
|
182
225
|
};
|
|
@@ -185,49 +228,55 @@
|
|
|
185
228
|
if (cannotApply) {
|
|
186
229
|
return {
|
|
187
230
|
imageUrl: noauthority,
|
|
188
|
-
status:
|
|
231
|
+
status: STATUS_MAP.NO,
|
|
189
232
|
tips: data[0].admin?.map((item) => `${item.name}(${item.departmentName})`)?.join('、'),
|
|
190
233
|
};
|
|
191
234
|
};
|
|
235
|
+
|
|
192
236
|
return {
|
|
193
237
|
imageUrl: noauthority,
|
|
194
|
-
status:
|
|
238
|
+
status: STATUS_MAP.DEFAULT,
|
|
195
239
|
}
|
|
196
240
|
};
|
|
197
241
|
|
|
198
242
|
const goViewApproval = () => {
|
|
199
|
-
|
|
200
|
-
if (
|
|
201
|
-
|
|
202
|
-
|
|
243
|
+
const url = curApproving.value?.oaFlowUrl;
|
|
244
|
+
if (!url) return;
|
|
245
|
+
|
|
246
|
+
window.open(url, '_blank');
|
|
203
247
|
};
|
|
204
248
|
|
|
205
249
|
const getPermissions = async () => {
|
|
206
|
-
|
|
250
|
+
const { workNumber } = props;
|
|
251
|
+
const permissions = allPermissions.value;
|
|
252
|
+
if (!permissions?.length || !workNumber) return;
|
|
207
253
|
|
|
208
254
|
const params = {
|
|
209
|
-
|
|
210
|
-
features:
|
|
211
|
-
workNumber: props.workNumber,
|
|
255
|
+
workNumber,
|
|
256
|
+
features: permissions.toString(),
|
|
212
257
|
};
|
|
213
258
|
|
|
214
|
-
|
|
259
|
+
const res = await Http.getPermissions(params);
|
|
215
260
|
permissionList.value = formatPermissionsData(res.body || []);
|
|
261
|
+
|
|
216
262
|
curStatus.value = getStatus(permissionList.value);
|
|
217
263
|
};
|
|
218
264
|
|
|
219
265
|
const showModal = () => {
|
|
266
|
+
getPermissions();
|
|
220
267
|
open.value = !open.value;
|
|
221
268
|
};
|
|
222
269
|
|
|
270
|
+
const { currentTop, dragElement } = useDraggable(props, showModal);
|
|
271
|
+
|
|
223
272
|
watchEffect(getPermissions);
|
|
224
273
|
|
|
225
274
|
watch(() => props.locale, (cur, pre) => {
|
|
226
275
|
if (cur === pre) return;
|
|
227
276
|
localStorage.setItem('permission_locale', props.locale);
|
|
228
277
|
}, {immediate: true})
|
|
229
|
-
|
|
230
278
|
</script>
|
|
279
|
+
|
|
231
280
|
<style scoped>
|
|
232
281
|
.crane-wraper {
|
|
233
282
|
display: flex;
|
|
@@ -244,3 +293,4 @@
|
|
|
244
293
|
}
|
|
245
294
|
</style>
|
|
246
295
|
|
|
296
|
+
../hooks/useDragable
|