Browse Source

新增行列默认单元格数据

master
CN\wuwx26 5 years ago
parent
commit
c5596dbc8a
  1. 36
      src/controllers/selection.js
  2. 16
      src/global/extend.js
  3. 14
      src/store/index.js

36
src/controllers/selection.js

@ -514,26 +514,26 @@ const selection = {
Store.iscopyself = true; Store.iscopyself = true;
if (!clipboardData) { if (!clipboardData) {
// let textarea = $("#luckysheet-copy-content"); let textarea = $("#luckysheet-copy-content");
// textarea.html(cpdata); textarea.html(cpdata);
// textarea.focus(); textarea.focus();
// textarea.select(); textarea.select();
// document.execCommand("selectAll"); document.execCommand("selectAll");
// document.execCommand("Copy"); document.execCommand("Copy");
// 等50毫秒,keyPress事件发生了再去处理数据 // 等50毫秒,keyPress事件发生了再去处理数据
// setTimeout(function () { setTimeout(function () {
// $("#luckysheet-copy-content").blur(); $("#luckysheet-copy-content").blur();
// }, 10); }, 10);
var oInput = document.createElement('input'); // var oInput = document.createElement('input');
oInput.setAttribute('readonly', 'readonly'); // oInput.setAttribute('readonly', 'readonly');
oInput.value = cpdata; // oInput.value = cpdata;
document.body.appendChild(oInput); // document.body.appendChild(oInput);
oInput.select(); // 选择对象 // oInput.select(); // 选择对象
document.execCommand("Copy"); // document.execCommand("Copy");
oInput.style.display='none'; // oInput.style.display='none';
document.body.removeChild(oInput); // document.body.removeChild(oInput);
} }
else { else {
clipboardData.setData('Text', cpdata); clipboardData.setData('Text', cpdata);

16
src/global/extend.js

@ -13,6 +13,7 @@ import Store from '../store';
//增加行列 //增加行列
function luckysheetextendtable(type, index, value, direction, sheetIndex) { function luckysheetextendtable(type, index, value, direction, sheetIndex) {
console.log(type, index, value, direction, sheetIndex)
sheetIndex = sheetIndex || Store.currentSheetIndex; sheetIndex = sheetIndex || Store.currentSheetIndex;
if(type=='row' && !checkProtectionAuthorityNormal(sheetIndex, "insertRows")){ if(type=='row' && !checkProtectionAuthorityNormal(sheetIndex, "insertRows")){
@ -627,9 +628,12 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
} }
//空行模板 //空行模板
let row = []; let row = [],
curRow = [...d][index]
for(let c = 0; c < d[0].length; c++){ for(let c = 0; c < d[0].length; c++){
row.push(null); let cell = curRow[c],
templateCell = cell ? {...cell, v: '', m: ''} : Store.defaultCell;
row.push(templateCell);
} }
//边框 //边框
@ -779,9 +783,12 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
} }
//空列模板 //空列模板
let col = []; let col = [],
curd= [...d];
for(let r = 0; r < d.length; r++){ for(let r = 0; r < d.length; r++){
col.push(null); let cell = curd[r][index],
templateCell = cell ? {...cell, v: '', m: ''} : Store.defaultCell;
col.push(templateCell);
} }
//边框 //边框
@ -892,6 +899,7 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) {
newDataVerification, newDataVerification,
newHyperlink newHyperlink
); );
} }
else{ else{
file.data = d; file.data = d;

14
src/store/index.js

@ -150,6 +150,20 @@ const Store = {
// Resources that currently need to be loaded asynchronously, especially plugins. 'Core' marks the core rendering process. // Resources that currently need to be loaded asynchronously, especially plugins. 'Core' marks the core rendering process.
asyncLoad:['core'], asyncLoad:['core'],
// 默认单元格
defaultCell: {
bg: null,
bl: 0,
ct: {fa: "General", t: "n"},
fc: "rgb(51, 51, 51)",
ff: 0,
fs: 11,
ht: 1,
it: 0,
vt: 1,
m: '',
v: ''
}
} }

Loading…
Cancel
Save