@jiangood/open-admin 1.3.4 → 2.0.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.
Files changed (153) hide show
  1. package/config/config.js +3 -8
  2. package/package.json +5 -9
  3. package/src/.umi-production/appData.json +325 -365
  4. package/src/.umi-production/core/helmet.ts +1 -1
  5. package/src/.umi-production/core/history.ts +1 -1
  6. package/src/.umi-production/core/historyIntelli.ts +1 -1
  7. package/src/.umi-production/core/pluginConfig.ts +1 -1
  8. package/src/.umi-production/core/polyfill.ts +216 -216
  9. package/src/.umi-production/core/route.tsx +2 -4
  10. package/src/.umi-production/exports.ts +3 -3
  11. package/src/.umi-production/testBrowser.tsx +1 -1
  12. package/src/.umi-production/tsconfig.json +1 -1
  13. package/src/.umi-production/umi.ts +2 -2
  14. package/src/framework/components/ErrorBoundary/index.tsx +86 -0
  15. package/src/framework/components/Gap/index.tsx +42 -0
  16. package/src/framework/components/NamedIcon/index.d.ts +6 -4
  17. package/src/framework/components/NamedIcon/index.jsx +9 -6
  18. package/src/framework/components/OrgTree/{index.jsx → index.tsx} +10 -19
  19. package/src/framework/components/PageLoading/{index.jsx → index.tsx} +2 -5
  20. package/src/framework/components/ProModal/index.tsx +1 -1
  21. package/src/framework/components/ProTable/components/ToolBar/{index.jsx → index.tsx} +3 -3
  22. package/src/framework/components/ProTable/index.less +1 -1
  23. package/src/framework/components/ProTable/{index.jsx → index.tsx} +9 -7
  24. package/src/framework/components/ProTable/utils/index.ts +62 -0
  25. package/src/framework/components/RoleTree/{index.jsx → index.tsx} +7 -17
  26. package/src/framework/components/ValueType/{index.jsx → index.tsx} +2 -1
  27. package/src/framework/components/ViewRange/index.tsx +15 -0
  28. package/src/framework/components/index.ts +2 -1
  29. package/src/framework/components/system/ButtonList.tsx +22 -0
  30. package/src/framework/components/system/index.tsx +4 -4
  31. package/src/framework/fields/BaseRemoteSelect/index.tsx +129 -0
  32. package/src/framework/fields/FieldDictSelect/{index.jsx → index.tsx} +10 -4
  33. package/src/framework/fields/FieldRemoteSelect/index.tsx +37 -0
  34. package/src/framework/fields/FieldRemoteSelectMultiple/index.tsx +29 -0
  35. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.tsx +33 -0
  36. package/src/framework/fields/FieldRemoteTree/index.tsx +31 -0
  37. package/src/framework/fields/FieldRemoteTreeCascader/index.tsx +39 -0
  38. package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +39 -0
  39. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.tsx +43 -0
  40. package/src/framework/fields/FieldSysOrgTree/{index.jsx → index.tsx} +2 -2
  41. package/src/framework/fields/FieldSysOrgTreeSelect/{index.jsx → index.tsx} +2 -2
  42. package/src/framework/fields/FieldTable/{index.jsx → index.tsx} +5 -5
  43. package/src/framework/fields/FieldUploadFile/{index.jsx → index.tsx} +1 -3
  44. package/src/framework/index.ts +0 -1
  45. package/src/framework/utils/ArrayUtils.ts +186 -0
  46. package/src/framework/utils/EventBusUtils.ts +0 -1
  47. package/src/framework/utils/MessageUtils.tsx +0 -2
  48. package/src/framework/utils/TreeUtils.ts +2 -2
  49. package/src/framework/utils/index.ts +1 -1
  50. package/src/framework/utils/system/FormRegistryUtils.ts +0 -1
  51. package/src/framework/utils/system/PermUtils.ts +2 -2
  52. package/src/framework/views/ViewApproveStatus/index.tsx +11 -0
  53. package/src/framework/views/ViewBoolean/index.tsx +6 -0
  54. package/src/framework/views/ViewFile/{index.jsx → index.tsx} +4 -4
  55. package/src/framework/views/ViewImage/{index.jsx → index.tsx} +3 -3
  56. package/src/framework/views/ViewPassword/{index.jsx → index.tsx} +2 -2
  57. package/src/framework/views/ViewProcessInstanceProgressButton/{index.jsx → index.tsx} +1 -2
  58. package/src/layouts/PageRender.jsx +6 -6
  59. package/src/layouts/admin/HeaderRight.jsx +2 -2
  60. package/src/layouts/admin/TabPageRender.jsx +28 -13
  61. package/src/layouts/admin/index.jsx +15 -14
  62. package/src/layouts/admin/index.less +1 -1
  63. package/src/layouts/index.jsx +12 -13
  64. package/src/layouts/index.less +2 -2
  65. package/src/loading.jsx +17 -16
  66. package/src/pages/login.jsx +132 -4
  67. package/src/{framework/pages/LoginPage.less → pages/login.less} +3 -3
  68. package/src/pages/system/dict/index.jsx +4 -3
  69. package/src/pages/system/file/index.jsx +6 -5
  70. package/src/pages/system/job/index.jsx +10 -9
  71. package/src/pages/system/{sysManual → manual}/index.jsx +1 -1
  72. package/src/pages/system/org/index.jsx +4 -5
  73. package/src/pages/system/role/index.jsx +5 -5
  74. package/src/pages/system/role/perm.jsx +6 -6
  75. package/src/pages/system/user/UserPerm.jsx +4 -4
  76. package/src/pages/system/user/index.jsx +2 -2
  77. package/src/pages/userCenter/ChangePassword.jsx +3 -5
  78. package/src/pages/userCenter/manual.jsx +1 -1
  79. package/src/pages/userCenter/message.jsx +1 -1
  80. package/src/framework/components/DownloadFileButton/index.d.ts +0 -11
  81. package/src/framework/components/Gap/index.d.ts +0 -23
  82. package/src/framework/components/Gap/index.jsx +0 -46
  83. package/src/framework/components/LinkButton/index.d.ts +0 -14
  84. package/src/framework/components/OrgTree/index.d.ts +0 -4
  85. package/src/framework/components/Page/index.d.ts +0 -17
  86. package/src/framework/components/PageLoading/index.d.ts +0 -1
  87. package/src/framework/components/ProTable/index.d.ts +0 -42
  88. package/src/framework/components/ProTable/utils/index.js +0 -43
  89. package/src/framework/components/RoleTree/index.d.ts +0 -4
  90. package/src/framework/components/ViewRange/index.d.ts +0 -14
  91. package/src/framework/components/ViewRange/index.jsx +0 -20
  92. package/src/framework/components/system/ButtonList.d.ts +0 -8
  93. package/src/framework/components/system/ButtonList.jsx +0 -42
  94. package/src/framework/fields/FieldBoolean/index.d.ts +0 -9
  95. package/src/framework/fields/FieldDate/index.d.ts +0 -23
  96. package/src/framework/fields/FieldDateRange/index.d.ts +0 -22
  97. package/src/framework/fields/FieldDictSelect/index.d.ts +0 -12
  98. package/src/framework/fields/FieldEditor/index.d.ts +0 -14
  99. package/src/framework/fields/FieldNumberRange/index.d.ts +0 -10
  100. package/src/framework/fields/FieldPercent/index.d.ts +0 -8
  101. package/src/framework/fields/FieldRemoteSelect/index.d.ts +0 -44
  102. package/src/framework/fields/FieldRemoteSelect/index.jsx +0 -66
  103. package/src/framework/fields/FieldRemoteSelectMultiple/index.d.ts +0 -20
  104. package/src/framework/fields/FieldRemoteSelectMultiple/index.jsx +0 -85
  105. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.d.ts +0 -21
  106. package/src/framework/fields/FieldRemoteSelectMultipleInline/index.jsx +0 -88
  107. package/src/framework/fields/FieldRemoteTree/index.d.ts +0 -20
  108. package/src/framework/fields/FieldRemoteTree/index.jsx +0 -50
  109. package/src/framework/fields/FieldRemoteTreeCascader/index.d.ts +0 -18
  110. package/src/framework/fields/FieldRemoteTreeCascader/index.jsx +0 -59
  111. package/src/framework/fields/FieldRemoteTreeSelect/index.d.ts +0 -19
  112. package/src/framework/fields/FieldRemoteTreeSelect/index.jsx +0 -57
  113. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.d.ts +0 -20
  114. package/src/framework/fields/FieldRemoteTreeSelectMultiple/index.jsx +0 -62
  115. package/src/framework/fields/FieldSysOrgTree/index.d.ts +0 -9
  116. package/src/framework/fields/FieldSysOrgTreeSelect/index.d.ts +0 -9
  117. package/src/framework/fields/FieldTable/index.d.ts +0 -14
  118. package/src/framework/fields/FieldTableSelect/index.d.ts +0 -19
  119. package/src/framework/fields/FieldUploadFile/index.d.ts +0 -31
  120. package/src/framework/pages/LoginPage.d.ts +0 -16
  121. package/src/framework/pages/LoginPage.jsx +0 -135
  122. package/src/framework/pages/LoginPageUtils.ts +0 -36
  123. package/src/framework/pages/index.ts +0 -2
  124. package/src/framework/utils/ArrUtils.ts +0 -229
  125. package/src/framework/views/ViewApproveStatus/index.d.ts +0 -5
  126. package/src/framework/views/ViewApproveStatus/index.jsx +0 -15
  127. package/src/framework/views/ViewBoolean/index.d.ts +0 -3
  128. package/src/framework/views/ViewBoolean/index.jsx +0 -4
  129. package/src/framework/views/ViewBooleanEnableDisable/index.d.ts +0 -5
  130. package/src/framework/views/ViewFile/index.d.ts +0 -10
  131. package/src/framework/views/ViewFileButton/index.d.ts +0 -10
  132. package/src/framework/views/ViewImage/index.d.ts +0 -6
  133. package/src/framework/views/ViewPassword/index.d.ts +0 -5
  134. package/src/framework/views/ViewProcessInstanceProgress/index.d.ts +0 -12
  135. package/src/framework/views/ViewProcessInstanceProgressButton/index.d.ts +0 -6
  136. package/src/framework/views/ViewText/index.d.ts +0 -16
  137. package/src/pages/system/api/index.jsx +0 -279
  138. package/src/pages/test/views.jsx +0 -95
  139. package/src/framework/components/DownloadFileButton/{index.jsx → index.tsx} +0 -0
  140. package/src/framework/components/LinkButton/{index.jsx → index.tsx} +0 -0
  141. package/src/framework/components/Page/{index.jsx → index.tsx} +0 -0
  142. package/src/framework/components/ValueType/{registry.jsx → registry.tsx} +1 -1
  143. /package/src/framework/fields/FieldBoolean/{index.jsx → index.tsx} +0 -0
  144. /package/src/framework/fields/FieldDate/{index.jsx → index.tsx} +0 -0
  145. /package/src/framework/fields/FieldDateRange/{index.jsx → index.tsx} +0 -0
  146. /package/src/framework/fields/FieldEditor/{index.jsx → index.tsx} +0 -0
  147. /package/src/framework/fields/FieldNumberRange/{index.jsx → index.tsx} +0 -0
  148. /package/src/framework/fields/FieldPercent/{index.jsx → index.tsx} +0 -0
  149. /package/src/framework/fields/FieldTableSelect/{index.jsx → index.tsx} +0 -0
  150. /package/src/framework/views/ViewBooleanEnableDisable/{index.jsx → index.tsx} +0 -0
  151. /package/src/framework/views/ViewFileButton/{index.jsx → index.tsx} +0 -0
  152. /package/src/framework/views/ViewProcessInstanceProgress/{index.jsx → index.tsx} +0 -0
  153. /package/src/framework/views/ViewText/{index.jsx → index.tsx} +0 -0
