zmdms-webui 2.4.2 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -289,12 +289,21 @@ interface ITableRefHandel {
289
289
  */
290
290
  clearErrorClass?: () => void;
291
291
  /**
292
- * 滚动
293
- */
294
- scrollTo?: (obj: {
295
- row: number;
296
- y: number;
297
- vid: string;
292
+ * 滚动到指定位置
293
+ * 虚拟滚动时:使用 virtuallist-antd 的 scrollTo 方法,需要传 row、y、vid
294
+ * 普通滚动时:操作 DOM,可以传 y、x 或 index
295
+ * @param options.row - 虚拟滚动时滚动到第几行
296
+ * @param options.y - 垂直滚动的像素值
297
+ * @param options.x - 水平滚动的像素值
298
+ * @param options.vid - 虚拟滚动的唯一标识符
299
+ * @param options.index - 滚动到指定行索引(普通滚动)
300
+ */
301
+ scrollTo?: (options: {
302
+ row?: number;
303
+ y?: number;
304
+ x?: number;
305
+ vid?: string;
306
+ index?: number;
298
307
  }) => void;
299
308
  /**
300
309
  * 重置
@@ -19,7 +19,7 @@ import useSummary from './useSummary.js';
19
19
  import useInnerPagination, { getInnerIndex } from './useInnerPagination.js';
20
20
  import { useScuRfresh, useCustomSort, useCalcScrollY, useEditChange, useMoveRowChange, useAddAndDelChange, useCustomFilter, useAutoMerge } from './hooks.js';
21
21
  import { HTML5Backend } from '../node_modules/react-dnd-html5-backend/dist/index.js';
22
- import { VList, scrollTo } from '../node_modules/virtuallist-antd/dist/index.es.js';
22
+ import { scrollTo, VList } from '../node_modules/virtuallist-antd/dist/index.es.js';
23
23
  import useTableValidate, { tableValidate } from './useTableValidate.js';
24
24
  import TitleDirectionColumn from './components/TitleDirectionColumn.js';
25
25
  import { useExcelExport } from './excel.js';
@@ -193,6 +193,43 @@ var Table = function (props) {
193
193
  });
194
194
  // 表格验证
195
195
  var _y = useTableValidate(), tableRef = _y.tableRef, getCurrentTable = _y.getCurrentTable, clearErrorClass = _y.clearErrorClass;
196
+ // 滚动条控制方法
197
+ var scrollToPosition = useMemoizedFn(function (options) {
198
+ var _a;
199
+ // 如果是虚拟滚动,使用 virtuallist-antd 的 scrollTo 方法
200
+ if (virtualKey && options.vid) {
201
+ scrollTo({
202
+ row: options.row || 0,
203
+ y: options.y || 0,
204
+ vid: options.vid || virtualKey,
205
+ });
206
+ }
207
+ else {
208
+ // 普通滚动,操作 DOM
209
+ var tableBody = (_a = tableRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(".ant-table-body");
210
+ if (tableBody) {
211
+ // 如果指定了 y 值,直接滚动到指定位置
212
+ if (typeof options.y === "number") {
213
+ tableBody.scrollTop = options.y;
214
+ }
215
+ // 如果指定了 x 值,直接滚动到指定位置
216
+ if (typeof options.x === "number") {
217
+ tableBody.scrollLeft = options.x;
218
+ }
219
+ // 如果指定了 index,滚动到指定行
220
+ if (typeof options.index === "number") {
221
+ var rows = tableBody.querySelectorAll(".ant-table-row");
222
+ var targetRow = rows[options.index];
223
+ if (targetRow) {
224
+ targetRow.scrollIntoView({
225
+ behavior: "smooth",
226
+ block: "center",
227
+ });
228
+ }
229
+ }
230
+ }
231
+ }
232
+ });
196
233
  // 虚拟滚动选项
197
234
  var vComponents = useMemo(function () {
198
235
  if (virtualKey) {
@@ -307,9 +344,13 @@ var Table = function (props) {
307
344
  }); },
308
345
  /** 清除错误样式 */
309
346
  clearErrorClass: clearErrorClass,
310
- /** 虚拟滚动 滚动到顶部方法 */
311
- scrollTo: function (obj) {
312
- scrollTo(obj);
347
+ /**
348
+ * 滚动到指定位置
349
+ * 虚拟滚动时使用 virtuallist-antd 的 scrollTo 方法
350
+ * 普通滚动时操作 DOM
351
+ */
352
+ scrollTo: function (options) {
353
+ scrollToPosition(options);
313
354
  },
314
355
  /** 动态列配置重置 */
315
356
  onResetDynamicList: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",