@yqg/permission 1.0.9 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yqg/permission",
3
- "version": "1.0.9",
3
+ "version": "1.1.1-beta.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "type": "module",
@@ -13,14 +13,16 @@
13
13
  "dev": "vite",
14
14
  "preview": "vite preview"
15
15
  },
16
- "devDependencies": {
17
- "@ant-design/icons-vue": "^7.0.1",
16
+ "dependencies": {
17
+ "@ant-design/icons-vue": "^7.0.1",
18
18
  "@commitlint/cli": "^19.5.0",
19
19
  "@commitlint/config-conventional": "^19.5.0",
20
20
  "ant-design-vue": "4.x",
21
21
  "axios": "^1.7.7",
22
22
  "vite-plugin-css-injected-by-js": "^3.5.2",
23
- "vue": "^3.5.12",
23
+ "vue": "^3.5.12"
24
+ },
25
+ "devDependencies": {
24
26
  "@typescript-eslint/parser": "^8.13.0",
25
27
  "@vitejs/plugin-vue": "^5.1.4",
26
28
  "eslint": "^9.14.0",
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(['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']);
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="05184"
42
- businessCode="CRANE"
34
+ workNumber="H00408"
35
+ businessCode="PPDL"
43
36
  :color="color"
44
37
  :locale="locale"
45
- @onSuccess="() => {console.log('成功')}"
38
+ @success="() => {console.log('成功')}"
46
39
  >
47
40
  </yqg-permission>
48
41
  </div>
@@ -1,6 +1,6 @@
1
1
  import axios from './axios';
2
2
 
3
- const urlPrefix = '/crane';
3
+ const urlPrefix = '/admin/crane';
4
4
 
5
5
  type apiType = {
6
6
  [key in string]: (params: any) => Promise<{body: any}>
@@ -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'), trigger: ['change', 'blur']
39
+ required: true, message: t('reasonPlaceholder')
41
40
  }, {
42
- max: 300, message: t('maxLengthTips', {length: 300}), trigger: ['change', 'blur']
41
+ max: 300, message: t('maxLengthTips', {length: 300})
43
42
  }]">
44
43
  <Textarea
45
- v-model:value.trim="formState.applyReason"
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(['onSubmit', 'onSuccess']);
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
- emit('onSubmit');
160
- successModal.value?.countDown(url, () => emit('onSuccess'));
157
+
158
+ successModal.value?.countDown(url, () => emit('onSuccess'));
161
159
  })
162
160
  };
163
161
 
@@ -173,7 +171,7 @@
173
171
 
