openxiangda 1.0.215 → 1.0.217
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/packages/sdk/dist/runtime/index.cjs +3346 -1752
- package/packages/sdk/dist/runtime/index.cjs.map +1 -1
- package/packages/sdk/dist/runtime/index.d.mts +1 -1
- package/packages/sdk/dist/runtime/index.d.ts +1 -1
- package/packages/sdk/dist/runtime/index.mjs +3316 -1699
- package/packages/sdk/dist/runtime/index.mjs.map +1 -1
- package/packages/sdk/dist/runtime/react.cjs +1613 -19
- package/packages/sdk/dist/runtime/react.cjs.map +1 -1
- package/packages/sdk/dist/runtime/react.d.mts +222 -2
- package/packages/sdk/dist/runtime/react.d.ts +222 -2
- package/packages/sdk/dist/runtime/react.mjs +1636 -19
- package/packages/sdk/dist/runtime/react.mjs.map +1 -1
- package/packages/sdk/source/admin-list/AdminList.tsx +1572 -0
- package/packages/sdk/source/admin-list/README.md +12 -0
- package/packages/sdk/source/admin-list/dataSources.ts +220 -0
- package/packages/sdk/source/admin-list/index.ts +41 -0
- package/packages/sdk/source/admin-list/preferences.ts +174 -0
- package/packages/sdk/source/admin-list/types.ts +254 -0
|
@@ -34026,6 +34026,7 @@ var init_xlsx = __esm({
|
|
|
34026
34026
|
// packages/sdk/src/runtime/react/index.ts
|
|
34027
34027
|
var react_exports = {};
|
|
34028
34028
|
__export(react_exports, {
|
|
34029
|
+
AdminList: () => AdminList,
|
|
34029
34030
|
AttachmentPreviewList: () => AttachmentPreviewList,
|
|
34030
34031
|
AuthClientError: () => AuthClientError,
|
|
34031
34032
|
ImagePreviewGrid: () => ImagePreviewGrid,
|
|
@@ -34041,7 +34042,11 @@ __export(react_exports, {
|
|
|
34041
34042
|
PublicAccessClientError: () => PublicAccessClientError,
|
|
34042
34043
|
PublicAccessGate: () => PublicAccessGate,
|
|
34043
34044
|
RuntimeAuthGuard: () => RuntimeAuthGuard,
|
|
34045
|
+
createAdminListPreferenceStore: () => createAdminListPreferenceStore,
|
|
34044
34046
|
createAuthClient: () => createAuthClient,
|
|
34047
|
+
createDataViewAdminListSource: () => createDataViewAdminListSource,
|
|
34048
|
+
createFormAdminListSource: () => createFormAdminListSource,
|
|
34049
|
+
createFunctionAdminListSource: () => createFunctionAdminListSource,
|
|
34045
34050
|
createPageFormRuntimeApi: () => createPageFormRuntimeApi,
|
|
34046
34051
|
createPageSdk: () => createPageSdk,
|
|
34047
34052
|
createPublicAccessClient: () => createPublicAccessClient,
|
|
@@ -34050,6 +34055,7 @@ __export(react_exports, {
|
|
|
34050
34055
|
getAuthErrorReason: () => getAuthErrorReason,
|
|
34051
34056
|
isAuthChallengeRequired: () => isAuthChallengeRequired,
|
|
34052
34057
|
isAuthClientError: () => isAuthClientError,
|
|
34058
|
+
mergeAdminListPreference: () => mergeAdminListPreference,
|
|
34053
34059
|
useAppMenus: () => useAppMenus,
|
|
34054
34060
|
useAuth: () => useAuth,
|
|
34055
34061
|
useCanAccessRoute: () => useCanAccessRoute,
|
|
@@ -35930,7 +35936,7 @@ var createPageSdk = (context) => {
|
|
|
35930
35936
|
});
|
|
35931
35937
|
}
|
|
35932
35938
|
};
|
|
35933
|
-
const
|
|
35939
|
+
const notification2 = {
|
|
35934
35940
|
sendByType: (params) => request({
|
|
35935
35941
|
path: buildOpenXiangdaAppPath(
|
|
35936
35942
|
context,
|
|
@@ -36117,7 +36123,7 @@ var createPageSdk = (context) => {
|
|
|
36117
36123
|
role,
|
|
36118
36124
|
permission,
|
|
36119
36125
|
process: process2,
|
|
36120
|
-
notification,
|
|
36126
|
+
notification: notification2,
|
|
36121
36127
|
workCenter,
|
|
36122
36128
|
loginLog,
|
|
36123
36129
|
dataView,
|
|
@@ -36994,8 +37000,8 @@ var parseResponse = async (response) => {
|
|
|
36994
37000
|
const contentType = response.headers.get("content-type") || "";
|
|
36995
37001
|
const payload = contentType.includes("application/json") ? await response.json() : await response.text();
|
|
36996
37002
|
if (!response.ok) {
|
|
36997
|
-
const
|
|
36998
|
-
throw new Error(
|
|
37003
|
+
const message4 = typeof payload === "object" && payload ? payload.message || payload.error || response.statusText : response.statusText;
|
|
37004
|
+
throw new Error(message4 || "\u8BF7\u6C42\u5931\u8D25");
|
|
36999
37005
|
}
|
|
37000
37006
|
if (typeof payload === "object" && payload) {
|
|
37001
37007
|
const hasCode = Object.prototype.hasOwnProperty.call(payload, "code");
|
|
@@ -37648,9 +37654,9 @@ init_cjs_shims();
|
|
|
37648
37654
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
37649
37655
|
var isTransientFetchError = (error) => {
|
|
37650
37656
|
const anyError = error;
|
|
37651
|
-
const
|
|
37657
|
+
const message4 = String(anyError?.message || error || "").toLowerCase();
|
|
37652
37658
|
const causeCode = String(anyError?.cause?.code || "").toLowerCase();
|
|
37653
|
-
return causeCode === "und_err_connect_timeout" ||
|
|
37659
|
+
return causeCode === "und_err_connect_timeout" || message4.includes("und_err_connect_timeout") || message4.includes("connect_timeout") || message4.includes("econnreset") || message4.includes("socket hang up") || message4.includes("network socket disconnected") || message4.includes("fetch failed");
|
|
37654
37660
|
};
|
|
37655
37661
|
var fetchWithTransientRetry = async (fetchImpl, input, init, options = {}) => {
|
|
37656
37662
|
if (!options.enabled) {
|
|
@@ -37713,8 +37719,8 @@ var isSuccessCode3 = (value) => {
|
|
|
37713
37719
|
var parseJsonResponse = async (response) => {
|
|
37714
37720
|
const payload = await response.json().catch(() => null);
|
|
37715
37721
|
if (!response.ok) {
|
|
37716
|
-
const
|
|
37717
|
-
throw new Error(
|
|
37722
|
+
const message4 = payload && typeof payload === "object" ? payload.message || payload.error || response.statusText : response.statusText;
|
|
37723
|
+
throw new Error(message4 || "\u8BF7\u6C42\u5931\u8D25");
|
|
37718
37724
|
}
|
|
37719
37725
|
if (payload && typeof payload === "object" && "code" in payload) {
|
|
37720
37726
|
const code = normalizeEnvelopeCode2(payload.code, response.status);
|
|
@@ -37875,8 +37881,8 @@ var import_icons = require("@ant-design/icons");
|
|
|
37875
37881
|
// packages/sdk/src/runtime/core/auth.ts
|
|
37876
37882
|
init_cjs_shims();
|
|
37877
37883
|
var AuthClientError = class extends Error {
|
|
37878
|
-
constructor(
|
|
37879
|
-
super(
|
|
37884
|
+
constructor(message4, options = {}) {
|
|
37885
|
+
super(message4);
|
|
37880
37886
|
this.name = "AuthClientError";
|
|
37881
37887
|
this.status = options.status;
|
|
37882
37888
|
this.code = options.code;
|
|
@@ -38941,7 +38947,7 @@ var OpenXiangdaPageProvider = ({
|
|
|
38941
38947
|
page,
|
|
38942
38948
|
route,
|
|
38943
38949
|
env,
|
|
38944
|
-
message:
|
|
38950
|
+
message: message4,
|
|
38945
38951
|
modal,
|
|
38946
38952
|
navigation
|
|
38947
38953
|
}) => {
|
|
@@ -39008,14 +39014,14 @@ var OpenXiangdaPageProvider = ({
|
|
|
39008
39014
|
servicePrefix: runtime.servicePrefix,
|
|
39009
39015
|
fetchImpl: runtime.fetchImpl,
|
|
39010
39016
|
route: routeInfo,
|
|
39011
|
-
message:
|
|
39017
|
+
message: message4,
|
|
39012
39018
|
modal,
|
|
39013
39019
|
navigation
|
|
39014
39020
|
}
|
|
39015
39021
|
);
|
|
39016
39022
|
}, [
|
|
39017
39023
|
env,
|
|
39018
|
-
|
|
39024
|
+
message4,
|
|
39019
39025
|
modal,
|
|
39020
39026
|
navigation,
|
|
39021
39027
|
page,
|
|
@@ -41414,12 +41420,12 @@ var import_icons6 = require("@ant-design/icons");
|
|
|
41414
41420
|
// packages/sdk/src/components/utils/confirmAction.ts
|
|
41415
41421
|
init_cjs_shims();
|
|
41416
41422
|
var confirmAction = (title, content) => {
|
|
41417
|
-
const
|
|
41423
|
+
const message4 = [title, content].filter(Boolean).join("\n") || "\u786E\u8BA4\u7EE7\u7EED\u5417\uFF1F";
|
|
41418
41424
|
if (typeof window === "undefined" || typeof window.confirm !== "function") {
|
|
41419
41425
|
return true;
|
|
41420
41426
|
}
|
|
41421
41427
|
try {
|
|
41422
|
-
return window.confirm(
|
|
41428
|
+
return window.confirm(message4);
|
|
41423
41429
|
} catch {
|
|
41424
41430
|
return true;
|
|
41425
41431
|
}
|
|
@@ -42685,9 +42691,9 @@ var getInstanceId = (operation, capabilities) => String(
|
|
|
42685
42691
|
operation.instanceId || operation.formInstanceId || capabilities?.instance?.id || capabilities?.instance?.formInstanceId || ""
|
|
42686
42692
|
);
|
|
42687
42693
|
var getTaskId = (operation) => String(operation.taskId || "");
|
|
42688
|
-
var requireValue = (value,
|
|
42694
|
+
var requireValue = (value, message4) => {
|
|
42689
42695
|
const normalized = String(value || "").trim();
|
|
42690
|
-
if (!normalized) throw new Error(
|
|
42696
|
+
if (!normalized) throw new Error(message4);
|
|
42691
42697
|
return normalized;
|
|
42692
42698
|
};
|
|
42693
42699
|
function useProcessActions(options) {
|
|
@@ -43044,8 +43050,8 @@ init_cjs_shims();
|
|
|
43044
43050
|
var PUBLIC_SESSION_RENEW_WINDOW_MS = 5 * 60 * 1e3;
|
|
43045
43051
|
var publicSessionInflight = /* @__PURE__ */ new Map();
|
|
43046
43052
|
var PublicAccessClientError = class extends Error {
|
|
43047
|
-
constructor(
|
|
43048
|
-
super(
|
|
43053
|
+
constructor(message4, options = {}) {
|
|
43054
|
+
super(message4);
|
|
43049
43055
|
this.name = "PublicAccessClientError";
|
|
43050
43056
|
this.status = options.status;
|
|
43051
43057
|
this.code = options.code;
|
|
@@ -43393,6 +43399,1594 @@ var isUnauthorizedPublicSessionError = (error) => {
|
|
|
43393
43399
|
return status === 401 || status === 403;
|
|
43394
43400
|
};
|
|
43395
43401
|
|
|
43402
|
+
// packages/sdk/src/runtime/react/admin-list/index.ts
|
|
43403
|
+
init_cjs_shims();
|
|
43404
|
+
|
|
43405
|
+
// packages/sdk/src/runtime/react/admin-list/AdminList.tsx
|
|
43406
|
+
init_cjs_shims();
|
|
43407
|
+
var import_antd12 = require("antd");
|
|
43408
|
+
var import_react21 = require("react");
|
|
43409
|
+
|
|
43410
|
+
// packages/sdk/src/runtime/react/admin-list/preferences.ts
|
|
43411
|
+
init_cjs_shims();
|
|
43412
|
+
var unique = (values) => Array.from(new Set(values.filter(Boolean)));
|
|
43413
|
+
var validSorts = (sorts, sortableKeys) => (sorts || []).filter(
|
|
43414
|
+
(sort) => sortableKeys.has(sort.field) && (sort.direction === "ascend" || sort.direction === "descend")
|
|
43415
|
+
);
|
|
43416
|
+
function mergeAdminListPreference(input) {
|
|
43417
|
+
const {
|
|
43418
|
+
allowedColumnKeys,
|
|
43419
|
+
columns,
|
|
43420
|
+
defaultSorts,
|
|
43421
|
+
defaults,
|
|
43422
|
+
locked,
|
|
43423
|
+
searchFields,
|
|
43424
|
+
user,
|
|
43425
|
+
version: version2
|
|
43426
|
+
} = input;
|
|
43427
|
+
const columnMap = new Map(columns.map((column) => [column.key, column]));
|
|
43428
|
+
const searchMap = new Map(searchFields.map((field) => [field.key, field]));
|
|
43429
|
+
const allowed = allowedColumnKeys?.length ? new Set(allowedColumnKeys) : new Set(columns.map((column) => column.key));
|
|
43430
|
+
const forcedVisible = new Set(locked?.visibleColumnKeys || []);
|
|
43431
|
+
const forcedHidden = new Set(locked?.hiddenColumnKeys || []);
|
|
43432
|
+
const forcedSearchVisible = new Set(locked?.visibleSearchKeys || []);
|
|
43433
|
+
const forcedSearchHidden = new Set(locked?.hiddenSearchKeys || []);
|
|
43434
|
+
const userColumns = new Map(
|
|
43435
|
+
(user?.columns || []).filter((column) => columnMap.has(column.key)).map((column) => [column.key, column])
|
|
43436
|
+
);
|
|
43437
|
+
const orderedColumnKeys = unique([
|
|
43438
|
+
...(user?.columns || []).map((column) => column.key),
|
|
43439
|
+
...columns.map((column) => column.key)
|
|
43440
|
+
]).filter((key) => columnMap.has(key) && allowed.has(key));
|
|
43441
|
+
const normalizedColumns = orderedColumnKeys.map((key) => {
|
|
43442
|
+
const definition = columnMap.get(key);
|
|
43443
|
+
const preference = userColumns.get(key);
|
|
43444
|
+
const visible = forcedHidden.has(key) ? false : forcedVisible.has(key) || definition.locked ? true : preference?.visible ?? definition.defaultVisible ?? !definition.hidden;
|
|
43445
|
+
return {
|
|
43446
|
+
key,
|
|
43447
|
+
visible,
|
|
43448
|
+
width: typeof preference?.width === "number" && preference.width >= 60 ? Math.round(preference.width) : definition.width,
|
|
43449
|
+
fixed: definition.fixed ?? (preference?.fixed === "left" || preference?.fixed === "right" ? preference.fixed : null)
|
|
43450
|
+
};
|
|
43451
|
+
});
|
|
43452
|
+
const userSearches = new Map(
|
|
43453
|
+
(user?.searches || []).filter((field) => searchMap.has(field.key)).map((field) => [field.key, field])
|
|
43454
|
+
);
|
|
43455
|
+
const orderedSearchKeys = unique([
|
|
43456
|
+
...(user?.searches || []).map((field) => field.key),
|
|
43457
|
+
...searchFields.map((field) => field.key)
|
|
43458
|
+
]).filter((key) => searchMap.has(key));
|
|
43459
|
+
const normalizedSearches = orderedSearchKeys.map((key) => {
|
|
43460
|
+
const definition = searchMap.get(key);
|
|
43461
|
+
return {
|
|
43462
|
+
key,
|
|
43463
|
+
visible: forcedSearchHidden.has(key) ? false : forcedSearchVisible.has(key) || definition.locked ? true : userSearches.get(key)?.visible ?? definition.defaultVisible ?? true
|
|
43464
|
+
};
|
|
43465
|
+
});
|
|
43466
|
+
const sortableKeys = new Set(
|
|
43467
|
+
columns.filter((column) => column.sortable && allowed.has(column.key)).map((column) => column.sortField || column.key)
|
|
43468
|
+
);
|
|
43469
|
+
return {
|
|
43470
|
+
version: version2,
|
|
43471
|
+
columns: normalizedColumns,
|
|
43472
|
+
searches: normalizedSearches,
|
|
43473
|
+
sorts: locked?.sorts?.length ? validSorts(locked.sorts, sortableKeys) : validSorts(user?.sorts, sortableKeys).length ? validSorts(user?.sorts, sortableKeys) : validSorts(defaultSorts, sortableKeys),
|
|
43474
|
+
density: locked?.density || user?.density || defaults?.density || "middle",
|
|
43475
|
+
pageSize: locked?.pageSize || (Number.isSafeInteger(user?.pageSize) && Number(user?.pageSize) > 0 ? Number(user?.pageSize) : defaults?.pageSize || 20),
|
|
43476
|
+
defaultVisibleSearchCount: Number.isSafeInteger(user?.defaultVisibleSearchCount) && Number(user?.defaultVisibleSearchCount) > 0 ? Number(user?.defaultVisibleSearchCount) : defaults?.defaultVisibleSearchCount || 4,
|
|
43477
|
+
showBorders: user?.showBorders ?? defaults?.showBorders ?? false,
|
|
43478
|
+
striped: user?.striped ?? defaults?.striped ?? false,
|
|
43479
|
+
hoverActions: user?.hoverActions ?? defaults?.hoverActions ?? true,
|
|
43480
|
+
updatedAt: user?.updatedAt
|
|
43481
|
+
};
|
|
43482
|
+
}
|
|
43483
|
+
function createAdminListPreferenceStore(sdk, appType) {
|
|
43484
|
+
const basePath = `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
43485
|
+
appType
|
|
43486
|
+
)}/admin-list/preferences`;
|
|
43487
|
+
return {
|
|
43488
|
+
async get(listKey) {
|
|
43489
|
+
const response = await sdk.request({
|
|
43490
|
+
path: `${basePath}/${encodeURIComponent(listKey)}`,
|
|
43491
|
+
method: "get"
|
|
43492
|
+
});
|
|
43493
|
+
return response.result || null;
|
|
43494
|
+
},
|
|
43495
|
+
async put(listKey, preference) {
|
|
43496
|
+
const response = await sdk.request({
|
|
43497
|
+
path: `${basePath}/${encodeURIComponent(listKey)}`,
|
|
43498
|
+
method: "put",
|
|
43499
|
+
body: preference
|
|
43500
|
+
});
|
|
43501
|
+
if (!response.result) {
|
|
43502
|
+
throw new Error("\u5217\u8868\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\uFF1A\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u914D\u7F6E");
|
|
43503
|
+
}
|
|
43504
|
+
return response.result;
|
|
43505
|
+
},
|
|
43506
|
+
async remove(listKey) {
|
|
43507
|
+
await sdk.request({
|
|
43508
|
+
path: `${basePath}/${encodeURIComponent(listKey)}`,
|
|
43509
|
+
method: "delete"
|
|
43510
|
+
});
|
|
43511
|
+
}
|
|
43512
|
+
};
|
|
43513
|
+
}
|
|
43514
|
+
|
|
43515
|
+
// packages/sdk/src/runtime/react/admin-list/AdminList.tsx
|
|
43516
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
43517
|
+
var { RangePicker } = import_antd12.DatePicker;
|
|
43518
|
+
var isEmpty = (value) => value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0;
|
|
43519
|
+
var normalizeFilterValue = (value) => {
|
|
43520
|
+
if (Array.isArray(value)) {
|
|
43521
|
+
return value.map(normalizeFilterValue);
|
|
43522
|
+
}
|
|
43523
|
+
if (value && typeof value === "object" && "format" in value && typeof value.format === "function") {
|
|
43524
|
+
return value.format("YYYY-MM-DD");
|
|
43525
|
+
}
|
|
43526
|
+
return value;
|
|
43527
|
+
};
|
|
43528
|
+
var normalizeFilters = (values) => Object.fromEntries(
|
|
43529
|
+
Object.entries(values).filter(([, value]) => !isEmpty(value)).map(([key, value]) => [key, normalizeFilterValue(value)])
|
|
43530
|
+
);
|
|
43531
|
+
var sortFingerprint = (sorts) => sorts.map((sort) => `${sort.field}:${sort.direction}`).join("|");
|
|
43532
|
+
var queryFingerprint = (query, sourceKey) => JSON.stringify({
|
|
43533
|
+
sourceKey,
|
|
43534
|
+
filters: query.filters,
|
|
43535
|
+
fixedFilters: query.fixedFilters,
|
|
43536
|
+
sorts: query.sorts
|
|
43537
|
+
});
|
|
43538
|
+
var getRowKey = (rowKey, row) => {
|
|
43539
|
+
if (typeof rowKey === "function") return rowKey(row);
|
|
43540
|
+
return row[rowKey];
|
|
43541
|
+
};
|
|
43542
|
+
var toColumnPreferences = (columns) => columns.map((column) => ({
|
|
43543
|
+
key: column.key,
|
|
43544
|
+
visible: column.defaultVisible ?? !column.hidden,
|
|
43545
|
+
width: column.width,
|
|
43546
|
+
fixed: column.fixed || null
|
|
43547
|
+
}));
|
|
43548
|
+
function renderSearchControl(field) {
|
|
43549
|
+
const placeholder = field.placeholder || (field.type === "select" || field.type === "multiSelect" ? `\u8BF7\u9009\u62E9${String(field.label)}` : `\u8BF7\u8F93\u5165${String(field.label)}`);
|
|
43550
|
+
if (field.type === "select" || field.type === "multiSelect") {
|
|
43551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43552
|
+
import_antd12.Select,
|
|
43553
|
+
{
|
|
43554
|
+
allowClear: true,
|
|
43555
|
+
disabled: field.disabled,
|
|
43556
|
+
mode: field.type === "multiSelect" ? "multiple" : void 0,
|
|
43557
|
+
options: field.options,
|
|
43558
|
+
placeholder
|
|
43559
|
+
}
|
|
43560
|
+
);
|
|
43561
|
+
}
|
|
43562
|
+
if (field.type === "number") {
|
|
43563
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43564
|
+
import_antd12.InputNumber,
|
|
43565
|
+
{
|
|
43566
|
+
disabled: field.disabled,
|
|
43567
|
+
placeholder,
|
|
43568
|
+
style: { width: "100%" }
|
|
43569
|
+
}
|
|
43570
|
+
);
|
|
43571
|
+
}
|
|
43572
|
+
if (field.type === "date") {
|
|
43573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43574
|
+
import_antd12.DatePicker,
|
|
43575
|
+
{
|
|
43576
|
+
disabled: field.disabled,
|
|
43577
|
+
placeholder,
|
|
43578
|
+
style: { width: "100%" }
|
|
43579
|
+
}
|
|
43580
|
+
);
|
|
43581
|
+
}
|
|
43582
|
+
if (field.type === "dateRange") {
|
|
43583
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43584
|
+
RangePicker,
|
|
43585
|
+
{
|
|
43586
|
+
disabled: field.disabled,
|
|
43587
|
+
style: { width: "100%" }
|
|
43588
|
+
}
|
|
43589
|
+
);
|
|
43590
|
+
}
|
|
43591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43592
|
+
import_antd12.Input,
|
|
43593
|
+
{
|
|
43594
|
+
allowClear: true,
|
|
43595
|
+
disabled: field.disabled,
|
|
43596
|
+
placeholder
|
|
43597
|
+
}
|
|
43598
|
+
);
|
|
43599
|
+
}
|
|
43600
|
+
function AdminList(props) {
|
|
43601
|
+
const {
|
|
43602
|
+
batchActions = [],
|
|
43603
|
+
className,
|
|
43604
|
+
columns,
|
|
43605
|
+
configVersion = 1,
|
|
43606
|
+
dataSource,
|
|
43607
|
+
defaultPageSize = 20,
|
|
43608
|
+
defaultSorts = [],
|
|
43609
|
+
defaultVisibleSearchCount = 4,
|
|
43610
|
+
emptyText,
|
|
43611
|
+
exportable = true,
|
|
43612
|
+
fileName,
|
|
43613
|
+
fixedFilters,
|
|
43614
|
+
listKey,
|
|
43615
|
+
lockedPreference,
|
|
43616
|
+
onQueryChange,
|
|
43617
|
+
onRow,
|
|
43618
|
+
onSelectionChange,
|
|
43619
|
+
pageSizeOptions = [20, 50, 100],
|
|
43620
|
+
preserveSelectionAcrossPages = true,
|
|
43621
|
+
rowActions = [],
|
|
43622
|
+
rowKey,
|
|
43623
|
+
rowSelectable,
|
|
43624
|
+
rowSelectionReason,
|
|
43625
|
+
searchFields = [],
|
|
43626
|
+
selectable = true,
|
|
43627
|
+
selectedRowKeys: controlledSelectedKeys,
|
|
43628
|
+
style,
|
|
43629
|
+
toolbar
|
|
43630
|
+
} = props;
|
|
43631
|
+
const [form] = import_antd12.Form.useForm();
|
|
43632
|
+
const [messageApi, messageHolder] = import_antd12.message.useMessage();
|
|
43633
|
+
const [notificationApi, notificationHolder] = import_antd12.notification.useNotification();
|
|
43634
|
+
const sourceKey = dataSource.key || "anonymous";
|
|
43635
|
+
const [rawPreference, setRawPreference] = (0, import_react21.useState)(null);
|
|
43636
|
+
const [preference, setPreference] = (0, import_react21.useState)(
|
|
43637
|
+
() => mergeAdminListPreference({
|
|
43638
|
+
version: configVersion,
|
|
43639
|
+
columns,
|
|
43640
|
+
searchFields,
|
|
43641
|
+
defaultSorts,
|
|
43642
|
+
defaults: {
|
|
43643
|
+
pageSize: defaultPageSize,
|
|
43644
|
+
defaultVisibleSearchCount
|
|
43645
|
+
},
|
|
43646
|
+
locked: lockedPreference
|
|
43647
|
+
})
|
|
43648
|
+
);
|
|
43649
|
+
const [settingsDraft, setSettingsDraft] = (0, import_react21.useState)(preference);
|
|
43650
|
+
const [settingsOpen, setSettingsOpen] = (0, import_react21.useState)(false);
|
|
43651
|
+
const [settingsTab, setSettingsTab] = (0, import_react21.useState)("search");
|
|
43652
|
+
const [columnSearch, setColumnSearch] = (0, import_react21.useState)("");
|
|
43653
|
+
const [expanded, setExpanded] = (0, import_react21.useState)(false);
|
|
43654
|
+
const [ready, setReady] = (0, import_react21.useState)(false);
|
|
43655
|
+
const [rows, setRows] = (0, import_react21.useState)([]);
|
|
43656
|
+
const [total, setTotal] = (0, import_react21.useState)(0);
|
|
43657
|
+
const [allowedColumnKeys, setAllowedColumnKeys] = (0, import_react21.useState)(void 0);
|
|
43658
|
+
const [hiddenFieldsCount, setHiddenFieldsCount] = (0, import_react21.useState)(0);
|
|
43659
|
+
const [loading, setLoading] = (0, import_react21.useState)(false);
|
|
43660
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
43661
|
+
const [query, setQuery] = (0, import_react21.useState)({
|
|
43662
|
+
currentPage: 1,
|
|
43663
|
+
pageSize: defaultPageSize,
|
|
43664
|
+
filters: {},
|
|
43665
|
+
sorts: defaultSorts,
|
|
43666
|
+
fixedFilters
|
|
43667
|
+
});
|
|
43668
|
+
const [selectedKeys, setSelectedKeys] = (0, import_react21.useState)([]);
|
|
43669
|
+
const selectedRowsRef = (0, import_react21.useRef)(/* @__PURE__ */ new Map());
|
|
43670
|
+
const previousFingerprintRef = (0, import_react21.useRef)("");
|
|
43671
|
+
const [exportConfirmOpen, setExportConfirmOpen] = (0, import_react21.useState)(false);
|
|
43672
|
+
const [exporting, setExporting] = (0, import_react21.useState)(false);
|
|
43673
|
+
const [draggedColumnKey, setDraggedColumnKey] = (0, import_react21.useState)("");
|
|
43674
|
+
const [draggedSearchKey, setDraggedSearchKey] = (0, import_react21.useState)("");
|
|
43675
|
+
const selectedKeysRef = (0, import_react21.useRef)([]);
|
|
43676
|
+
const dataSourceRef = (0, import_react21.useRef)(dataSource);
|
|
43677
|
+
dataSourceRef.current = dataSource;
|
|
43678
|
+
const definitionFingerprint = JSON.stringify({
|
|
43679
|
+
columns: columns.map((column) => ({
|
|
43680
|
+
key: column.key,
|
|
43681
|
+
width: column.width,
|
|
43682
|
+
fixed: column.fixed,
|
|
43683
|
+
hidden: column.hidden,
|
|
43684
|
+
locked: column.locked,
|
|
43685
|
+
sortable: column.sortable,
|
|
43686
|
+
sortField: column.sortField
|
|
43687
|
+
})),
|
|
43688
|
+
searches: searchFields.map((field) => ({
|
|
43689
|
+
key: field.key,
|
|
43690
|
+
type: field.type,
|
|
43691
|
+
locked: field.locked,
|
|
43692
|
+
defaultVisible: field.defaultVisible
|
|
43693
|
+
})),
|
|
43694
|
+
defaultSorts,
|
|
43695
|
+
fixedFilters,
|
|
43696
|
+
lockedPreference
|
|
43697
|
+
});
|
|
43698
|
+
const clearSelection = (0, import_react21.useCallback)(
|
|
43699
|
+
(reason) => {
|
|
43700
|
+
if (selectedKeysRef.current.length && reason) {
|
|
43701
|
+
void messageApi.info(reason);
|
|
43702
|
+
}
|
|
43703
|
+
selectedRowsRef.current.clear();
|
|
43704
|
+
selectedKeysRef.current = [];
|
|
43705
|
+
setSelectedKeys([]);
|
|
43706
|
+
onSelectionChange?.({ rowKeys: [], rows: [] });
|
|
43707
|
+
},
|
|
43708
|
+
[messageApi, onSelectionChange]
|
|
43709
|
+
);
|
|
43710
|
+
(0, import_react21.useEffect)(() => {
|
|
43711
|
+
if (!controlledSelectedKeys) return;
|
|
43712
|
+
const nextKeys = [...controlledSelectedKeys];
|
|
43713
|
+
const nextKeySet = new Set(nextKeys);
|
|
43714
|
+
for (const key of selectedRowsRef.current.keys()) {
|
|
43715
|
+
if (!nextKeySet.has(key)) selectedRowsRef.current.delete(key);
|
|
43716
|
+
}
|
|
43717
|
+
for (const row of rows) {
|
|
43718
|
+
const key = getRowKey(rowKey, row);
|
|
43719
|
+
if (nextKeySet.has(key)) selectedRowsRef.current.set(key, row);
|
|
43720
|
+
}
|
|
43721
|
+
selectedKeysRef.current = nextKeys;
|
|
43722
|
+
setSelectedKeys(nextKeys);
|
|
43723
|
+
}, [controlledSelectedKeys, rowKey, rows]);
|
|
43724
|
+
(0, import_react21.useEffect)(() => {
|
|
43725
|
+
if (!rowSelectable || !selectedKeysRef.current.length || !rows.length) {
|
|
43726
|
+
return;
|
|
43727
|
+
}
|
|
43728
|
+
const disabledKeys = new Set(
|
|
43729
|
+
rows.filter((row) => !rowSelectable(row)).map((row) => getRowKey(rowKey, row))
|
|
43730
|
+
);
|
|
43731
|
+
if (!disabledKeys.size) return;
|
|
43732
|
+
const nextKeys = selectedKeysRef.current.filter(
|
|
43733
|
+
(key) => !disabledKeys.has(key)
|
|
43734
|
+
);
|
|
43735
|
+
if (nextKeys.length === selectedKeysRef.current.length) return;
|
|
43736
|
+
for (const key of disabledKeys) selectedRowsRef.current.delete(key);
|
|
43737
|
+
selectedKeysRef.current = nextKeys;
|
|
43738
|
+
setSelectedKeys(nextKeys);
|
|
43739
|
+
onSelectionChange?.({
|
|
43740
|
+
rowKeys: nextKeys,
|
|
43741
|
+
rows: nextKeys.map((key) => selectedRowsRef.current.get(key)).filter(Boolean)
|
|
43742
|
+
});
|
|
43743
|
+
}, [onSelectionChange, rowKey, rowSelectable, rows]);
|
|
43744
|
+
(0, import_react21.useEffect)(() => {
|
|
43745
|
+
let active = true;
|
|
43746
|
+
setReady(false);
|
|
43747
|
+
const load = async () => {
|
|
43748
|
+
const saved = dataSourceRef.current.preferences ? await dataSourceRef.current.preferences.get(listKey).catch(() => null) : null;
|
|
43749
|
+
if (!active) return;
|
|
43750
|
+
setRawPreference(saved);
|
|
43751
|
+
const merged = mergeAdminListPreference({
|
|
43752
|
+
version: configVersion,
|
|
43753
|
+
columns,
|
|
43754
|
+
searchFields,
|
|
43755
|
+
defaultSorts,
|
|
43756
|
+
defaults: {
|
|
43757
|
+
pageSize: defaultPageSize,
|
|
43758
|
+
defaultVisibleSearchCount
|
|
43759
|
+
},
|
|
43760
|
+
user: saved,
|
|
43761
|
+
locked: lockedPreference
|
|
43762
|
+
});
|
|
43763
|
+
setPreference(merged);
|
|
43764
|
+
setSettingsDraft(merged);
|
|
43765
|
+
setQuery({
|
|
43766
|
+
currentPage: 1,
|
|
43767
|
+
pageSize: merged.pageSize || defaultPageSize,
|
|
43768
|
+
filters: {},
|
|
43769
|
+
sorts: merged.sorts || defaultSorts,
|
|
43770
|
+
fixedFilters
|
|
43771
|
+
});
|
|
43772
|
+
form.resetFields();
|
|
43773
|
+
selectedRowsRef.current.clear();
|
|
43774
|
+
selectedKeysRef.current = [];
|
|
43775
|
+
setSelectedKeys([]);
|
|
43776
|
+
previousFingerprintRef.current = "";
|
|
43777
|
+
setReady(true);
|
|
43778
|
+
};
|
|
43779
|
+
void load();
|
|
43780
|
+
return () => {
|
|
43781
|
+
active = false;
|
|
43782
|
+
};
|
|
43783
|
+
}, [
|
|
43784
|
+
configVersion,
|
|
43785
|
+
defaultPageSize,
|
|
43786
|
+
defaultVisibleSearchCount,
|
|
43787
|
+
definitionFingerprint,
|
|
43788
|
+
form,
|
|
43789
|
+
listKey,
|
|
43790
|
+
sourceKey
|
|
43791
|
+
]);
|
|
43792
|
+
(0, import_react21.useEffect)(() => {
|
|
43793
|
+
if (!allowedColumnKeys) return;
|
|
43794
|
+
const merged = mergeAdminListPreference({
|
|
43795
|
+
version: configVersion,
|
|
43796
|
+
columns,
|
|
43797
|
+
searchFields,
|
|
43798
|
+
defaultSorts,
|
|
43799
|
+
defaults: {
|
|
43800
|
+
pageSize: defaultPageSize,
|
|
43801
|
+
defaultVisibleSearchCount
|
|
43802
|
+
},
|
|
43803
|
+
user: rawPreference,
|
|
43804
|
+
locked: lockedPreference,
|
|
43805
|
+
allowedColumnKeys
|
|
43806
|
+
});
|
|
43807
|
+
setPreference((current) => ({
|
|
43808
|
+
...merged,
|
|
43809
|
+
pageSize: current.pageSize,
|
|
43810
|
+
sorts: current.sorts
|
|
43811
|
+
}));
|
|
43812
|
+
}, [
|
|
43813
|
+
allowedColumnKeys,
|
|
43814
|
+
columns,
|
|
43815
|
+
configVersion,
|
|
43816
|
+
defaultPageSize,
|
|
43817
|
+
defaultSorts,
|
|
43818
|
+
defaultVisibleSearchCount,
|
|
43819
|
+
lockedPreference,
|
|
43820
|
+
rawPreference,
|
|
43821
|
+
searchFields
|
|
43822
|
+
]);
|
|
43823
|
+
const loadData = (0, import_react21.useCallback)(async () => {
|
|
43824
|
+
if (!ready) return;
|
|
43825
|
+
setLoading(true);
|
|
43826
|
+
setError(null);
|
|
43827
|
+
onQueryChange?.(query);
|
|
43828
|
+
try {
|
|
43829
|
+
const result = await dataSourceRef.current.query(query);
|
|
43830
|
+
setRows(result.rows || []);
|
|
43831
|
+
setTotal(Math.max(0, Number(result.total || 0)));
|
|
43832
|
+
setAllowedColumnKeys(result.allowedColumnKeys);
|
|
43833
|
+
setHiddenFieldsCount(Math.max(0, Number(result.hiddenFieldsCount || 0)));
|
|
43834
|
+
} catch (requestError) {
|
|
43835
|
+
setRows([]);
|
|
43836
|
+
setTotal(0);
|
|
43837
|
+
setError(
|
|
43838
|
+
requestError instanceof Error ? requestError : new Error(String(requestError || "\u6570\u636E\u52A0\u8F7D\u5931\u8D25"))
|
|
43839
|
+
);
|
|
43840
|
+
} finally {
|
|
43841
|
+
setLoading(false);
|
|
43842
|
+
}
|
|
43843
|
+
}, [onQueryChange, query, ready]);
|
|
43844
|
+
(0, import_react21.useEffect)(() => {
|
|
43845
|
+
if (!ready) return;
|
|
43846
|
+
const fingerprint = queryFingerprint(query, sourceKey);
|
|
43847
|
+
if (previousFingerprintRef.current && previousFingerprintRef.current !== fingerprint && selectedKeysRef.current.length) {
|
|
43848
|
+
clearSelection("\u67E5\u8BE2\u6761\u4EF6\u6216\u6392\u5E8F\u5DF2\u53D8\u5316\uFF0C\u5DF2\u6E05\u7A7A\u8DE8\u9875\u9009\u62E9");
|
|
43849
|
+
}
|
|
43850
|
+
previousFingerprintRef.current = fingerprint;
|
|
43851
|
+
void loadData();
|
|
43852
|
+
}, [
|
|
43853
|
+
clearSelection,
|
|
43854
|
+
loadData,
|
|
43855
|
+
query,
|
|
43856
|
+
ready,
|
|
43857
|
+
sourceKey
|
|
43858
|
+
]);
|
|
43859
|
+
const visibleSearchFields = (0, import_react21.useMemo)(() => {
|
|
43860
|
+
const searchMap = new Map(searchFields.map((field) => [field.key, field]));
|
|
43861
|
+
const ordered = (preference.searches || []).filter((item) => item.visible !== false).map((item) => searchMap.get(item.key)).filter(Boolean);
|
|
43862
|
+
const fallback = ordered.length ? ordered : searchFields;
|
|
43863
|
+
return expanded ? fallback : fallback.slice(
|
|
43864
|
+
0,
|
|
43865
|
+
preference.defaultVisibleSearchCount || defaultVisibleSearchCount
|
|
43866
|
+
);
|
|
43867
|
+
}, [
|
|
43868
|
+
defaultVisibleSearchCount,
|
|
43869
|
+
expanded,
|
|
43870
|
+
preference.defaultVisibleSearchCount,
|
|
43871
|
+
preference.searches,
|
|
43872
|
+
searchFields
|
|
43873
|
+
]);
|
|
43874
|
+
const resolvedColumns = (0, import_react21.useMemo)(() => {
|
|
43875
|
+
const definitions = new Map(columns.map((column) => [column.key, column]));
|
|
43876
|
+
const sortablePriority = new Map(
|
|
43877
|
+
(preference.sorts || []).map((sort, index) => [
|
|
43878
|
+
sort.field,
|
|
43879
|
+
index + 1
|
|
43880
|
+
])
|
|
43881
|
+
);
|
|
43882
|
+
const preferenceColumns = preference.columns || toColumnPreferences(columns);
|
|
43883
|
+
const tableColumns = preferenceColumns.filter((item) => item.visible !== false).map((item) => {
|
|
43884
|
+
const definition = definitions.get(item.key);
|
|
43885
|
+
if (!definition) return null;
|
|
43886
|
+
const sortField = definition.sortField || definition.key;
|
|
43887
|
+
const activeSort = (preference.sorts || []).find(
|
|
43888
|
+
(sort) => sort.field === sortField
|
|
43889
|
+
);
|
|
43890
|
+
const title = definition.sortable ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { size: 4, children: [
|
|
43891
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: definition.title }),
|
|
43892
|
+
sortablePriority.has(sortField) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { bordered: false, color: "blue", children: sortablePriority.get(sortField) }) : null
|
|
43893
|
+
] }) : definition.title;
|
|
43894
|
+
return {
|
|
43895
|
+
key: definition.key,
|
|
43896
|
+
title,
|
|
43897
|
+
dataIndex: definition.dataIndex,
|
|
43898
|
+
align: definition.align,
|
|
43899
|
+
width: item.width || definition.width,
|
|
43900
|
+
fixed: item.fixed || definition.fixed,
|
|
43901
|
+
ellipsis: definition.ellipsis,
|
|
43902
|
+
sorter: definition.sortable ? { multiple: sortablePriority.get(sortField) || 99 } : void 0,
|
|
43903
|
+
sortOrder: activeSort?.direction,
|
|
43904
|
+
render: (value, row, index) => definition.render ? definition.render(value, row, index) : value
|
|
43905
|
+
};
|
|
43906
|
+
}).filter(Boolean);
|
|
43907
|
+
if (rowActions.length) {
|
|
43908
|
+
tableColumns.push({
|
|
43909
|
+
key: "__actions",
|
|
43910
|
+
title: "\u64CD\u4F5C",
|
|
43911
|
+
width: Math.max(96, Math.min(220, rowActions.length * 56)),
|
|
43912
|
+
fixed: "right",
|
|
43913
|
+
render: (_value, row) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Space, { size: 4, wrap: true, children: rowActions.map((action) => {
|
|
43914
|
+
const hidden = typeof action.hidden === "function" ? action.hidden(row) : action.hidden;
|
|
43915
|
+
if (hidden) return null;
|
|
43916
|
+
const disabled = typeof action.disabled === "function" ? action.disabled(row) : action.disabled;
|
|
43917
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
43918
|
+
import_antd12.Button,
|
|
43919
|
+
{
|
|
43920
|
+
danger: action.danger,
|
|
43921
|
+
disabled,
|
|
43922
|
+
size: "small",
|
|
43923
|
+
type: "link",
|
|
43924
|
+
onClick: () => void action.onClick(row),
|
|
43925
|
+
children: action.label
|
|
43926
|
+
},
|
|
43927
|
+
action.key
|
|
43928
|
+
);
|
|
43929
|
+
}) })
|
|
43930
|
+
});
|
|
43931
|
+
}
|
|
43932
|
+
return tableColumns;
|
|
43933
|
+
}, [columns, preference.columns, preference.sorts, rowActions]);
|
|
43934
|
+
const applySearch = (values) => {
|
|
43935
|
+
setQuery((current) => ({
|
|
43936
|
+
...current,
|
|
43937
|
+
currentPage: 1,
|
|
43938
|
+
filters: normalizeFilters(values)
|
|
43939
|
+
}));
|
|
43940
|
+
};
|
|
43941
|
+
const resetSearch = () => {
|
|
43942
|
+
form.resetFields();
|
|
43943
|
+
setQuery((current) => ({
|
|
43944
|
+
...current,
|
|
43945
|
+
currentPage: 1,
|
|
43946
|
+
filters: {}
|
|
43947
|
+
}));
|
|
43948
|
+
};
|
|
43949
|
+
const handleTableChange = (pagination, _filters, sorter) => {
|
|
43950
|
+
const sorterList = Array.isArray(sorter) ? sorter : [sorter];
|
|
43951
|
+
const nextSorts = sorterList.filter(
|
|
43952
|
+
(item) => item?.order === "ascend" || item?.order === "descend"
|
|
43953
|
+
).map((item) => {
|
|
43954
|
+
const definition = columns.find(
|
|
43955
|
+
(column) => column.key === String(item.columnKey || item.field)
|
|
43956
|
+
);
|
|
43957
|
+
return {
|
|
43958
|
+
field: definition?.sortField || definition?.key || String(item.field || item.columnKey),
|
|
43959
|
+
direction: item.order
|
|
43960
|
+
};
|
|
43961
|
+
});
|
|
43962
|
+
const sortsChanged = sortFingerprint(nextSorts) !== sortFingerprint(query.sorts);
|
|
43963
|
+
const nextPageSize = pagination.pageSize || query.pageSize;
|
|
43964
|
+
setPreference((current) => ({
|
|
43965
|
+
...current,
|
|
43966
|
+
sorts: nextSorts,
|
|
43967
|
+
pageSize: nextPageSize
|
|
43968
|
+
}));
|
|
43969
|
+
setQuery((current) => ({
|
|
43970
|
+
...current,
|
|
43971
|
+
currentPage: sortsChanged ? 1 : pagination.current || current.currentPage,
|
|
43972
|
+
pageSize: nextPageSize,
|
|
43973
|
+
sorts: nextSorts
|
|
43974
|
+
}));
|
|
43975
|
+
};
|
|
43976
|
+
const handleSelectionChange = (keys2, selectedRows) => {
|
|
43977
|
+
const nextKeys = preserveSelectionAcrossPages ? keys2 : keys2.filter(
|
|
43978
|
+
(key) => rows.some((row) => getRowKey(rowKey, row) === key)
|
|
43979
|
+
);
|
|
43980
|
+
const nextKeySet = new Set(nextKeys);
|
|
43981
|
+
for (const key of selectedRowsRef.current.keys()) {
|
|
43982
|
+
if (!nextKeySet.has(key)) selectedRowsRef.current.delete(key);
|
|
43983
|
+
}
|
|
43984
|
+
for (const row of [...rows, ...selectedRows]) {
|
|
43985
|
+
const key = getRowKey(rowKey, row);
|
|
43986
|
+
if (nextKeySet.has(key)) selectedRowsRef.current.set(key, row);
|
|
43987
|
+
}
|
|
43988
|
+
setSelectedKeys(nextKeys);
|
|
43989
|
+
selectedKeysRef.current = nextKeys;
|
|
43990
|
+
onSelectionChange?.({
|
|
43991
|
+
rowKeys: nextKeys,
|
|
43992
|
+
rows: nextKeys.map((key) => selectedRowsRef.current.get(key)).filter(Boolean)
|
|
43993
|
+
});
|
|
43994
|
+
};
|
|
43995
|
+
const pollExportTask = (0, import_react21.useCallback)(
|
|
43996
|
+
async (initial) => {
|
|
43997
|
+
if (!dataSource.getExportTask) return initial;
|
|
43998
|
+
let task = initial;
|
|
43999
|
+
for (let attempt = 0; attempt < 120; attempt += 1) {
|
|
44000
|
+
if (task.status === "completed" || task.status === "failed") break;
|
|
44001
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
44002
|
+
task = await dataSource.getExportTask(task.id);
|
|
44003
|
+
if (task.status === "running") {
|
|
44004
|
+
notificationApi.info({
|
|
44005
|
+
key: `admin-list-export:${task.id}`,
|
|
44006
|
+
title: `\u6B63\u5728\u751F\u6210 ${Math.max(
|
|
44007
|
+
0,
|
|
44008
|
+
Math.min(100, Number(task.progress || 0))
|
|
44009
|
+
)}%`,
|
|
44010
|
+
description: task.total ? `\u5171 ${task.total} \u6761` : "\u6B63\u5728\u5206\u6279\u5904\u7406\u5BFC\u51FA\u6570\u636E",
|
|
44011
|
+
duration: 0,
|
|
44012
|
+
showProgress: true
|
|
44013
|
+
});
|
|
44014
|
+
}
|
|
44015
|
+
}
|
|
44016
|
+
return task;
|
|
44017
|
+
},
|
|
44018
|
+
[dataSource, notificationApi]
|
|
44019
|
+
);
|
|
44020
|
+
const executeExport = async (scope) => {
|
|
44021
|
+
if (!dataSource.createExportTask) return;
|
|
44022
|
+
setExporting(true);
|
|
44023
|
+
try {
|
|
44024
|
+
const input = {
|
|
44025
|
+
scope,
|
|
44026
|
+
query: { ...query },
|
|
44027
|
+
rowIds: scope === "selected" ? selectedKeys : void 0,
|
|
44028
|
+
fieldKeys: (preference.columns || []).filter((column) => column.visible !== false).map((column) => column.key).filter((key) => {
|
|
44029
|
+
const definition = columns.find((column) => column.key === key);
|
|
44030
|
+
return definition && definition.exportable !== false;
|
|
44031
|
+
}),
|
|
44032
|
+
fileName
|
|
44033
|
+
};
|
|
44034
|
+
const created = await dataSource.createExportTask(input);
|
|
44035
|
+
notificationApi.info({
|
|
44036
|
+
key: `admin-list-export:${created.id}`,
|
|
44037
|
+
title: "\u5BFC\u51FA\u4EFB\u52A1\u5DF2\u521B\u5EFA",
|
|
44038
|
+
description: "\u53EF\u7EE7\u7EED\u4F7F\u7528\u5F53\u524D\u9875\u9762\uFF0C\u5B8C\u6210\u540E\u4F1A\u901A\u77E5",
|
|
44039
|
+
duration: 3
|
|
44040
|
+
});
|
|
44041
|
+
const finished = await pollExportTask(created);
|
|
44042
|
+
if (finished.status === "completed") {
|
|
44043
|
+
notificationApi.success({
|
|
44044
|
+
key: `admin-list-export:${finished.id}`,
|
|
44045
|
+
title: "\u5BFC\u51FA\u5B8C\u6210",
|
|
44046
|
+
description: finished.message || "\u6587\u4EF6\u5DF2\u751F\u6210",
|
|
44047
|
+
duration: 0,
|
|
44048
|
+
actions: finished.downloadUrl ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44049
|
+
import_antd12.Button,
|
|
44050
|
+
{
|
|
44051
|
+
size: "small",
|
|
44052
|
+
type: "primary",
|
|
44053
|
+
onClick: () => {
|
|
44054
|
+
if (typeof window !== "undefined") {
|
|
44055
|
+
window.open(finished.downloadUrl, "_blank", "noopener");
|
|
44056
|
+
}
|
|
44057
|
+
},
|
|
44058
|
+
children: "\u4E0B\u8F7D\u6587\u4EF6"
|
|
44059
|
+
}
|
|
44060
|
+
) : void 0
|
|
44061
|
+
});
|
|
44062
|
+
} else if (finished.status === "failed") {
|
|
44063
|
+
notificationApi.error({
|
|
44064
|
+
key: `admin-list-export:${finished.id}`,
|
|
44065
|
+
title: "\u5BFC\u51FA\u5931\u8D25",
|
|
44066
|
+
description: finished.message || "\u8BF7\u7A0D\u540E\u91CD\u8BD5",
|
|
44067
|
+
duration: 0
|
|
44068
|
+
});
|
|
44069
|
+
}
|
|
44070
|
+
} catch (exportError) {
|
|
44071
|
+
notificationApi.error({
|
|
44072
|
+
title: "\u5BFC\u51FA\u5931\u8D25",
|
|
44073
|
+
description: exportError instanceof Error ? exportError.message : String(exportError || "\u8BF7\u7A0D\u540E\u91CD\u8BD5")
|
|
44074
|
+
});
|
|
44075
|
+
} finally {
|
|
44076
|
+
setExporting(false);
|
|
44077
|
+
setExportConfirmOpen(false);
|
|
44078
|
+
}
|
|
44079
|
+
};
|
|
44080
|
+
const exportMenuItems = [
|
|
44081
|
+
{
|
|
44082
|
+
key: "selected",
|
|
44083
|
+
label: `\u5BFC\u51FA\u9009\u4E2D\uFF08${selectedKeys.length} \u6761\uFF09`,
|
|
44084
|
+
disabled: selectedKeys.length === 0,
|
|
44085
|
+
onClick: () => void executeExport("selected")
|
|
44086
|
+
},
|
|
44087
|
+
{
|
|
44088
|
+
key: "all",
|
|
44089
|
+
label: `\u5BFC\u51FA\u5168\u90E8\uFF08\u5F53\u524D\u6761\u4EF6\u5171 ${total} \u6761\uFF09`,
|
|
44090
|
+
onClick: () => setExportConfirmOpen(true)
|
|
44091
|
+
}
|
|
44092
|
+
];
|
|
44093
|
+
const openSettings = () => {
|
|
44094
|
+
setSettingsDraft(preference);
|
|
44095
|
+
setSettingsOpen(true);
|
|
44096
|
+
};
|
|
44097
|
+
const saveSettings = async () => {
|
|
44098
|
+
const normalized = mergeAdminListPreference({
|
|
44099
|
+
version: configVersion,
|
|
44100
|
+
columns,
|
|
44101
|
+
searchFields,
|
|
44102
|
+
defaultSorts,
|
|
44103
|
+
defaults: {
|
|
44104
|
+
pageSize: defaultPageSize,
|
|
44105
|
+
defaultVisibleSearchCount
|
|
44106
|
+
},
|
|
44107
|
+
user: settingsDraft,
|
|
44108
|
+
locked: lockedPreference,
|
|
44109
|
+
allowedColumnKeys
|
|
44110
|
+
});
|
|
44111
|
+
try {
|
|
44112
|
+
const saved = dataSource.preferences ? await dataSource.preferences.put(listKey, normalized) : normalized;
|
|
44113
|
+
const next = { ...normalized, ...saved };
|
|
44114
|
+
setRawPreference(next);
|
|
44115
|
+
setPreference(next);
|
|
44116
|
+
setSettingsDraft(next);
|
|
44117
|
+
setSettingsOpen(false);
|
|
44118
|
+
setQuery((current) => ({
|
|
44119
|
+
...current,
|
|
44120
|
+
currentPage: 1,
|
|
44121
|
+
pageSize: next.pageSize || current.pageSize,
|
|
44122
|
+
sorts: next.sorts || current.sorts
|
|
44123
|
+
}));
|
|
44124
|
+
void messageApi.success("\u5217\u8868\u8BBE\u7F6E\u5DF2\u4FDD\u5B58");
|
|
44125
|
+
} catch (saveError) {
|
|
44126
|
+
void messageApi.error(
|
|
44127
|
+
saveError instanceof Error ? saveError.message : "\u5217\u8868\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25"
|
|
44128
|
+
);
|
|
44129
|
+
}
|
|
44130
|
+
};
|
|
44131
|
+
const resetSettings = async () => {
|
|
44132
|
+
try {
|
|
44133
|
+
await dataSource.preferences?.remove(listKey);
|
|
44134
|
+
const reset = mergeAdminListPreference({
|
|
44135
|
+
version: configVersion,
|
|
44136
|
+
columns,
|
|
44137
|
+
searchFields,
|
|
44138
|
+
defaultSorts,
|
|
44139
|
+
defaults: {
|
|
44140
|
+
pageSize: defaultPageSize,
|
|
44141
|
+
defaultVisibleSearchCount
|
|
44142
|
+
},
|
|
44143
|
+
locked: lockedPreference,
|
|
44144
|
+
allowedColumnKeys
|
|
44145
|
+
});
|
|
44146
|
+
setRawPreference(null);
|
|
44147
|
+
setPreference(reset);
|
|
44148
|
+
setSettingsDraft(reset);
|
|
44149
|
+
setQuery((current) => ({
|
|
44150
|
+
...current,
|
|
44151
|
+
currentPage: 1,
|
|
44152
|
+
pageSize: reset.pageSize || current.pageSize,
|
|
44153
|
+
sorts: reset.sorts || current.sorts
|
|
44154
|
+
}));
|
|
44155
|
+
void messageApi.success("\u5DF2\u6062\u590D\u7CFB\u7EDF\u9ED8\u8BA4\u8BBE\u7F6E");
|
|
44156
|
+
} catch (resetError) {
|
|
44157
|
+
void messageApi.error(
|
|
44158
|
+
resetError instanceof Error ? resetError.message : "\u6062\u590D\u9ED8\u8BA4\u8BBE\u7F6E\u5931\u8D25"
|
|
44159
|
+
);
|
|
44160
|
+
}
|
|
44161
|
+
};
|
|
44162
|
+
const reorderDraft = (kind, draggedKey, targetKey) => {
|
|
44163
|
+
if (!draggedKey || draggedKey === targetKey) return;
|
|
44164
|
+
setSettingsDraft((current) => {
|
|
44165
|
+
const items = [...current[kind] || []];
|
|
44166
|
+
const from = items.findIndex((item) => item.key === draggedKey);
|
|
44167
|
+
const to = items.findIndex((item) => item.key === targetKey);
|
|
44168
|
+
if (from < 0 || to < 0) return current;
|
|
44169
|
+
const [moved] = items.splice(from, 1);
|
|
44170
|
+
items.splice(to, 0, moved);
|
|
44171
|
+
return { ...current, [kind]: items };
|
|
44172
|
+
});
|
|
44173
|
+
};
|
|
44174
|
+
const updateDraftColumn = (key, patch) => {
|
|
44175
|
+
setSettingsDraft((current) => ({
|
|
44176
|
+
...current,
|
|
44177
|
+
columns: (current.columns || []).map(
|
|
44178
|
+
(column) => column.key === key ? { ...column, ...patch } : column
|
|
44179
|
+
)
|
|
44180
|
+
}));
|
|
44181
|
+
};
|
|
44182
|
+
const settingsContent = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44183
|
+
import_antd12.Tabs,
|
|
44184
|
+
{
|
|
44185
|
+
activeKey: settingsTab,
|
|
44186
|
+
items: [
|
|
44187
|
+
{
|
|
44188
|
+
key: "search",
|
|
44189
|
+
label: "\u641C\u7D22\u9879",
|
|
44190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 12, style: { width: "100%" }, children: [
|
|
44191
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
|
|
44192
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u9ED8\u8BA4\u5C55\u793A" }),
|
|
44193
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44194
|
+
import_antd12.InputNumber,
|
|
44195
|
+
{
|
|
44196
|
+
min: 1,
|
|
44197
|
+
max: Math.max(1, searchFields.length),
|
|
44198
|
+
value: settingsDraft.defaultVisibleSearchCount || defaultVisibleSearchCount,
|
|
44199
|
+
onChange: (value) => setSettingsDraft((current) => ({
|
|
44200
|
+
...current,
|
|
44201
|
+
defaultVisibleSearchCount: Number(value) || defaultVisibleSearchCount
|
|
44202
|
+
}))
|
|
44203
|
+
}
|
|
44204
|
+
),
|
|
44205
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u9879" })
|
|
44206
|
+
] }),
|
|
44207
|
+
(settingsDraft.searches || []).map((item, index) => {
|
|
44208
|
+
const definition = searchFields.find(
|
|
44209
|
+
(field) => field.key === item.key
|
|
44210
|
+
);
|
|
44211
|
+
if (!definition) return null;
|
|
44212
|
+
const locked = definition.locked || lockedPreference?.lockedSearchKeys?.includes(item.key);
|
|
44213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44214
|
+
"div",
|
|
44215
|
+
{
|
|
44216
|
+
draggable: !locked,
|
|
44217
|
+
onDragStart: () => setDraggedSearchKey(item.key),
|
|
44218
|
+
onDragOver: (event) => event.preventDefault(),
|
|
44219
|
+
onDrop: () => reorderDraft(
|
|
44220
|
+
"searches",
|
|
44221
|
+
draggedSearchKey,
|
|
44222
|
+
item.key
|
|
44223
|
+
),
|
|
44224
|
+
style: {
|
|
44225
|
+
alignItems: "center",
|
|
44226
|
+
border: "1px solid rgba(5, 5, 5, 0.08)",
|
|
44227
|
+
borderRadius: 8,
|
|
44228
|
+
display: "grid",
|
|
44229
|
+
gap: 8,
|
|
44230
|
+
gridTemplateColumns: "28px 1fr auto",
|
|
44231
|
+
padding: "10px 12px"
|
|
44232
|
+
},
|
|
44233
|
+
children: [
|
|
44234
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44235
|
+
"span",
|
|
44236
|
+
{
|
|
44237
|
+
"aria-label": `\u62D6\u52A8\u7B2C ${index + 1} \u9879`,
|
|
44238
|
+
style: { color: "#8c8c8c", cursor: "grab" },
|
|
44239
|
+
children: "\u62D6\u52A8"
|
|
44240
|
+
}
|
|
44241
|
+
),
|
|
44242
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: definition.label }),
|
|
44243
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44244
|
+
import_antd12.Checkbox,
|
|
44245
|
+
{
|
|
44246
|
+
checked: item.visible !== false,
|
|
44247
|
+
disabled: locked,
|
|
44248
|
+
onChange: (event) => setSettingsDraft((current) => ({
|
|
44249
|
+
...current,
|
|
44250
|
+
searches: (current.searches || []).map(
|
|
44251
|
+
(search) => search.key === item.key ? {
|
|
44252
|
+
...search,
|
|
44253
|
+
visible: event.target.checked
|
|
44254
|
+
} : search
|
|
44255
|
+
)
|
|
44256
|
+
})),
|
|
44257
|
+
children: "\u663E\u793A"
|
|
44258
|
+
}
|
|
44259
|
+
)
|
|
44260
|
+
]
|
|
44261
|
+
},
|
|
44262
|
+
item.key
|
|
44263
|
+
);
|
|
44264
|
+
})
|
|
44265
|
+
] })
|
|
44266
|
+
},
|
|
44267
|
+
{
|
|
44268
|
+
key: "columns",
|
|
44269
|
+
label: "\u5217\u8BBE\u7F6E",
|
|
44270
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 12, style: { width: "100%" }, children: [
|
|
44271
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44272
|
+
import_antd12.Input,
|
|
44273
|
+
{
|
|
44274
|
+
allowClear: true,
|
|
44275
|
+
placeholder: "\u641C\u7D22\u5217\u540D\u79F0",
|
|
44276
|
+
value: columnSearch,
|
|
44277
|
+
onChange: (event) => setColumnSearch(event.target.value)
|
|
44278
|
+
}
|
|
44279
|
+
),
|
|
44280
|
+
(settingsDraft.columns || []).filter((item) => {
|
|
44281
|
+
const definition = columns.find(
|
|
44282
|
+
(column) => column.key === item.key
|
|
44283
|
+
);
|
|
44284
|
+
return definition && String(definition.title).toLowerCase().includes(columnSearch.trim().toLowerCase());
|
|
44285
|
+
}).map((item, index) => {
|
|
44286
|
+
const definition = columns.find(
|
|
44287
|
+
(column) => column.key === item.key
|
|
44288
|
+
);
|
|
44289
|
+
if (!definition) return null;
|
|
44290
|
+
const locked = definition.locked || lockedPreference?.lockedColumnKeys?.includes(item.key);
|
|
44291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44292
|
+
"div",
|
|
44293
|
+
{
|
|
44294
|
+
draggable: !locked,
|
|
44295
|
+
onDragStart: () => setDraggedColumnKey(item.key),
|
|
44296
|
+
onDragOver: (event) => event.preventDefault(),
|
|
44297
|
+
onDrop: () => reorderDraft(
|
|
44298
|
+
"columns",
|
|
44299
|
+
draggedColumnKey,
|
|
44300
|
+
item.key
|
|
44301
|
+
),
|
|
44302
|
+
style: {
|
|
44303
|
+
alignItems: "center",
|
|
44304
|
+
border: "1px solid rgba(5, 5, 5, 0.08)",
|
|
44305
|
+
borderRadius: 8,
|
|
44306
|
+
display: "grid",
|
|
44307
|
+
gap: 8,
|
|
44308
|
+
gridTemplateColumns: "32px 1fr 72px 116px",
|
|
44309
|
+
padding: "8px 10px"
|
|
44310
|
+
},
|
|
44311
|
+
children: [
|
|
44312
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44313
|
+
"span",
|
|
44314
|
+
{
|
|
44315
|
+
"aria-label": `\u62D6\u52A8\u7B2C ${index + 1} \u5217`,
|
|
44316
|
+
style: { color: "#8c8c8c", cursor: "grab" },
|
|
44317
|
+
children: "\u62D6\u52A8"
|
|
44318
|
+
}
|
|
44319
|
+
),
|
|
44320
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44321
|
+
import_antd12.Checkbox,
|
|
44322
|
+
{
|
|
44323
|
+
checked: item.visible !== false,
|
|
44324
|
+
disabled: locked,
|
|
44325
|
+
onChange: (event) => updateDraftColumn(item.key, {
|
|
44326
|
+
visible: event.target.checked
|
|
44327
|
+
}),
|
|
44328
|
+
children: [
|
|
44329
|
+
definition.title,
|
|
44330
|
+
locked ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { bordered: false, style: { marginInlineStart: 4 }, children: "\u9501\u5B9A" }) : null
|
|
44331
|
+
]
|
|
44332
|
+
}
|
|
44333
|
+
),
|
|
44334
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44335
|
+
import_antd12.InputNumber,
|
|
44336
|
+
{
|
|
44337
|
+
min: 60,
|
|
44338
|
+
max: 800,
|
|
44339
|
+
size: "small",
|
|
44340
|
+
value: item.width,
|
|
44341
|
+
onChange: (value) => updateDraftColumn(item.key, {
|
|
44342
|
+
width: value ? Number(value) : void 0
|
|
44343
|
+
})
|
|
44344
|
+
}
|
|
44345
|
+
),
|
|
44346
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44347
|
+
import_antd12.Select,
|
|
44348
|
+
{
|
|
44349
|
+
size: "small",
|
|
44350
|
+
value: item.fixed || "none",
|
|
44351
|
+
options: [
|
|
44352
|
+
{ label: "\u56FA\u5B9A\u5728\u5DE6\u4FA7", value: "left" },
|
|
44353
|
+
{ label: "\u4E0D\u56FA\u5B9A", value: "none" },
|
|
44354
|
+
{ label: "\u56FA\u5B9A\u5728\u53F3\u4FA7", value: "right" }
|
|
44355
|
+
],
|
|
44356
|
+
onChange: (value) => updateDraftColumn(item.key, {
|
|
44357
|
+
fixed: value === "left" || value === "right" ? value : null
|
|
44358
|
+
})
|
|
44359
|
+
}
|
|
44360
|
+
)
|
|
44361
|
+
]
|
|
44362
|
+
},
|
|
44363
|
+
item.key
|
|
44364
|
+
);
|
|
44365
|
+
})
|
|
44366
|
+
] })
|
|
44367
|
+
},
|
|
44368
|
+
{
|
|
44369
|
+
key: "sort",
|
|
44370
|
+
label: "\u6392\u5E8F",
|
|
44371
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 12, style: { width: "100%" }, children: [
|
|
44372
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44373
|
+
import_antd12.Alert,
|
|
44374
|
+
{
|
|
44375
|
+
showIcon: true,
|
|
44376
|
+
type: "info",
|
|
44377
|
+
title: "\u5217\u5934\u5FEB\u6377\u6392\u5E8F\u4F1A\u540C\u6B65\u66F4\u65B0\u6B64\u5904"
|
|
44378
|
+
}
|
|
44379
|
+
),
|
|
44380
|
+
(settingsDraft.sorts || []).map((sort, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44381
|
+
"div",
|
|
44382
|
+
{
|
|
44383
|
+
style: {
|
|
44384
|
+
alignItems: "center",
|
|
44385
|
+
border: "1px solid rgba(5, 5, 5, 0.08)",
|
|
44386
|
+
borderRadius: 8,
|
|
44387
|
+
display: "grid",
|
|
44388
|
+
gap: 8,
|
|
44389
|
+
gridTemplateColumns: "28px 1fr 100px auto",
|
|
44390
|
+
padding: 10
|
|
44391
|
+
},
|
|
44392
|
+
children: [
|
|
44393
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Tag, { bordered: false, color: "blue", children: index + 1 }),
|
|
44394
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44395
|
+
import_antd12.Select,
|
|
44396
|
+
{
|
|
44397
|
+
value: sort.field,
|
|
44398
|
+
options: columns.filter((column) => column.sortable).map((column) => ({
|
|
44399
|
+
label: column.title,
|
|
44400
|
+
value: column.sortField || column.key
|
|
44401
|
+
})),
|
|
44402
|
+
onChange: (field) => setSettingsDraft((current) => ({
|
|
44403
|
+
...current,
|
|
44404
|
+
sorts: (current.sorts || []).map(
|
|
44405
|
+
(item, itemIndex) => itemIndex === index ? { ...item, field } : item
|
|
44406
|
+
)
|
|
44407
|
+
}))
|
|
44408
|
+
}
|
|
44409
|
+
),
|
|
44410
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44411
|
+
import_antd12.Select,
|
|
44412
|
+
{
|
|
44413
|
+
value: sort.direction,
|
|
44414
|
+
options: [
|
|
44415
|
+
{ label: "\u5347\u5E8F", value: "ascend" },
|
|
44416
|
+
{ label: "\u964D\u5E8F", value: "descend" }
|
|
44417
|
+
],
|
|
44418
|
+
onChange: (direction) => setSettingsDraft((current) => ({
|
|
44419
|
+
...current,
|
|
44420
|
+
sorts: (current.sorts || []).map(
|
|
44421
|
+
(item, itemIndex) => itemIndex === index ? { ...item, direction } : item
|
|
44422
|
+
)
|
|
44423
|
+
}))
|
|
44424
|
+
}
|
|
44425
|
+
),
|
|
44426
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44427
|
+
import_antd12.Button,
|
|
44428
|
+
{
|
|
44429
|
+
danger: true,
|
|
44430
|
+
size: "small",
|
|
44431
|
+
type: "link",
|
|
44432
|
+
onClick: () => setSettingsDraft((current) => ({
|
|
44433
|
+
...current,
|
|
44434
|
+
sorts: (current.sorts || []).filter(
|
|
44435
|
+
(_item, itemIndex) => itemIndex !== index
|
|
44436
|
+
)
|
|
44437
|
+
})),
|
|
44438
|
+
children: "\u5220\u9664"
|
|
44439
|
+
}
|
|
44440
|
+
)
|
|
44441
|
+
]
|
|
44442
|
+
},
|
|
44443
|
+
`${sort.field}:${index}`
|
|
44444
|
+
)),
|
|
44445
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44446
|
+
import_antd12.Button,
|
|
44447
|
+
{
|
|
44448
|
+
block: true,
|
|
44449
|
+
disabled: (settingsDraft.sorts || []).length >= columns.filter((column) => column.sortable).length,
|
|
44450
|
+
onClick: () => {
|
|
44451
|
+
const used = new Set(
|
|
44452
|
+
(settingsDraft.sorts || []).map((sort) => sort.field)
|
|
44453
|
+
);
|
|
44454
|
+
const next = columns.find(
|
|
44455
|
+
(column) => column.sortable && !used.has(column.sortField || column.key)
|
|
44456
|
+
);
|
|
44457
|
+
if (!next) return;
|
|
44458
|
+
setSettingsDraft((current) => ({
|
|
44459
|
+
...current,
|
|
44460
|
+
sorts: [
|
|
44461
|
+
...current.sorts || [],
|
|
44462
|
+
{
|
|
44463
|
+
field: next.sortField || next.key,
|
|
44464
|
+
direction: "ascend"
|
|
44465
|
+
}
|
|
44466
|
+
]
|
|
44467
|
+
}));
|
|
44468
|
+
},
|
|
44469
|
+
children: "\u6DFB\u52A0\u6392\u5E8F\u5B57\u6BB5"
|
|
44470
|
+
}
|
|
44471
|
+
)
|
|
44472
|
+
] })
|
|
44473
|
+
},
|
|
44474
|
+
{
|
|
44475
|
+
key: "display",
|
|
44476
|
+
label: "\u663E\u793A",
|
|
44477
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 20, style: { width: "100%" }, children: [
|
|
44478
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", children: [
|
|
44479
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u8868\u683C\u5BC6\u5EA6" }),
|
|
44480
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44481
|
+
import_antd12.Segmented,
|
|
44482
|
+
{
|
|
44483
|
+
options: [
|
|
44484
|
+
{ label: "\u7D27\u51D1", value: "small" },
|
|
44485
|
+
{ label: "\u9ED8\u8BA4", value: "middle" },
|
|
44486
|
+
{ label: "\u5BBD\u677E", value: "large" }
|
|
44487
|
+
],
|
|
44488
|
+
value: settingsDraft.density,
|
|
44489
|
+
onChange: (density) => setSettingsDraft((current) => ({
|
|
44490
|
+
...current,
|
|
44491
|
+
density
|
|
44492
|
+
}))
|
|
44493
|
+
}
|
|
44494
|
+
)
|
|
44495
|
+
] }),
|
|
44496
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", children: [
|
|
44497
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u9ED8\u8BA4\u6BCF\u9875" }),
|
|
44498
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44499
|
+
import_antd12.Segmented,
|
|
44500
|
+
{
|
|
44501
|
+
options: pageSizeOptions.map((value) => ({
|
|
44502
|
+
label: `${value}`,
|
|
44503
|
+
value
|
|
44504
|
+
})),
|
|
44505
|
+
value: settingsDraft.pageSize,
|
|
44506
|
+
onChange: (pageSize) => setSettingsDraft((current) => ({
|
|
44507
|
+
...current,
|
|
44508
|
+
pageSize: Number(pageSize)
|
|
44509
|
+
}))
|
|
44510
|
+
}
|
|
44511
|
+
)
|
|
44512
|
+
] }),
|
|
44513
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
44514
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u5B8C\u6574\u8FB9\u6846" }),
|
|
44515
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44516
|
+
import_antd12.Switch,
|
|
44517
|
+
{
|
|
44518
|
+
checked: settingsDraft.showBorders,
|
|
44519
|
+
onChange: (showBorders) => setSettingsDraft((current) => ({
|
|
44520
|
+
...current,
|
|
44521
|
+
showBorders
|
|
44522
|
+
}))
|
|
44523
|
+
}
|
|
44524
|
+
)
|
|
44525
|
+
] }),
|
|
44526
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
44527
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u6591\u9A6C\u7EB9" }),
|
|
44528
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44529
|
+
import_antd12.Switch,
|
|
44530
|
+
{
|
|
44531
|
+
checked: settingsDraft.striped,
|
|
44532
|
+
onChange: (striped) => setSettingsDraft((current) => ({
|
|
44533
|
+
...current,
|
|
44534
|
+
striped
|
|
44535
|
+
}))
|
|
44536
|
+
}
|
|
44537
|
+
)
|
|
44538
|
+
] }),
|
|
44539
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { style: { justifyContent: "space-between", width: "100%" }, children: [
|
|
44540
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { children: "\u884C\u60AC\u6D6E\u64CD\u4F5C" }),
|
|
44541
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44542
|
+
import_antd12.Switch,
|
|
44543
|
+
{
|
|
44544
|
+
checked: settingsDraft.hoverActions,
|
|
44545
|
+
onChange: (hoverActions) => setSettingsDraft((current) => ({
|
|
44546
|
+
...current,
|
|
44547
|
+
hoverActions
|
|
44548
|
+
}))
|
|
44549
|
+
}
|
|
44550
|
+
)
|
|
44551
|
+
] })
|
|
44552
|
+
] })
|
|
44553
|
+
}
|
|
44554
|
+
],
|
|
44555
|
+
onChange: setSettingsTab
|
|
44556
|
+
}
|
|
44557
|
+
);
|
|
44558
|
+
const unauthorized = Number(error?.status) === 403;
|
|
44559
|
+
const localeEmpty = error ? unauthorized ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44560
|
+
import_antd12.Result,
|
|
44561
|
+
{
|
|
44562
|
+
status: "403",
|
|
44563
|
+
title: "\u6682\u65E0\u8BBF\u95EE\u6743\u9650",
|
|
44564
|
+
subTitle: "\u8BF7\u8054\u7CFB\u5E94\u7528\u7BA1\u7406\u5458\u5F00\u901A\u9875\u9762\u6743\u9650"
|
|
44565
|
+
}
|
|
44566
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44567
|
+
import_antd12.Result,
|
|
44568
|
+
{
|
|
44569
|
+
status: "error",
|
|
44570
|
+
title: "\u6570\u636E\u52A0\u8F7D\u5931\u8D25",
|
|
44571
|
+
subTitle: error.message || "\u7F51\u7EDC\u5F02\u5E38\u6216\u670D\u52A1\u6682\u4E0D\u53EF\u7528",
|
|
44572
|
+
extra: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: () => void loadData(), type: "primary", children: "\u91CD\u65B0\u52A0\u8F7D" })
|
|
44573
|
+
}
|
|
44574
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44575
|
+
import_antd12.Empty,
|
|
44576
|
+
{
|
|
44577
|
+
description: emptyText || "\u6682\u65E0\u7B26\u5408\u6761\u4EF6\u7684\u6570\u636E",
|
|
44578
|
+
image: import_antd12.Empty.PRESENTED_IMAGE_SIMPLE,
|
|
44579
|
+
children: Object.keys(query.filters).length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: resetSearch, children: "\u6E05\u7A7A\u7B5B\u9009" }) : null
|
|
44580
|
+
}
|
|
44581
|
+
);
|
|
44582
|
+
const tablePagination = {
|
|
44583
|
+
current: query.currentPage,
|
|
44584
|
+
pageSize: query.pageSize,
|
|
44585
|
+
pageSizeOptions,
|
|
44586
|
+
showQuickJumper: true,
|
|
44587
|
+
showSizeChanger: true,
|
|
44588
|
+
showTotal: (count) => `\u5171 ${count} \u6761`,
|
|
44589
|
+
total
|
|
44590
|
+
};
|
|
44591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className, style, children: [
|
|
44592
|
+
messageHolder,
|
|
44593
|
+
notificationHolder,
|
|
44594
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 12, style: { width: "100%" }, children: [
|
|
44595
|
+
searchFields.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Card, { size: "small", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44596
|
+
import_antd12.Form,
|
|
44597
|
+
{
|
|
44598
|
+
form,
|
|
44599
|
+
layout: "vertical",
|
|
44600
|
+
onFinish: applySearch,
|
|
44601
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44602
|
+
"div",
|
|
44603
|
+
{
|
|
44604
|
+
style: {
|
|
44605
|
+
alignItems: "end",
|
|
44606
|
+
display: "grid",
|
|
44607
|
+
gap: 12,
|
|
44608
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))"
|
|
44609
|
+
},
|
|
44610
|
+
children: [
|
|
44611
|
+
visibleSearchFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44612
|
+
import_antd12.Form.Item,
|
|
44613
|
+
{
|
|
44614
|
+
label: field.label,
|
|
44615
|
+
name: field.render ? void 0 : field.key,
|
|
44616
|
+
style: { marginBottom: 0 },
|
|
44617
|
+
children: field.render ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Form.Item, { noStyle: true, shouldUpdate: true, children: () => field.render?.({
|
|
44618
|
+
disabled: field.disabled,
|
|
44619
|
+
value: form.getFieldValue(field.key),
|
|
44620
|
+
onChange: (value) => form.setFieldValue(field.key, value)
|
|
44621
|
+
}) }) : renderSearchControl(field)
|
|
44622
|
+
},
|
|
44623
|
+
field.key
|
|
44624
|
+
)),
|
|
44625
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Form.Item, { style: { marginBottom: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { wrap: true, children: [
|
|
44626
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { htmlType: "submit", type: "primary", children: "\u67E5\u8BE2" }),
|
|
44627
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: resetSearch, children: "\u91CD\u7F6E" }),
|
|
44628
|
+
searchFields.length > (preference.defaultVisibleSearchCount || defaultVisibleSearchCount) ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44629
|
+
import_antd12.Button,
|
|
44630
|
+
{
|
|
44631
|
+
type: "link",
|
|
44632
|
+
onClick: () => setExpanded((current) => !current),
|
|
44633
|
+
children: expanded ? "\u6536\u8D77" : "\u66F4\u591A\u7B5B\u9009"
|
|
44634
|
+
}
|
|
44635
|
+
) : null
|
|
44636
|
+
] }) })
|
|
44637
|
+
]
|
|
44638
|
+
}
|
|
44639
|
+
)
|
|
44640
|
+
}
|
|
44641
|
+
) }) : null,
|
|
44642
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44643
|
+
import_antd12.Card,
|
|
44644
|
+
{
|
|
44645
|
+
styles: { body: { padding: 12 } },
|
|
44646
|
+
size: "small",
|
|
44647
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44648
|
+
import_antd12.Space,
|
|
44649
|
+
{
|
|
44650
|
+
align: "center",
|
|
44651
|
+
style: { justifyContent: "space-between", width: "100%" },
|
|
44652
|
+
wrap: true,
|
|
44653
|
+
children: [
|
|
44654
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { wrap: true, children: [
|
|
44655
|
+
typeof toolbar === "function" ? toolbar({ reload: () => void loadData() }) : toolbar,
|
|
44656
|
+
batchActions.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44657
|
+
import_antd12.Dropdown,
|
|
44658
|
+
{
|
|
44659
|
+
menu: {
|
|
44660
|
+
items: batchActions.map((action) => ({
|
|
44661
|
+
key: action.key,
|
|
44662
|
+
label: action.label,
|
|
44663
|
+
danger: action.danger,
|
|
44664
|
+
disabled: action.disabled || selectedKeys.length === 0,
|
|
44665
|
+
onClick: () => void action.onClick(
|
|
44666
|
+
selectedKeys.map(
|
|
44667
|
+
(key) => selectedRowsRef.current.get(key)
|
|
44668
|
+
).filter(Boolean),
|
|
44669
|
+
selectedKeys
|
|
44670
|
+
)
|
|
44671
|
+
}))
|
|
44672
|
+
},
|
|
44673
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { disabled: selectedKeys.length === 0, children: "\u6279\u91CF\u64CD\u4F5C" })
|
|
44674
|
+
}
|
|
44675
|
+
) : null,
|
|
44676
|
+
exportable && dataSource.createExportTask ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Dropdown, { menu: { items: exportMenuItems }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { loading: exporting, children: "\u5BFC\u51FA" }) }) : null
|
|
44677
|
+
] }),
|
|
44678
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
|
|
44679
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: () => void loadData(), children: "\u5237\u65B0" }),
|
|
44680
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: openSettings, children: "\u5217\u8868\u8BBE\u7F6E" })
|
|
44681
|
+
] })
|
|
44682
|
+
]
|
|
44683
|
+
}
|
|
44684
|
+
)
|
|
44685
|
+
}
|
|
44686
|
+
),
|
|
44687
|
+
selectedKeys.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44688
|
+
import_antd12.Alert,
|
|
44689
|
+
{
|
|
44690
|
+
action: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44691
|
+
import_antd12.Button,
|
|
44692
|
+
{
|
|
44693
|
+
size: "small",
|
|
44694
|
+
type: "link",
|
|
44695
|
+
onClick: () => clearSelection(),
|
|
44696
|
+
children: "\u6E05\u7A7A\u9009\u62E9"
|
|
44697
|
+
}
|
|
44698
|
+
),
|
|
44699
|
+
showIcon: true,
|
|
44700
|
+
title: `\u5DF2\u9009\u62E9 ${selectedKeys.length} \u6761${preserveSelectionAcrossPages ? "\uFF08\u652F\u6301\u8DE8\u9875\u4FDD\u7559\uFF09" : ""}`,
|
|
44701
|
+
type: "info"
|
|
44702
|
+
}
|
|
44703
|
+
) : null,
|
|
44704
|
+
hiddenFieldsCount ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44705
|
+
import_antd12.Alert,
|
|
44706
|
+
{
|
|
44707
|
+
closable: true,
|
|
44708
|
+
showIcon: true,
|
|
44709
|
+
title: `\u90E8\u5206\u5B57\u6BB5\u56E0\u6743\u9650\u9650\u5236\u672A\u5C55\u793A\uFF08${hiddenFieldsCount} \u4E2A\uFF09`,
|
|
44710
|
+
type: "info"
|
|
44711
|
+
}
|
|
44712
|
+
) : null,
|
|
44713
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44714
|
+
import_antd12.Table,
|
|
44715
|
+
{
|
|
44716
|
+
bordered: preference.showBorders,
|
|
44717
|
+
columns: resolvedColumns,
|
|
44718
|
+
dataSource: rows,
|
|
44719
|
+
loading,
|
|
44720
|
+
locale: { emptyText: localeEmpty },
|
|
44721
|
+
pagination: tablePagination,
|
|
44722
|
+
rowClassName: (_row, index) => preference.striped && index % 2 === 1 ? "admin-list-row-striped" : "",
|
|
44723
|
+
rowKey: (row) => getRowKey(rowKey, row),
|
|
44724
|
+
rowSelection: selectable ? {
|
|
44725
|
+
preserveSelectedRowKeys: preserveSelectionAcrossPages,
|
|
44726
|
+
selectedRowKeys: selectedKeys,
|
|
44727
|
+
getCheckboxProps: (row) => ({
|
|
44728
|
+
disabled: rowSelectable ? !rowSelectable(row) : false,
|
|
44729
|
+
title: rowSelectionReason?.(row)
|
|
44730
|
+
}),
|
|
44731
|
+
onChange: handleSelectionChange
|
|
44732
|
+
} : void 0,
|
|
44733
|
+
scroll: { x: "max-content" },
|
|
44734
|
+
size: preference.density,
|
|
44735
|
+
onChange: handleTableChange,
|
|
44736
|
+
onRow
|
|
44737
|
+
}
|
|
44738
|
+
)
|
|
44739
|
+
] }),
|
|
44740
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44741
|
+
import_antd12.Drawer,
|
|
44742
|
+
{
|
|
44743
|
+
destroyOnHidden: true,
|
|
44744
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
44745
|
+
import_antd12.Space,
|
|
44746
|
+
{
|
|
44747
|
+
style: { justifyContent: "space-between", width: "100%" },
|
|
44748
|
+
children: [
|
|
44749
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44750
|
+
import_antd12.Button,
|
|
44751
|
+
{
|
|
44752
|
+
onClick: () => import_antd12.Modal.confirm({
|
|
44753
|
+
title: "\u6062\u590D\u7CFB\u7EDF\u9ED8\u8BA4\u8BBE\u7F6E\uFF1F",
|
|
44754
|
+
content: "\u5F53\u524D\u8D26\u53F7\u4FDD\u5B58\u7684\u5217\u8868\u914D\u7F6E\u5C06\u88AB\u6E05\u9664\u3002",
|
|
44755
|
+
okText: "\u6062\u590D",
|
|
44756
|
+
cancelText: "\u53D6\u6D88",
|
|
44757
|
+
onOk: resetSettings
|
|
44758
|
+
}),
|
|
44759
|
+
children: "\u6062\u590D\u9ED8\u8BA4"
|
|
44760
|
+
}
|
|
44761
|
+
),
|
|
44762
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { children: [
|
|
44763
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { onClick: () => setSettingsOpen(false), children: "\u53D6\u6D88" }),
|
|
44764
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_antd12.Button, { type: "primary", onClick: () => void saveSettings(), children: "\u5E94\u7528\u8BBE\u7F6E" })
|
|
44765
|
+
] })
|
|
44766
|
+
]
|
|
44767
|
+
}
|
|
44768
|
+
),
|
|
44769
|
+
open: settingsOpen,
|
|
44770
|
+
title: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
44771
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: "\u5217\u8868\u8BBE\u7F6E" }),
|
|
44772
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44773
|
+
"div",
|
|
44774
|
+
{
|
|
44775
|
+
style: {
|
|
44776
|
+
color: "rgba(0, 0, 0, 0.45)",
|
|
44777
|
+
fontSize: 12,
|
|
44778
|
+
fontWeight: 400,
|
|
44779
|
+
marginTop: 2
|
|
44780
|
+
},
|
|
44781
|
+
children: "\u914D\u7F6E\u5C06\u4FDD\u5B58\u5230\u5F53\u524D\u8D26\u53F7"
|
|
44782
|
+
}
|
|
44783
|
+
)
|
|
44784
|
+
] }),
|
|
44785
|
+
width: 420,
|
|
44786
|
+
onClose: () => {
|
|
44787
|
+
if (JSON.stringify(settingsDraft) !== JSON.stringify(preference)) {
|
|
44788
|
+
import_antd12.Modal.confirm({
|
|
44789
|
+
title: "\u653E\u5F03\u672A\u4FDD\u5B58\u7684\u8BBE\u7F6E\uFF1F",
|
|
44790
|
+
content: "\u5F53\u524D\u8C03\u6574\u5C1A\u672A\u5E94\u7528\uFF0C\u5173\u95ED\u540E\u5C06\u4E22\u5931\u3002",
|
|
44791
|
+
okText: "\u653E\u5F03\u4FEE\u6539",
|
|
44792
|
+
cancelText: "\u7EE7\u7EED\u7F16\u8F91",
|
|
44793
|
+
onOk: () => setSettingsOpen(false)
|
|
44794
|
+
});
|
|
44795
|
+
return;
|
|
44796
|
+
}
|
|
44797
|
+
setSettingsOpen(false);
|
|
44798
|
+
},
|
|
44799
|
+
children: settingsContent
|
|
44800
|
+
}
|
|
44801
|
+
),
|
|
44802
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44803
|
+
import_antd12.Modal,
|
|
44804
|
+
{
|
|
44805
|
+
cancelText: "\u53D6\u6D88",
|
|
44806
|
+
confirmLoading: exporting,
|
|
44807
|
+
okText: "\u5F00\u59CB\u5BFC\u51FA",
|
|
44808
|
+
open: exportConfirmOpen,
|
|
44809
|
+
title: "\u5BFC\u51FA\u5168\u90E8\u6570\u636E",
|
|
44810
|
+
onCancel: () => setExportConfirmOpen(false),
|
|
44811
|
+
onOk: () => void executeExport("all"),
|
|
44812
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_antd12.Space, { direction: "vertical", size: 12, style: { width: "100%" }, children: [
|
|
44813
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: "\u6570\u636E\u8303\u56F4\uFF1A\u5F53\u524D\u67E5\u8BE2\u7ED3\u679C" }),
|
|
44814
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
44815
|
+
"\u9884\u8BA1\u6570\u91CF\uFF1A",
|
|
44816
|
+
total,
|
|
44817
|
+
" \u6761"
|
|
44818
|
+
] }),
|
|
44819
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: "\u5BFC\u51FA\u683C\u5F0F\uFF1AExcel (.xlsx)" }),
|
|
44820
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
44821
|
+
import_antd12.Alert,
|
|
44822
|
+
{
|
|
44823
|
+
showIcon: true,
|
|
44824
|
+
title: "\u5927\u6570\u636E\u91CF\u5C06\u5728\u540E\u53F0\u751F\u6210\uFF0C\u5B8C\u6210\u540E\u901A\u77E5",
|
|
44825
|
+
type: "info"
|
|
44826
|
+
}
|
|
44827
|
+
)
|
|
44828
|
+
] })
|
|
44829
|
+
}
|
|
44830
|
+
)
|
|
44831
|
+
] });
|
|
44832
|
+
}
|
|
44833
|
+
|
|
44834
|
+
// packages/sdk/src/runtime/react/admin-list/dataSources.ts
|
|
44835
|
+
init_cjs_shims();
|
|
44836
|
+
var nonEmpty = (value) => value !== void 0 && value !== null && value !== "" && (!Array.isArray(value) || value.length > 0);
|
|
44837
|
+
var toFilterExpression = (filters, operators = {}) => ({
|
|
44838
|
+
logic: "AND",
|
|
44839
|
+
rules: Object.entries(filters).filter(([, value]) => nonEmpty(value)).map(([key, value]) => ({
|
|
44840
|
+
key,
|
|
44841
|
+
operator: operators[key] || (Array.isArray(value) ? "IN" : "EQ"),
|
|
44842
|
+
value
|
|
44843
|
+
}))
|
|
44844
|
+
});
|
|
44845
|
+
var toOrder = (query) => query.sorts.map((sort) => ({
|
|
44846
|
+
id: sort.field,
|
|
44847
|
+
isAsc: sort.direction === "ascend" ? "y" : "n"
|
|
44848
|
+
}));
|
|
44849
|
+
var normalizeList = (result) => {
|
|
44850
|
+
const value = result || {};
|
|
44851
|
+
return {
|
|
44852
|
+
rows: value.rows || value.data || value.records || value.list || [],
|
|
44853
|
+
total: Number(value.total ?? value.totalCount ?? 0),
|
|
44854
|
+
currentPage: value.currentPage,
|
|
44855
|
+
pageSize: value.pageSize,
|
|
44856
|
+
allowedColumnKeys: value.allowedColumnKeys,
|
|
44857
|
+
hiddenFieldsCount: value.hiddenFieldsCount
|
|
44858
|
+
};
|
|
44859
|
+
};
|
|
44860
|
+
var createExportClient = (options, source) => {
|
|
44861
|
+
const appType = options.appType || options.sdk.context.app.appType || "";
|
|
44862
|
+
const basePath = `/openxiangda-api/v1/apps/${encodeURIComponent(
|
|
44863
|
+
appType
|
|
44864
|
+
)}/admin-list/exports`;
|
|
44865
|
+
return {
|
|
44866
|
+
createExportTask: async (input) => {
|
|
44867
|
+
const response = await options.sdk.request({
|
|
44868
|
+
path: basePath,
|
|
44869
|
+
method: "post",
|
|
44870
|
+
body: {
|
|
44871
|
+
listKey: options.listKey,
|
|
44872
|
+
source,
|
|
44873
|
+
...input
|
|
44874
|
+
}
|
|
44875
|
+
});
|
|
44876
|
+
if (!response.result) {
|
|
44877
|
+
throw new Error("\u521B\u5EFA\u5BFC\u51FA\u4EFB\u52A1\u5931\u8D25\uFF1A\u670D\u52A1\u7AEF\u672A\u8FD4\u56DE\u4EFB\u52A1");
|
|
44878
|
+
}
|
|
44879
|
+
return response.result;
|
|
44880
|
+
},
|
|
44881
|
+
getExportTask: async (taskId) => {
|
|
44882
|
+
const response = await options.sdk.request({
|
|
44883
|
+
path: `${basePath}/${encodeURIComponent(taskId)}`,
|
|
44884
|
+
method: "get"
|
|
44885
|
+
});
|
|
44886
|
+
if (!response.result) {
|
|
44887
|
+
throw new Error("\u67E5\u8BE2\u5BFC\u51FA\u4EFB\u52A1\u5931\u8D25\uFF1A\u4EFB\u52A1\u4E0D\u5B58\u5728");
|
|
44888
|
+
}
|
|
44889
|
+
return response.result;
|
|
44890
|
+
}
|
|
44891
|
+
};
|
|
44892
|
+
};
|
|
44893
|
+
function createFormAdminListSource(options) {
|
|
44894
|
+
const appType = options.appType || options.sdk.context.app.appType || "";
|
|
44895
|
+
const exportClient = createExportClient(options, {
|
|
44896
|
+
type: "form",
|
|
44897
|
+
formUuid: options.formUuid,
|
|
44898
|
+
idField: options.idField || "formInstId",
|
|
44899
|
+
filterOperators: options.filterOperators || {}
|
|
44900
|
+
});
|
|
44901
|
+
return {
|
|
44902
|
+
key: `form:${appType}:${options.formUuid}`,
|
|
44903
|
+
preferences: createAdminListPreferenceStore(options.sdk, appType),
|
|
44904
|
+
async query(query) {
|
|
44905
|
+
const filters = {
|
|
44906
|
+
...options.fixedFilters || {},
|
|
44907
|
+
...query.fixedFilters || {},
|
|
44908
|
+
...query.filters
|
|
44909
|
+
};
|
|
44910
|
+
const response = await options.sdk.form.advancedSearch({
|
|
44911
|
+
appType,
|
|
44912
|
+
formUuid: options.formUuid,
|
|
44913
|
+
currentPage: query.currentPage,
|
|
44914
|
+
pageSize: query.pageSize,
|
|
44915
|
+
filters: toFilterExpression(filters, options.filterOperators),
|
|
44916
|
+
order: toOrder(query)
|
|
44917
|
+
});
|
|
44918
|
+
return normalizeList(response.result);
|
|
44919
|
+
},
|
|
44920
|
+
...exportClient
|
|
44921
|
+
};
|
|
44922
|
+
}
|
|
44923
|
+
function createDataViewAdminListSource(options) {
|
|
44924
|
+
const appType = options.appType || options.sdk.context.app.appType || "";
|
|
44925
|
+
const exportClient = createExportClient(options, {
|
|
44926
|
+
type: "dataView",
|
|
44927
|
+
dataViewCode: options.dataViewCode,
|
|
44928
|
+
fields: options.fields,
|
|
44929
|
+
idField: options.idField || "id",
|
|
44930
|
+
filterOperators: options.filterOperators || {}
|
|
44931
|
+
});
|
|
44932
|
+
return {
|
|
44933
|
+
key: `data-view:${appType}:${options.dataViewCode}`,
|
|
44934
|
+
preferences: createAdminListPreferenceStore(options.sdk, appType),
|
|
44935
|
+
async query(query) {
|
|
44936
|
+
const filters = {
|
|
44937
|
+
...options.fixedFilters || {},
|
|
44938
|
+
...query.fixedFilters || {},
|
|
44939
|
+
...query.filters
|
|
44940
|
+
};
|
|
44941
|
+
const response = await options.sdk.dataView.query(
|
|
44942
|
+
options.dataViewCode,
|
|
44943
|
+
{
|
|
44944
|
+
appType,
|
|
44945
|
+
fields: options.fields,
|
|
44946
|
+
currentPage: query.currentPage,
|
|
44947
|
+
pageSize: query.pageSize,
|
|
44948
|
+
filters: toFilterExpression(filters, options.filterOperators),
|
|
44949
|
+
order: toOrder(query)
|
|
44950
|
+
}
|
|
44951
|
+
);
|
|
44952
|
+
return normalizeList(response.result);
|
|
44953
|
+
},
|
|
44954
|
+
...exportClient
|
|
44955
|
+
};
|
|
44956
|
+
}
|
|
44957
|
+
function createFunctionAdminListSource(options) {
|
|
44958
|
+
const appType = options.appType || options.sdk.context.app.appType || "";
|
|
44959
|
+
const exportClient = createExportClient(options, {
|
|
44960
|
+
type: "function",
|
|
44961
|
+
functionCode: options.functionCode
|
|
44962
|
+
});
|
|
44963
|
+
return {
|
|
44964
|
+
key: `function:${appType}:${options.functionCode}`,
|
|
44965
|
+
preferences: createAdminListPreferenceStore(options.sdk, appType),
|
|
44966
|
+
async query(query) {
|
|
44967
|
+
const response = await options.sdk.function.invoke(options.functionCode, {
|
|
44968
|
+
appType,
|
|
44969
|
+
input: {
|
|
44970
|
+
contract: "admin_list_v1",
|
|
44971
|
+
query: {
|
|
44972
|
+
...query,
|
|
44973
|
+
fixedFilters: {
|
|
44974
|
+
...options.fixedFilters || {},
|
|
44975
|
+
...query.fixedFilters || {}
|
|
44976
|
+
}
|
|
44977
|
+
}
|
|
44978
|
+
}
|
|
44979
|
+
});
|
|
44980
|
+
const invocation = response.result;
|
|
44981
|
+
if (!invocation) {
|
|
44982
|
+
throw new Error("AdminList App Function \u672A\u8FD4\u56DE\u7ED3\u679C");
|
|
44983
|
+
}
|
|
44984
|
+
return normalizeList(invocation.result || invocation.output);
|
|
44985
|
+
},
|
|
44986
|
+
...exportClient
|
|
44987
|
+
};
|
|
44988
|
+
}
|
|
44989
|
+
|
|
43396
44990
|
// packages/sdk/src/runtime/core/index.ts
|
|
43397
44991
|
init_cjs_shims();
|
|
43398
44992
|
|