zmdms-webui 1.4.0 → 1.4.2

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.
@@ -12,15 +12,22 @@ import { Popover } from 'antd';
12
12
 
13
13
  var EnhanceCell = function (props) {
14
14
  var _a, _b;
15
- var record = props.record, propsIndex = props.index, editable = props.editable, editableConfig = props.editableConfig, dataIndex = props.dataIndex, title = props.title, onEditableSave = props.onEditableSave, dataSourceRef = props.dataSourceRef; props.onMouseEnter; props.onMouseLeave; var children = props.children, currentPage = props.currentPage, isValidate = props.isValidate, validate = props.validate, isRealTimeValidate = props.isRealTimeValidate, insertTableFromClipboard = props.insertTableFromClipboard, resetProps = __rest(props, ["record", "index", "editable", "editableConfig", "dataIndex", "title", "onEditableSave", "dataSourceRef", "onMouseEnter", "onMouseLeave", "children", "currentPage", "isValidate", "validate", "isRealTimeValidate", "insertTableFromClipboard"]);
15
+ var record = props.record, propsIndex = props.index, editable = props.editable, editableConfig = props.editableConfig, dataIndex = props.dataIndex, title = props.title, onEditableSave = props.onEditableSave, dataSourceRef = props.dataSourceRef; props.onMouseEnter; props.onMouseLeave; var children = props.children, currentPage = props.currentPage, isValidate = props.isValidate, validate = props.validate, isRealTimeValidate = props.isRealTimeValidate, insertTableFromClipboard = props.insertTableFromClipboard, filterConfigRef = props.filterConfigRef, __rowKey = props.__rowKey, resetProps = __rest(props, ["record", "index", "editable", "editableConfig", "dataIndex", "title", "onEditableSave", "dataSourceRef", "onMouseEnter", "onMouseLeave", "children", "currentPage", "isValidate", "validate", "isRealTimeValidate", "insertTableFromClipboard", "filterConfigRef", "__rowKey"]);
16
16
  // 当前单元格的类型
17
17
  var tdType = editableConfig === null || editableConfig === void 0 ? void 0 : editableConfig.type;
18
18
  // 设置最新的index
19
- var index = getInnerIndex(currentPage, propsIndex);
19
+ var index = getInnerIndex(currentPage, propsIndex, {
20
+ filterConfigRef: filterConfigRef,
21
+ rowKey: __rowKey,
22
+ record: record,
23
+ dataSourceRef: dataSourceRef,
24
+ });
20
25
  // 最新的record
21
- // const newRecord = dataSourceRef?.current?.[index] || record;
22
- // TODO: 这里不能用之前的那种方式取值,因为如果采用过滤的模式,那么数据可能会错行
23
- var newRecord = record || ((_a = dataSourceRef === null || dataSourceRef === void 0 ? void 0 : dataSourceRef.current) === null || _a === void 0 ? void 0 : _a[index]);
26
+ // 支持过滤模式。过滤模式时,必须要通过实际数据找索引。
27
+ var newRecord = ((_a = dataSourceRef === null || dataSourceRef === void 0 ? void 0 : dataSourceRef.current) === null || _a === void 0 ? void 0 : _a[index]) || record;
28
+ // TODO: 这里不能用之前的那种方式取值,因为如果采用过滤的模式,那么数据可能会错行。
29
+ // 20250114:用下面这种方式取值,如果是配置了scu的话,值就会有问题。
30
+ // const newRecord = record || dataSourceRef?.current?.[index];
24
31
  // 当前数据
25
32
  var _c = useState(newRecord ? newRecord[dataIndex] : undefined), val = _c[0], setVal = _c[1];
26
33
  var iptNumberRef = useRef();
@@ -1,6 +1,6 @@
1
1
  import { __rest, __assign, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { memo, useMemo, useCallback, useImperativeHandle } from 'react';
3
+ import { memo, useRef, useMemo, useCallback, useImperativeHandle } from 'react';
4
4
  import { Table as Table$1 } from 'antd';
5
5
  import { BasicBodyRow, MoveBodyRow } from './components/EnhanceBodyRow.js';
6
6
  import EnhanceCell from './components/EnhanceBodyCell.js';
@@ -74,11 +74,14 @@ var Table = function (props) {
74
74
  }), paginationConfig = _r.paginationConfig, currentPage = _r.currentPage, setCurrent = _r.setCurrent, pageSize = _r.pageSize;
75
75
  // 内部表格编辑事件
76
76
  var onEditableSave = useEditChange(dataSourceRef, onTableChange);
77
+ // 记录表头过滤的一些配置(通过ref记录,key => filter) 复制整列、过滤后修改数据,需要先走过滤
78
+ var filterConfigRef = useRef({});
77
79
  // 内部表格拖拽事件
78
80
  var onRow = useMoveRowChange(dataSourceRef, onTableChange, {
79
81
  isMove: isMove,
80
82
  refreshScuCell: refreshScuCell,
81
83
  currentPage: currentPage,
84
+ filterConfigRef: filterConfigRef,
82
85
  }).onRow;
83
86
  // 内部表格新增删除事件
84
87
  var onAddAndDel = useAddAndDelChange(dataSourceRef, onTableChange, {
@@ -88,6 +91,7 @@ var Table = function (props) {
88
91
  refreshScuCell: refreshScuCell,
89
92
  isAddAndDelAuto: isAddAndDelAuto,
90
93
  currentPage: currentPage,
94
+ filterConfigRef: filterConfigRef,
91
95
  });
92
96
  // 处理列配置信息 得到新的列配置信息
93
97
  var newColumns = useColumns(columns, {
@@ -125,6 +129,7 @@ var Table = function (props) {
125
129
  // 是否隐藏某一列的增加按钮
126
130
  hiddenAddBtnHandleRef: hiddenAddBtnHandleRef,
127
131
  rowKey: props.rowKey,
132
+ filterConfigRef: filterConfigRef,
128
133
  }).newColumns;
129
134
  // 内部表格总结栏
130
135
  var getSummaryHandle = useSummary(summaryConfig, newColumns, {
@@ -210,9 +215,14 @@ var Table = function (props) {
210
215
  // 暴露给外部一些方法
211
216
  useImperativeHandle(tableRefHandle, function () {
212
217
  return {
213
- /** 获取真实的索引,内部分页时使用 */
214
- getRealyIndex: function (index) {
215
- return getInnerIndex(currentPage, index);
218
+ /** 获取真实的索引,内部分页时使用 record的作用是过滤数据时,如果有修改数据。那么合格record就有 用处 */
219
+ getRealyIndex: function (index, record) {
220
+ return getInnerIndex(currentPage, index, {
221
+ filterConfigRef: filterConfigRef,
222
+ rowKey: resetProps.rowKey,
223
+ record: record,
224
+ dataSourceRef: dataSourceRef,
225
+ });
216
226
  },
217
227
  /** 获取当前表格的配置信息 */
218
228
  getDynamicList: function () {
@@ -1,7 +1,7 @@
1
1
  import { __assign, __spreadArray, __awaiter, __generator } from '../_virtual/_tslib.js';
2
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
3
  import { useRef } from 'react';
4
- import { getTableColumns, getFilterRecords, startColumnInsertTableData, parsePasteData } from './utils.js';
4
+ import { getTableColumns, parsePasteData, getFilterRecords, startColumnInsertTableData } from './utils.js';
5
5
  import '../node_modules/classnames/index.js';
6
6
  import 'ahooks';
7
7
  import './components/EnhanceHeaderCell.js';
@@ -13,6 +13,7 @@ import PopoverIcon from './components/PopoverIcon.js';
13
13
  import FilterDropdown, { createFilterValue, filterHandle } from './components/FilterDropdown.js';
14
14
  import { PLACEHOLDER_NULL } from '../config/constant.js';
15
15
  import SearchOutlined from '../node_modules/@ant-design/icons/es/icons/SearchOutlined.js';
16
+ import ModalComponent from '../modal/modal.js';
16
17
 
17
18
  // 处理columns
18
19
  // 根据传入的一些信息 重新生成新的columns配置
@@ -20,12 +21,12 @@ import SearchOutlined from '../node_modules/@ant-design/icons/es/icons/SearchOut
20
21
  function useColumns(columns, options) {
21
22
  var _this = this;
22
23
  var _a, _b;
23
- var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey;
24
+ var dynamicKey = options.dynamicKey, isRemeberFilter = options.isRemeberFilter, hiddenDynamicIcon = options.hiddenDynamicIcon, currentDynamicList = options.currentDynamicList, dataSource = options.dataSource, dataSourceRef = options.dataSourceRef, onEditableSave = options.onEditableSave, isEdit = options.isEdit, isAdd = options.isAdd, isTheadTitleAdd = options.isTheadTitleAdd, isDel = options.isDel, delPopTitle = options.delPopTitle, dynamicSettingRef = options.dynamicSettingRef, onCurrentListChange = options.onCurrentListChange, onAddAndDel = options.onAddAndDel, getRefreshScuCell = options.getRefreshScuCell, isDelAll = options.isDelAll, currentPage = options.currentPage, onTableChange = options.onTableChange, order = options.order, setOrder = options.setOrder, customSortHandle = options.customSortHandle, isResizableColumn = options.isResizableColumn, isResizableTitleEllipsis = options.isResizableTitleEllipsis, isRealTimeValidate = options.isRealTimeValidate, hiddenDelBtnHandleRef = options.hiddenDelBtnHandleRef, hiddenAddBtnHandleRef = options.hiddenAddBtnHandleRef, rowKey = options.rowKey, filterConfigRef = options.filterConfigRef;
24
25
  var newColumns = getTableColumns(columns, currentDynamicList).columns;
25
26
  // 表头过滤的一些配置(获取表头过滤的input的输入框的引用)
26
27
  var searchValueInputRef = useRef(null);
27
28
  // 记录表头过滤的一些配置(通过ref记录,key => filter) 复制整列时,需要先走过滤
28
- var filterConfigRef = useRef({});
29
+ // const filterConfigRef = useRef<any>({});
29
30
  // 循环遍历 neColumns 根据一些内容进行处理
30
31
  var myNewColumns = [];
31
32
  var enhanceColumnHandle = function (_column, options) {
@@ -172,68 +173,96 @@ function useColumns(columns, options) {
172
173
  * @param index 开始的行索引
173
174
  */
174
175
  var insertTableFromClipboard = function (e, options) { return __awaiter(_this, void 0, void 0, function () {
175
- var dataIndex, index, _a, isUpdate, verticalTextList, columns_1, column, filterDataSource, _b, pasteConfig, newDataSource, oldDataSource, err_1;
176
- var _c, _d, _e;
177
- return __generator(this, function (_f) {
178
- switch (_f.label) {
176
+ var dataIndex, index, _a, isUpdate, _b, verticalTextList, text, isContinue_1, newDataSource_1, columns_1, column, filterDataSource, _c, pasteConfig, newDataSource, oldDataSource, err_1;
177
+ var _d, _e, _f, _g, _h, _j;
178
+ return __generator(this, function (_k) {
179
+ switch (_k.label) {
179
180
  case 0:
180
181
  dataIndex = _key;
181
182
  index = options.index, _a = options.isUpdate, isUpdate = _a === void 0 ? true : _a;
182
- _f.label = 1;
183
+ _k.label = 1;
183
184
  case 1:
184
- _f.trys.push([1, 3, , 4]);
185
+ _k.trys.push([1, 5, , 6]);
185
186
  return [4 /*yield*/, parsePasteData(e, {
186
- maxRow: ((_c = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _c === void 0 ? void 0 : _c.pageSize)
187
- ? ((_d = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _d === void 0 ? void 0 : _d.pageSize) - index
188
- : ((_e = dataSourceRef.current) === null || _e === void 0 ? void 0 : _e.length) - index,
187
+ maxRow: ((_d = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _d === void 0 ? void 0 : _d.pageSize)
188
+ ? ((_e = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current) === null || _e === void 0 ? void 0 : _e.pageSize) - index
189
+ : ((_f = dataSourceRef.current) === null || _f === void 0 ? void 0 : _f.length) - index,
189
190
  })];
190
191
  case 2:
191
- verticalTextList = _f.sent();
192
- if (verticalTextList.length > 0) {
193
- // 阻止默认行为,接管粘贴操作
194
- e.preventDefault();
195
- columns_1 = newColumns;
196
- column = _column;
197
- filterDataSource = getFilterRecords(dataSourceRef.current, filterConfigRef.current);
198
- _b = startColumnInsertTableData({
199
- verticalTextList: verticalTextList,
200
- startColumn: column,
201
- columns: columns_1,
202
- startIndex: index,
203
- startDataIndex: dataIndex,
204
- rowKey: rowKey,
205
- realDataSource: dataSourceRef.current,
206
- currentDataSource: filterDataSource,
207
- }), pasteConfig = _b.pasteConfig, newDataSource = _b.newDataSource, oldDataSource = _b.oldDataSource;
208
- if (isUpdate) {
209
- onTableChange &&
210
- onTableChange(newDataSource, oldDataSource, {
211
- type: "paste",
212
- pasteConfig: pasteConfig,
213
- currentIndex: index,
214
- field: dataIndex,
215
- });
192
+ _b = _k.sent(), verticalTextList = _b.verticalTextList, text = _b.text;
193
+ if (!(verticalTextList.length > 0)) return [3 /*break*/, 4];
194
+ isContinue_1 = true;
195
+ return [4 /*yield*/, new Promise(function (resolve, reject) {
196
+ ModalComponent.confirm({
197
+ title: "发现粘贴内容中有分隔符。请确认是否只将值填入当前输入框,还是执行扩展!",
198
+ okText: "确认扩展",
199
+ cancelText: "仅粘贴到当前输入框",
200
+ onOk: function () {
201
+ isContinue_1 = true;
202
+ resolve(1);
203
+ },
204
+ onCancel: function () {
205
+ isContinue_1 = false;
206
+ resolve(1);
207
+ },
208
+ });
209
+ })];
210
+ case 3:
211
+ _k.sent();
212
+ if (!isContinue_1) {
213
+ newDataSource_1 = (_j = (_h = (_g = dataSourceRef.current) === null || _g === void 0 ? void 0 : _g.slice) === null || _h === void 0 ? void 0 : _h.call(_g)) === null || _j === void 0 ? void 0 : _j.map(function (item) { return (__assign({}, item)); });
214
+ if (newDataSource_1 && newDataSource_1[index]) {
215
+ newDataSource_1[index][dataIndex] = text;
216
216
  }
217
217
  return [2 /*return*/, {
218
- newDataSource: newDataSource,
219
- oldDataSource: oldDataSource,
220
- pasteConfig: pasteConfig,
218
+ newDataSource: newDataSource_1,
219
+ oldDataSource: dataSourceRef.current,
220
+ pasteConfig: {},
221
221
  }];
222
222
  }
223
+ // 阻止默认行为,接管粘贴操作
224
+ e.preventDefault();
225
+ columns_1 = newColumns;
226
+ column = _column;
227
+ filterDataSource = getFilterRecords(dataSourceRef.current, filterConfigRef.current);
228
+ _c = startColumnInsertTableData({
229
+ verticalTextList: verticalTextList,
230
+ startColumn: column,
231
+ columns: columns_1,
232
+ startIndex: index,
233
+ startDataIndex: dataIndex,
234
+ rowKey: rowKey,
235
+ realDataSource: dataSourceRef.current,
236
+ currentDataSource: filterDataSource,
237
+ }), pasteConfig = _c.pasteConfig, newDataSource = _c.newDataSource, oldDataSource = _c.oldDataSource;
238
+ if (isUpdate) {
239
+ onTableChange &&
240
+ onTableChange(newDataSource, oldDataSource, {
241
+ type: "paste",
242
+ pasteConfig: pasteConfig,
243
+ currentIndex: index,
244
+ field: dataIndex,
245
+ });
246
+ }
223
247
  return [2 /*return*/, {
224
- newDataSource: dataSourceRef.current,
225
- oldDataSource: dataSourceRef.current,
226
- pasteConfig: {},
248
+ newDataSource: newDataSource,
249
+ oldDataSource: oldDataSource,
250
+ pasteConfig: pasteConfig,
227
251
  }];
228
- case 3:
229
- err_1 = _f.sent();
252
+ case 4: return [2 /*return*/, {
253
+ newDataSource: dataSourceRef.current,
254
+ oldDataSource: dataSourceRef.current,
255
+ pasteConfig: {},
256
+ }];
257
+ case 5:
258
+ err_1 = _k.sent();
230
259
  console.log("粘贴事件内部错误", err_1);
231
260
  return [2 /*return*/, {
232
261
  newDataSource: dataSourceRef.current,
233
262
  oldDataSource: dataSourceRef.current,
234
263
  pasteConfig: {},
235
264
  }];
236
- case 4: return [2 /*return*/];
265
+ case 6: return [2 /*return*/];
237
266
  }
238
267
  });
239
268
  }); };
@@ -243,7 +272,7 @@ function useColumns(columns, options) {
243
272
  var _onCell_1 = _column.onCell;
244
273
  _column.onCell = function (record, index) {
245
274
  var result = _onCell_1 ? _onCell_1(record, index) : {};
246
- return __assign({ record: record, index: index, editable: editable, editableConfig: editableConfig, dataIndex: _key, title: title, onEditableSave: onEditableSave, currentPage: currentPage, isValidate: validate ? true : false, dataSourceRef: dataSourceRef, validate: validate, isRealTimeValidate: isRealTimeValidate, insertTableFromClipboard: insertTableFromClipboard }, result);
275
+ return __assign({ record: record, index: index, editable: editable, editableConfig: editableConfig, dataIndex: _key, title: title, onEditableSave: onEditableSave, currentPage: currentPage, isValidate: validate ? true : false, dataSourceRef: dataSourceRef, validate: validate, isRealTimeValidate: isRealTimeValidate, insertTableFromClipboard: insertTableFromClipboard, filterConfigRef: filterConfigRef, __rowKey: rowKey }, result);
247
276
  };
248
277
  }
249
278
  // 处理配置了scu的相关逻辑
@@ -1,8 +1,45 @@
1
1
  import { __assign } from '../_virtual/_tslib.js';
2
2
  import { useRef, useState, useEffect, useMemo } from 'react';
3
3
 
4
+ // 是否有过滤数据
5
+ function isFilterData(filterConfigRef) {
6
+ try {
7
+ if (!(filterConfigRef === null || filterConfigRef === void 0 ? void 0 : filterConfigRef.current)) {
8
+ return false;
9
+ }
10
+ var filterConfig = filterConfigRef.current;
11
+ var keys = Object.keys(filterConfig);
12
+ if (keys.length === 0) {
13
+ return false;
14
+ }
15
+ for (var i = 0; i < keys.length; i++) {
16
+ var key = keys[i];
17
+ var value = filterConfig[key];
18
+ if (Array.isArray(value) && value.length > 0) {
19
+ return true;
20
+ }
21
+ }
22
+ return false;
23
+ }
24
+ catch (err) {
25
+ return false;
26
+ }
27
+ }
4
28
  // 获取内部当前索引位置
5
- function getInnerIndex(currentPage, index) {
29
+ function getInnerIndex(currentPage, index, options) {
30
+ var _a = options || {}, filterConfigRef = _a.filterConfigRef, rowKey = _a.rowKey, record = _a.record, dataSourceRef = _a.dataSourceRef;
31
+ if (isFilterData(filterConfigRef) && record && rowKey) {
32
+ try {
33
+ var parseRowKey_1 = typeof rowKey === "string" ? rowKey : rowKey(record);
34
+ var rowKeyValue_1 = record[parseRowKey_1];
35
+ return dataSourceRef.current.findIndex(function (item) {
36
+ return item[parseRowKey_1] === rowKeyValue_1;
37
+ });
38
+ }
39
+ catch (err) {
40
+ console.error(err);
41
+ }
42
+ }
6
43
  // 得到当前修改索引相对于 整体数据源 的索引
7
44
  var currentPageObj = currentPage === null || currentPage === void 0 ? void 0 : currentPage.current;
8
45
  if (!currentPageObj) {
@@ -261,10 +261,16 @@ function parsePasteData(e, options) {
261
261
  // 如果只有一个数据,并且没有横向的分隔符。说明就是单纯的复制,不需要后续处理
262
262
  if (verticalTextList.length === 1 &&
263
263
  verticalTextList[0].indexOf("\t") === -1) {
264
- return [2 /*return*/, []];
264
+ return [2 /*return*/, {
265
+ text: text,
266
+ verticalTextList: [],
267
+ }];
265
268
  }
266
269
  }
267
- return [2 /*return*/, verticalTextList];
270
+ return [2 /*return*/, {
271
+ text: text,
272
+ verticalTextList: verticalTextList,
273
+ }];
268
274
  }
269
275
  });
270
276
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",