@bit-sun/business-component 4.0.13-alpha.8 → 4.2.0-aiwei-alpha.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.
- package/.umirc.ts +21 -10
- package/dist/components/Business/AddSelectBusiness/index.d.ts +3 -4
- package/dist/components/Business/BsLayouts/Components/AllFunc/drawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/ChooseStore/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/leftTree.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/MenuSetting/rightTree.d.ts +2 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/DrawContent.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/globalMenu/customMenuHeader.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/CustomerMenu/index.d.ts +1 -1
- package/dist/components/Business/BsLayouts/Components/GlobalHeader/index.d.ts +1 -2
- package/dist/components/Business/BsLayouts/Components/RightContent/LoginModal.d.ts +1 -2
- package/dist/components/Business/BsLayouts/index.d.ts +1 -1
- package/dist/components/Business/BsSulaQueryTable/SearchItemSetting.d.ts +5 -5
- package/dist/components/Business/BsSulaQueryTable/index.d.ts +1 -2
- package/dist/components/Business/BsSulaQueryTable/setting.d.ts +11 -8
- package/dist/components/Business/BsSulaQueryTable/utils.d.ts +14 -15
- package/dist/components/Business/CommodityEntry/index.d.ts +1 -2
- package/dist/components/Business/CommonAlert/index.d.ts +1 -2
- package/dist/components/Business/CommonGuideWrapper/index.d.ts +3 -3
- package/dist/components/Business/DetailPageWrapper/index.d.ts +11 -6
- package/dist/components/Business/HomePageWrapper/index.d.ts +1 -2
- package/dist/components/Business/ItemPropertySelector/index.d.ts +2 -0
- package/dist/components/Business/JsonQueryTable/components/FieldsModifyModal.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/FieldsSettingsTable.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/Formula.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/components/MaintainOptions.d.ts +1 -2
- package/dist/components/Business/JsonQueryTable/drawer/index.d.ts +1 -2
- package/dist/components/Business/ModalUtils/index.d.ts +8 -0
- package/dist/components/Business/PropertyModal/index.d.ts +1 -2
- package/dist/components/Business/PropertyModal/propertyGroup.d.ts +1 -1
- package/dist/components/Business/SearchSelect/index.d.ts +1 -1
- package/dist/components/Business/SearchSelect/utils.d.ts +4 -2
- package/dist/components/Business/StateFlow/index.d.ts +1 -2
- package/dist/components/Business/SystemLog/index.d.ts +78 -0
- package/dist/components/Business/TreeSearchSelect/index.d.ts +1 -1
- package/dist/components/Business/columnSettingTable/columnSetting.d.ts +9 -8
- package/dist/components/Business/columnSettingTable/components/TableSumComponent.d.ts +1 -2
- package/dist/components/Business/columnSettingTable/index.d.ts +21 -4
- package/dist/components/Business/columnSettingTable/sulaSettingTable.d.ts +22 -5
- package/dist/components/Business/columnSettingTable/utils.d.ts +1 -2
- package/dist/components/Business/moreTreeTable/FixedScrollBar.d.ts +1 -1
- package/dist/components/Common/ParagraphCopier/index.d.ts +1 -1
- package/dist/components/Common/Section/index.d.ts +1 -1
- package/dist/components/Functional/AddSelect/index.d.ts +1 -2
- package/dist/components/Functional/AuthButton/index.d.ts +1 -2
- package/dist/components/Functional/DataImport/index.d.ts +3 -3
- package/dist/components/Functional/DataValidation/index.d.ts +15 -5
- package/dist/components/Functional/ExportFunctions/ExportIcon/index.d.ts +1 -2
- package/dist/components/Functional/QueryMutipleInput/index.d.ts +3 -3
- package/dist/components/Functional/QueryMutipleSelect/index.d.ts +1 -2
- package/dist/components/Functional/SearchSelect/index.d.ts +1 -1
- package/dist/components/Functional/SearchSelect/utils.d.ts +4 -4
- package/dist/components/Functional/TreeSearchSelect/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/CustomSelectorModal.d.ts +1 -1
- package/dist/components/Solution/RuleComponent/CustomPlugin/CustomSelector/index.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/Formula.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/InnerSelect.d.ts +1 -2
- package/dist/components/Solution/RuleComponent/RenderCompItem.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/RuleInstance.d.ts +1 -2
- package/dist/components/Solution/RuleSetter/baseRule.d.ts +1 -1
- package/dist/components/Solution/RuleSetter/index.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +4206 -2108
- package/dist/index.js +4215 -2106
- package/dist/plugin/TableColumnSetting/index.d.ts +6 -5
- package/dist/utils/RequestCacheManager.d.ts +82 -0
- package/dist/utils/TableUtils.d.ts +18 -19
- package/dist/utils/cachedRequest.d.ts +76 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/utils.d.ts +41 -0
- package/package.json +16 -14
- package/src/assets/btn-cancel.svg +3 -0
- package/src/assets/btn-copy.svg +3 -0
- package/src/assets/btn-delete.svg +2 -29
- package/src/assets/btn-edit.svg +2 -19
- package/src/assets/btn-hangUp.svg +3 -0
- package/src/assets/btn-print.svg +3 -0
- package/src/assets/btn-refresh.svg +3 -0
- package/src/assets/btn-unhook.svg +3 -0
- package/src/components/Business/AddSelectBusiness/index.md +8 -2
- package/src/components/Business/AddSelectBusiness/index.tsx +4 -1
- package/src/components/Business/BsLayouts/Components/ChooseStore/services.ts +1 -1
- package/src/components/Business/BsLayouts/Components/GlobalHeader/index.less +1 -1
- package/src/components/Business/BsLayouts/Components/RightContent/LoginModal.tsx +1 -1
- package/src/components/Business/BsLayouts/Components/RightContent/home.less +1 -1
- package/src/components/Business/BsLayouts/Components/SearchFunc/index.less +2 -2
- package/src/components/Business/BsLayouts/service.ts +1 -1
- package/src/components/Business/BsSulaQueryTable/SearchItemSetting.tsx +6 -5
- package/src/components/Business/BsSulaQueryTable/index.less +5 -3
- package/src/components/Business/BsSulaQueryTable/index.md +45 -32
- package/src/components/Business/BsSulaQueryTable/index.tsx +154 -76
- package/src/components/Business/BsSulaQueryTable/setting.tsx +47 -11
- package/src/components/Business/BsSulaQueryTable/utils.less +1 -1
- package/src/components/Business/BsSulaQueryTable/utils.tsx +15 -12
- package/src/components/Business/CommodityEntry/index.md +1 -1
- package/src/components/Business/CommodityEntry/index.tsx +11 -9
- package/src/components/Business/DetailPageWrapper/index.less +1 -1
- package/src/components/Business/DetailPageWrapper/index.tsx +24 -5
- package/src/components/Business/DetailPageWrapper/utils.tsx +7 -2
- package/src/components/Business/HomePageWrapper/index.less +1 -1
- package/src/components/Business/ItemPropertySelector/index.tsx +88 -0
- package/src/components/Business/JsonQueryTable/function.ts +1 -1
- package/src/components/Business/JsonQueryTable/index.tsx +1 -1
- package/src/components/Business/ModalUtils/index.tsx +45 -0
- package/src/components/Business/PropertyModal/index.tsx +1 -1
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +625 -76
- package/src/components/Business/SearchSelect/index.md +4 -4
- package/src/components/Business/SearchSelect/utils.ts +27 -5
- package/src/components/Business/SystemLog/index.md +37 -0
- package/src/components/Business/SystemLog/index.tsx +87 -0
- package/src/components/Business/columnSettingTable/columnSetting.tsx +28 -12
- package/src/components/Business/columnSettingTable/index.less +5 -3
- package/src/components/Business/columnSettingTable/index.md +200 -136
- package/src/components/Business/columnSettingTable/index.tsx +168 -39
- package/src/components/Business/columnSettingTable/sulaSettingTable.tsx +188 -56
- package/src/components/Functional/AddSelect/helps.ts +1 -1
- package/src/components/Functional/AddSelect/index.tsx +132 -13
- package/src/components/Functional/BillEntry/index.less +3 -0
- package/src/components/Functional/BillEntry/index.tsx +1 -1
- package/src/components/Functional/DataImport/index.tsx +1 -1
- package/src/components/Functional/DataValidation/index.md +1 -0
- package/src/components/Functional/DataValidation/index.tsx +161 -27
- package/src/components/Functional/ExportFunctions/ExportIcon/index.tsx +1 -1
- package/src/components/Functional/QueryMutipleInput/index.tsx +12 -3
- package/src/components/Functional/QueryMutipleSelect/index.tsx +3 -2
- package/src/components/Functional/SearchSelect/index.less +4 -0
- package/src/components/Functional/SearchSelect/index.tsx +68 -24
- package/src/components/Functional/SearchSelect/utils.tsx +17 -11
- package/src/components/Functional/TreeSearchSelect/index.tsx +3 -2
- package/src/components/Solution/RuleComponent/InnerSelect.tsx +1 -0
- package/src/components/Solution/RuleComponent/RenderCompItem.tsx +11 -2
- package/src/components/Solution/RuleComponent/index.js +75 -4
- package/src/components/Solution/RuleComponent/ruleFiled.js +26 -2
- package/src/components/Solution/RuleComponent/services.ts +1 -1
- package/src/components/Solution/RuleSetter/service.js +1 -1
- package/src/index.ts +3 -0
- package/src/plugin/TableColumnSetting/index.less +5 -3
- package/src/plugin/TableColumnSetting/index.tsx +80 -13
- package/src/styles/bsDefault.less +9 -3
- package/src/utils/RequestCacheManager.ts +213 -0
- package/src/utils/RequestCache_Examples.md +137 -0
- package/src/utils/RequestCache_README.md +170 -0
- package/src/utils/TableUtils.less +1 -1
- package/src/utils/cachedRequest.ts +288 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/request.ts +8 -4
- package/src/utils/requestUtils.ts +1 -1
- package/src/utils/utils.ts +41 -1
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 带缓存功能的请求工具
|
|
3
|
+
* 基于现有的request工具,增加1秒缓存机制
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import request from "umi-request";
|
|
7
|
+
import RequestCacheManager from "./RequestCacheManager";
|
|
8
|
+
import { message } from "antd";
|
|
9
|
+
import { judgeIsRequestError } from "./requestUtils";
|
|
10
|
+
|
|
11
|
+
// 创建缓存管理器实例,设置1秒缓存时间
|
|
12
|
+
const cacheManager = RequestCacheManager.getInstance({
|
|
13
|
+
ttl: 1000, // 1秒缓存时间
|
|
14
|
+
maxSize: 100 // 最大缓存100个请求
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
interface RequestOptions {
|
|
18
|
+
url?: string;
|
|
19
|
+
method?: string;
|
|
20
|
+
params?: any;
|
|
21
|
+
data?: any;
|
|
22
|
+
headers?: any;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 处理响应数据
|
|
28
|
+
*/
|
|
29
|
+
const handleResponseData = async (response: any) => {
|
|
30
|
+
return Promise.resolve({
|
|
31
|
+
data: response,
|
|
32
|
+
status: response.status
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 生成请求配置的唯一标识
|
|
38
|
+
*/
|
|
39
|
+
const generateRequestId = (url: string, options?: RequestOptions): string => {
|
|
40
|
+
return `${url}_${JSON.stringify(options || {})}`;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 带缓存的请求方法(支持并发请求合并)
|
|
45
|
+
*/
|
|
46
|
+
const cachedRequest = async (url: string, options?: RequestOptions) => {
|
|
47
|
+
const startTime = Date.now();
|
|
48
|
+
const method = (options?.method || 'GET').toUpperCase();
|
|
49
|
+
const params = options?.params || options?.data;
|
|
50
|
+
|
|
51
|
+
// 1) 检查缓存命中
|
|
52
|
+
const cachedData = cacheManager.getCache(url, params, method);
|
|
53
|
+
if (cachedData) {
|
|
54
|
+
console.log(`[RequestCache] 命中缓存: ${url}`, {
|
|
55
|
+
原始起止时间: `${cachedData.startTime} - ${cachedData.endTime}`,
|
|
56
|
+
更新时间: Date.now()
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// 返回缓存数据,起止时间在缓存命中时已更新
|
|
60
|
+
return Promise.resolve({
|
|
61
|
+
data: cachedData.data,
|
|
62
|
+
status: cachedData.data.status
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 2) 检查是否已有进行中的同键请求,若有则直接复用该Promise
|
|
67
|
+
const pending = cacheManager.getPending(url, params, method);
|
|
68
|
+
if (pending) {
|
|
69
|
+
console.log(`[RequestCache] 复用进行中请求: ${url}`);
|
|
70
|
+
return pending.then((response) => handleResponseData(response));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 3) 没有缓存且没有进行中请求,发起真实请求并注册为进行中
|
|
74
|
+
// 兼容部分旧代码使用的 body 字段(映射到 data)
|
|
75
|
+
const normalizedOptions = { ...(options || {}) };
|
|
76
|
+
if (normalizedOptions.body !== undefined && normalizedOptions.data === undefined) {
|
|
77
|
+
normalizedOptions.data = normalizedOptions.body;
|
|
78
|
+
delete normalizedOptions.body;
|
|
79
|
+
}
|
|
80
|
+
const realRequestPromise = request(url, normalizedOptions)
|
|
81
|
+
.then((response) => {
|
|
82
|
+
const endTime = Date.now();
|
|
83
|
+
// 缓存成功的响应
|
|
84
|
+
if (!judgeIsRequestError(response)) {
|
|
85
|
+
cacheManager.setCache(url, params, method, response, startTime, endTime);
|
|
86
|
+
console.log(`[RequestCache] 缓存请求: ${url}`, {
|
|
87
|
+
起止时间: `${startTime} - ${endTime}`,
|
|
88
|
+
耗时: endTime - startTime
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return response;
|
|
92
|
+
})
|
|
93
|
+
.catch((error) => {
|
|
94
|
+
console.error(`[RequestCache] 请求失败: ${url}`, error);
|
|
95
|
+
throw error;
|
|
96
|
+
})
|
|
97
|
+
.finally(() => {
|
|
98
|
+
// 无论成功失败都清理进行中状态
|
|
99
|
+
cacheManager.clearPending(url, params, method);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
cacheManager.setPending(url, params, method, realRequestPromise);
|
|
103
|
+
return realRequestPromise.then((response) => handleResponseData(response));
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* GET 请求
|
|
108
|
+
*/
|
|
109
|
+
// 兼容旧签名与 umi-request 签名的辅助函数
|
|
110
|
+
const normalizeParamsOptions = (paramsOrOptions?: any, options?: RequestOptions): { params?: any; options?: RequestOptions } => {
|
|
111
|
+
if (options !== undefined) {
|
|
112
|
+
return { params: paramsOrOptions, options };
|
|
113
|
+
}
|
|
114
|
+
const o = paramsOrOptions;
|
|
115
|
+
if (o && (o.params !== undefined || o.headers !== undefined || o.data !== undefined || o.method !== undefined || o.timeout !== undefined)) {
|
|
116
|
+
return { options: o };
|
|
117
|
+
}
|
|
118
|
+
return { params: o };
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* GET 请求(兼容两种签名:get(url, params?, options?) 与 get(url, options))
|
|
123
|
+
*/
|
|
124
|
+
const cachedGet = (url: string, paramsOrOptions?: any, options?: RequestOptions) => {
|
|
125
|
+
const { params, options: opt } = normalizeParamsOptions(paramsOrOptions, options);
|
|
126
|
+
return cachedRequest(url, {
|
|
127
|
+
...opt,
|
|
128
|
+
method: 'GET',
|
|
129
|
+
params
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* POST 请求(兼容两种签名:post(url, data?, options?) 与 post(url, options))
|
|
135
|
+
*/
|
|
136
|
+
const cachedPost = (url: string, dataOrOptions?: any, options?: RequestOptions) => {
|
|
137
|
+
let data = undefined;
|
|
138
|
+
let opt: RequestOptions | undefined = undefined;
|
|
139
|
+
if (options !== undefined) {
|
|
140
|
+
data = dataOrOptions;
|
|
141
|
+
opt = options;
|
|
142
|
+
} else {
|
|
143
|
+
const o = dataOrOptions;
|
|
144
|
+
if (o && (o.params !== undefined || o.headers !== undefined || o.data !== undefined || o.method !== undefined || o.timeout !== undefined)) {
|
|
145
|
+
opt = o;
|
|
146
|
+
data = o?.data;
|
|
147
|
+
} else {
|
|
148
|
+
data = o;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return cachedRequest(url, {
|
|
152
|
+
...opt,
|
|
153
|
+
method: 'POST',
|
|
154
|
+
data
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* PATCH 请求(兼容两种签名)
|
|
160
|
+
*/
|
|
161
|
+
const cachedPatch = (url: string, dataOrOptions?: any, options?: RequestOptions) => {
|
|
162
|
+
let data = undefined;
|
|
163
|
+
let opt: RequestOptions | undefined = undefined;
|
|
164
|
+
if (options !== undefined) {
|
|
165
|
+
data = dataOrOptions;
|
|
166
|
+
opt = options;
|
|
167
|
+
} else {
|
|
168
|
+
const o = dataOrOptions;
|
|
169
|
+
if (o && (o.params !== undefined || o.headers !== undefined || o.data !== undefined || o.method !== undefined || o.timeout !== undefined)) {
|
|
170
|
+
opt = o;
|
|
171
|
+
data = o?.data;
|
|
172
|
+
} else {
|
|
173
|
+
data = o;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return cachedRequest(url, {
|
|
177
|
+
...opt,
|
|
178
|
+
method: 'PATCH',
|
|
179
|
+
data
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* PUT 请求(兼容两种签名)
|
|
185
|
+
*/
|
|
186
|
+
const cachedPut = (url: string, dataOrOptions?: any, options?: RequestOptions) => {
|
|
187
|
+
let data = undefined;
|
|
188
|
+
let opt: RequestOptions | undefined = undefined;
|
|
189
|
+
if (options !== undefined) {
|
|
190
|
+
data = dataOrOptions;
|
|
191
|
+
opt = options;
|
|
192
|
+
} else {
|
|
193
|
+
const o = dataOrOptions;
|
|
194
|
+
if (o && (o.params !== undefined || o.headers !== undefined || o.data !== undefined || o.method !== undefined || o.timeout !== undefined)) {
|
|
195
|
+
opt = o;
|
|
196
|
+
data = o?.data;
|
|
197
|
+
} else {
|
|
198
|
+
data = o;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return cachedRequest(url, {
|
|
202
|
+
...opt,
|
|
203
|
+
method: 'PUT',
|
|
204
|
+
data
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* DELETE 请求(兼容两种签名)
|
|
210
|
+
*/
|
|
211
|
+
const cachedDelete = (url: string, dataOrOptions?: any, options?: RequestOptions) => {
|
|
212
|
+
let data = undefined;
|
|
213
|
+
let opt: RequestOptions | undefined = undefined;
|
|
214
|
+
if (options !== undefined) {
|
|
215
|
+
data = dataOrOptions;
|
|
216
|
+
opt = options;
|
|
217
|
+
} else {
|
|
218
|
+
const o = dataOrOptions;
|
|
219
|
+
if (o && (o.params !== undefined || o.headers !== undefined || o.data !== undefined || o.method !== undefined || o.timeout !== undefined)) {
|
|
220
|
+
opt = o;
|
|
221
|
+
data = o?.data;
|
|
222
|
+
} else {
|
|
223
|
+
data = o;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return cachedRequest(url, {
|
|
227
|
+
...opt,
|
|
228
|
+
method: 'DELETE',
|
|
229
|
+
data
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* 通用请求方法(兼容现有接口)
|
|
235
|
+
* 支持两种调用:
|
|
236
|
+
* 1) request(url: string, options?: RequestOptions)
|
|
237
|
+
* 2) request({ url: string, ...options })
|
|
238
|
+
*/
|
|
239
|
+
const cachedRequestUtil: any = (...args: any[]) => {
|
|
240
|
+
if (typeof args[0] === 'string') {
|
|
241
|
+
const url: string = args[0];
|
|
242
|
+
const options: RequestOptions = args[1] || {};
|
|
243
|
+
return cachedRequest(url, options);
|
|
244
|
+
}
|
|
245
|
+
if (typeof args[0] === 'object' && args[0] && args[0].url) {
|
|
246
|
+
const { url, ...parms } = args[0];
|
|
247
|
+
return cachedRequest(url, parms);
|
|
248
|
+
}
|
|
249
|
+
throw new Error('[RequestCache] invalid request arguments');
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 清除缓存
|
|
254
|
+
*/
|
|
255
|
+
const clearRequestCache = (url?: string, params?: any, method?: string) => {
|
|
256
|
+
cacheManager.clearCache(url, params, method);
|
|
257
|
+
console.log(`[RequestCache] 清除缓存: ${url || '所有缓存'}`);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 获取缓存统计信息
|
|
262
|
+
*/
|
|
263
|
+
const getCacheStats = () => {
|
|
264
|
+
const stats = cacheManager.getCacheStats();
|
|
265
|
+
console.log('[RequestCache] 缓存统计:', stats);
|
|
266
|
+
return stats;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// 绑定方法到请求工具对象
|
|
270
|
+
cachedRequestUtil.get = cachedGet;
|
|
271
|
+
cachedRequestUtil.post = cachedPost;
|
|
272
|
+
cachedRequestUtil.patch = cachedPatch;
|
|
273
|
+
cachedRequestUtil.put = cachedPut;
|
|
274
|
+
cachedRequestUtil.delete = cachedDelete;
|
|
275
|
+
cachedRequestUtil.clearCache = clearRequestCache;
|
|
276
|
+
cachedRequestUtil.getCacheStats = getCacheStats;
|
|
277
|
+
|
|
278
|
+
export default cachedRequestUtil;
|
|
279
|
+
export {
|
|
280
|
+
cachedRequest,
|
|
281
|
+
cachedGet,
|
|
282
|
+
cachedPost,
|
|
283
|
+
cachedPatch,
|
|
284
|
+
cachedPut,
|
|
285
|
+
cachedDelete,
|
|
286
|
+
clearRequestCache,
|
|
287
|
+
getCacheStats
|
|
288
|
+
};
|
package/src/utils/index.ts
CHANGED
package/src/utils/request.ts
CHANGED
|
@@ -7,27 +7,31 @@ const get = (url, params?: any) => {
|
|
|
7
7
|
}).then(handleResponseData);
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
const post = (url, data?: any) => {
|
|
10
|
+
const post = (url, data?: any, params?: any) => {
|
|
11
11
|
return request.post(url, {
|
|
12
12
|
data,
|
|
13
|
+
...params,
|
|
13
14
|
}).then(handleResponseData);
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
const patch = (url, data?: any) => {
|
|
17
|
+
const patch = (url, data?: any, params?: any) => {
|
|
17
18
|
return request.patch(url, {
|
|
18
19
|
data,
|
|
20
|
+
...params,
|
|
19
21
|
}).then(handleResponseData);
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
const put = (url, data?: any) => {
|
|
24
|
+
const put = (url, data?: any, params?: any) => {
|
|
23
25
|
return request.put(url, {
|
|
24
26
|
data,
|
|
27
|
+
...params,
|
|
25
28
|
}).then(handleResponseData);
|
|
26
29
|
};
|
|
27
30
|
|
|
28
|
-
const deleteS = (url, data?: any) => {
|
|
31
|
+
const deleteS = (url, data?: any, params?: any) => {
|
|
29
32
|
return request.delete(url, {
|
|
30
33
|
data,
|
|
34
|
+
...params,
|
|
31
35
|
}).then(handleResponseData);
|
|
32
36
|
};
|
|
33
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import request from "umi-request";
|
|
3
|
-
import ENUM from './enumConfig';
|
|
3
|
+
// 注意:本文件的导入保留,用于工具函数内部兼容;业务代码请使用 '@/utils/cachedRequest'import ENUM from './enumConfig';
|
|
4
4
|
import { getCurrentTenantId, getEmployeeId, getSessionId, getAccountId } from './LocalstorageUtils';
|
|
5
5
|
import { getEekaSessionId, getEekaAccountId, getEekaEmployeeId, getEekaTenantId, getEekaToken,
|
|
6
6
|
getGuoyaoshukeCompanyId, getGuoyaoshukeTenantId, getGuoyaoshukeTenantCode, getGuoyaoshukeToken, getGuoyaoshukeUscCode
|
package/src/utils/utils.ts
CHANGED
|
@@ -267,4 +267,44 @@ export const handleConvertResponse = (items: any, total: number): object => {
|
|
|
267
267
|
|
|
268
268
|
export const noEmptyArray = (targetObj: any) => {
|
|
269
269
|
return Array.isArray(targetObj) && targetObj.length !== 0;
|
|
270
|
-
};
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export const formContainerAndItemLayout = (type: string, title: any, name: string) => {
|
|
273
|
+
return type === 'form' ? {
|
|
274
|
+
container: {
|
|
275
|
+
type: 'card',
|
|
276
|
+
props: {
|
|
277
|
+
title,
|
|
278
|
+
id: Math.random(),
|
|
279
|
+
level: 1,
|
|
280
|
+
name
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
itemLayout: {
|
|
284
|
+
span: 8, // span表示每项所占的栅格数
|
|
285
|
+
labelCol: {
|
|
286
|
+
span: 8,
|
|
287
|
+
},
|
|
288
|
+
wrapperCol: {
|
|
289
|
+
span: 18,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
} : {
|
|
293
|
+
container: {
|
|
294
|
+
type: 'card',
|
|
295
|
+
props: {
|
|
296
|
+
title,
|
|
297
|
+
id: Math.random(),
|
|
298
|
+
level: 1,
|
|
299
|
+
bordered: null,
|
|
300
|
+
isWhiteCard: true,
|
|
301
|
+
name
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
itemLayout: {
|
|
305
|
+
wrapperCol: {
|
|
306
|
+
span: 0,
|
|
307
|
+
},
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
}
|