@yqg/permission 1.1.3-beta.0 → 1.2.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.
Files changed (32) hide show
  1. package/README.md +4 -3
  2. package/dist/apply-modal-BBqMmKS2.js +8742 -0
  3. package/dist/{checkbox-item-CbU84h2h.js → checkbox-item-CFWhXmMU.js} +1940 -1626
  4. package/dist/{index-CwpGTkMT.js → index-BAGvIeoy.js} +2101 -2129
  5. package/dist/index.js +2 -2
  6. package/dist/index.umd.cjs +73 -85
  7. package/dist/{yqg-permission-5wZs7Zr5.js → yqg-permission-Bxzu3bMl.js} +6587 -8550
  8. package/dist_/345/211/257/346/234/254/apply-modal-Bgd3UWf-.js +8739 -0
  9. package/dist_/345/211/257/346/234/254/card.png +0 -0
  10. package/dist_/345/211/257/346/234/254/checkbox-item-DiIgFuBE.js +4988 -0
  11. package/dist_/345/211/257/346/234/254/dialog.png +0 -0
  12. package/dist_/345/211/257/346/234/254/image.png +0 -0
  13. package/dist_/345/211/257/346/234/254/index-CUS1Jydp.js +6164 -0
  14. package/dist_/345/211/257/346/234/254/index.js +5 -0
  15. package/dist_/345/211/257/346/234/254/index.umd.cjs +259 -0
  16. package/dist_/345/211/257/346/234/254/yqg-permission-ChMRXqi6.js +14944 -0
  17. package/package.json +7 -8
  18. package/src/App.vue +21 -16
  19. package/src/assets/apply.png +0 -0
  20. package/src/assets/applyicon.png +0 -0
  21. package/src/axios/index.ts +1 -1
  22. package/src/components/apply-modal.vue +25 -37
  23. package/src/components/checkbox-item.vue +48 -28
  24. package/src/components/success-modal.vue +7 -7
  25. package/src/components/yqg-permission.vue +99 -48
  26. package/src/hooks/useDragable.ts +136 -0
  27. package/src/i18n/en-US.ts +22 -17
  28. package/src/i18n/zh-CH.ts +7 -5
  29. package/src/typings/index.d.ts +6 -0
  30. package/src/vite-env.d.ts +1 -1
  31. package/vite.config.ts +1 -1
  32. package/dist/apply-modal-C5gl_EGn.js +0 -6844
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yqg/permission",
3
- "version": "1.1.3-beta.0",
3
+ "version": "1.2.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
- "dependencies": {
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
- "ant-design-vue": "4.x",
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,11 +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(['PPDL.0801-test2.XIUGAI.test5', 'PPDL.0801-test2.XIUGAI.test4', 'PPDL.0801-test2.XIUGAI.test6']);
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
+ ]);
12
21
  // const permissions = reactive(['CRANE.BUSINESS.QUERY', 'RANE.BUSINESS.CREATE', 'CRANE.BUSINESS.UPDATE', 'CRANE.BUSINESS.DELETE']);
13
22
  const changeColor = () => {
14
23
  color.value = color.value === '#f00' ? '#1677ff' : '#f00';
15
- }
24
+ }
16
25
  const changeLocale = () => {
17
26
  locale.value = locale.value === 'zh-CN' ? 'en-US' : 'zh-CN';
18
27
  }
