|
|
@@ -215,7 +215,7 @@ class CopyPaste extends BasePlugin {
|
|
|
const rowSet = [];
|
|
|
|
|
|
arrayEach(copyableColumns, (column) => {
|
|
|
- rowSet.push(this.hot.getCopyableData(row, column));
|
|
|
+ rowSet.push(this.getCopyData(row, column));
|
|
|
});
|
|
|
|
|
|
dataSet.push(rowSet);
|
|
|
@@ -253,7 +253,8 @@ class CopyPaste extends BasePlugin {
|
|
|
const rowSet = [];
|
|
|
|
|
|
arrayEach(copyableColumns, (column) => {
|
|
|
- rowSet.push(this.hot.getCopyableData(row, column));
|
|
|
+
|
|
|
+ rowSet.push(this.prepareCopyData(row, column));
|
|
|
});
|
|
|
|
|
|
dataSet.push(rowSet);
|
|
|
@@ -262,6 +263,38 @@ class CopyPaste extends BasePlugin {
|
|
|
return dataSet;
|
|
|
}
|
|
|
|
|
|
+ // 复制key - value 的dropdown 时 返回 key
|
|
|
+ prepareCopyData(row, column) {
|
|
|
+ let rawData = this.hot.getCopyableData(row, column);
|
|
|
+ const settings = this.hot.getSettings();
|
|
|
+ if (settings && settings.columns) {
|
|
|
+ const colMeta = settings.columns[column];
|
|
|
+ if (colMeta && colMeta.source && colMeta.source.length > 0) {
|
|
|
+ if (typeof colMeta.source[0] === 'object') {
|
|
|
+ colMeta.source.forEach((option) => {
|
|
|
+ if (option.value === rawData) rawData = option.key;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ if (typeof colMeta.source[0] === 'object') {
|
|
|
+ colMeta.source.forEach((option) => {
|
|
|
+ if (option.key === value) value = option.value;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return value;
|
|
|
+ }
|
|
|
/**
|
|
|
* Simulates the paste action.
|
|
|
*
|
|
|
@@ -373,7 +406,8 @@ class CopyPaste extends BasePlugin {
|
|
|
const newRow = [];
|
|
|
|
|
|
for (let column = startColumn, valuesColumn = 0; column <= endColumn; column += 1) {
|
|
|
- newRow.push(inputArray[valuesRow][valuesColumn]);
|
|
|
+
|
|
|
+ newRow.push(this.preparePaseData(column, inputArray[valuesRow][valuesColumn]));
|
|
|
|
|
|
valuesColumn = valuesColumn === newValuesMaxColumn ? 0 : valuesColumn += 1;
|
|
|
}
|