@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.
@@ -19,10 +19,10 @@
19
19
  :class="['PENDING'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
20
20
  {{ statusMap[item.businessApplyType] }}
21
21
  {{ item.businessApplyType === 'TEMP_OWNER' ? `(${(item?.ownStatusVO?.dayDiff > 0 ?
22
- t('lastDays', {
23
- count:
24
- item?.ownStatusVO?.dayDiff
25
- }) : t('today'))})` : ''}}
22
+ t('lastDays', {
23
+ count:
24
+ item?.ownStatusVO?.dayDiff
25
+ }) : t('today'))})` : '' }}
26
26
  </Tag>
27
27
 
28
28
  <Popover v-if="item.desc">
@@ -34,16 +34,17 @@
34
34
 
35
35
  <Popover v-if="item.relatedCompleteNames?.length">
36
36
  <template #content>
37
- <div style="max-width: 400px;">
38
- {{ t('adaptDepartment') }}:{{item.relatedCompleteNames.map((item: any) => {
39
- return item;
40
- }).join('、') }}
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">
44
45
  <img :src="departmentImg" height="14" width="14">
45
46
  <span class="crane-weak-color crane-margin-left-4">{{ item.relatedCompleteNames.length
46
- }}</span>
47
+ }}</span>
47
48
  </div>
48
49
  </Popover>
49
50
 
@@ -59,15 +60,15 @@
59
60
  </template>
60
61
  <div class="crane-weak-color crane-margin-left-4 crane-text-overflow">
61
62
  {{item.categoryVOS?.map((item:
62
- any) => {
63
- return item.categoryName;
63
+ any) => {
64
+ return item.categoryName;
64
65
  }).join('、')
65
66
  }}
66
67
  </div>
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"
@@ -88,7 +89,7 @@ import t from '../utils';
88
89
 
89
90
  const OWNER_STATUS = 'OWNER';
90
91
 
91
- const levelMap:LevelMapType = {
92
+ const levelMap: LevelMapType = {
92
93
  L1: {
93
94
  color: '#1AA83B',
94
95
  text: t('levels.L1'),
@@ -120,7 +121,7 @@ let props = defineProps({
120
121
  },
121
122
  item: {
122
123
  type: Object as PropType<PermissionType>,
123
- default: () => {}
124
+ default: () => { }
124
125
  }
125
126
  });
126
127
 
@@ -136,7 +137,7 @@ const tempTimeOptions = computed(() => {
136
137
  const getCategoryValue = (category: CategoryType) => {
137
138
  return `【${category.categoryName}】:${category.attributeValues?.map((item: any) => item.attributeName)?.join('、') || t('empty')}`;
138
139
  };
139
-
140
+
140
141
  const onChangeTimeHandler = () => {
141
142
  emit('updateTime', props.item);
142
143
  emit('onChangeTime', props.item);
@@ -145,15 +146,21 @@ 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;
151
157
  white-space: nowrap;
152
- }
158
+ }
153
159
 
154
- .permission-item-wraper {
160
+ .permission-item-wraper {
155
161
  padding-right: 32px;
156
- }
162
+ }
163
+
157
164
  .crane-checkbox-line {
158
165
  line-height: 28px;
159
166
  display: flex;
@@ -166,31 +173,36 @@ const onChangeTimeHandler = () => {
166
173
  padding: 2px 4px;
167
174
  line-height: 12px;
168
175
  font-weight: 500;
169
- }
170
- .crane-margin-right-0 {
176
+ }
177
+
178
+ .crane-margin-right-0 {
171
179
  margin-right: 0;
172
- }
173
- .crane-margin-left-4 {
180
+ }
181
+
182
+ .crane-margin-left-4 {
174
183
  margin-left: 4px;
175
- }
176
- .crane-margin-right-4 {
184
+ }
185
+
186
+ .crane-margin-right-4 {
177
187
  margin-right: 4px;
178
- }
179
- .crane-margin-left-12 {
188
+ }
189
+
190
+ .crane-margin-left-12 {
180
191
  margin-left: 12px;
181
- }
182
- .crane-disabled-color {
192
+ }
193
+
194
+ .crane-disabled-color {
183
195
  color: #C9CDD4;
184
- }
185
- .crane-weak-color {
196
+ }
197
+
198
+ .crane-weak-color {
186
199
  color: #86909C;
187
- }
188
- .crane-text-overflow {
200
+ }
201
+
202
+ .crane-text-overflow {
189
203
  max-width: 160px;
190
- overflow: hidden;
191
- text-overflow: ellipsis;
204
+ overflow: hidden;
205
+ text-overflow: ellipsis;
192
206
  white-space: nowrap;
193
- }
194
-
195
-
207
+ }
196
208
  </style>
@@ -2,59 +2,59 @@
2
2
  <contextHolder></contextHolder>
3
3
  </template>
4
4
  <script lang="ts" setup>
5
- import { createVNode } from 'vue';
6
- import { CheckCircleFilled } from '@ant-design/icons-vue';
7
- import { Modal } from 'ant-design-vue';
8
- import t from '../utils';
5
+ import { createVNode } from 'vue';
6
+ import { CheckCircleFilled } from '@ant-design/icons-vue';
7
+ import { Modal } from 'ant-design-vue';
8
+ import t from '../utils';
9
9
 
10
- const [modal, contextHolder] = Modal.useModal();
10
+ const [modal, contextHolder] = Modal.useModal();
11
11
 
12
- const countDown = (url: string, callback?: ()=>void) => {
13
- let secondsToGo = 10;
14
- const modal1 = modal.confirm({
15
- title: t('resoultTitle'),
16
- content: t('successTips'),
17
- cancelText: `${t('close')}(${secondsToGo}s)`,
18
- okText:`${t('viewApprovalDetail')}>>`,
19
- wrapClassName: 'yqg-permission-modal-wrap',
20
- icon: createVNode(CheckCircleFilled, {style: 'color: #52c41a;'}),
21
- onOk: () => {
22
- window.open(url);
23
- modal1.destroy();
24
- callback && callback();
25
- window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
26
- if (!window.YQG_PERMISSION_CALLBACK && !callback) {
27
- location.reload();
28
- }
29
- },
30
- onCancel: () => {
31
- modal1.destroy();
32
- callback && callback();
33
- window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
34
- if (!window.YQG_PERMISSION_CALLBACK && !callback) {
35
- location.reload();
36
- }
37
- },
38
- });
12
+ const countDown = (url: string, callback?: () => void) => {
13
+ let secondsToGo = 10;
14
+ const modal1 = modal.confirm({
15
+ title: t('resoultTitle'),
16
+ content: t('successTips'),
17
+ cancelText: `${t('close')}(${secondsToGo}s)`,
18
+ okText: `${t('viewApprovalDetail')}>>`,
19
+ wrapClassName: 'yqg-permission-modal-wrap',
20
+ icon: createVNode(CheckCircleFilled, { style: 'color: #52c41a;' }),
21
+ onOk: () => {
22
+ window.open(url);
23
+ modal1.destroy();
24
+ callback && callback();
25
+ window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
26
+ if (!window.YQG_PERMISSION_CALLBACK && !callback) {
27
+ location.reload();
28
+ }
29
+ },
30
+ onCancel: () => {
31
+ modal1.destroy();
32
+ callback && callback();
33
+ window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
34
+ if (!window.YQG_PERMISSION_CALLBACK && !callback) {
35
+ location.reload();
36
+ }
37
+ },
38
+ });
39
39
 
40
- const interval = setInterval(() => {
41
- secondsToGo -= 1;
42
- modal1.update({
43
- cancelText: `${t('close')}(${secondsToGo}s)`,
44
- });
45
- }, 1000);
40
+ const interval = setInterval(() => {
41
+ secondsToGo -= 1;
42
+ modal1.update({
43
+ cancelText: `${t('close')}(${secondsToGo}s)`,
44
+ });
45
+ }, 1000);
46
46
 
47
- setTimeout(() => {
48
- clearInterval(interval);
49
- modal1.destroy();
50
- }, secondsToGo * 1000);
51
- }
47
+ setTimeout(() => {
48
+ clearInterval(interval);
49
+ modal1.destroy();
50
+ }, secondsToGo * 1000);
51
+ }
52
52
 
53
- defineExpose({countDown});
53
+ defineExpose({ countDown });
54
54
 
55
55
  </script>
56
56
  <style>
57
57
  .yqg-permission-modal-wrap .yqg-permission-modal-confirm-btns {
58
- text-align: center!important;
58
+ text-align: center !important;
59
59
  }
60
60
  </style>
@@ -1,21 +1,21 @@
1
1
  <template>
2
- <ConfigProvider prefixCls="yqg-permission" :theme="{
3
- token: {
4
- colorPrimary: props.color,
5
- }
6
- }">
7
- <div class="crane-wraper">
2
+ <ConfigProvider prefixCls="yqg-permission" :key="locale" :theme="{
3
+ token: {
4
+ colorPrimary: color,
5
+ }
6
+ }">
7
+ <div class="crane-wraper" :key="locale">
8
8
  <template v-if="[COM_TYPE.FLOATBUTTON, COM_TYPE.TEXT].includes(type)">
9
9
  <FloatButton ref="dragElement" type="primary" :tooltip="t('clickToApply')" :style="{
10
- right: RIGHT_DEFAULT,
11
- top: currentTop,
12
- }">
10
+ right: RIGHT_DEFAULT,
11
+ top: currentTop,
12
+ }">
13
13
  <template #icon>
14
14
  <img :src="applyIconUrl" height="20" width="20" />
15
15
  </template>
16
16
  </FloatButton>
17
17
  </template>
18
- <template v-else-if="type===COM_TYPE.CUSTOM">
18
+ <template v-else-if="type === COM_TYPE.CUSTOM">
19
19
  <div @click="showModal">
20
20
  <slot name="custom" />
21
21
  </div>
@@ -28,7 +28,7 @@
28
28
  {{ t('unavailableTips') }}
29
29
  </div>
30
30
  <div>
31
- <Button type="primary" @click="showModal">+ {{t('applyPermission')}}</Button>
31
+ <Button type="primary" @click="showModal">+ {{ t('applyPermission') }}</Button>
32
32
  </div>
33
33
  </template>
34
34
  <!-- 审批中 -->
@@ -36,14 +36,14 @@
36
36
  <img :src="curStatus.imageUrl" height="200" width="200" style="margin-top: calc(50vh - 273px)" />
37
37
  <div class="crane-margin10">
38
38
  <span class="crane-unapply" v-html="t('appliedTips', {
39
- status: `<style>.crane-unapply span {color: orange;}</style><span>${curStatus.tips}</span>`
40
- })">
39
+ status: `<style>.crane-unapply span {color: orange;}</style><span>${curStatus.tips}</span>`
40
+ })">
41
41
  </span>
42
42
  </div>
43
43
  <div>
44
- <Button class="crane-margin-right10"
45
- @click="goViewApproval">{{t('viewApprovalDetail')}}</Button>
46
- <Button type="primary" @click="showModal">+ {{t('applyMore')}}</Button>
44
+ <Button class="crane-margin-right10" @click="goViewApproval">{{ t('viewApprovalDetail')
45
+ }}</Button>
46
+ <Button type="primary" @click="showModal">+ {{ t('applyMore') }}</Button>
47
47
  </div>
48
48
  </template>
49
49
  <!-- 不可申请 -->
@@ -53,9 +53,9 @@
53
53
  {{ t('unapplyTips') }}
54
54
  <Popover>
55
55
  <template #content>
56
- <div style="max-width: 400px;">{{t('manager')}}: {{ curStatus.tips }}</div>
56
+ <div style="max-width: 400px;">{{ t('manager') }}: {{ curStatus.tips }}</div>
57
57
  </template>
58
- <span style="color: #1677ff;">{{t('callManager') }}</span>
58
+ <span style="color: #1677ff;">{{ t('callManager') }}</span>
59
59
  </Popover>
60
60
  </div>
61
61
  </div>
@@ -63,142 +63,167 @@
63
63
  </div>
64
64
 
65
65
  <ApplyModal v-model="open" :permissionList="permissionList" :spining="loading" :workNumber="workNumber"
66
- @onSuccess="() => emit('onSuccess')" @onSubmit="getPermissions">
66
+ :zIndex="zIndex" :defaultCheckedIds="defaultCheckedIds" :isAllChecked="isAllChecked"
67
+ @onSuccess="() => emit('onSuccess')" @onSubmit="getPermissions" :color="color">
67
68
  </ApplyModal>
68
-
69
69
  </ConfigProvider>
70
+
70
71
  </template>
71
72
  <script lang="ts" setup>
72
- import { ref, defineAsyncComponent, computed, watchEffect, watch } from 'vue';
73
- import { Button, ConfigProvider, Popover , message, FloatButton} from 'ant-design-vue';
74
- import applyIconUrl from '@/assets/applyicon.png';
75
- import noauthority from '@/assets/noauthority.png';
76
- import Http from '../axios/index';
77
- import t from '../utils';
78
- import useDraggable from '../hooks/useDragable';
79
- import useStatus from '../hooks/useStatus';
73
+ import { ref, defineAsyncComponent, computed, watchEffect, watch } from 'vue';
74
+ import { Button, ConfigProvider, Popover, message, FloatButton } from 'ant-design-vue';
75
+ import applyIconUrl from '@/assets/applyicon.png';
76
+ import noauthority from '@/assets/noauthority.png';
77
+ import Http from '../axios/index';
78
+ import t, { setLocale } from '../utils';
79
+ import useDraggable from '../hooks/useDragable';
80
+ import useStatus from '../hooks/useStatus';
80
81
  import useFormat from '../hooks/useFormat';
82
+ import '../style/reset.css';
81
83
 
82
- const STATUS_MAP = {
83
- DEFAULT: 'DEFAULT',
84
- PENDING: 'PENDING',
85
- NO: 'NO',
86
- } as const;
87
-
88
- const COM_TYPE = {
89
- FLOATBUTTON: 'floatButton',
90
- DEFAULT: 'default',
91
- TEXT: 'text',
92
- CUSTOM: 'custom',
93
- };
94
- const RIGHT_DEFAULT = '10px';
95
-
96
- // 重置 message 类名,避免被全局样式覆盖
97
- message.config({prefixCls: 'yqg-permission-message'});
98
-
99
- const ApplyModal = defineAsyncComponent(() =>import('./apply-modal.vue'));
100
-
101
- const emit = defineEmits(['onSuccess']);
102
-
103
- const props = defineProps({
104
- workNumber: {
105
- type: String,
106
- default: ''
107
- },
108
- permissions: {
109
- type: [String, Array<String>],
110
- default: []
111
- },
112
- locale: {
113
- type: String,
114
- default: 'zh-CN'
115
- },
116
- color: {
117
- type: String,
118
- default: '#1677ff'
119
- },
120
- type: {
121
- type: String,
122
- default: 'default'
123
- },
124
- top: {
125
- type: String,
126
- default: '100px'
127
- }
128
- });
129
-
130
- const open = ref(false);
131
- const curApproving = ref<PermissionType>();
132
- const loading = ref(false);
133
- let permissionList = ref<PermissionListType>([]);
134
- let curStatus = ref<Record<string, any>>({
135
- imageUrl: noauthority,
136
- status: '',
137
- })
138
-
139
- const allPermissions = computed(() => {
140
- permissionList.value = [];
141
- if (Array.isArray(props.permissions)) {
142
- return props.permissions.filter((item) => item.trim());
143
- }
144
- return props.permissions?.split(',')?.filter((item) => item.trim()) || [];
145
- });
146
-
147
- const goViewApproval = () => {
148
- const url = curApproving.value?.oaFlowUrl;
149
- if (!url) return;
150
-
151
- window.open(url, '_blank');
84
+ const STATUS_MAP = {
85
+ DEFAULT: 'DEFAULT',
86
+ PENDING: 'PENDING',
87
+ NO: 'NO',
88
+ } as const;
89
+
90
+ const COM_TYPE = {
91
+ FLOATBUTTON: 'floatButton',
92
+ DEFAULT: 'default',
93
+ TEXT: 'text',
94
+ CUSTOM: 'custom',
95
+ };
96
+ const RIGHT_DEFAULT = '10px';
97
+
98
+ // 重置 message 类名,避免被全局样式覆盖
99
+ message.config({ prefixCls : 'yqg-permission-message'});
100
+
101
+ const ApplyModal = defineAsyncComponent(() => import('./apply-modal.vue'));
102
+
103
+ const emit = defineEmits(['onSuccess']);
104
+
105
+ const props = defineProps({
106
+ workNumber: {
107
+ type: String,
108
+ default: ''
109
+ },
110
+ permissions: {
111
+ type: [String, Array<String>],
112
+ default: []
113
+ },
114
+ locale: {
115
+ type: String,
116
+ default: 'zh'
117
+ },
118
+ color: {
119
+ type: String,
120
+ default: '#1677ff'
121
+ },
122
+ type: {
123
+ type: String,
124
+ default: 'default'
125
+ },
126
+ top: {
127
+ type: String,
128
+ default: '100px'
129
+ },
130
+ zIndex: {
131
+ type: Number,
132
+ default: 10000
133
+ },
134
+ // 某些业务场景需要在特定页面隐藏某些数据维度
135
+ omitCategoryIds: {
136
+ type: [String, Array<number>],
137
+ required: false,
138
+ default: () => []
139
+ },
140
+ });
141
+
142
+ const open = ref(false);
143
+ const curApproving = ref<PermissionType>();
144
+ const loading = ref(false);
145
+ const defaultCheckedIds = ref<string[]>([]);
146
+ const isAllChecked = ref(false);
147
+ let permissionList = ref<PermissionListType>([]);
148
+ let curStatus = ref<Record<string, any>>({
149
+ imageUrl: noauthority,
150
+ status: '',
151
+ })
152
+
153
+ const needOmitCategoryIds = computed(() => {
154
+ if (Array.isArray(props.omitCategoryIds)) {
155
+ return props.omitCategoryIds;
156
+ }
157
+ return props.omitCategoryIds?.split(',')?.map((item) => Number(item)) || [];
158
+ });
159
+
160
+ const allPermissions = computed(() => {
161
+ permissionList.value = [];
162
+ if (Array.isArray(props.permissions)) {
163
+ return props.permissions.filter((item) => item.trim());
164
+ }
165
+ return props.permissions?.split(',')?.filter((item) => item.trim()) || [];
166
+ });
167
+
168
+ const goViewApproval = () => {
169
+ const url = curApproving.value?.oaFlowUrl;
170
+ if (!url) return;
171
+
172
+ window.open(url, '_blank');
173
+ };
174
+
175
+ const getPermissions = async () => {
176
+ const { workNumber } = props;
177
+ const permissions = allPermissions.value;
178
+ if (!permissions?.length || !workNumber) return;
179
+
180
+ const params = {
181
+ workNumber,
182
+ features: permissions.toString(),
152
183
  };
153
184
 
154
- const getPermissions = async () => {
155
- const { workNumber } = props;
156
- const permissions = allPermissions.value;
157
- if (!permissions?.length || !workNumber) return;
158
-
159
- const params = {
160
- workNumber,
161
- features: permissions.toString(),
162
- };
163
-
164
- loading.value = true;
165
- const res = await Http.getPermissions(params);
166
- permissionList.value = useFormat(res.body || []);
167
- curStatus.value = useStatus(permissionList.value, curApproving);
168
- loading.value = false;
169
- };
170
-
171
- const showModal = () => {
172
- open.value = !open.value;
173
- getPermissions();
174
- };
185
+ loading.value = true;
186
+ const res = await Http.getPermissions(params);
187
+ const datalist = useFormat(res.body || [], needOmitCategoryIds.value);
188
+ permissionList.value = datalist.data;
189
+ defaultCheckedIds.value = datalist.checkList;
190
+ isAllChecked.value = datalist.isAllChecked;
191
+ curStatus.value = useStatus(permissionList.value, curApproving);
192
+ loading.value = false;
193
+ };
175
194
 
176
- const { currentTop, dragElement } = useDraggable(props, showModal);
195
+ const showModal = () => {
196
+ open.value = !open.value;
197
+ getPermissions();
198
+ };
177
199
 
178
- watchEffect(() => {
179
- if (props.type === COM_TYPE.DEFAULT) {
180
- getPermissions();
181
- }
182
- });
183
- watch(() => props.locale, (cur, pre) => {
184
- if (cur === pre) return;
185
- localStorage.setItem('permission_locale', props.locale);
186
- }, {immediate: true});
200
+ const { currentTop, dragElement } = useDraggable(props, showModal);
201
+
202
+ watchEffect(() => {
203
+ if (props.type === COM_TYPE.DEFAULT) {
204
+ getPermissions();
205
+ }
206
+ });
207
+ watch(() => props.locale, (cur, pre) => {
208
+ if (cur === pre) return;
209
+ setLocale(cur);
210
+ }, { immediate: true });
187
211
  </script>
188
212
 
189
213
  <style scoped>
190
- .crane-wraper {
191
- display: flex;
192
- align-items: center;
193
- flex-direction: column;
194
- font-size: 14px;
195
- white-space: nowrap;
196
- }
197
- .crane-margin10 {
198
- margin: 10px;
199
- }
200
- .crane-margin-right10 {
201
- margin-right: 10px;
202
- }
203
- </style>
204
- ../hooks/useSort../hooks/useFormat
214
+ .crane-wraper {
215
+ display: flex;
216
+ align-items: center;
217
+ flex-direction: column;
218
+ font-size: 14px;
219
+ white-space: nowrap;
220
+ }
221
+
222
+ .crane-margin10 {
223
+ margin: 10px;
224
+ }
225
+
226
+ .crane-margin-right10 {
227
+ margin-right: 10px;
228
+ }
229
+ </style>
@@ -5,7 +5,7 @@ export default function useCategory(tree: PermissionType[], checkedIds: string[]
5
5
  const categoryList: CategoryType[] = [];
6
6
  deepTree(tree, (item) => {
7
7
  if (!item.children && checkedIds.includes(item.feature)) {
8
- item.categoryVOS.forEach((category: any) => {
8
+ item.categoryVOS?.forEach((category: any) => {
9
9
  category.attributeValueIds_view = category?.attributeValueIds || [];
10
10
  categoryList.push(category);
11
11
  });