@donglegeyu/company-ui 1.2.26 → 1.2.27
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/dist/cjs/basic-components/CompanyUpload/index.d.ts +2 -1
- package/dist/cjs/basic-components/CompanyUpload/index.js +4 -0
- package/dist/cjs/template-components/SmartListTemplate/index.js +25 -12
- package/dist/cjs/template-components/StatisticsListPage/index.d.ts +15 -0
- package/dist/cjs/template-components/StatisticsListPage/index.js +154 -18
- package/dist/cjs/template-components/StatisticsListPage/index.scss +0 -19
- package/dist/es/basic-components/CompanyUpload/index.d.ts +2 -1
- package/dist/es/basic-components/CompanyUpload/index.js +10 -2
- package/dist/es/template-components/SmartListTemplate/index.js +17 -7
- package/dist/es/template-components/StatisticsListPage/index.d.ts +15 -0
- package/dist/es/template-components/StatisticsListPage/index.js +207 -32
- package/dist/es/template-components/StatisticsListPage/index.scss +0 -19
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { UploadProps } from "antd";
|
|
3
|
-
|
|
3
|
+
declare const CompanyUpload: React.ForwardRefExoticComponent<UploadProps<any> & React.RefAttributes<import("antd/es/upload").UploadRef<any>>> & {
|
|
4
4
|
<U extends any>(props: UploadProps<U> & {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
} & React.RefAttributes<import("antd/es/upload").UploadRef<U>>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -11,3 +11,4 @@ export declare const CompanyUpload: React.ForwardRefExoticComponent<UploadProps<
|
|
|
11
11
|
};
|
|
12
12
|
LIST_IGNORE: string;
|
|
13
13
|
};
|
|
14
|
+
export { CompanyUpload };
|
|
@@ -28,6 +28,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
28
28
|
var CompanyUpload = (props) => {
|
|
29
29
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Upload, { ...props }) });
|
|
30
30
|
};
|
|
31
|
+
CompanyUpload.Dragger = (props) => {
|
|
32
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.ConfigProvider, { theme: import_theme.companyTheme, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Upload.Dragger, { ...props }) });
|
|
33
|
+
};
|
|
34
|
+
CompanyUpload.LIST_IGNORE = import_antd.Upload.LIST_IGNORE;
|
|
31
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
36
|
0 && (module.exports = {
|
|
33
37
|
CompanyUpload
|
|
@@ -245,18 +245,31 @@ function SmartListTemplate({
|
|
|
245
245
|
visibleFieldDefs = fields.filter((field) => field.key !== "action");
|
|
246
246
|
}
|
|
247
247
|
const regularColumns = visibleFieldDefs.map(
|
|
248
|
-
(field) =>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
248
|
+
(field) => {
|
|
249
|
+
const enableEllipsis = field.ellipsis !== false;
|
|
250
|
+
return {
|
|
251
|
+
title: field.label,
|
|
252
|
+
dataIndex: field.key,
|
|
253
|
+
key: field.key,
|
|
254
|
+
width: field.width || 120,
|
|
255
|
+
fixed: field.fixed,
|
|
256
|
+
ellipsis: enableEllipsis,
|
|
257
|
+
render: (_, record) => {
|
|
258
|
+
const customContent = bodyCell ? bodyCell(
|
|
259
|
+
{ ...field, key: field.key },
|
|
260
|
+
record
|
|
261
|
+
) : null;
|
|
262
|
+
if (customContent !== null) {
|
|
263
|
+
return customContent;
|
|
264
|
+
}
|
|
265
|
+
const text = record[field.key];
|
|
266
|
+
if (!enableEllipsis || text === null || text === void 0) {
|
|
267
|
+
return text;
|
|
268
|
+
}
|
|
269
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.EllipsisText, { children: text });
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
}
|
|
260
273
|
);
|
|
261
274
|
if (actionField) {
|
|
262
275
|
regularColumns.push({
|
|
@@ -58,12 +58,23 @@ export interface StatisticsListPageProps<T = Record<string, unknown>> {
|
|
|
58
58
|
statisticCards?: StatisticCardConfig[];
|
|
59
59
|
/** 顶部搜索框占位符 */
|
|
60
60
|
searchPlaceholder?: string;
|
|
61
|
+
/** 顶部搜索框宽度 */
|
|
62
|
+
searchWidth?: number | string;
|
|
61
63
|
/** 顶部搜索对应字段 key(提交到 fetchData 的参数名) */
|
|
62
64
|
searchKey?: string;
|
|
63
65
|
/** 高级筛选字段(抽屉内) */
|
|
64
66
|
filterFields?: StatisticsFilterField[];
|
|
65
67
|
/** 表格列配置 */
|
|
66
68
|
columns: StatisticsColumn<T>[];
|
|
69
|
+
/** 操作列配置:传入后自动在表格右侧追加操作列(固定右侧) */
|
|
70
|
+
actionColumn?: {
|
|
71
|
+
/** 操作列宽度 */
|
|
72
|
+
width?: number;
|
|
73
|
+
/** 操作列标题 */
|
|
74
|
+
title?: string;
|
|
75
|
+
/** 操作列渲染函数 */
|
|
76
|
+
render: (record: T, index: number) => ReactNode;
|
|
77
|
+
};
|
|
67
78
|
/** 数据请求函数 - 严格对齐 PageResponse 契约 */
|
|
68
79
|
fetchData?: (params: Record<string, unknown>) => Promise<PageResponse<T>>;
|
|
69
80
|
/** 默认分页大小 */
|
|
@@ -72,6 +83,10 @@ export interface StatisticsListPageProps<T = Record<string, unknown>> {
|
|
|
72
83
|
rowKey?: string | ((record: T) => string);
|
|
73
84
|
/** 表格尺寸 */
|
|
74
85
|
size?: 'small' | 'middle' | 'large';
|
|
86
|
+
/** 密度切换回调(不传则组件内部自治管理密度) */
|
|
87
|
+
onSizeChange?: (size: 'small' | 'middle' | 'large') => void;
|
|
88
|
+
/** 刷新回调(不传则不显示刷新按钮;传入后点击会用当前 filterParams 触发) */
|
|
89
|
+
onRefresh?: (filterParams: Record<string, unknown>) => void;
|
|
75
90
|
/** 表格 Y 轴滚动高度(默认自适应视口) */
|
|
76
91
|
scrollY?: string | number;
|
|
77
92
|
/** 表格空状态文案 */
|
|
@@ -39,6 +39,7 @@ var import_zh_CN = __toESM(require("antd/locale/zh_CN"));
|
|
|
39
39
|
var import_icons = require("@ant-design/icons");
|
|
40
40
|
var import_basic_components = require("../../basic-components");
|
|
41
41
|
var import_shared_components = require("../../shared-components");
|
|
42
|
+
var import_ColumnSettingsPanel = __toESM(require("../ColumnSettingsPanel"));
|
|
42
43
|
var import_useCompanyToken = require("../../theme/useCompanyToken");
|
|
43
44
|
var import_index = require("./index.scss");
|
|
44
45
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -80,13 +81,17 @@ var StatisticsListPage = (props) => {
|
|
|
80
81
|
titleActions,
|
|
81
82
|
statisticCards,
|
|
82
83
|
searchPlaceholder = "请输入",
|
|
84
|
+
searchWidth = 280,
|
|
83
85
|
searchKey = "keyword",
|
|
84
86
|
filterFields = [],
|
|
85
87
|
columns,
|
|
88
|
+
actionColumn,
|
|
86
89
|
fetchData,
|
|
87
90
|
defaultPageSize = 20,
|
|
88
91
|
rowKey = "id",
|
|
89
92
|
size = "middle",
|
|
93
|
+
onSizeChange,
|
|
94
|
+
onRefresh,
|
|
90
95
|
scrollY = "calc(100vh - 420px)",
|
|
91
96
|
emptyText = "暂无数据",
|
|
92
97
|
toolbarLeftExtra,
|
|
@@ -98,6 +103,28 @@ var StatisticsListPage = (props) => {
|
|
|
98
103
|
const [tempFilters, setTempFilters] = (0, import_react.useState)({});
|
|
99
104
|
const [filterTags, setFilterTags] = (0, import_react.useState)([]);
|
|
100
105
|
const [filterParams, setFilterParams] = (0, import_react.useState)({});
|
|
106
|
+
const [internalSize, setInternalSize] = (0, import_react.useState)(size);
|
|
107
|
+
const effectiveSize = onSizeChange ? size : internalSize;
|
|
108
|
+
const [densityOpen, setDensityOpen] = (0, import_react.useState)(false);
|
|
109
|
+
const [columnFields, setColumnFields] = (0, import_react.useState)(
|
|
110
|
+
() => (columns || []).filter((col) => col.key !== "action").map((col) => ({
|
|
111
|
+
key: col.key,
|
|
112
|
+
label: col.label,
|
|
113
|
+
visible: col.visible !== false,
|
|
114
|
+
width: col.width,
|
|
115
|
+
fixed: col.fixed
|
|
116
|
+
}))
|
|
117
|
+
);
|
|
118
|
+
const defaultColumnFields = (0, import_react.useMemo)(
|
|
119
|
+
() => (columns || []).filter((col) => col.key !== "action").map((col) => ({
|
|
120
|
+
key: col.key,
|
|
121
|
+
label: col.label,
|
|
122
|
+
visible: col.visible !== false,
|
|
123
|
+
width: col.width,
|
|
124
|
+
fixed: col.fixed
|
|
125
|
+
})),
|
|
126
|
+
[columns]
|
|
127
|
+
);
|
|
101
128
|
const [dataSource, setDataSource] = (0, import_react.useState)([]);
|
|
102
129
|
const [loading, setLoading] = (0, import_react.useState)(false);
|
|
103
130
|
const [pagination, setPagination] = (0, import_react.useState)({
|
|
@@ -247,19 +274,88 @@ var StatisticsListPage = (props) => {
|
|
|
247
274
|
},
|
|
248
275
|
[fetchData, filterParams, searchKey, searchValue]
|
|
249
276
|
);
|
|
277
|
+
const visibleColumnMap = (0, import_react.useMemo)(() => {
|
|
278
|
+
const map = /* @__PURE__ */ new Map();
|
|
279
|
+
columnFields.forEach((f) => map.set(f.key, f.visible));
|
|
280
|
+
return map;
|
|
281
|
+
}, [columnFields]);
|
|
250
282
|
const tableColumns = (0, import_react.useMemo)(() => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
283
|
+
const list = (columns || []).filter((col) => {
|
|
284
|
+
if (col.key === "action")
|
|
285
|
+
return false;
|
|
286
|
+
const visible = visibleColumnMap.get(col.key);
|
|
287
|
+
return visible === void 0 ? col.visible !== false : visible;
|
|
288
|
+
}).map((col) => {
|
|
289
|
+
const base = {
|
|
290
|
+
key: col.key,
|
|
291
|
+
dataIndex: col.key,
|
|
292
|
+
title: col.label,
|
|
293
|
+
width: col.width,
|
|
294
|
+
fixed: col.fixed
|
|
295
|
+
};
|
|
296
|
+
if (col.render) {
|
|
297
|
+
base.render = col.render;
|
|
298
|
+
} else {
|
|
299
|
+
base.ellipsis = false;
|
|
300
|
+
base.render = (text) => {
|
|
301
|
+
const content = text === void 0 || text === null ? "--" : String(text);
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.EllipsisText, { children: content });
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
return base;
|
|
306
|
+
});
|
|
307
|
+
if (actionColumn) {
|
|
308
|
+
list.push({
|
|
309
|
+
key: "action",
|
|
310
|
+
title: actionColumn.title || "操作",
|
|
311
|
+
width: actionColumn.width || 148,
|
|
312
|
+
fixed: "right",
|
|
313
|
+
align: "left",
|
|
314
|
+
onHeaderCell: () => ({ style: { paddingLeft: 24, paddingRight: 16 } }),
|
|
315
|
+
render: (_, record, index) => actionColumn.render(record, index)
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return list;
|
|
319
|
+
}, [columns, visibleColumnMap, actionColumn]);
|
|
320
|
+
const sizeLabels = {
|
|
321
|
+
small: "紧凑",
|
|
322
|
+
middle: "默认",
|
|
323
|
+
large: "宽松"
|
|
324
|
+
};
|
|
325
|
+
const densityMenuItems = (0, import_react.useMemo)(
|
|
326
|
+
() => [
|
|
327
|
+
{ key: "large", label: "宽松" },
|
|
328
|
+
{ key: "middle", label: "默认" },
|
|
329
|
+
{ key: "small", label: "紧凑" }
|
|
330
|
+
],
|
|
331
|
+
[]
|
|
332
|
+
);
|
|
333
|
+
const handleDensityMenuClick = (0, import_react.useCallback)(
|
|
334
|
+
(info) => {
|
|
335
|
+
const next = info.key;
|
|
336
|
+
if (onSizeChange) {
|
|
337
|
+
onSizeChange(next);
|
|
338
|
+
} else {
|
|
339
|
+
setInternalSize(next);
|
|
340
|
+
}
|
|
341
|
+
setDensityOpen(false);
|
|
342
|
+
},
|
|
343
|
+
[onSizeChange]
|
|
344
|
+
);
|
|
345
|
+
const handleRefresh = (0, import_react.useCallback)(() => {
|
|
346
|
+
if (onRefresh) {
|
|
347
|
+
onRefresh(filterParams);
|
|
348
|
+
} else {
|
|
349
|
+
setPagination((prev) => ({ ...prev, current: 1 }));
|
|
350
|
+
loadData();
|
|
351
|
+
}
|
|
352
|
+
}, [onRefresh, filterParams, loadData]);
|
|
353
|
+
const handleColumnSettingsConfirm = (0, import_react.useCallback)((fields) => {
|
|
354
|
+
setColumnFields(fields);
|
|
262
355
|
}, []);
|
|
356
|
+
const handleColumnSettingsReset = (0, import_react.useCallback)(() => {
|
|
357
|
+
setColumnFields(defaultColumnFields);
|
|
358
|
+
}, [defaultColumnFields]);
|
|
263
359
|
const extraNode = titleExtra ?? titleSuffix;
|
|
264
360
|
const titleExtraNode = extraNode ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "slp-title-extra", children: [
|
|
265
361
|
showTitleExtraDivider && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "slp-divider" }),
|
|
@@ -287,7 +383,7 @@ var StatisticsListPage = (props) => {
|
|
|
287
383
|
value: searchValue,
|
|
288
384
|
onChange: (e) => setSearchValue(e.target.value),
|
|
289
385
|
placeholder: searchPlaceholder,
|
|
290
|
-
style: { width:
|
|
386
|
+
style: { width: searchWidth },
|
|
291
387
|
onPressEnter: handleSearch,
|
|
292
388
|
suffix: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
293
389
|
import_shared_components.SvgIcon,
|
|
@@ -319,12 +415,52 @@ var StatisticsListPage = (props) => {
|
|
|
319
415
|
] }),
|
|
320
416
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "slp-table-header-right", children: [
|
|
321
417
|
toolbarRightExtra,
|
|
322
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
323
|
-
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
419
|
+
import_ColumnSettingsPanel.default,
|
|
420
|
+
{
|
|
421
|
+
fields: columnFields,
|
|
422
|
+
defaultFields: defaultColumnFields,
|
|
423
|
+
onConfirm: handleColumnSettingsConfirm,
|
|
424
|
+
onReset: handleColumnSettingsReset,
|
|
425
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "列设置", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
426
|
+
import_basic_components.CompanyButton,
|
|
427
|
+
{
|
|
428
|
+
type: "default",
|
|
429
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "setting", size: 16 })
|
|
430
|
+
}
|
|
431
|
+
) })
|
|
432
|
+
}
|
|
433
|
+
),
|
|
434
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
435
|
+
import_basic_components.CompanyDropdown,
|
|
436
|
+
{
|
|
437
|
+
open: densityOpen,
|
|
438
|
+
onOpenChange: setDensityOpen,
|
|
439
|
+
trigger: ["click"],
|
|
440
|
+
popupRender: () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
441
|
+
import_basic_components.CompanyMenu,
|
|
442
|
+
{
|
|
443
|
+
onClick: handleDensityMenuClick,
|
|
444
|
+
items: densityMenuItems,
|
|
445
|
+
selectedKeys: [effectiveSize],
|
|
446
|
+
style: { minWidth: 80 }
|
|
447
|
+
}
|
|
448
|
+
),
|
|
449
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: `密度:${sizeLabels[effectiveSize]}`, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
450
|
+
import_basic_components.CompanyButton,
|
|
451
|
+
{
|
|
452
|
+
type: "default",
|
|
453
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "density", size: 16 })
|
|
454
|
+
}
|
|
455
|
+
) })
|
|
456
|
+
}
|
|
457
|
+
),
|
|
458
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_basic_components.CompanyTooltip, { title: "刷新", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
459
|
+
import_basic_components.CompanyButton,
|
|
324
460
|
{
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
461
|
+
type: "default",
|
|
462
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_shared_components.SvgIcon, { href: "refresh", size: 16 }),
|
|
463
|
+
onClick: handleRefresh
|
|
328
464
|
}
|
|
329
465
|
) })
|
|
330
466
|
] })
|
|
@@ -353,7 +489,7 @@ var StatisticsListPage = (props) => {
|
|
|
353
489
|
loading,
|
|
354
490
|
pagination: false,
|
|
355
491
|
rowKey,
|
|
356
|
-
size,
|
|
492
|
+
size: effectiveSize,
|
|
357
493
|
scroll: { y: scrollY },
|
|
358
494
|
locale: { emptyText }
|
|
359
495
|
}
|
|
@@ -110,25 +110,6 @@
|
|
|
110
110
|
background: var(--primary-1, #fff1e6);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
.icon-only-btn {
|
|
115
|
-
display: inline-flex;
|
|
116
|
-
align-items: center;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
width: 32px;
|
|
119
|
-
height: 32px;
|
|
120
|
-
border: 1px solid var(--color-border, rgba(5, 5, 5, 0.15));
|
|
121
|
-
border-radius: calc(var(--border-radius-base, 8) * 1px);
|
|
122
|
-
cursor: pointer;
|
|
123
|
-
color: var(--color-text-tertiary, rgba(0, 0, 0, 0.45));
|
|
124
|
-
transition: all var(--motion-duration-fast, 0.2s)
|
|
125
|
-
var(--motion-ease-in-out, cubic-bezier(0.4, 0, 0.2, 1));
|
|
126
|
-
|
|
127
|
-
&:hover {
|
|
128
|
-
background: var(--primary-1, #fff1e6);
|
|
129
|
-
color: var(--primary-color, #f95914);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
113
|
}
|
|
133
114
|
|
|
134
115
|
.slp-filter-tags {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { UploadProps } from "antd";
|
|
3
|
-
|
|
3
|
+
declare const CompanyUpload: React.ForwardRefExoticComponent<UploadProps<any> & React.RefAttributes<import("antd/es/upload").UploadRef<any>>> & {
|
|
4
4
|
<U extends any>(props: UploadProps<U> & {
|
|
5
5
|
children?: React.ReactNode;
|
|
6
6
|
} & React.RefAttributes<import("antd/es/upload").UploadRef<U>>): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
@@ -11,3 +11,4 @@ export declare const CompanyUpload: React.ForwardRefExoticComponent<UploadProps<
|
|
|
11
11
|
};
|
|
12
12
|
LIST_IGNORE: string;
|
|
13
13
|
};
|
|
14
|
+
export { CompanyUpload };
|
|
@@ -8,9 +8,17 @@ import React from "react";
|
|
|
8
8
|
import { Upload as AntdUpload, ConfigProvider } from "antd";
|
|
9
9
|
import { companyTheme } from "../../theme";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
|
|
11
|
+
var CompanyUpload = function CompanyUpload(props) {
|
|
12
12
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
13
13
|
theme: companyTheme,
|
|
14
14
|
children: /*#__PURE__*/_jsx(AntdUpload, _objectSpread({}, props))
|
|
15
15
|
});
|
|
16
|
-
};
|
|
16
|
+
};
|
|
17
|
+
CompanyUpload.Dragger = function (props) {
|
|
18
|
+
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
19
|
+
theme: companyTheme,
|
|
20
|
+
children: /*#__PURE__*/_jsx(AntdUpload.Dragger, _objectSpread({}, props))
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
CompanyUpload.LIST_IGNORE = AntdUpload.LIST_IGNORE;
|
|
24
|
+
export { CompanyUpload };
|
|
@@ -22,7 +22,7 @@ import { CompanyTable, CompanyButton, CompanyPagination, CompanyDropdown, Compan
|
|
|
22
22
|
import { ConfigProvider } from 'antd';
|
|
23
23
|
import zhCN from 'antd/locale/zh_CN';
|
|
24
24
|
import FilterForm from "../FilterForm";
|
|
25
|
-
import { SvgIcon, FilterOptionsDrawer } from "../../shared-components";
|
|
25
|
+
import { SvgIcon, FilterOptionsDrawer, EllipsisText } from "../../shared-components";
|
|
26
26
|
import ColumnSettingsPanel from "../ColumnSettingsPanel";
|
|
27
27
|
import "./index.scss";
|
|
28
28
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -329,19 +329,29 @@ export default function SmartListTemplate(_ref) {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
var regularColumns = visibleFieldDefs.map(function (field) {
|
|
332
|
+
var enableEllipsis = field.ellipsis !== false;
|
|
332
333
|
return {
|
|
333
334
|
title: field.label,
|
|
334
335
|
dataIndex: field.key,
|
|
335
336
|
key: field.key,
|
|
336
337
|
width: field.width || 120,
|
|
337
338
|
fixed: field.fixed,
|
|
338
|
-
ellipsis:
|
|
339
|
-
render:
|
|
340
|
-
var
|
|
339
|
+
ellipsis: enableEllipsis,
|
|
340
|
+
render: function render(_, record) {
|
|
341
|
+
var customContent = bodyCell ? bodyCell(_objectSpread(_objectSpread({}, field), {}, {
|
|
341
342
|
key: field.key
|
|
342
|
-
}), record);
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
}), record) : null;
|
|
344
|
+
if (customContent !== null) {
|
|
345
|
+
return customContent;
|
|
346
|
+
}
|
|
347
|
+
var text = record[field.key];
|
|
348
|
+
if (!enableEllipsis || text === null || text === undefined) {
|
|
349
|
+
return text;
|
|
350
|
+
}
|
|
351
|
+
return /*#__PURE__*/_jsx(EllipsisText, {
|
|
352
|
+
children: text
|
|
353
|
+
});
|
|
354
|
+
}
|
|
345
355
|
};
|
|
346
356
|
});
|
|
347
357
|
if (actionField) {
|
|
@@ -58,12 +58,23 @@ export interface StatisticsListPageProps<T = Record<string, unknown>> {
|
|
|
58
58
|
statisticCards?: StatisticCardConfig[];
|
|
59
59
|
/** 顶部搜索框占位符 */
|
|
60
60
|
searchPlaceholder?: string;
|
|
61
|
+
/** 顶部搜索框宽度 */
|
|
62
|
+
searchWidth?: number | string;
|
|
61
63
|
/** 顶部搜索对应字段 key(提交到 fetchData 的参数名) */
|
|
62
64
|
searchKey?: string;
|
|
63
65
|
/** 高级筛选字段(抽屉内) */
|
|
64
66
|
filterFields?: StatisticsFilterField[];
|
|
65
67
|
/** 表格列配置 */
|
|
66
68
|
columns: StatisticsColumn<T>[];
|
|
69
|
+
/** 操作列配置:传入后自动在表格右侧追加操作列(固定右侧) */
|
|
70
|
+
actionColumn?: {
|
|
71
|
+
/** 操作列宽度 */
|
|
72
|
+
width?: number;
|
|
73
|
+
/** 操作列标题 */
|
|
74
|
+
title?: string;
|
|
75
|
+
/** 操作列渲染函数 */
|
|
76
|
+
render: (record: T, index: number) => ReactNode;
|
|
77
|
+
};
|
|
67
78
|
/** 数据请求函数 - 严格对齐 PageResponse 契约 */
|
|
68
79
|
fetchData?: (params: Record<string, unknown>) => Promise<PageResponse<T>>;
|
|
69
80
|
/** 默认分页大小 */
|
|
@@ -72,6 +83,10 @@ export interface StatisticsListPageProps<T = Record<string, unknown>> {
|
|
|
72
83
|
rowKey?: string | ((record: T) => string);
|
|
73
84
|
/** 表格尺寸 */
|
|
74
85
|
size?: 'small' | 'middle' | 'large';
|
|
86
|
+
/** 密度切换回调(不传则组件内部自治管理密度) */
|
|
87
|
+
onSizeChange?: (size: 'small' | 'middle' | 'large') => void;
|
|
88
|
+
/** 刷新回调(不传则不显示刷新按钮;传入后点击会用当前 filterParams 触发) */
|
|
89
|
+
onRefresh?: (filterParams: Record<string, unknown>) => void;
|
|
75
90
|
/** 表格 Y 轴滚动高度(默认自适应视口) */
|
|
76
91
|
scrollY?: string | number;
|
|
77
92
|
/** 表格空状态文案 */
|
|
@@ -27,8 +27,9 @@ import { useState, useEffect, useCallback, useMemo, Component } from 'react';
|
|
|
27
27
|
import { Card, Empty, Space, Typography, ConfigProvider } from 'antd';
|
|
28
28
|
import zhCN from 'antd/locale/zh_CN';
|
|
29
29
|
import { FilterOutlined, CloseOutlined, DeleteOutlined } from '@ant-design/icons';
|
|
30
|
-
import { CompanyButton, CompanyInput, CompanySelect, CompanyTable, CompanyPagination, CompanyDrawer, CompanyDatePicker, CompanyTooltip, CompanyMessage, CompanyForm } from "../../basic-components";
|
|
31
|
-
import { PageTitle, SvgIcon } from "../../shared-components";
|
|
30
|
+
import { CompanyButton, CompanyInput, CompanySelect, CompanyTable, CompanyPagination, CompanyDrawer, CompanyDatePicker, CompanyTooltip, CompanyMessage, CompanyForm, CompanyDropdown, CompanyMenu } from "../../basic-components";
|
|
31
|
+
import { PageTitle, SvgIcon, EllipsisText } from "../../shared-components";
|
|
32
|
+
import ColumnSettingsPanel from "../ColumnSettingsPanel";
|
|
32
33
|
import { useCompanyToken } from "../../theme/useCompanyToken";
|
|
33
34
|
import "./index.scss";
|
|
34
35
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -107,11 +108,14 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
107
108
|
statisticCards = props.statisticCards,
|
|
108
109
|
_props$searchPlacehol = props.searchPlaceholder,
|
|
109
110
|
searchPlaceholder = _props$searchPlacehol === void 0 ? '请输入' : _props$searchPlacehol,
|
|
111
|
+
_props$searchWidth = props.searchWidth,
|
|
112
|
+
searchWidth = _props$searchWidth === void 0 ? 280 : _props$searchWidth,
|
|
110
113
|
_props$searchKey = props.searchKey,
|
|
111
114
|
searchKey = _props$searchKey === void 0 ? 'keyword' : _props$searchKey,
|
|
112
115
|
_props$filterFields = props.filterFields,
|
|
113
116
|
filterFields = _props$filterFields === void 0 ? [] : _props$filterFields,
|
|
114
117
|
columns = props.columns,
|
|
118
|
+
actionColumn = props.actionColumn,
|
|
115
119
|
fetchData = props.fetchData,
|
|
116
120
|
_props$defaultPageSiz = props.defaultPageSize,
|
|
117
121
|
defaultPageSize = _props$defaultPageSiz === void 0 ? 20 : _props$defaultPageSiz,
|
|
@@ -119,6 +123,8 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
119
123
|
rowKey = _props$rowKey === void 0 ? 'id' : _props$rowKey,
|
|
120
124
|
_props$size = props.size,
|
|
121
125
|
size = _props$size === void 0 ? 'middle' : _props$size,
|
|
126
|
+
onSizeChange = props.onSizeChange,
|
|
127
|
+
onRefresh = props.onRefresh,
|
|
122
128
|
_props$scrollY = props.scrollY,
|
|
123
129
|
scrollY = _props$scrollY === void 0 ? 'calc(100vh - 420px)' : _props$scrollY,
|
|
124
130
|
_props$emptyText = props.emptyText,
|
|
@@ -151,23 +157,65 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
151
157
|
filterParams = _useState10[0],
|
|
152
158
|
setFilterParams = _useState10[1];
|
|
153
159
|
|
|
154
|
-
//
|
|
155
|
-
var _useState11 = useState(
|
|
160
|
+
// 密度切换:受控优先,非受控走内部 state
|
|
161
|
+
var _useState11 = useState(size),
|
|
156
162
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
157
|
-
|
|
158
|
-
|
|
163
|
+
internalSize = _useState12[0],
|
|
164
|
+
setInternalSize = _useState12[1];
|
|
165
|
+
var effectiveSize = onSizeChange ? size : internalSize;
|
|
159
166
|
var _useState13 = useState(false),
|
|
160
167
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
168
|
+
densityOpen = _useState14[0],
|
|
169
|
+
setDensityOpen = _useState14[1];
|
|
170
|
+
|
|
171
|
+
// 列设置:从 columns prop 派生为 ColumnField[],支持勾选显隐
|
|
172
|
+
var _useState15 = useState(function () {
|
|
173
|
+
return (columns || []).filter(function (col) {
|
|
174
|
+
return col.key !== 'action';
|
|
175
|
+
}).map(function (col) {
|
|
176
|
+
return {
|
|
177
|
+
key: col.key,
|
|
178
|
+
label: col.label,
|
|
179
|
+
visible: col.visible !== false,
|
|
180
|
+
width: col.width,
|
|
181
|
+
fixed: col.fixed
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}),
|
|
185
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
186
|
+
columnFields = _useState16[0],
|
|
187
|
+
setColumnFields = _useState16[1];
|
|
188
|
+
var defaultColumnFields = useMemo(function () {
|
|
189
|
+
return (columns || []).filter(function (col) {
|
|
190
|
+
return col.key !== 'action';
|
|
191
|
+
}).map(function (col) {
|
|
192
|
+
return {
|
|
193
|
+
key: col.key,
|
|
194
|
+
label: col.label,
|
|
195
|
+
visible: col.visible !== false,
|
|
196
|
+
width: col.width,
|
|
197
|
+
fixed: col.fixed
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
}, [columns]);
|
|
201
|
+
|
|
202
|
+
// 表格数据
|
|
203
|
+
var _useState17 = useState([]),
|
|
204
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
205
|
+
dataSource = _useState18[0],
|
|
206
|
+
setDataSource = _useState18[1];
|
|
207
|
+
var _useState19 = useState(false),
|
|
208
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
209
|
+
loading = _useState20[0],
|
|
210
|
+
setLoading = _useState20[1];
|
|
211
|
+
var _useState21 = useState({
|
|
164
212
|
current: 1,
|
|
165
213
|
pageSize: defaultPageSize,
|
|
166
214
|
total: 0
|
|
167
215
|
}),
|
|
168
|
-
|
|
169
|
-
pagination =
|
|
170
|
-
setPagination =
|
|
216
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
217
|
+
pagination = _useState22[0],
|
|
218
|
+
setPagination = _useState22[1];
|
|
171
219
|
|
|
172
220
|
// 加载数据(空指针防御 + try/catch)
|
|
173
221
|
var loadData = useCallback( /*#__PURE__*/function () {
|
|
@@ -366,26 +414,114 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
366
414
|
}
|
|
367
415
|
}, [fetchData, filterParams, searchKey, searchValue]);
|
|
368
416
|
|
|
369
|
-
//
|
|
417
|
+
// 构造表格列(结合列设置 visible 状态 + EllipsisText 接管省略)
|
|
418
|
+
var visibleColumnMap = useMemo(function () {
|
|
419
|
+
var map = new Map();
|
|
420
|
+
columnFields.forEach(function (f) {
|
|
421
|
+
return map.set(f.key, f.visible);
|
|
422
|
+
});
|
|
423
|
+
return map;
|
|
424
|
+
}, [columnFields]);
|
|
370
425
|
var tableColumns = useMemo(function () {
|
|
371
|
-
|
|
372
|
-
|
|
426
|
+
var list = (columns || []).filter(function (col) {
|
|
427
|
+
if (col.key === 'action') return false;
|
|
428
|
+
var visible = visibleColumnMap.get(col.key);
|
|
429
|
+
return visible === undefined ? col.visible !== false : visible;
|
|
373
430
|
}).map(function (col) {
|
|
374
|
-
|
|
431
|
+
var base = {
|
|
375
432
|
key: col.key,
|
|
376
433
|
dataIndex: col.key,
|
|
377
434
|
title: col.label,
|
|
378
435
|
width: col.width,
|
|
379
|
-
fixed: col.fixed
|
|
380
|
-
render: col.render
|
|
436
|
+
fixed: col.fixed
|
|
381
437
|
};
|
|
438
|
+
if (col.render) {
|
|
439
|
+
base.render = col.render;
|
|
440
|
+
} else {
|
|
441
|
+
base.ellipsis = false;
|
|
442
|
+
base.render = function (text) {
|
|
443
|
+
var content = text === undefined || text === null ? '--' : String(text);
|
|
444
|
+
return /*#__PURE__*/_jsx(EllipsisText, {
|
|
445
|
+
children: content
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
return base;
|
|
382
450
|
});
|
|
383
|
-
|
|
451
|
+
if (actionColumn) {
|
|
452
|
+
list.push({
|
|
453
|
+
key: 'action',
|
|
454
|
+
title: actionColumn.title || '操作',
|
|
455
|
+
width: actionColumn.width || 148,
|
|
456
|
+
fixed: 'right',
|
|
457
|
+
align: 'left',
|
|
458
|
+
onHeaderCell: function onHeaderCell() {
|
|
459
|
+
return {
|
|
460
|
+
style: {
|
|
461
|
+
paddingLeft: 24,
|
|
462
|
+
paddingRight: 16
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
},
|
|
466
|
+
render: function render(_, record, index) {
|
|
467
|
+
return actionColumn.render(record, index);
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
return list;
|
|
472
|
+
}, [columns, visibleColumnMap, actionColumn]);
|
|
384
473
|
|
|
385
|
-
//
|
|
386
|
-
var
|
|
387
|
-
|
|
474
|
+
// 密度菜单项(对齐 SmartListTemplate)
|
|
475
|
+
var sizeLabels = {
|
|
476
|
+
small: '紧凑',
|
|
477
|
+
middle: '默认',
|
|
478
|
+
large: '宽松'
|
|
479
|
+
};
|
|
480
|
+
var densityMenuItems = useMemo(function () {
|
|
481
|
+
return [{
|
|
482
|
+
key: 'large',
|
|
483
|
+
label: '宽松'
|
|
484
|
+
}, {
|
|
485
|
+
key: 'middle',
|
|
486
|
+
label: '默认'
|
|
487
|
+
}, {
|
|
488
|
+
key: 'small',
|
|
489
|
+
label: '紧凑'
|
|
490
|
+
}];
|
|
388
491
|
}, []);
|
|
492
|
+
var handleDensityMenuClick = useCallback(function (info) {
|
|
493
|
+
var next = info.key;
|
|
494
|
+
if (onSizeChange) {
|
|
495
|
+
onSizeChange(next);
|
|
496
|
+
} else {
|
|
497
|
+
setInternalSize(next);
|
|
498
|
+
}
|
|
499
|
+
setDensityOpen(false);
|
|
500
|
+
}, [onSizeChange]);
|
|
501
|
+
|
|
502
|
+
// 刷新:优先调用外部 onRefresh,否则用当前 filterParams 触发内部重新拉取
|
|
503
|
+
var handleRefresh = useCallback(function () {
|
|
504
|
+
if (onRefresh) {
|
|
505
|
+
onRefresh(filterParams);
|
|
506
|
+
} else {
|
|
507
|
+
setPagination(function (prev) {
|
|
508
|
+
return _objectSpread(_objectSpread({}, prev), {}, {
|
|
509
|
+
current: 1
|
|
510
|
+
});
|
|
511
|
+
});
|
|
512
|
+
loadData();
|
|
513
|
+
}
|
|
514
|
+
}, [onRefresh, filterParams, loadData]);
|
|
515
|
+
|
|
516
|
+
// 列设置:确认勾选结果
|
|
517
|
+
var handleColumnSettingsConfirm = useCallback(function (fields) {
|
|
518
|
+
setColumnFields(fields);
|
|
519
|
+
}, []);
|
|
520
|
+
|
|
521
|
+
// 列设置:重置为默认
|
|
522
|
+
var handleColumnSettingsReset = useCallback(function () {
|
|
523
|
+
setColumnFields(defaultColumnFields);
|
|
524
|
+
}, [defaultColumnFields]);
|
|
389
525
|
|
|
390
526
|
// 标题右侧补充区域:优先 titleExtra,兼容旧 titleSuffix,按 showTitleExtraDivider 决定是否带前置分割线
|
|
391
527
|
var extraNode = titleExtra !== null && titleExtra !== void 0 ? titleExtra : titleSuffix;
|
|
@@ -429,7 +565,7 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
429
565
|
},
|
|
430
566
|
placeholder: searchPlaceholder,
|
|
431
567
|
style: {
|
|
432
|
-
width:
|
|
568
|
+
width: searchWidth
|
|
433
569
|
},
|
|
434
570
|
onPressEnter: handleSearch,
|
|
435
571
|
suffix: /*#__PURE__*/_jsx(SvgIcon, {
|
|
@@ -449,16 +585,55 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
449
585
|
}), toolbarLeftExtra]
|
|
450
586
|
}), /*#__PURE__*/_jsxs("div", {
|
|
451
587
|
className: "slp-table-header-right",
|
|
452
|
-
children: [toolbarRightExtra, /*#__PURE__*/_jsx(
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
588
|
+
children: [toolbarRightExtra, /*#__PURE__*/_jsx(ColumnSettingsPanel, {
|
|
589
|
+
fields: columnFields,
|
|
590
|
+
defaultFields: defaultColumnFields,
|
|
591
|
+
onConfirm: handleColumnSettingsConfirm,
|
|
592
|
+
onReset: handleColumnSettingsReset,
|
|
593
|
+
children: /*#__PURE__*/_jsx(CompanyTooltip, {
|
|
594
|
+
title: "\u5217\u8BBE\u7F6E",
|
|
595
|
+
children: /*#__PURE__*/_jsx(CompanyButton, {
|
|
596
|
+
type: "default",
|
|
597
|
+
icon: /*#__PURE__*/_jsx(SvgIcon, {
|
|
598
|
+
href: "setting",
|
|
599
|
+
size: 16
|
|
600
|
+
})
|
|
460
601
|
})
|
|
461
602
|
})
|
|
603
|
+
}), /*#__PURE__*/_jsx(CompanyDropdown, {
|
|
604
|
+
open: densityOpen,
|
|
605
|
+
onOpenChange: setDensityOpen,
|
|
606
|
+
trigger: ['click'],
|
|
607
|
+
popupRender: function popupRender() {
|
|
608
|
+
return /*#__PURE__*/_jsx(CompanyMenu, {
|
|
609
|
+
onClick: handleDensityMenuClick,
|
|
610
|
+
items: densityMenuItems,
|
|
611
|
+
selectedKeys: [effectiveSize],
|
|
612
|
+
style: {
|
|
613
|
+
minWidth: 80
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
},
|
|
617
|
+
children: /*#__PURE__*/_jsx(CompanyTooltip, {
|
|
618
|
+
title: "\u5BC6\u5EA6\uFF1A".concat(sizeLabels[effectiveSize]),
|
|
619
|
+
children: /*#__PURE__*/_jsx(CompanyButton, {
|
|
620
|
+
type: "default",
|
|
621
|
+
icon: /*#__PURE__*/_jsx(SvgIcon, {
|
|
622
|
+
href: "density",
|
|
623
|
+
size: 16
|
|
624
|
+
})
|
|
625
|
+
})
|
|
626
|
+
})
|
|
627
|
+
}), /*#__PURE__*/_jsx(CompanyTooltip, {
|
|
628
|
+
title: "\u5237\u65B0",
|
|
629
|
+
children: /*#__PURE__*/_jsx(CompanyButton, {
|
|
630
|
+
type: "default",
|
|
631
|
+
icon: /*#__PURE__*/_jsx(SvgIcon, {
|
|
632
|
+
href: "refresh",
|
|
633
|
+
size: 16
|
|
634
|
+
}),
|
|
635
|
+
onClick: handleRefresh
|
|
636
|
+
})
|
|
462
637
|
})]
|
|
463
638
|
})]
|
|
464
639
|
}), filterTags.length > 0 && /*#__PURE__*/_jsxs("div", {
|
|
@@ -493,7 +668,7 @@ export var StatisticsListPage = function StatisticsListPage(props) {
|
|
|
493
668
|
loading: loading,
|
|
494
669
|
pagination: false,
|
|
495
670
|
rowKey: rowKey,
|
|
496
|
-
size:
|
|
671
|
+
size: effectiveSize,
|
|
497
672
|
scroll: {
|
|
498
673
|
y: scrollY
|
|
499
674
|
},
|
|
@@ -110,25 +110,6 @@
|
|
|
110
110
|
background: var(--primary-1, #fff1e6);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
.icon-only-btn {
|
|
115
|
-
display: inline-flex;
|
|
116
|
-
align-items: center;
|
|
117
|
-
justify-content: center;
|
|
118
|
-
width: 32px;
|
|
119
|
-
height: 32px;
|
|
120
|
-
border: 1px solid var(--color-border, rgba(5, 5, 5, 0.15));
|
|
121
|
-
border-radius: calc(var(--border-radius-base, 8) * 1px);
|
|
122
|
-
cursor: pointer;
|
|
123
|
-
color: var(--color-text-tertiary, rgba(0, 0, 0, 0.45));
|
|
124
|
-
transition: all var(--motion-duration-fast, 0.2s)
|
|
125
|
-
var(--motion-ease-in-out, cubic-bezier(0.4, 0, 0.2, 1));
|
|
126
|
-
|
|
127
|
-
&:hover {
|
|
128
|
-
background: var(--primary-1, #fff1e6);
|
|
129
|
-
color: var(--primary-color, #f95914);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
113
|
}
|
|
133
114
|
|
|
134
115
|
.slp-filter-tags {
|