|
|
@@ -1,3 +1,4 @@
|
|
|
+import { roundForObj, isNumber } from '@sc/util';
|
|
|
import BasePlugin from './../_base';
|
|
|
import Hooks from './../../pluginHooks';
|
|
|
import SheetClip from './../../../lib/SheetClip/SheetClip';
|
|
|
@@ -280,17 +281,22 @@ class CopyPaste extends BasePlugin {
|
|
|
return rawData;
|
|
|
}
|
|
|
|
|
|
- // 粘贴key - value 的dropdown 时 返回 value
|
|
|
+ // 粘贴数据预处理
|
|
|
preparePaseData(column, value) {
|
|
|
const settings = this.hot.getSettings();
|
|
|
if (settings && settings.columns) {
|
|
|
const colMeta = settings.columns[column];
|
|
|
if (colMeta && colMeta.source && colMeta.source.length > 0) {
|
|
|
+ // 粘贴key - value 的dropdown 时 返回 value
|
|
|
if (typeof colMeta.source[0] === 'object') {
|
|
|
colMeta.source.forEach((option) => {
|
|
|
if (option.key === value) value = option.value;
|
|
|
});
|
|
|
}
|
|
|
+ } else if (isNumber(value) && ['number', 'function'].includes(typeof colMeta.decimal)) {
|
|
|
+ // 粘贴数值字符串时,将其转换为number并根据小数位数进行四舍五入
|
|
|
+ const decimalNum = typeof colMeta.decimal === 'function' ? colMeta.decimal() : colMeta.decimal;
|
|
|
+ value = roundForObj(value, decimalNum);
|
|
|
}
|
|
|
}
|
|
|
return value;
|