@pubinfo/module-rbac 2.0.0-beta.3

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 (291) hide show
  1. package/package.json +53 -0
  2. package/src/api/modules/assist/gonggaofuwu.ts +109 -0
  3. package/src/api/modules/assist/index.ts +5 -0
  4. package/src/api/modules/assist/qunzujiekou.ts +95 -0
  5. package/src/api/modules/assist/quyujiekou.ts +97 -0
  6. package/src/api/modules/assist/typings.d.ts +364 -0
  7. package/src/api/modules/configData/heibaimingdanfuwu.ts +95 -0
  8. package/src/api/modules/configData/index.ts +5 -0
  9. package/src/api/modules/configData/typings.d.ts +347 -0
  10. package/src/api/modules/configData/xitongpeizhifuwu.ts +322 -0
  11. package/src/api/modules/configData/zidianfuwu.ts +151 -0
  12. package/src/api/modules/log/caozuorizhifuwu.ts +37 -0
  13. package/src/api/modules/log/denglurizhifuwu.ts +37 -0
  14. package/src/api/modules/log/index.ts +4 -0
  15. package/src/api/modules/log/typings.d.ts +179 -0
  16. package/src/api/modules/rbac/gangweijiekou.ts +93 -0
  17. package/src/api/modules/rbac/index.ts +13 -0
  18. package/src/api/modules/rbac/jiaosejiekou.ts +124 -0
  19. package/src/api/modules/rbac/pubJiaosezukongzhiqi.ts +113 -0
  20. package/src/api/modules/rbac/shujuquanxianzhubiaokongzhiqi.ts +186 -0
  21. package/src/api/modules/rbac/typings.d.ts +2001 -0
  22. package/src/api/modules/rbac/yonghujiekou.ts +225 -0
  23. package/src/api/modules/rbac/yonghushoucangbiaojiekou.ts +93 -0
  24. package/src/api/modules/rbac/yonghuzuijinchangyongbiaojiekou.ts +72 -0
  25. package/src/api/modules/rbac/ziyuanjiekou.ts +223 -0
  26. package/src/api/modules/rbac/zuhuguanlijiekou.ts +91 -0
  27. package/src/api/modules/rbac/zuzhijiaosebiaokongzhiqi.ts +76 -0
  28. package/src/api/modules/rbac/zuzhijiekou.ts +171 -0
  29. package/src/api/request.ts +3 -0
  30. package/src/assets/icons/403.svg +1 -0
  31. package/src/assets/icons/403_dark.svg +1 -0
  32. package/src/assets/icons/404.svg +1 -0
  33. package/src/assets/icons/404_dark.svg +1 -0
  34. package/src/assets/icons/add-child.svg +1 -0
  35. package/src/assets/icons/authority.svg +1 -0
  36. package/src/assets/icons/authorize.svg +1 -0
  37. package/src/assets/icons/blacklist-disable.svg +1 -0
  38. package/src/assets/icons/blacklist-enable.svg +1 -0
  39. package/src/assets/icons/browser-360.svg +1 -0
  40. package/src/assets/icons/browser-chrome.svg +1 -0
  41. package/src/assets/icons/browser-edge.svg +1 -0
  42. package/src/assets/icons/browser-ie.svg +1 -0
  43. package/src/assets/icons/browser-other.svg +1 -0
  44. package/src/assets/icons/browser-qq.svg +1 -0
  45. package/src/assets/icons/browser-safari.svg +1 -0
  46. package/src/assets/icons/browser-uc.svg +1 -0
  47. package/src/assets/icons/change-org.svg +1 -0
  48. package/src/assets/icons/edit.svg +1 -0
  49. package/src/assets/icons/empty-data.svg +1 -0
  50. package/src/assets/icons/favorites.svg +1 -0
  51. package/src/assets/icons/icard.svg +1 -0
  52. package/src/assets/icons/icon_animation.svg +1 -0
  53. package/src/assets/icons/icon_breadcrumb.svg +1 -0
  54. package/src/assets/icons/icon_copyright.svg +1 -0
  55. package/src/assets/icons/icon_jt.svg +1 -0
  56. package/src/assets/icons/icon_layout.svg +1 -0
  57. package/src/assets/icons/icon_mainpage.svg +1 -0
  58. package/src/assets/icons/icon_menu.svg +1 -0
  59. package/src/assets/icons/icon_page_size.svg +1 -0
  60. package/src/assets/icons/icon_position_type.svg +1 -0
  61. package/src/assets/icons/icon_safe_manage.svg +1 -0
  62. package/src/assets/icons/icon_screen_scale.svg +6 -0
  63. package/src/assets/icons/icon_system_manage.svg +1 -0
  64. package/src/assets/icons/icon_tabbar.svg +1 -0
  65. package/src/assets/icons/icon_toolbar.svg +1 -0
  66. package/src/assets/icons/icon_topbar.svg +1 -0
  67. package/src/assets/icons/icon_watermark.svg +1 -0
  68. package/src/assets/icons/image-load-fail.svg +1 -0
  69. package/src/assets/icons/log-center.svg +1 -0
  70. package/src/assets/icons/logo-sig.svg +1 -0
  71. package/src/assets/icons/logo.svg +1 -0
  72. package/src/assets/icons/mima.svg +1 -0
  73. package/src/assets/icons/not-data.svg +1 -0
  74. package/src/assets/icons/org-main.svg +1 -0
  75. package/src/assets/icons/org-unmain.svg +1 -0
  76. package/src/assets/icons/process-management.svg +1 -0
  77. package/src/assets/icons/project-management.svg +1 -0
  78. package/src/assets/icons/rbac.svg +1 -0
  79. package/src/assets/icons/remove.svg +1 -0
  80. package/src/assets/icons/resource-app.svg +1 -0
  81. package/src/assets/icons/resource-btn.svg +1 -0
  82. package/src/assets/icons/resource-index.svg +1 -0
  83. package/src/assets/icons/resource-menu.svg +1 -0
  84. package/src/assets/icons/resource-nonmenu.svg +1 -0
  85. package/src/assets/icons/setting-manage.svg +1 -0
  86. package/src/assets/icons/test.svg +1 -0
  87. package/src/assets/icons/theme-check-mark.svg +1 -0
  88. package/src/assets/icons/theme-title.svg +1 -0
  89. package/src/assets/icons/toolbar-collapse.svg +1 -0
  90. package/src/assets/icons/tree_icon.svg +1 -0
  91. package/src/assets/icons/tree_icon_checked.svg +1 -0
  92. package/src/assets/icons/view.svg +1 -0
  93. package/src/assets/icons/workbench.svg +1 -0
  94. package/src/assets/icons/zddata.svg +1 -0
  95. package/src/assets/icons/zy_checked.svg +1 -0
  96. package/src/assets/icons/zy_default.svg +1 -0
  97. package/src/assets/images/layout/item1.webp +0 -0
  98. package/src/assets/images/layout/item1_dark.webp +0 -0
  99. package/src/assets/images/layout/item2.webp +0 -0
  100. package/src/assets/images/layout/item2_dark.webp +0 -0
  101. package/src/assets/images/layout/item3.webp +0 -0
  102. package/src/assets/images/layout/item3_dark.webp +0 -0
  103. package/src/assets/images/layout/item4.webp +0 -0
  104. package/src/assets/images/layout/item4_dark.webp +0 -0
  105. package/src/assets/images/layout/item5.webp +0 -0
  106. package/src/assets/images/layout/item5_dark.webp +0 -0
  107. package/src/assets/images/page-width/anto_min_w_dark.webp +0 -0
  108. package/src/assets/images/page-width/auto.webp +0 -0
  109. package/src/assets/images/page-width/auto_dark.webp +0 -0
  110. package/src/assets/images/page-width/auto_min_w.webp +0 -0
  111. package/src/assets/images/page-width/auto_min_w_dark.webp +0 -0
  112. package/src/assets/images/page-width/icon_auto.webp +0 -0
  113. package/src/assets/images/page-width/icon_auto_dark.webp +0 -0
  114. package/src/assets/images/page-width/icon_auto_min_w.webp +0 -0
  115. package/src/assets/images/page-width/icon_auto_min_w_dark.webp +0 -0
  116. package/src/assets/images/page-width/icon_middle.webp +0 -0
  117. package/src/assets/images/page-width/icon_middle_dark.webp +0 -0
  118. package/src/assets/images/page-width/icon_middle_max_w.webp +0 -0
  119. package/src/assets/images/page-width/icon_middle_max_w_dark.webp +0 -0
  120. package/src/assets/images/page-width/middle.webp +0 -0
  121. package/src/assets/images/page-width/middle_dark.webp +0 -0
  122. package/src/assets/images/page-width/middle_max_w.webp +0 -0
  123. package/src/assets/images/page-width/middle_max_w_dark.webp +0 -0
  124. package/src/assets/lottie/breadcrumb/dark/enable.json +1 -0
  125. package/src/assets/lottie/breadcrumb/dark/enableMainMenu.json +1 -0
  126. package/src/assets/lottie/breadcrumb/dark/style.json +1 -0
  127. package/src/assets/lottie/breadcrumb/light/enable.json +1 -0
  128. package/src/assets/lottie/breadcrumb/light/enableMainMenu.json +1 -0
  129. package/src/assets/lottie/breadcrumb/light/style.json +1 -0
  130. package/src/assets/lottie/layout/data-test.json +1 -0
  131. package/src/assets/lottie/layout/data.json +1 -0
  132. package/src/assets/lottie/menu/dark/enableHotkeys.json +1 -0
  133. package/src/assets/lottie/menu/dark/enableSubMenuCollapseButton.json +1 -0
  134. package/src/assets/lottie/menu/dark/isRounded.json +1 -0
  135. package/src/assets/lottie/menu/dark/menuActiveStyle.json +1 -0
  136. package/src/assets/lottie/menu/dark/subMenuCollapse.json +1 -0
  137. package/src/assets/lottie/menu/dark/subMenuUniqueOpened.json +1 -0
  138. package/src/assets/lottie/menu/light/enableHotkeys.json +1 -0
  139. package/src/assets/lottie/menu/light/enableSubMenuCollapseButton.json +1 -0
  140. package/src/assets/lottie/menu/light/isRounded.json +1 -0
  141. package/src/assets/lottie/menu/light/menuActiveStyle.json +1 -0
  142. package/src/assets/lottie/menu/light/subMenuCollapse.json +1 -0
  143. package/src/assets/lottie/menu/light/subMenuUniqueOpened.json +1 -0
  144. package/src/assets/lottie/other/dark/enableCopyright.json +1 -0
  145. package/src/assets/lottie/other/dark/enableHotkeys.json +1 -0
  146. package/src/assets/lottie/other/dark/switchTabbarAndToolbar.json +1 -0
  147. package/src/assets/lottie/other/light/enableCopyright.json +1 -0
  148. package/src/assets/lottie/other/light/enableHotkeys.json +1 -0
  149. package/src/assets/lottie/other/light/switchTabbarAndToolbar.json +1 -0
  150. package/src/assets/lottie/page_animation/dark/fadeinout.json +1 -0
  151. package/src/assets/lottie/page_animation/dark/fadeinout_old.json +1 -0
  152. package/src/assets/lottie/page_animation/dark/tobottom.json +1 -0
  153. package/src/assets/lottie/page_animation/dark/tobottom_old.json +1 -0
  154. package/src/assets/lottie/page_animation/dark/toleft.json +1 -0
  155. package/src/assets/lottie/page_animation/dark/toleft_old.json +1 -0
  156. package/src/assets/lottie/page_animation/dark/toright.json +1 -0
  157. package/src/assets/lottie/page_animation/dark/toright_old.json +1 -0
  158. package/src/assets/lottie/page_animation/dark/totop.json +1 -0
  159. package/src/assets/lottie/page_animation/dark/totop_old.json +1 -0
  160. package/src/assets/lottie/page_animation/light/fadeinout.json +1 -0
  161. package/src/assets/lottie/page_animation/light/tobottom.json +1 -0
  162. package/src/assets/lottie/page_animation/light/toleft.json +1 -0
  163. package/src/assets/lottie/page_animation/light/toright.json +1 -0
  164. package/src/assets/lottie/page_animation/light/totop.json +1 -0
  165. package/src/assets/lottie/tabbar/dark/enable.json +1 -0
  166. package/src/assets/lottie/tabbar/dark/enableHotkeys.json +1 -0
  167. package/src/assets/lottie/tabbar/dark/enableIcon.json +1 -0
  168. package/src/assets/lottie/tabbar/dark/enableMemory.json +1 -0
  169. package/src/assets/lottie/tabbar/dark/style.json +1 -0
  170. package/src/assets/lottie/tabbar/light/enable.json +1 -0
  171. package/src/assets/lottie/tabbar/light/enableHotkeys.json +1 -0
  172. package/src/assets/lottie/tabbar/light/enableIcon.json +1 -0
  173. package/src/assets/lottie/tabbar/light/enableMemory.json +1 -0
  174. package/src/assets/lottie/tabbar/light/style.json +1 -0
  175. package/src/assets/lottie/toolbar/dark/enableColorScheme.json +1 -0
  176. package/src/assets/lottie/toolbar/dark/enableFullscreen.json +1 -0
  177. package/src/assets/lottie/toolbar/dark/enableI18n.json +1 -0
  178. package/src/assets/lottie/toolbar/dark/enableNotification.json +1 -0
  179. package/src/assets/lottie/toolbar/dark/enablePageReload.json +1 -0
  180. package/src/assets/lottie/toolbar/dark/enableUserPreferences.json +1 -0
  181. package/src/assets/lottie/toolbar/dark/navSearchEnable.json +1 -0
  182. package/src/assets/lottie/toolbar/dark/navSearchEnableHotkeys.json +1 -0
  183. package/src/assets/lottie/toolbar/light/enableColorScheme.json +1 -0
  184. package/src/assets/lottie/toolbar/light/enableFullscreen.json +1 -0
  185. package/src/assets/lottie/toolbar/light/enableI18n.json +1 -0
  186. package/src/assets/lottie/toolbar/light/enableNotification.json +1 -0
  187. package/src/assets/lottie/toolbar/light/enablePageReload.json +1 -0
  188. package/src/assets/lottie/toolbar/light/enableUserPreferences.json +1 -0
  189. package/src/assets/lottie/toolbar/light/navSearchEnable.json +1 -0
  190. package/src/assets/lottie/toolbar/light/navSearchEnableHotkeys.json +1 -0
  191. package/src/assets/lottie/watermark/dark/enableWatermark.json +1 -0
  192. package/src/assets/lottie/watermark/light/enableWatermark.json +1 -0
  193. package/src/assets/styles/vxe-table.css +13 -0
  194. package/src/components/GroupSelector/index.vue +311 -0
  195. package/src/components/OrgTree/index.vue +91 -0
  196. package/src/components/OrgUserSelector/OrgSelector.vue +135 -0
  197. package/src/components/OrgUserSelector/UserSelector.vue +164 -0
  198. package/src/components/OrgUserSelector/index.ts +47 -0
  199. package/src/components/OrgUserSelector/provider.ts +373 -0
  200. package/src/components/ResourceSelector/enum.ts +5 -0
  201. package/src/components/ResourceSelector/hooks/useAppAndResource.ts +96 -0
  202. package/src/components/ResourceSelector/index.vue +432 -0
  203. package/src/composables/useLottie.ts +65 -0
  204. package/src/index.ts +31 -0
  205. package/src/interface.ts +54 -0
  206. package/src/routes/index.ts +156 -0
  207. package/src/routes/modules/authority.manage.menu.ts +105 -0
  208. package/src/routes/modules/log.manage.menu.ts +45 -0
  209. package/src/routes/modules/safe.manage.menu.ts +71 -0
  210. package/src/routes/modules/stylesetting.manage.menu.ts +130 -0
  211. package/src/routes/modules/system.manage.menu.ts +92 -0
  212. package/src/stores/index.ts +1 -0
  213. package/src/views/blackWhiteList/components/drawerBlackWhiteList.vue +132 -0
  214. package/src/views/blackWhiteList/enum.ts +7 -0
  215. package/src/views/blackWhiteList/index.vue +309 -0
  216. package/src/views/blackWhiteList/types.ts +4 -0
  217. package/src/views/breadcrumb_setting/animationData.ts +15 -0
  218. package/src/views/breadcrumb_setting/index.vue +147 -0
  219. package/src/views/components/HCheckList.vue +47 -0
  220. package/src/views/components/animation_item.vue +37 -0
  221. package/src/views/components/setItem.vue +126 -0
  222. package/src/views/data-permission/components/createAndEditDataPermission.vue +354 -0
  223. package/src/views/data-permission/enum.ts +59 -0
  224. package/src/views/data-permission/index.vue +190 -0
  225. package/src/views/dictionary/components/drawerDictionary.vue +108 -0
  226. package/src/views/dictionary/components/drawerDictionaryItem.vue +115 -0
  227. package/src/views/dictionary/enum.ts +8 -0
  228. package/src/views/dictionary/index.vue +194 -0
  229. package/src/views/dictionary/itemlist.vue +164 -0
  230. package/src/views/group/components/drawerGroup.vue +177 -0
  231. package/src/views/group/enum.ts +25 -0
  232. package/src/views/group/index.vue +207 -0
  233. package/src/views/layout_setting/index.vue +306 -0
  234. package/src/views/log_center/components/browserType.vue +35 -0
  235. package/src/views/log_center/components/loginHistoryDetail.vue +71 -0
  236. package/src/views/log_center/components/operateHistoryDetail.vue +80 -0
  237. package/src/views/log_center/login_history.vue +239 -0
  238. package/src/views/log_center/operate_history.vue +233 -0
  239. package/src/views/menu_setting/animationData.ts +27 -0
  240. package/src/views/menu_setting/index.vue +207 -0
  241. package/src/views/organization/components/drawerOrganization.vue +161 -0
  242. package/src/views/organization/components/drawerRole.vue +159 -0
  243. package/src/views/organization/components/roleSelect.vue +258 -0
  244. package/src/views/organization/enum.ts +26 -0
  245. package/src/views/organization/index.vue +516 -0
  246. package/src/views/other_setting/animationData.ts +15 -0
  247. package/src/views/other_setting/index.vue +250 -0
  248. package/src/views/other_setting/interface.ts +26 -0
  249. package/src/views/page_animation_setting/animationData.ts +23 -0
  250. package/src/views/page_animation_setting/index.vue +200 -0
  251. package/src/views/page_w_setting/index.vue +238 -0
  252. package/src/views/position/components/drawerPosition.vue +131 -0
  253. package/src/views/position/enum.ts +8 -0
  254. package/src/views/position/index.vue +167 -0
  255. package/src/views/region/components/drawerRegion.vue +143 -0
  256. package/src/views/region/enum.ts +24 -0
  257. package/src/views/region/index.vue +246 -0
  258. package/src/views/resource/components/ResourceEdit.vue +209 -0
  259. package/src/views/resource/components/RoleRelation.vue +100 -0
  260. package/src/views/resource/enum.ts +35 -0
  261. package/src/views/resource/index.vue +237 -0
  262. package/src/views/resource/interface.ts +6 -0
  263. package/src/views/role/components/ResourceRelation.vue +113 -0
  264. package/src/views/role/components/drawerRole.vue +191 -0
  265. package/src/views/role/enum.ts +26 -0
  266. package/src/views/role/index.vue +183 -0
  267. package/src/views/role/interface.ts +6 -0
  268. package/src/views/role_group/components/ResourceRelation.vue +91 -0
  269. package/src/views/role_group/components/drawerRole.vue +153 -0
  270. package/src/views/role_group/components/roleSelect.vue +224 -0
  271. package/src/views/role_group/enum.ts +22 -0
  272. package/src/views/role_group/index.vue +170 -0
  273. package/src/views/role_group/interface.ts +6 -0
  274. package/src/views/safe_setting/index.vue +237 -0
  275. package/src/views/tabbar_setting/animationData.ts +23 -0
  276. package/src/views/tabbar_setting/index.vue +186 -0
  277. package/src/views/tenant/components/TenantEdit.vue +226 -0
  278. package/src/views/tenant/index.vue +192 -0
  279. package/src/views/tenant/interface.ts +4 -0
  280. package/src/views/theme_setting/index.vue +465 -0
  281. package/src/views/toolbar_setting/animationData.ts +42 -0
  282. package/src/views/toolbar_setting/index.vue +189 -0
  283. package/src/views/user/components/OrgAndPosition.vue +156 -0
  284. package/src/views/user/components/UserAuthorization.vue +260 -0
  285. package/src/views/user/components/UserEdit.vue +267 -0
  286. package/src/views/user/components/roleSelect.vue +258 -0
  287. package/src/views/user/enum.ts +13 -0
  288. package/src/views/user/index.vue +266 -0
  289. package/src/views/user/interface.ts +43 -0
  290. package/src/views/watermark_setting/animationData.ts +7 -0
  291. package/src/views/watermark_setting/index.vue +236 -0