@@ -29,44 +38,40 @@ const changeLocale = () => {
29
38
  <!-- 03541 -->
30
39
  <!-- 02124 -->
31
40
  <!-- 05184 -->
32
- <yqg-permission
41
+ <yqg-permission
33
42
  :permissions="permissions"
34
- workNumber="H00408"
35
- businessCode="PPDL"
43
+ workNumber="05184"
36
44
  :color="color"
37
45
  :locale="locale"
38
- @success="() => {console.log('成功')}"
46
+ @onSuccess="() => {console.log('成功')}"
39
47
  >
40
48
  </yqg-permission>
41
49
  </div>
42
- <!-- <data class="case-card">
50
+ <data class="case-card">
43
51
  <div>2:文字组件</div>
44
- <yqg-permission
45
- :permissions="permissions"
46
- businessCode="CRANE"
52
+ <yqg-permission
53
+ :permissions="['ddd']"
47
54
  :color="color"
48
55
  workNumber="02124"
49
56
  type="text"
50
57
  >
51
58
  </yqg-permission>
52
59
  </data>
53
- -->
54
60
 
55
-
61
+
56
62
  <!-- <div class="case-card">
57
63
  <div>3:自定义</div>
58
- <yqg-permission
64
+ <yqg-permission
59
65
  :permissions="permissions"
60
- businessCode="CRANE"
61
66
  :color="color"
62
67
  workNumber="02124"
63
- locale="zh-CN"
68
+ locale="zh-CN"
64
69
  type="custom"
65
70
  >
66
71
  <div style="color: red;" slot="custom">自定义按钮</div>
67
72
  </yqg-permission>
68
73
  </div> -->
69
-
74
+
70
75
  </div>
71
76
 
72
77
  </template>
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  import axios from './axios';
2
2
 
3
- const urlPrefix = '/admin/crane';
3
+ const urlPrefix = '/crane';
4
4
 
5
5
  type apiType = {
6
6
  [key in string]: (params: any) => Promise<{body: any}>
@@ -5,6 +5,7 @@
5
5
  width="800px"
6
6
  @ok="handleOk"
7
7
  :okText="t('submit')"
8
+ :maskClosable="false"
8
9
  :ok-button-props="{ loading: loading }"
9
10
  :cancelText="t('cancel')">
10
11
  <Form
@@ -17,7 +18,11 @@
17
18
  :label="t('applyPermission')"
18
19
  name="roleIds"
19
20
  :rules="[{ required: true, message: t('selectPlaceholder')}]">
21
+ <span v-if="!permissionList.length">
22
+ {{t('noPermissionTips')}}
23
+ </span>
20
24
  <CheckboxGroup
25
+ v-else
21
26
  v-model:value="formState.roleIds"
22
27
  style="display: block;"
23
28
  @change="onChangeHandler"
@@ -34,27 +39,20 @@
34
39
 
35
40
  <FormItem
36
41
  name="applyReason"
37
- :label="t('applyReason')"
42
+ :label="t('applyReason')"
38
43
  :rules="[{
39
- required: true, message: t('reasonPlaceholder')
44
+ required: true, message: t('reasonPlaceholder'), trigger: ['change', 'blur']
40
45
  }, {
41
- max: 300, message: t('maxLengthTips', {length: 300})
46
+ max: 300, message: t('maxLengthTips', {length: 300}), trigger: ['change', 'blur']
42
47
  }]">
43
48
  <Textarea
44
- v-model:value="formState.applyReason"
45
- show-count
46
- :maxlength="300"
49
+ v-model:value.trim="formState.applyReason"
47
50
  :placeholder="t('applyReasonPlaceholder')"
48
- :auto-size="{ minRows: 2, maxRows: 5 }">
51
+ :auto-size="{ minRows: 4, maxRows: 4 }">
49
52
  </Textarea>
50
- <div style="margin-top: 4px;">
51
- <Tag
52
- :bordered="false"
53
- style="cursor: pointer;"
54
- v-for="item in reasons"
55
- @click="addReasonHandler(item)"
56
- :key="item">{{ item }}</Tag>
57
- </div>
53
+ <span class="reason-tips" style="font-size: 12px">
54
+ {{t('applyReasonTips')}}
55
+ </span>
58
56
  </FormItem>
59
57
 
60
58
  <FormItem :label="t('approvalProcess')">
@@ -81,7 +79,6 @@
81
79
  FormItem,
82
80
  CheckboxGroup,
83
81
  Textarea,
84
- Tag,
85
82
  message
86
83
  } from 'ant-design-vue';
87
84
  import SuccessModal from './success-modal.vue';
@@ -91,12 +88,6 @@
91
88
  import('./checkbox-item.vue')
92
89
  );
93
90
 
94
- const reasons = [
95
- t('applyReason1'),
96
- t('applyReason2'),
97
- t('applyReason3'),
98
- ]
99
-
100
91
  const props = defineProps({
101
92
  permissionList: {
102
93
  type: Array as () => PermissionType[],
@@ -112,7 +103,7 @@
112
103
  },
113
104
 
114
105
  });