174
172
  const onChangeHandler = throttle(async () => {
175
173
  if (formState.roleIds.length > 5) {
176
- return;
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 > 5) {
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"
@@ -17,48 +14,32 @@
17
14
  </span>
18
15
  <Popover>
19
16
  <template #content>
20
- <div style="max-width: 400px;">{{ item.name }}</div>
17
+ {{ item.name }}
21
18
  </template>
22
19
  <span class="crane-text-overflow">{{ item.name }}</span>
23
20
  </Popover>
24
21
  <Tag
25
- v-if="item.businessApplyType && item.businessApplyType !== 'TEMP_OWNER'"
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="['PENDING', 'TEMP_OWNER'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
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
 
48
31
  <Popover v-if="item.desc">
49
32
  <template #content>
50
- <div style="max-width: 400px;">{{ item.desc }}</div>
33
+ {{ item.desc }}
51
34
  </template>
52
35
  <QuestionCircleOutlined class=" crane-week-color"/>
53
36
  </Popover>
54
37
 
55
38
  <Popover v-if="item.relatedDepartments">
56
39
  <template #content>
57
- <div style="max-width: 400px;">
58
- {{t('adaptDepartment')}}:{{ item.relatedDepartments.map((item: any) => {
40
+ {{t('adaptDepartment')}}:{{ item.relatedDepartments.map((item: any) => {
59
41
  return item.name;
60
42
  }).join('、') }}
61
- </div>
62
43
  </template>
63
44
  <span class="crane-flex-center crane-margin-left-4">
64
45
  <img :src="departmentImg" height="14" width="14">
@@ -66,7 +47,7 @@
66
47
  </span>
67
48
  </Popover>
68
49
 
69
- <span v-if="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
50
+ <span v-show="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
70
51
  {{t('availableTime')}}:
71
52
  <Select
72
53
  v-model:value="validTime"
@@ -117,6 +98,8 @@
117
98
  });
118
99
  const timeStatusOptions = formatOptions('availiables');
119
100
  const statusMap = t('status');
101
+ const StatusTypePending = 'PENDING';
102
+ const disabled = ['NO', 'PENDING'].includes(props.item.businessApplyType);
120
103
  const validTime = ref('');
121
104
 
122
105
  //1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
@@ -21,17 +21,17 @@
21
21
  onOk: () => {
22
22
  window.open(url);
23
23
  modal1.destroy();
24
- callback && callback();
25
- window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
26
- if (!window.YQG_PERMISSION_CALLBACK && !callback) {
24
+ if (callback) {
25
+ callback();
26
+ } else {
27
27
  location.reload();
28
28
  }
29
29
  },
30
30
  onCancel: () => {
31
31
  modal1.destroy();
32
- callback && callback();
33
- window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
34
- if (!window.YQG_PERMISSION_CALLBACK && !callback) {
32
+ if (callback) {
33
+ callback();
34
+ } else {
35
35
  location.reload();
36
36
  }
37
37
  },
@@ -1,11 +1,12 @@
1
1
  <template>
2
2
  <ConfigProvider
3
- v-if="allPermissions.length"
4
- prefixCls="yqg-permission"
5
- :theme="{
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 === statusMap.DEFAULT">
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 === statusMap.PENDING">
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 === statusMap.NO" class="crane-wraper">
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="() => emit('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
- const ApplyModal = defineAsyncComponent(() =>
93
- import('./apply-modal.vue')
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, 'TEMP_OWNER', 'PENDING', 'OWNER', 'NO'];
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 === statusMap.PENDING);
174
- const cannotApply = data.every((per) => per.businessApplyType === statusMap.NO);
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: statusMap.PENDING,
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: statusMap.NO,
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: statusMap.DEFAULT,
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
  }
@@ -217,7 +221,6 @@
217
221
  };
218
222
 
219
223
  const showModal = () => {
220
- getPermissions();
221
224
  open.value = !open.value;
222
225
  };
223
226
 
package/src/i18n/en-US.ts CHANGED
@@ -4,7 +4,7 @@ export default {
4
4
  applyReason: '申请理由',
5
5
  approvalProcess: '审批流程',
6
6
  applyReason1: '新入职员工申请',
7
- applyReason2: '项目需要',
7
+ applyReason2: '临时项目',
8
8
  applyReason3: '数据查询与分析',
9
9
  applyReasonPlaceholder: '请尽可能详细描述申请理由',
10
10
  cancel: '取消',
@@ -20,7 +20,7 @@ export default {
20
20
  adaptDepartment: '适用部门',
21
21
  noApprovalProcess: '无审批流程',
22
22
  excessTips: '一次最多可申请{number}个权限',
23
- unavailableTips: '您暂无权限查看/操作该页面,请点击下方按钮进行申请',
23
+ unavailableTips: '您暂无权限查看/操作该页面,请点击按钮进行申请',
24
24
  appliedTips: '权限已申请,正在{status}...',
25
25
  unapplyTips: '您暂无权限查看/操作该页面,且该页面中没有您可以申请的权限,',
26
26
  callManager: '如有需要请联系系统管理员',
@@ -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
@@ -4,7 +4,7 @@ export default {
4
4
  applyReason: '申请理由',
5
5
  approvalProcess: '审批流程',
6
6
  applyReason1: '新入职员工申请',
7
- applyReason2: '项目需要',
7
+ applyReason2: '临时项目',
8
8
  applyReason3: '数据查询与分析',
9
9
  applyReasonPlaceholder: '请尽可能详细描述申请理由',
10
10
  cancel: '取消',
@@ -20,7 +20,7 @@ export default {
20
20
  adaptDepartment: '适用部门',
21
21
  noApprovalProcess: '无审批流程',
22
22
  excessTips: '一次最多可申请{number}个权限',
23
- unavailableTips: '您暂无权限查看/操作该页面,请点击下方按钮进行申请',
23
+ unavailableTips: '您暂无权限查看/操作该页面,请点击按钮进行申请',
24
24
  appliedTips: '权限已申请,正在{status}...',
25
25
  unapplyTips: '您暂无权限查看/操作该页面,且该页面中没有您可以申请的权限,',
26
26
  callManager: '如有需要请联系系统管理员',
@@ -30,8 +30,6 @@ export default {
30
30
  reasonPlaceholder: '请输入申请理由',
31
31
  maxCountTips: '一次最多只可申请{count}个权限',
32
32
  maxLengthTips: '最多{length}个字符',
33
- lastDays: '{count}天后到期',
34
- taday: '今天到期',
35
33
  availiables: {
36
34
  SEVEN_DAYS: '7天',
37
35
  THIRTY_DAYS: '30天',
@@ -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" />
package/vite.config.ts CHANGED
@@ -13,7 +13,7 @@ export default defineConfig({
13
13
  },
14
14
  server: {
15
15
  proxy: {
16
- '/crane': {
16
+ '/admin': {
17
17
  target: 'https://crane-test.yangqianguan.com',
18
18
  changeOrigin: true,
19
19
  },