ztxkui 4.2.9 → 4.2.10
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.
|
@@ -61,6 +61,30 @@ import { EditableContext } from './table-enhance-row';
|
|
|
61
61
|
import { Form, Input, InputNumber, Select, message } from '../../index';
|
|
62
62
|
import { ERROR_TD_CLASSNAME } from './index';
|
|
63
63
|
import { getInnerIndex } from './hooks/useInnerPagination';
|
|
64
|
+
import { exactRound } from 'ztxkutils/dist/tools';
|
|
65
|
+
/**
|
|
66
|
+
* 数据转换 将粘贴过来的数据格式化处理
|
|
67
|
+
*/
|
|
68
|
+
function transformData(data, config) {
|
|
69
|
+
var newData = data;
|
|
70
|
+
if (!config) {
|
|
71
|
+
return newData;
|
|
72
|
+
}
|
|
73
|
+
var editableConfig = config.editableConfig;
|
|
74
|
+
if (!editableConfig) {
|
|
75
|
+
return newData;
|
|
76
|
+
}
|
|
77
|
+
var type = editableConfig.type, precision = editableConfig.precision;
|
|
78
|
+
if (type === 'inputNumber') {
|
|
79
|
+
// 先转换成符合规则的数字
|
|
80
|
+
newData = isNaN(Number(newData))
|
|
81
|
+
? newData
|
|
82
|
+
: typeof precision === 'number'
|
|
83
|
+
? Number(exactRound(newData, precision))
|
|
84
|
+
: Number(newData);
|
|
85
|
+
}
|
|
86
|
+
return newData;
|
|
87
|
+
}
|
|
64
88
|
var TableEnhanceCell = memo(function (_a) {
|
|
65
89
|
var title = _a.title, index = _a.index, editable = _a.editable, editableConfig = _a.editableConfig, children = _a.children, dataIndex = _a.dataIndex, record = _a.record, handleSave = _a.handleSave, onTableChange = _a.onTableChange, columns = _a.columns, currentpage = _a.currentpage, restProps = __rest(_a, ["title", "index", "editable", "editableConfig", "children", "dataIndex", "record", "handleSave", "onTableChange", "columns", "currentpage"]);
|
|
66
90
|
var form = useContext(EditableContext);
|
|
@@ -164,16 +188,23 @@ var TableEnhanceCell = memo(function (_a) {
|
|
|
164
188
|
var result = {};
|
|
165
189
|
resultItemList.forEach(function (resultItem, index) {
|
|
166
190
|
var _a;
|
|
191
|
+
var config = null;
|
|
192
|
+
try {
|
|
193
|
+
config = newColumns_1[currentColumnIndex_1 + index];
|
|
194
|
+
}
|
|
195
|
+
catch (err) {
|
|
196
|
+
console.error("table paste error", err);
|
|
197
|
+
}
|
|
167
198
|
if (resultItem === '' || resultItem == null) {
|
|
168
199
|
return;
|
|
169
200
|
}
|
|
170
201
|
if (index === 0) {
|
|
171
|
-
result[dataIndex] = resultItem;
|
|
202
|
+
result[dataIndex] = transformData(resultItem, config);
|
|
172
203
|
}
|
|
173
204
|
else {
|
|
174
205
|
var key = (_a = newColumns_1[currentColumnIndex_1 + index]) === null || _a === void 0 ? void 0 : _a.dataIndex;
|
|
175
206
|
if (key) {
|
|
176
|
-
result[key] = resultItem;
|
|
207
|
+
result[key] = transformData(resultItem, config);
|
|
177
208
|
}
|
|
178
209
|
}
|
|
179
210
|
});
|