@@ -1,229 +0,0 @@
1
- /**
2
- * 数组工具类
3
- * 提供了一系列对数组进行操作的静态方法。
4
- */
5
- export class ArrUtils {
6
-
7
- /**
8
- * 检查数组是否包含某个元素。
9
- * @param arr 目标数组。
10
- * @param item 要检查的元素。
11
- * @returns 如果包含则返回 true,否则返回 false。
12
- */
13
- static contains<T>(arr: T[], item: T): boolean {
14
- return arr.indexOf(item) !== -1;
15
- }
16
-
17
- /**
18
- * 检查数组是否包含至少一个指定的元素。
19
- * 注意:原始实现中的 this.contains(item) 逻辑错误,已修正为检查 arr 是否包含 item。
20
- *
21
- * @param arr 目标数组。
22
- * @param items 要检查的一个或多个元素。
23
- * @returns 如果包含任意一个元素则返回 true,否则返回 false。
24
- */
25
- static containsAny<T>(arr: T[], ...items: T[]): boolean {
26
- for (const item of items) {
27
- // 这里调用自身的静态方法
28
- if (ArrUtils.contains(arr, item)) {
29
- return true;
30
- }
31
- }
32
- return false;
33
- }
34
-
35
- /**
36
- * 在数组末尾添加一个元素。
37
- * @param arr 目标数组。
38
- * @param item 要添加的元素。
39
- */
40
- static add<T>(arr: T[], item: T): void {
41
- arr.push(item);
42
- }
43
-
44
- /**
45
- * 在数组的指定索引处添加一个元素。
46
- * @param arr 目标数组。
47
- * @param index 插入位置的索引。
48
- * @param item 要添加的元素。
49
- */
50
- static addAt<T>(arr: T[], index: number, item: T): void {
51
- arr.splice(index, 0, item);
52
- }
53
-
54
- /**
55
- * 将另一个数组的所有元素追加到目标数组的尾部。
56
- * @param arr 目标数组。
57
- * @param items 要追加的元素数组。
58
- */
59
- static addAll<T>(arr: T[], items: T[]): void {
60
- // 使用 ES6 的 spread 运算符或 push.apply 效率更高
61
- arr.push(...items);
62
- }
63
-
64
- /**
65
- * 移除数组指定索引处的元素。
66
- * @param arr 目标数组。
67
- * @param index 要移除元素的索引。
68
- */
69
- static removeAt<T>(arr: T[], index: number): void {
70
- if (index >= 0 && index < arr.length) {
71
- arr.splice(index, 1);
72
- }
73
- }
74
-
75
- /**
76
- * 移除数组中第一个匹配的元素。
77
- * @param arr 目标数组。
78
- * @param item 要移除的元素。
79
- */
80
- static remove<T>(arr: T[], item: T): void {
81
- const index = arr.indexOf(item);
82
- if (index !== -1) {
83
- // 这里调用自身的静态方法
84
- ArrUtils.removeAt(arr, index);
85
- }
86
- }
87
-
88
- /**
89
- * 清空数组。
90
- * @param arr 目标数组。
91
- */
92
- static clear<T>(arr: T[]): void {
93
- arr.length = 0;
94
- }
95
-
96
- /**
97
- * 截取数组的一个子集。
98
- * @param arr 目标数组。
99
- * @param fromIndex 开始索引(包含)。
100
- * @param toIndex 结束索引(不包含)。
101
- * @returns 截取后的新数组。
102
- */
103
- static sub<T>(arr: T[], fromIndex?: number, toIndex?: number): T[] {
104
- return arr.slice(fromIndex, toIndex);
105
- }
106
-
107
- /**
108
- * 交换数组中两个元素的位置。
109
- * @param arr 目标数组。
110
- * @param item1 元素1。
111
- * @param item2 元素2。
112
- */
113
- static swap<T>(arr: T[], item1: T, item2: T): void {
114
- const index1 = arr.indexOf(item1);
115
- const index2 = arr.indexOf(item2);
116
-
117
- if (index1 !== -1 && index2 !== -1) {
118
- // 使用解构赋值进行交换,更简洁
119
- [arr[index1], arr[index2]] = [arr[index2], arr[index1]];
120
- }
121
- }
122
-
123
- /**
124
- * 在数组的指定索引处插入一个元素(与 addAt 相同,保留以兼容原 API)。
125
- * @param arr 目标数组。
126
- * @param index 插入位置的索引。
127
- * @param item 要插入的元素。
128
- */
129
- static insert<T>(arr: T[], index: number, item: T): void {
130
- ArrUtils.addAt(arr, index, item);
131
- }
132
-
133
- /**
134
- * 如果元素不存在于数组中,则将其添加到数组末尾。
135
- * @param arr 目标数组。
136
- * @param item 要添加的元素。
137
- */
138
- static pushIfNotExist<T>(arr: T[], item: T): void {
139
- if (!ArrUtils.contains(arr, item)) {
140
- arr.push(item);
141
- }
142
- }
143
-
144
- /**
145
- * 将新数组中的所有元素添加到目标数组的末尾。
146
- * @param arr 目标数组。
147
- * @param newArr 要添加的元素数组。
148
- */
149
- static pushAll<T>(arr: T[], newArr: T[]): void {
150
- ArrUtils.addAll(arr, newArr);
151
- }
152
-
153
- /**
154
- * 获取对象数组中某一属性值最大的对象。
155
- * 使用泛型 K 约束 key 必须是 T 的属性,并确保属性值可以进行数值比较。
156
- *
157
- * @param arr 对象数组。
158
- * @param key 用于比较的属性名。
159
- * @returns 属性值最大的对象,如果数组为空则返回 undefined。
160
- */
161
- static maxBy<T extends Record<K, any>, K extends keyof T>(
162
- arr: T[],
163
- key: K
164
- ): T | undefined {
165
- if (arr == null || arr.length === 0) {
166
- return undefined;
167
- }
168
-
169
- let maxElement: T | undefined = undefined;
170
- let maxValue: number = -Infinity;
171
-
172
- for (const element of arr) {
173
- // 运行时类型检查(虽然 TS 层面已约束 K,但值可能不是数字)
174
- const value = element[key];
175
-
176
- // 确保比较的是数字类型
177
- if (typeof value === 'number' && value > maxValue) {
178
- maxValue = value;
179
- maxElement = element;
180
- } else if (typeof value !== 'number') {
181
- // 可选:如果遇到非数字,可以跳过或根据需求抛出错误/记录警告
182
- // console.warn(`Element with key ${String(key)} has non-numeric value: ${value}`);
183
- }
184
- }
185
-
186
- return maxElement;
187
- }
188
-
189
- /**
190
- * 对数组进行去重。
191
- * @param arr 目标数组。
192
- * @returns 去重后的新数组。
193
- */
194
- static unique<T>(arr: T[]): T[] {
195
- return [...new Set(arr)];
196
- }
197
- }
198
-
199
- // 示例用法(可选)
200
- /*
201
- interface User {
202
- id: number;
203
- score: number;
204
- name: string;
205
- }
206
-
207
- const users: User[] = [
208
- { id: 1, score: 90, name: 'Alice' },
209
- { id: 2, score: 95, name: 'Bob' },
210
- { id: 3, score: 88, name: 'Charlie' },
211
- ];
212
-
213
- const maxUser = ArrUtil.maxBy(users, 'score');
214
- console.log(maxUser); // { id: 2, score: 95, name: 'Bob' }
215
-
216
- const numbers = [1, 2, 2, 3, 4, 1];
217
- const uniqueNumbers = ArrUtil.unique(numbers);
218
- console.log(uniqueNumbers); // [1, 2, 3, 4]
219
-
220
- let list = [10, 20];
221
- ArrUtil.register(list, 30);
222
- console.log(list); // [10, 20, 30]
223
-
224
- ArrUtil.remove(list, 20);
225
- console.log(list); // [10, 30]
226
-
227
- ArrUtil.addAll(list, [40, 50]);
228
- console.log(list); // [10, 30, 40, 50]
229
- */
@@ -1,5 +0,0 @@
1
- import { ViewProps } from "../types";
2
- import {Component} from "react";
3
-
4
-
5
- export class ViewApproveStatus extends Component<ViewProps<String>,any>{}
@@ -1,15 +0,0 @@
1
- import {DictUtils} from "../../utils";
2
- import {Tag} from "antd";
3
- import {Component} from "react";
4
-
5
- /**
6
- * 查看审批状态组件
7
- * @param props
8
- * @constructor
9
- */
10
- export class ViewApproveStatus extends Component {
11
- render() {
12
- let {value} = this.props;
13
- return DictUtils.dictTag('approveStatus', value)
14
- }
15
- }
@@ -1,3 +0,0 @@
1
- import { ViewProps } from "../types";
2
-
3
- export function ViewBoolean(props: ViewProps<boolean>);
@@ -1,4 +0,0 @@
1
- export function ViewBoolean(props) {
2
- let {value} = props;
3
- return value == null ? null : (value ? '是' : '否')
4
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { ViewProps } from '../types';
3
-
4
- export class ViewBooleanEnableDisable extends React.Component<ViewProps<boolean | null | undefined>, any> {
5
- }
@@ -1,10 +0,0 @@
1
- // @ts-ignore
2
- import React from "react";
3
- import { ViewProps } from "../types";
4
-
5
- interface ViewFileProps extends ViewProps<string> {
6
- height: string;
7
- }
8
-
9
- export class ViewFile extends React.Component<ViewFileProps, any> {
10
- }
@@ -1,10 +0,0 @@
1
- // @ts-ignore
2
- import React from "react";
3
- import { ViewProps } from "../types";
4
-
5
- interface ViewFileButtonProps extends ViewProps<string> {
6
- height: string;
7
- }
8
-
9
- export class ViewFileButton extends React.Component<ViewFileButtonProps, any> {
10
- }
@@ -1,6 +0,0 @@
1
- // @ts-ignore
2
- import React from "react";
3
- import { ViewProps } from "../types";
4
-
5
- export class ViewImage extends React.Component<ViewProps<string|string[]>, any> {
6
- }
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { ViewProps } from "../types";
3
-
4
- export class ViewPassword extends React.Component<ViewProps<string>, any> {
5
- }
@@ -1,12 +0,0 @@
1
- // @ts-ignore
2
- import React from "react";
3
- import { ViewProps } from "../types";
4
-
5
-
6
-
7
- /**
8
- * 业务标识businessKey
9
- */
10
- export class ViewProcessInstanceProgress extends React.Component<ViewProps<string>, any> {
11
- }
12
-
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import { ViewProps } from "../types";
3
-
4
- export class ViewProcessInstanceProgressButton extends React.Component<ViewProps<string>, any> {
5
-
6
- }
@@ -1,16 +0,0 @@
1
- import React from "react";
2
- import { ViewProps } from "../types";
3
-
4
- interface ViewTextProps extends ViewProps<string> {
5
- /**
6
- * 是否启用文本省略
7
- */
8
- ellipsis?: boolean;
9
- /**
10
- * 文本省略的最大长度
11
- */
12
- maxLength?: number;
13
- }
14
-
15
- export class ViewText extends React.Component<ViewTextProps, any> {
16
- }
@@ -1,279 +0,0 @@
1
- import {PlusOutlined} from '@ant-design/icons'
2
- import {Button, Form, Input, message, Modal, Popconfirm, Switch, Table, Tabs} from 'antd'
3
- import React from 'react'
4
- import {
5
- ArrUtils,
6
- ButtonList,
7
- FieldBoolean,
8
- FieldDate,
9
- HttpUtils, ObjectUtils,
10
- Page,
11
- ProTable,
12
- StringUtils,
13
- ViewPassword
14
- } from "../../../framework";
15
-
16
-
17
- export default class extends React.Component {
18
-
19
- state = {
20
- formValues: {},
21
- formOpen: false,
22
-
23
- list: [],
24
- grantFormOpen: false
25
- }
26
-
27
- formRef = React.createRef()
28
- tableRef = React.createRef()
29
-
30
- componentDidMount() {
31
- HttpUtils.get("/admin/apiAccount/permList").then(rs => {
32
- this.setState({list: rs})
33
- })
34
- }
35
-
36
- handleAdd = () => {
37
- this.setState({formOpen: true, formValues: {}})
38
- }
39
-
40
- handleEdit = record => {
41
- this.setState({formOpen: true, formValues: record})
42
- }
43
-
44
- onFinish = values => {
45
- HttpUtils.post('admin/apiAccount/save', values).then(rs => {
46
- this.setState({formOpen: false})
47
- this.tableRef.current.reload()
48
- })
49
- }
50
-
51
- handleDelete = record => {
52
- HttpUtils.post('admin/apiAccount/delete', {id: record.id}).then(rs => {
53
- this.tableRef.current.reload()
54
- })
55
- }
56
-
57
- columns = [
58
- {
59
- title: '账户名称',
60
- dataIndex: 'name',
61
- },
62
- {
63
- title: 'appSecret',
64
- dataIndex: 'appSecret',
65
- render(v) {
66
- return <ViewPassword value={v}></ViewPassword>;
67
- }
68
- },
69
- {
70
- title: '准入IP',
71
- dataIndex: 'accessIp',
72
- },
73
- {
74
- title: '有效期',
75
- dataIndex: 'endTime',
76
- },
77
- {
78
- title: '启用',
79
- dataIndex: 'enable',
80
- render(v) {
81
- return v == null ? null : (v ? '是' : '否')
82
- },
83
- },
84
- {
85
- title: '权限',
86
- dataIndex: 'perms',
87
- render(perms) {
88
- if (!perms) {
89
- return
90
- }
91
- return perms.join(', ')
92
- }
93
- },
94
- {
95
- title: '操作',
96
- dataIndex: 'option',
97
- render: (_, record) => (
98
- <ButtonList>
99
- <Button size='small' perm='api'
100
- onClick={() => {
101
- this.handlePreGrant(record);
102
- }}
103
- type='primary'>授权</Button>
104
- <Button size='small' perm='api' onClick={() => this.handleEdit(record)}>编辑</Button>
105
- <Popconfirm perm='api' title='是否确定删除接口访客' onConfirm={() => this.handleDelete(record)}>
106
- <Button size='small'>删除</Button>
107
- </Popconfirm>
108
- <Button size='small' perm='api' href={'/admin/apiAccount/export/' + record.id} target={'_blank'}>下载文档</Button>
109
- </ButtonList>
110
- ),
111
- },
112
- ]
113
-
114
- handlePreGrant(record) {
115
- this.setState({grantFormOpen: true, formValues: ObjectUtils.clone(record)})
116
- }
117
-
118
- randomAppSecret = () => {
119
- const appSecret = StringUtils.random(32)
120
- this.formRef.current.setFieldsValue({appSecret})
121
- }
122
-
123
- onGrantItemChange = (id, checked) => {
124
- const perms = this.state.formValues.perms
125
- if (checked) {
126
- ArrUtils.add(perms, id)
127
- } else {
128
- ArrUtils.remove(perms, id)
129
- }
130
- this.setState({formValues: this.state.formValues})
131
- }
132
-
133
- onGrant = () => {
134
- const hide = message.loading('授权中...', 0)
135
- let accountId = this.state.formValues.id;
136
- HttpUtils.post('admin/apiAccount/grant/'+accountId, this.state.formValues.perms).then(rs => {
137
- this.setState({grantFormOpen: false})
138
- this.tableRef.current.reload()
139
- }).finally(hide)
140
- };
141
-
142
-
143
- render() {
144
- return <Page padding>
145
- <Tabs items={[
146
- {
147
- label: '接口文档',
148
- key: 'doc',
149
- children: <iframe src={'/admin/swagger-ui/index.html'} width="100%" height="1000px"></iframe>
150
- },
151
- {
152
- label: '账号管理',
153
- key: '1',
154
- children: <ProTable
155
- actionRef={this.tableRef}
156
- toolBarRender={() => {
157
- return <ButtonList>
158
- <Button perm='api' type='primary' onClick={this.handleAdd}>
159
- <PlusOutlined/> 新增
160
- </Button>
161
- </ButtonList>
162
- }}
163
- request={(params) => HttpUtils.get('admin/apiAccount/page', params)}
164
- columns={this.columns}
165
- />
166
- },
167
- {
168
- label: '访问记录',
169
- key: 'log',
170
- children: <ProTable
171
- request={(params) => HttpUtils.get('admin/apiLog/page', params)}
172
- columns={[
173
- {
174
- title: '接口',
175
- dataIndex: 'url',
176
- },
177
- {
178
- title: 'ip',
179
- dataIndex: 'ip',
180
- },
181
- {
182
- title: 'ipLocation',
183
- dataIndex: 'ipLocation',
184
- },
185
- {
186
- title: '执行时间',
187
- dataIndex: 'executionTime',
188
- },
189
- {
190
- title: '接口账户',
191
- dataIndex: 'accountName',
192
- }
193
- ]}
194
- />
195
- },
196
-
197
- ]}>
198
-
199
- </Tabs>
200
-
201
-
202
- <Modal title='接口访客'
203
- open={this.state.formOpen}
204
- onOk={() => this.formRef.current.submit()}
205
- onCancel={() => this.setState({formOpen: false})}
206
- destroyOnHidden
207
- mask={{closable:false}}
208
- >
209
-
210
- <Form ref={this.formRef} labelCol={{flex: '100px'}}
211
- initialValues={this.state.formValues}
212
- onFinish={this.onFinish}
213
-
214
- >
215
- <Form.Item name='id' noStyle></Form.Item>
216
-
217
- <Form.Item label='名称' name='name' rules={[{required: true}]}>
218
- <Input/>
219
- </Form.Item>
220
-
221
-
222
- <Form.Item label='appId' name='appId'>
223
- <Input placeholder='多个用逗号分隔'/>
224
- </Form.Item>
225
- <Form.Item label='appSecret' name='appSecret' rules={[{required: true}, {len: 32}]}
226
- help={<Button size='small' type='link' onClick={this.randomAppSecret}>随机生成</Button>}
227
- >
228
- <Input/>
229
- </Form.Item>
230
-
231
- <Form.Item label='准入IP' name='accessIp'>
232
- <Input placeholder='多个用逗号分隔'/>
233
- </Form.Item>
234
- <Form.Item label='有效期' name='endTime' style={{marginTop: 32}}>
235
- <FieldDate type='YYYY-MM-DD'/>
236
- </Form.Item>
237
- <Form.Item label='启用' name='enable' rules={[{required: true}]}>
238
- <FieldBoolean/>
239
- </Form.Item>
240
-
241
- </Form>
242
- </Modal>
243
-
244
-
245
- <Modal title='权限列表' destroyOnHidden={true} width={800}
246
- open={this.state.grantFormOpen}
247
- onCancel={() => this.setState({grantFormOpen: false, formValues: null})}
248
- onOk={this.onGrant}
249
- >
250
- <Table
251
- dataSource={this.state.list}
252
- pagination={false}
253
- rowKey='id'
254
- size={'small'}
255
- columns={[
256
- {dataIndex: 'id', title: '标识'},
257
- {dataIndex: 'name', title: '名称'},
258
- {dataIndex: 'description', title: '描述'},
259
- {dataIndex: 'path', title: '路径'},
260
- {
261
- dataIndex: 'option', title: '操作',
262
- render: (_, record) => {
263
- let id = record.id;
264
- return <Switch checked={this.state.formValues.perms.includes(id)}
265
- onChange={(checked) => {
266
- this.onGrantItemChange(id, checked)
267
- }} />
268
- }
269
- }
270
- ]}
271
-
272
- />
273
- </Modal>
274
- </Page>
275
-
276
-
277
- }
278
- }
279
-