115
- const emit = defineEmits(['onSuccess']);
106
+ const emit = defineEmits(['onSubmit', 'onSuccess']);
116
107
  const open = defineModel({
117
108
  required: true,
118
109
  default: false,
@@ -131,17 +122,6 @@
131
122
  applyReason: '',
132
123
  submitWorkNumber: submitWorkNumber.value,
133
124
  });
134
-
135
- const addReasonHandler = (item: string) => {
136
- if (formState.applyReason.includes(item)) {
137
- return;
138
- }
139
- if (!formState.applyReason || formState.applyReason.endsWith('、')) {
140
- formState.applyReason += item;
141
- } else {
142
- formState.applyReason += `、${item}`;
143
- }
144
- }
145
125
 
146
126
  const handleOk = async() => {
147
127
  if (formState.roleIds.length > 5) {
@@ -154,8 +134,8 @@
154
134
  const url = res?.body?.oaFlowUrl;
155
135
  open.value = false;
156
136
  loading.value = false;
157
-
158
- successModal.value?.countDown(url, () => emit('onSuccess'));
137
+ emit('onSubmit');
138
+ successModal.value?.countDown(url, () => emit('onSuccess'));
159
139
  })
160
140
  };
161
141
 
@@ -171,7 +151,7 @@
171
151
 
