@yqg/permission 1.3.0-alpha.4 → 1.3.0-alpha.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yqg/permission",
3
- "version": "1.3.0-alpha.4",
3
+ "version": "1.3.0-alpha.6",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",
package/src/App.vue CHANGED
@@ -9,11 +9,14 @@ const color = ref<string>('#1677ff');
9
9
  const locale = ref<LocaleType>('zh-CN');
10
10
 
11
11
  const permissions = reactive([
12
- 'CRANE.EMPLOYEE.QUERY',
13
- 'CRANE.EMPLOYEE.DETAIL_QUERY',
14
- 'CRANE.EMPLOYEE.ATTRIBUTE_CREATE',
15
- 'CRANE.EMPLOYEE.ROLE_ASSIGN',
16
- 'CRANE.EMPLOYEE.DEPARTMENT_ROLE.ATTRIBUTE_ROLE_CREATE',
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',
17
20
  ]);
18
21
  // const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
19
22
  const changeColor = () => {
@@ -37,7 +40,7 @@ const changeLocale = () => {
37
40
  <!-- 05184 -->
38
41
  <yqg-permission
39
42
  :permissions="permissions"
40
- workNumber="04701"
43
+ workNumber="05621"
41
44
  :color="color"
42
45
  :locale="locale"
43
46
  @onSuccess="() => {console.log('成功')}"
@@ -69,6 +69,10 @@ import SuccessModal from './success-modal.vue';
69
69
  import ApprovalSteps from './approval-steps.vue';
70
70
  import t, {throttle, deepTree} from '../utils';
71
71
  import useCategory from '../hooks/useCategory';
72
+ import useDefaultTime from '../hooks/useDefaultTime';
73
+
74
+ const OWNER_STATUS = 'OWNER';
75
+ const MAX_COUNT = 5;
72
76
 
73
77
  const CategorySelector = defineAsyncComponent(() =>
74
78
  import('./category-selector.vue')
@@ -155,7 +159,6 @@ const getParams = () => {
155
159
  };
156
160
 
157
161
  });
158
-
159
162
  deepTree(permissionList.value, (item: any) => {
160
163
  if (!item.children && formState.features.includes(item.feature)) {
161
164
  roleVoList.push({
@@ -180,6 +183,7 @@ const setDefaultTime = (permission: PermissionType) => {
180
183
 
181
184
  const onChangeTime = throttle(async () => {
182
185
  const params = getParams();
186
+
183
187
  if (params.roleVoList.length === 0) {
184
188
  stepNodes.value = [];
185
189
  return;
@@ -199,33 +203,40 @@ const onCheck = (checkedIds:any, info:any) => {
199
203
  if (!item.children && formState.features.includes(item.feature)) {
200
204
  curTotal += 1;
201
205
  }
206
+ if (!item.children && !formState.features.includes(item.feature)) {
207
+ // 新选择的节点,设置默认时间
208
+ item.validTime = useDefaultTime(item, OWNER_STATUS);
209
+ }
202
210
  })
203
211
 
204
- if (curTotal === 5) {
205
- message.warning(t('maxCountTips', {count: 5}));
212
+ if (curTotal > MAX_COUNT) {
213
+ message.warning(t('maxCountTips', { count: MAX_COUNT }));
206
214
  return;
207
215
  }
208
- onChangeTime();
209
- if (!info.node.children && total > 5) {
216
+ if (!info.node.children && total > MAX_COUNT) {
210
217
  //选择的是子节点
211
218
  formState.features = formState.features.filter((item) => item !== info.node.feature);
212
- message.warning(t('maxCountTips', {count: 5}));
219
+ message.warning(t('maxCountTips', { count: MAX_COUNT }));
220
+ onChangeTime();
221
+
213
222
  return;
214
223
  }
215
224
 
216
- if (info.node.children && total > 5) {
225
+ if (info.node.children && total > MAX_COUNT) {
217
226
  //选择的是父节点,则找出刚选的所有叶子节点, 并且删除其中多余(total-5)的节点
218
- const diff = total - 5;
227
+ const diff = total - MAX_COUNT;
219
228
  let leafNodes:string[] = [];
220
229
  deepTree([info.node], (item: any) => {
221
- if (!item.children && !formState.features.includes(item.feature)) {
230
+ if (!item.children && !item.disabled && !formState.features.includes(item.feature)) {
222
231
  leafNodes.push(item.feature);
223
232
  }
224
233
  })
225
234
  // 从后面删除多余的节点
226
235
  leafNodes = leafNodes.slice(0, leafNodes.length - diff);
227
236
  formState.features = formState.features.concat(leafNodes);
228
- message.warning(t('maxCountTips', {count: 5}));
237
+ message.warning(t('maxCountTips', { count: MAX_COUNT }));
238
+ onChangeTime();
239
+
229
240
  return;
230
241
  };
231
242
 
@@ -233,7 +244,6 @@ const onCheck = (checkedIds:any, info:any) => {
233
244
 
234
245
  // 收集需要展示的数据属性
235
246
  categoryList.value = useCategory(permissionList.value, formState.features);
236
- console.log(categoryList.value, formState.features);
237
247
  // 预览审批流程
238
248
  }
239
249
 
@@ -19,7 +19,7 @@
19
19
  </template>
20
20
  </TreeSelect>
21
21
  <span v-if="item.attributeValueIds_view?.includes(-1)" style="color: #ff4d4f; font-size: 12px;">
22
- {{ t('categoryChangeTips') }}
22
+ {{ t('categoryChangeTips', { category: item.categoryName }) }}
23
23
  </span>
24
24
  </FormItem>
25
25
  </template>
@@ -69,7 +69,7 @@
69
69
  <!-- 选择框 -->
70
70
  <span v-if="checkedKeys.includes(item.feature)" class="crane-weak-color crane-margin-left-12">
71
71
  {{ t('availableTime') }}:
72
- <Select v-model:value="validTime" style="width: 100px"
72
+ <Select v-model:value="item.validTime" style="width: 100px"
73
73
  :disabled="item.businessApplyType === OWNER_STATUS"
74
74
  :options="item.businessApplyType === OWNER_STATUS ? validTimeOptions : tempTimeOptions"
75
75
  @change="onChangeTimeHandler" size="small">
@@ -79,7 +79,7 @@
79
79
  </div>
80
80
  </template>
81
81
  <script lang="ts" setup>
82
- import { PropType, ref, watch, defineEmits, computed } from 'vue';
82
+ import { PropType, defineEmits, computed } from 'vue';
83
83
  import { Tag, Popover, Select } from 'ant-design-vue';
84
84
  import { QuestionCircleOutlined } from '@ant-design/icons-vue';
85
85
  import departmentImg from '@/assets/department.png';
@@ -125,7 +125,6 @@ let props = defineProps({
125
125
  });
126
126
 
127
127
  const statusMap = t('status');
128
- const validTime = ref('');
129
128
 
130
129
  const tempTimeOptions = computed(() => {
131
130
  return props.validTimeOptions.filter((item: any) => {
@@ -134,39 +133,11 @@ const tempTimeOptions = computed(() => {
134
133
  });
135
134
 
136
135
 
137
- //1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
138
- //2登录人所在部门 ≠ 权限适用范围,根据等级来,高(L3)默认给7天,中(L2)默认给30天,低(L1)默认给60天
139
- const setDefaultTime = (item: PermissionType) => {
140
- if (item.businessApplyType === OWNER_STATUS) {
141
- return item.virtualOwnState?.timeStatus
142
- }
143
- const validMap = {
144
- L1: 'SIXTY_DAYS',
145
- L2: 'THIRTY_DAYS',
146
- L3: 'SEVEN_DAYS',
147
- };
148
- const { relatedDepartmentIds = [], curDepartmentId = 0, securityLevel } = item;
149
- if (relatedDepartmentIds?.includes(curDepartmentId as number)) {
150
- item.validTime = 'NINETY_DAYS';
151
- } else {
152
- item.validTime = validMap[securityLevel];
153
- }
154
- return item.validTime;
155
- };
156
-
157
136
  const getCategoryValue = (category: CategoryType) => {
158
137
  return `【${category.categoryName}】:${category.attributeValues?.map((item: any) => item.attributeName)?.join('、') || t('empty')}`;
159
138
  };
160
-
161
- watch(() => props.checkedKeys, (newVal, oldVal) => {
162
- if ((oldVal && !oldVal.includes(props.item.feature)) && newVal.includes(props.item.feature)) {
163
- validTime.value = setDefaultTime(props.item);
164
- props.item.validTime = setDefaultTime(props.item);
165
- emit('updateTime', props.item);
166
- }}, { immediate: true });
167
139
 
168
- const onChangeTimeHandler = (value:any) => {
169
- props.item.validTime = value;
140
+ const onChangeTimeHandler = () => {
170
141
  emit('updateTime', props.item);
171
142
  emit('onChangeTime', props.item);
172
143
  };
@@ -187,7 +187,7 @@ import useFormat from '../hooks/useFormat';
187
187
  watch(() => props.locale, (cur, pre) => {
188
188
  if (cur === pre) return;
189
189
  localStorage.setItem('permission_locale', props.locale);
190
- }, {immediate: true})
190
+ }, {immediate: true});
191
191
  </script>
192
192
 
193
193
  <style scoped>
@@ -0,0 +1,20 @@
1
+
2
+ //1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
3
+ //2登录人所在部门 ≠ 权限适用范围,根据等级来,高(L3)默认给7天,中(L2)默认给30天,低(L1)默认给60天
4
+ export default function useDefaultTime (item: PermissionType, status:string):string {
5
+ if (item.businessApplyType === status) {
6
+ return item.virtualOwnState?.timeStatus
7
+ }
8
+ const validMap = {
9
+ L1: 'SIXTY_DAYS',
10
+ L2: 'THIRTY_DAYS',
11
+ L3: 'SEVEN_DAYS',
12
+ };
13
+ const { relatedDepartmentIds = [], curDepartmentId = 0, securityLevel } = item;
14
+ if (relatedDepartmentIds?.includes(curDepartmentId as number)) {
15
+ item.validTime = 'NINETY_DAYS';
16
+ } else {
17
+ item.validTime = validMap[securityLevel];
18
+ }
19
+ return item.validTime;
20
+ };
package/src/i18n/zh-CH.ts CHANGED
@@ -36,8 +36,8 @@ export default {
36
36
  categoryTips: '当前您所拥有的数据范围如下:',
37
37
  empty: '空',
38
38
  category: '数据权限',
39
- categotySelectTips: '上方选中的权限包含数据权限,请根据实际工作需要申请/更改数据范围',
40
- categoryChangeTips: '提醒:您选择的数据权限范围较大!请确认实际工作场景是否需要全量「部门」权限,并在申请理由中写明,避免审批不通过!',
39
+ categotySelectTips: '上方选中的权限包含数据权限,请根据实际工作需要申请/更改数据范围。',
40
+ categoryChangeTips: '提醒:您选择的数据权限范围较大!请确认实际工作场景是否需要全量「{category}」权限,并在申请理由中写明,避免审批不通过!',
41
41
  availiables: {
42
42
  SEVEN_DAYS: '7天',
43
43
  THIRTY_DAYS: '30天',
@@ -4,8 +4,8 @@ type optionsType = {
4
4
  [key: string]: any;
5
5
  };
6
6
  const t = (key: string, options?: optionsType) => {
7
- // key的格式为:'xxx.xxx.xxx'
8
- const en = localStorage.getItem('permission_locale') || 'en-US';
7
+ // key的格式为:'xxx.xxx.xxx'//国际化todo
8
+ const en = localStorage.getItem('permission_locale') || 'zh-CN';
9
9
  const keys = key.split('.');
10
10
  let result = language[en as string] || language['en-US'];
11
11
  for (let i = 0; i < keys.length; i++) {
package/tsconfig.app.json CHANGED
@@ -25,8 +25,9 @@
25
25
  "src/**/*.ts",
26
26
  "src/**/*.d.ts",
27
27
  "src/**/*.tsx",
28
- "src/**/*.vue"
29
- ],
28
+ "src/**/*.vue",
29
+ "src/i18n/zh-CH.js"
30
+ ],
30
31
  "exclude": [
31
32
  "node_modules",
32
33
  "vite.config.ts" // 如果不需要解析 vite.config.ts