@@ -0,0 +1,237 @@
1
+ <script setup lang="tsx">
2
+ import type { ProColumns } from '@pubinfo/pro-components';
3
+ import type { AddForm, TreeNode } from './interface';
4
+ import { getRbacResourceResourceDelete, getRbacResourceResourceTree } from '@/api/modules/rbac';
5
+ import { ProTable } from '@pubinfo/pro-components';
6
+ import { Badge, message, Modal } from 'ant-design-vue';
7
+ import { cloneDeep } from 'lodash-es';
8
+ import { PubinfoIcon } from 'pubinfo';
9
+ import ResourceEdit from './components/ResourceEdit.vue';
10
+ import RoleRelation from './components/RoleRelation.vue';
11
+ import { ACTION, RESOURCE_TYPE, resourceOptions } from './enum';
12
+
13
+ defineOptions({
14
+ name: 'Resource',
15
+ });
16
+
17
+ const { auth } = useAuth();
18
+
19
+ const columns: ProColumns<TreeNode> = [
20
+ {
21
+ valueType: 'a-input',
22
+ width: 200,
23
+ title: '资源名称',
24
+ dataIndex: 'name',
25
+ ellipsis: true,
26
+ fieldProps: {
27
+ placeholder: '请输入资源名称',
28
+ allowClear: true,
29
+ },
30
+ },
31
+ {
32
+ valueType: 'a-input',
33
+ title: '资源编码',
34
+ dataIndex: 'code',
35
+ ellipsis: true,
36
+ fieldProps: {
37
+ placeholder: '请输入资源编码',
38
+ allowClear: true,
39
+ },
40
+ },
41
+ {
42
+ valueType: 'a-select',
43
+ title: '资源类型',
44
+ dataIndex: 'type',
45
+ fieldProps: {
46
+ placeholder: '请选择资源类型',
47
+ allowClear: true,
48
+ options: resourceOptions,
49
+ },
50
+ customRender({ text }) {
51
+ const icon = ['', 'app', 'index', 'menu', 'btn', 'nonmenu'];
52
+ return (
53
+ <div class="flex items-center space-x-1">
54
+ <PubinfoIcon name={`resource-${icon[text]}`} class="text-xl" />
55
+ <span>{resourceOptions.find(item => item.value === text)?.label}</span>
56
+ </div>
57
+ );
58
+ },
59
+ },
60
+ {
61
+ valueType: 'a-select',
62
+ title: '是否启用',
63
+ dataIndex: 'enable',
64
+ width: 100,
65
+ fieldProps: {
66
+ placeholder: '请选择是否启用',
67
+ allowClear: true,
68
+ options: [
69
+ { value: 1, label: '是' },
70
+ { value: 0, label: '否' },
71
+ ],
72
+ },
73
+ customRender({ text }) {
74
+ return (
75
+ text
76
+ ? <Badge status="success" text="是" />
77
+ : <Badge status="error" text="否" />
78
+ );
79
+ },
80
+ },
81
+ {
82
+ title: '权限标识',
83
+ dataIndex: 'permissionCode',
84
+ ellipsis: true,
85
+ hideInSearch: true,
86
+ },
87
+ {
88
+ title: '排序',
89
+ dataIndex: 'sort',
90
+ hideInSearch: true,
91
+ },
92
+ {
93
+ title: '操作',
94
+ dataIndex: 'action',
95
+ fixed: 'right',
96
+ width: 320,
97
+ hideInSearch: true,
98
+ hideInTable() {
99
+ return !auth([
100
+ 'resource_role_relation',
101
+ 'resource_add_child',
102
+ 'resource_edit',
103
+ 'resource_remove',
104
+ ]);
105
+ },
106
+ },
107
+ ];
108
+
109
+ function recursiveTreeMap<T extends { children?: T[] }>(tree: T[], fn: (node: T) => any) {
110
+ return tree?.map((node) => {
111
+ node.children = node.children && recursiveTreeMap(node.children, fn);
112
+ return fn(node);
113
+ }) ?? [];
114
+ }
115
+
116
+ const tableRef = ref();
117
+ const dataSource = computed(() => tableRef.value?.dataSource ?? []);
118
+ function getTreeData() {
119
+ tableRef.value.reload();
120
+ }
121
+
122
+ async function request(query: any) {
123
+ const { pageSize, current, enabled, ...rest } = cloneDeep(query);
124
+ const params: AddForm = {
125
+ ...rest,
126
+ enabled: Boolean(enabled),
127
+ };
128
+ const dataSource = await getRbacResourceResourceTree(params, {
129
+ transform(data) {
130
+ return recursiveTreeMap<TreeNode>(data?.data ?? [], (node) => {
131
+ return node.leaf ? { ...node, children: undefined } : node;
132
+ }) as TreeNode[];
133
+ },
134
+ });
135
+
136
+ return {
137
+ success: true,
138
+ data: dataSource,
139
+ };
140
+ }
141
+
142
+ const editRef = ref();
143
+ const relationRef = ref();
144
+ function onAction(key: string, record?: TreeNode) {
145
+ switch (key) {
146
+ case ACTION.ROLE_RELATION:
147
+ relationRef.value.open(record);
148
+ break;
149
+
150
+ case ACTION.ADD:
151
+ editRef.value.open(key);
152
+ break;
153
+
154
+ case ACTION.ADD_CHILD:
155
+ editRef.value.open(key, record);
156
+ break;
157
+
158
+ case ACTION.EDIT:
159
+ editRef.value.open(key, record);
160
+ break;
161
+
162
+ case ACTION.REMOVE:
163
+ if (!record?.leaf) {
164
+ message.info('非叶子节点不能删除');
165
+ return;
166
+ }
167
+ Modal.confirm({
168
+ title: '删除',
169
+ content: '确定要删除该资源吗?',
170
+ async onOk() {
171
+ const res = await getRbacResourceResourceDelete({ id: record?.id as string });
172
+ if (res.success) {
173
+ message.success('删除成功');
174
+ getTreeData();
175
+ }
176
+ },
177
+ });
178
+ break;
179
+ }
180
+ }
181
+ </script>
182
+
183
+ <template>
184
+ <div
185
+ w-full
186
+ h-full
187
+ py-10px
188
+ px-10px
189
+ >
190
+ <ProTable
191
+ ref="tableRef"
192
+ row-key="id"
193
+ :columns="columns"
194
+ :request="request"
195
+ :pagination="false"
196
+ :scroll="{ x: 1024 }"
197
+ auto-height
198
+ >
199
+ <template #toolbar>
200
+ <a-button v-auth="'resource_app_add'" type="primary" @click="onAction(ACTION.ADD)">
201
+ <PlusCircleOutlined />
202
+ {{ ACTION.ADD }}
203
+ </a-button>
204
+ </template>
205
+
206
+ <template #bodyCell="{ column, record }">
207
+ <template v-if="column.dataIndex === 'action'">
208
+ <a-space>
209
+ <a v-auth="'resource_role_relation'" class="flex items-center" @click="onAction(ACTION.ROLE_RELATION, record)">
210
+ <PubinfoIcon name="view" class="mr-1 text-base" />
211
+ <span>{{ ACTION.ROLE_RELATION }}</span>
212
+ </a>
213
+ <a
214
+ v-if="record.type !== RESOURCE_TYPE.BUTTON"
215
+ v-auth="'resource_add_child'"
216
+ class="flex items-center"
217
+ @click="onAction(ACTION.ADD_CHILD, record)"
218
+ >
219
+ <PubinfoIcon name="add-child" class="mr-1 text-base" />
220
+ <span>{{ ACTION.ADD_CHILD }}</span>
221
+ </a>
222
+ <a v-auth="'resource_edit'" class="flex items-center" @click="onAction(ACTION.EDIT, record)">
223
+ <PubinfoIcon name="edit" class="mr-1 text-base" />
224
+ <span>{{ ACTION.EDIT }}</span>
225
+ </a>
226
+ <span v-auth="'resource_remove'" class="flex items-center text-red-500 hover:cursor-pointer hover:opacity-80" @click="onAction(ACTION.REMOVE, record)">
227
+ <PubinfoIcon name="remove" class="mr-1 text-base" />
228
+ <span>{{ ACTION.REMOVE }}</span>
229
+ </span>
230
+ </a-space>
231
+ </template>
232
+ </template>
233
+ </ProTable>
234
+ <ResourceEdit ref="editRef" :data-source="dataSource" @submit="getTreeData" />
235
+ <RoleRelation ref="relationRef" />
236
+ </div>
237
+ </template>
@@ -0,0 +1,6 @@
1
+ export type Form = API.PubResource;
2
+ export type AddForm = API.PubResourceAddDto;
3
+ export type EditForm = API.PubResourceUpdateDto;
4
+ export type TreeNode = Form & {
5
+ children?: TreeNode[]
6
+ };
@@ -0,0 +1,113 @@
1
+ <script setup lang="ts">
2
+ import type { ProColumns } from '@pubinfo/pro-components';
3
+ import type { TreeNode } from '../interface';
4
+ import { postRbacOrgRoleRoleOrgPage, postRbacRoleRoleUserPage } from '@/api/modules/rbac';
5
+ import { ProTable } from '@pubinfo/pro-components';
6
+ import { useToggle } from '@vueuse/core';
7
+
8
+ defineOptions({
9
+ name: 'ResourceRelation',
10
+ });
11
+ const options = ref(['用户自选角色', '组织基础角色']);
12
+ const val = ref(options.value[0]);
13
+
14
+ const [open, setOpen] = useToggle(false);
15
+ const roleId = ref('');
16
+ const protable = ref();
17
+ function optionChange() {
18
+ protable.value.fetch();
19
+ }
20
+ async function request(params: any) {
21
+ params.pageSize = 15;
22
+ params.roleId = roleId.value;
23
+ const { current, pageSize, ...rest } = params;
24
+ const request = val.value === '用户自选角色' ? postRbacRoleRoleUserPage : postRbacOrgRoleRoleOrgPage;
25
+ const res = await request({
26
+ currentPage: current,
27
+ pageSize,
28
+ ...rest,
29
+ });
30
+ return {
31
+ success: res.success,
32
+ data: res.data?.records ?? [],
33
+ total: res.data?.total ?? 0,
34
+ };
35
+ }
36
+ const columns = computed<ProColumns<any>>(() => {
37
+ if (val.value === '用户自选角色') {
38
+ return [
39
+ {
40
+ title: '用户名称',
41
+ dataIndex: 'realName',
42
+ ellipsis: true,
43
+ },
44
+ {
45
+ title: '组织名称',
46
+ dataIndex: 'orgName',
47
+ ellipsis: true,
48
+ },
49
+ ];
50
+ }
51
+ else {
52
+ return [
53
+ {
54
+ title: '组织名称',
55
+ dataIndex: 'name',
56
+ ellipsis: true,
57
+ },
58
+ ];
59
+ }
60
+ });
61
+
62
+ function onOpen(record: TreeNode) {
63
+ roleId.value = record.id || '';
64
+ setOpen(true);
65
+ }
66
+
67
+ defineExpose({
68
+ open: onOpen,
69
+ });
70
+ </script>
71
+
72
+ <template>
73
+ <a-drawer
74
+ v-model:open="open"
75
+ title="分配查看"
76
+ placement="right"
77
+ :width="720"
78
+ destroy-on-close
79
+ :footer-style="{ textAlign: 'right' }"
80
+ :body-style="{ paddingLeft: 0, paddingRight: 0 }"
81
+ >
82
+ <div class="mb-20px p-x-15px">
83
+ <a-segmented v-model:value="val" block :options="options" @change="optionChange" />
84
+ </div>
85
+ <ProTable
86
+ ref="protable"
87
+ row-key="id"
88
+ :request="request"
89
+ :columns="columns"
90
+ :search="false"
91
+ :toolbar="false"
92
+ :auto-height="{ offset: 50 }"
93
+ >
94
+ <template #bodyCell="{ column, record }">
95
+ <template v-if="column.dataIndex === 'name'">
96
+ <div class="flex items-center">
97
+ <span class="mr-4px">{{ record.name }}</span>
98
+ <a-tag v-if="record.isInherit === '1'" color="processing">
99
+ 及子组织
100
+ </a-tag>
101
+ </div>
102
+ </template>
103
+ </template>
104
+ </ProTable>
105
+ </a-drawer>
106
+ </template>
107
+
108
+ <style lang="scss" scoped>
109
+ :deep(.ant-drawer-body) {
110
+ padding-right: 0;
111
+ padding-left: 0;
112
+ }
113
+ </style>
@@ -0,0 +1,191 @@
1
+ <script setup lang="ts">
2
+ import type { SelectedResourceInfo } from '@/components/ResourceSelector/hooks/useAppAndResource';
3
+ import type { Rule } from 'ant-design-vue/es/form';
4
+ import type { FormExpose } from 'ant-design-vue/es/form/Form';
5
+ import { getRbacRoleInfo, postRbacRoleAddRole, postRbacRoleRoleUpdate } from '@/api/modules/rbac';
6
+ import useAppAndResource from '@/components/ResourceSelector/hooks/useAppAndResource';
7
+ import ResourceSelector from '@/components/ResourceSelector/index.vue';
8
+ import { useToggle } from '@vueuse/core';
9
+ import { message } from 'ant-design-vue';
10
+ import { ACTION, kjOptions } from '../enum';
11
+
12
+ defineOptions({
13
+ name: 'DrawerRole',
14
+ });
15
+
16
+ const emit = defineEmits(['submit']);
17
+
18
+ const {
19
+ resourceModelRef,
20
+ selectedResources,
21
+ updateTreeDataAndResourceMap,
22
+ setSelectedResources,
23
+ updateSelectedResources,
24
+ clearSelectedResources,
25
+ openResourceModel,
26
+ } = useAppAndResource();
27
+
28
+ const rules: Record<string, Rule[]> = {
29
+ name: [
30
+ { required: true, message: '请输入名称', trigger: 'change' },
31
+ { min: 2, max: 32, message: '角色名称长度不能少于2位,不能超过32位', trigger: 'change' },
32
+ ],
33
+ code: [
34
+ { required: true, message: '请输入编号', trigger: 'change' },
35
+ { min: 2, max: 32, message: '角色编码长度不能少于2位,不能超过32位', trigger: 'change' },
36
+ ],
37
+ viewScope: [{ required: true, message: '请选择可见范围', trigger: 'change' }],
38
+ resourceIds: [{ required: true, validator: resourceValidate, trigger: ['blur', 'change'] }],
39
+ };
40
+
41
+ function resourceValidate(_: unknown, value: string[]) {
42
+ if (value && value.length > 0) {
43
+ return Promise.resolve();
44
+ }
45
+ return Promise.reject(new Error('请选择所属资源'));
46
+ }
47
+
48
+ const state = reactive<{ title: string, type: string }>({
49
+ title: '',
50
+ type: '',
51
+ });
52
+ const [open, setOpen] = useToggle(false);
53
+ const formRef = ref<FormExpose>();
54
+ const form = ref<Partial<API.PubRoleAddDto>>({ enable: true });
55
+
56
+ async function onOpen(key: ACTION, record?: API.PubRoleResourceBo) {
57
+ state.title = key;
58
+ if (key === ACTION.EDIT) {
59
+ const res = await getRbacRoleInfo({ id: record?.id as string });
60
+ if (res.success) {
61
+ form.value = res.data ?? {};
62
+
63
+ await updateTreeDataAndResourceMap('');
64
+ if (form.value.resourceIds) {
65
+ updateSelectedResources(form.value.resourceIds);
66
+ }
67
+ }
68
+ }
69
+ else {
70
+ form.value = {
71
+ enable: true,
72
+ };
73
+ clearSelectedResources();
74
+ await updateTreeDataAndResourceMap('');
75
+ }
76
+ setOpen(true);
77
+ }
78
+
79
+ const [loading, setLoading] = useToggle(false);
80
+
81
+ function onSubmit() {
82
+ const request = state.title === ACTION.EDIT ? postRbacRoleRoleUpdate : postRbacRoleAddRole;
83
+ formRef.value?.validate().then(() => {
84
+ setLoading(true);
85
+ const params: any = { ...form.value };
86
+ request(params)
87
+ .then((res) => {
88
+ if (res.success) {
89
+ message.success(`${state.title}成功!`);
90
+ setOpen(false);
91
+ emit('submit');
92
+ }
93
+ })
94
+ .finally(() => setLoading(false));
95
+ });
96
+ }
97
+ function close() {
98
+ form.value = {
99
+ enable: true,
100
+ };
101
+ setOpen(false);
102
+ }
103
+
104
+ function chooseResource() {
105
+ if (form.value.resourceIds) {
106
+ openResourceModel(form.value.resourceIds);
107
+ }
108
+ else {
109
+ openResourceModel([]);
110
+ }
111
+ }
112
+
113
+ function onResourceSelected(data: SelectedResourceInfo[]) {
114
+ form.value.resourceIds = data.map(item => item.id);
115
+ setSelectedResources(data);
116
+ }
117
+
118
+ defineExpose({
119
+ open: onOpen,
120
+ });
121
+ </script>
122
+
123
+ <template>
124
+ <a-drawer
125
+ v-model:open="open"
126
+ :title="`${state.title}角色`"
127
+ placement="right"
128
+ :width="600"
129
+ destroy-on-close
130
+ :footer-style="{ textAlign: 'right' }"
131
+ @close="close"
132
+ >
133
+ <a-form
134
+ ref="formRef"
135
+ :model="form"
136
+ :rules="rules"
137
+ :label-col="{ span: 4 }"
138
+ >
139
+ <a-form-item label="角色名称" name="name">
140
+ <a-input v-model:value="form.name" :maxlength="32" />
141
+ </a-form-item>
142
+
143
+ <a-form-item label="角色编号" name="code">
144
+ <a-input v-model:value="form.code" :disabled="state.title === ACTION.EDIT" :maxlength="32" />
145
+ </a-form-item>
146
+ <a-form-item label="可见范围" name="viewScope">
147
+ <a-select v-model:value="form.viewScope" :options="kjOptions" />
148
+ </a-form-item>
149
+
150
+ <a-form-item label="是否启用">
151
+ <a-switch v-model:checked="form.enable" />
152
+ </a-form-item>
153
+
154
+ <a-form-item label="角色描述">
155
+ <a-textarea
156
+ v-model:value="form.description"
157
+ :maxlength="250"
158
+ show-count
159
+ />
160
+ </a-form-item>
161
+ <a-form-item label="所属资源" name="resourceIds">
162
+ <a-button type="primary" @click="chooseResource">
163
+ 编辑资源
164
+ </a-button>
165
+ <div class="pt-10px">
166
+ <template v-for="item in selectedResources" :key="item">
167
+ <a-tooltip v-if="item.name.length > 20" :title="item.name">
168
+ <span class="inline-block mb-6px mr-6px bg-[#E8F3FF] rounded-2px px-8px py-3px whitespace-nowrap dark:bg-[#141414]">
169
+ {{ `${item.name.slice(0, 20)}...` }}
170
+ </span>
171
+ </a-tooltip>
172
+ <span v-else class="inline-block mb-6px mr-6px bg-[#E8F3FF] rounded-2px px-8px py-3px whitespace-nowrap dark:bg-[#141414]">
173
+ {{ item.name }}
174
+ </span>
175
+ </template>
176
+ </div>
177
+ </a-form-item>
178
+ </a-form>
179
+ <template #footer>
180
+ <a-space>
181
+ <a-button @click="close">
182
+ 取消
183
+ </a-button>
184
+ <a-button type="primary" :loading="loading" @click="onSubmit()">
185
+ 提交
186
+ </a-button>
187
+ </a-space>
188
+ </template>
189
+ <ResourceSelector ref="resourceModelRef" @select="onResourceSelected" />
190
+ </a-drawer>
191
+ </template>
@@ -0,0 +1,26 @@
1
+ export enum ACTION {
2
+ ADD = '新增',
3
+ /** 编辑 */
4
+ EDIT = '修改',
5
+ /** 删除 */
6
+ REMOVE = '删除',
7
+ /** 分配查看 */
8
+ RESOURCE_RELATION = '分配查看',
9
+ }
10
+
11
+ export enum RESOURCE_TYPE {
12
+ OWNER = '1',
13
+ ALL = '2',
14
+ }
15
+ export enum ENABLE_TYPE {
16
+ ON = 1,
17
+ OFF = 0,
18
+ }
19
+ export const kjOptions = [
20
+ { label: '仅自己', value: RESOURCE_TYPE.OWNER },
21
+ { label: '全部可见', value: RESOURCE_TYPE.ALL },
22
+ ];
23
+ export const enableOptons = [
24
+ { label: '正常', value: ENABLE_TYPE.ON },
25
+ { label: '关闭', value: ENABLE_TYPE.OFF },
26
+ ];