172
152
  const onChangeHandler = throttle(async () => {
173
153
  if (formState.roleIds.length > 5) {
174
- return message.warning(t('maxCountTips', {count: 5}));
154
+ return;
175
155
  }
176
156
 
177
157
  if (!formState.roleIds.length) {
@@ -184,6 +164,14 @@
184
164
  stepNodes.value = res?.body?.nodes || [];
185
165
  }, 0)
186
166
 
167
+ watch(() => formState.roleIds, (val) => {
168
+ // 写到watch里避免闪烁
169
+ if (val.length > 5) {
170
+ formState.roleIds.pop();
171
+ message.warning(t('maxCountTips', {count: 5}));
172
+ }
173
+ })
174
+
187
175
  watch(() => open.value, (cur) => {
188
176
  if (cur) {
189
177
  formRef.value?.resetFields();
@@ -1,53 +1,72 @@
1
1
  <template>
2
2
  <div class="crane-checkbox-line">
3
- <Checkbox :value="item.roleId" :disabled="disabled" @change="onCheck">
3
+ <Checkbox
4
+ :value="item.roleId"
5
+ :disabled="['OWNER', 'PENDING', 'NO'].includes(props.item.businessApplyType)"
6
+ @change="onCheck">
4
7
  <div class="crane-flex-center crane-checkbox-label">
5
8
  <Tag
6
- v-if="item.securityLevel"
7
- :bordered="false"
8
- :color="levelMap[item.securityLevel].color"
9
+ v-if="item.securityLevel"
10
+ :bordered="false"
11
+ :style="{color: levelMap[item.securityLevel].color, background: levelMap[item.securityLevel].background}"
9
12
  class="crane-tag-position">
10
13
  {{ levelMap[item.securityLevel].text }}
11
14
  </Tag>
12
-
15
+
13
16
  <span>{{t(`operationType.${item.operationType}`)}}|
14
17
  </span>
15
18
  <Popover>
16
19
  <template #content>
17
- {{ item.name }}
20
+ <div style="max-width: 400px;">{{ item.name }}</div>
18
21
  </template>
19
22
  <span class="crane-text-overflow">{{ item.name }}</span>
20
23
  </Popover>
21
24
  <Tag
22
- v-if="item.businessApplyType"
23
- :bordered="false"
25
+ v-if="item.businessApplyType && item.businessApplyType !== 'TEMP_OWNER'"
26
+ :bordered="false"
24
27
  class="crane-tag-position crane-margin-left-4 crane-margin-right-0"
25
- :class="item.businessApplyType !== StatusTypePending ? 'crane-disabled-color' : ''">
28
+ :class="['PENDING', 'TEMP_OWNER'].includes(item.businessApplyType) ? '' : 'crane-disabled-color'">
26
29
  {{ statusMap[item.businessApplyType] }}
27
30
  </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
+
28
45
  </div>
29
46
  </Checkbox>
30
47
 
31
48
  <Popover v-if="item.desc">
32
49
  <template #content>
33
- {{ item.desc }}
50
+ <div style="max-width: 400px;">{{ item.desc }}</div>
34
51
  </template>
35
52
  <QuestionCircleOutlined class=" crane-week-color"/>
36
53
  </Popover>
37
54
 
38
- <Popover v-if="item.relatedDepartments">
55
+ <Popover v-if="item.relatedCompleteNames?.length">
39
56
  <template #content>
40
- {{t('adaptDepartment')}}:{{ item.relatedDepartments.map((item: any) => {
41
- return item.name;
57
+ <div style="max-width: 400px;">
58
+ {{t('adaptDepartment')}}:{{ item.relatedCompleteNames.map((item: any) => {
59
+ return item;
42
60
  }).join('、') }}
61
+ </div>
43
62
  </template>
44
63
  <span class="crane-flex-center crane-margin-left-4">
45
64
  <img :src="departmentImg" height="14" width="14">
46
- <span class="crane-week-color crane-margin-left-4">{{ item.relatedDepartments.length }}</span>
65
+ <span class="crane-week-color crane-margin-left-4">{{ item.relatedCompleteNames.length }}</span>
47
66
  </span>
48
67
  </Popover>
49
68
 
50
- <span v-show="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
69
+ <span v-if="checkedIds.includes(item.roleId)" class="crane-week-color crane-margin-left-12">
51
70
  {{t('availableTime')}}:
52
71
  <Select
53
72
  v-model:value="validTime"
@@ -69,16 +88,19 @@
69
88
 
70
89
  const levelMap:LevelMapType = {
71
90
  L1: {
72
- color: 'green',
73
- text: t('levels.L1')
91
+ color: '#1AA83B',
92
+ text: t('levels.L1'),
93
+ background: '#E3F9E9',
74
94
  },
75
95
  L2: {
76
- color: 'orange',
77
- text: t('levels.L2')
78
- },
96
+ color: '#F37D1C',
97
+ text: t('levels.L2'),
98
+ background: '#FFE4BA'
99
+ },
79
100
  L3: {
80
- color: 'red',
81
- text: t('levels.L3')
101
+ color: '#F2494B',
102
+ text: t('levels.L3'),
103
+ background: '#FDCDC5'
82
104
  },
83
105
  };
84
106
 
@@ -98,8 +120,6 @@
98
120
  });
99
121
  const timeStatusOptions = formatOptions('availiables');
100
122
  const statusMap = t('status');
101
- const StatusTypePending = 'PENDING';
102
- const disabled = ['NO', 'PENDING'].includes(props.item.businessApplyType);
103
123
  const validTime = ref('');
104
124
 
105
125
  //1登录人所在部门 = 权限适用范围,都默认90天,不需要区分等级和类型,
@@ -138,7 +158,7 @@
138
158
  }
139
159
  .crane-checkbox-line {
140
160
  margin-bottom: 12px;
141
- display: flex;
161
+ display: flex;
142
162
  align-items: center;
143
163
  }
144
164
  .crane-checkbox-line:last-child {
@@ -149,8 +169,8 @@
149
169
  }
150
170
  .crane-tag-position {
151
171
  margin-right: 4px;
152
- font-size: 10px;
153
- padding: 2px 4px;
172
+ font-size: 10px;
173
+ padding: 2px 4px;
154
174
  line-height: 12px;
155
175
  font-weight: 500;
156
176
  }
@@ -177,5 +197,5 @@
177
197
  overflow: hidden;
178
198
  text-overflow: ellipsis
179
199
  }
180
-
200
+
181
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';
@@ -21,17 +21,17 @@
21
21
  onOk: () => {
22
22
  window.open(url);
23
23
  modal1.destroy();
24
- if (callback) {
25
- callback();
26
- } else {
24
+ callback && callback();
25
+ window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
26
+ if (!window.YQG_PERMISSION_CALLBACK && !callback) {
27
27
  location.reload();
28
28
  }
29
29
  },
30
30
  onCancel: () => {
31
31
  modal1.destroy();
32
- if (callback) {
33
- callback();
34
- } else {
32
+ callback && callback();
33
+ window.YQG_PERMISSION_CALLBACK && window.YQG_PERMISSION_CALLBACK();
34
+ if (!window.YQG_PERMISSION_CALLBACK && !callback) {
35
35
  location.reload();
36
36
  }
37
37
  },