Browse Source

fix(columlen): columlen

columlen to columnlen
master
liurunze 5 years ago
parent
commit
b656c27a39
  1. 4
      docs/guide/data.md
  2. 4
      docs/guide/operate.md
  3. 4
      docs/zh/guide/data.md
  4. 4
      docs/zh/guide/operate.md
  5. 4
      src/controllers/controlHistory.js
  6. 24
      src/controllers/handler.js
  7. 4
      src/controllers/menuButton.js
  8. 30
      src/controllers/rowColumnOperation.js
  9. 8
      src/controllers/selection.js
  10. 4
      src/controllers/server.js
  11. 2
      src/demoData/sheetCell.js
  12. 2
      src/demoData/sheetComment.js
  13. 2
      src/demoData/sheetConditionFormat.js
  14. 2
      src/demoData/sheetFormula.js
  15. 2
      src/demoData/sheetSparkline.js
  16. 8
      src/function/functionImplementation.js
  17. 16
      src/global/draw.js
  18. 30
      src/global/extend.js
  19. 6
      src/global/refresh.js
  20. 32
      src/global/rhchInit.js

4
docs/guide/data.md

@ -192,12 +192,12 @@
}
```
### config.columlen
### config.columnlen
- Type:Object
- Default:{}
- Usage:The column width of each cell, example:
```js
"columlen": {
"columnlen": {
"0": 97,
"1": 115,
"2": 128

4
docs/guide/operate.md

@ -75,8 +75,8 @@
- Update: `luckysheetfile[3].config.["rowlen"]["3"] = 10`
2. Examples of modifying column width:
- Enter: `{"t":"cg","i":1,"v":{"20":74, "15":170, "6":40},"k":" columlen"}`
- Update: `luckysheetfile[1].config.["columlen"]["20"] = 74`
- Enter: `{"t":"cg","i":1,"v":{"20":74, "15":170, "6":40},"k":" columnlen"}`
- Update: `luckysheetfile[1].config.["columnlen"]["20"] = 74`
3. Examples of merged cells:
- Enter: `{"t":"cg","i":1,"v":{"5_10":{row:[1,3], column:[3,5]},"k":" merge "}`

4
docs/zh/guide/data.md

@ -192,12 +192,12 @@
}
```
### config.columlen
### config.columnlen
- 类型:Object
- 默认值:{}
- 作用:每个单元格的列宽,示例:
```js
"columlen": {
"columnlen": {
"0": 97,
"1": 115,
"2": 128

4
docs/zh/guide/operate.md

@ -75,8 +75,8 @@
- 更新:`luckysheetfile[3].config.["rowlen"]["3"] = 10`
2. 修改列宽度举例:
- 输入:`{"t":"cg","i":1,"v":{"20":74, "15":170, "6":40},"k":" columlen"}`
- 更新:`luckysheetfile[1].config.["columlen"]["20"] = 74`
- 输入:`{"t":"cg","i":1,"v":{"20":74, "15":170, "6":40},"k":" columnlen"}`
- 更新:`luckysheetfile[1].config.["columnlen"]["20"] = 74`
3. 合并单元格举例:
- 输入:`{"t":"cg","i":1,"v":{"5_10":{row:[1,3], column:[3,5]},"k":" merge "}`

4
src/controllers/controlHistory.js

@ -108,7 +108,7 @@ const controlHistory = {
server.saveParam("cg", ctr.sheetIndex, ctr.config["rowlen"], { "k": "rowlen" });
}
else if(ctr.ctrlType == "resizeC"){
server.saveParam("cg", ctr.sheetIndex, ctr.config["columlen"], { "k": "columlen" });
server.saveParam("cg", ctr.sheetIndex, ctr.config["columnlen"], { "k": "columnlen" });
}
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
@ -359,7 +359,7 @@ const controlHistory = {
server.saveParam("cg", ctr.sheetIndex, ctr.curconfig["rowlen"], { "k": "rowlen" });
}
else if(ctr.ctrlType == "resizeC"){
server.saveParam("cg", ctr.sheetIndex, ctr.curconfig["columlen"], { "k": "columlen" });
server.saveParam("cg", ctr.sheetIndex, ctr.curconfig["columnlen"], { "k": "columnlen" });
}
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);

24
src/controllers/handler.js

@ -919,11 +919,11 @@ export default function luckysheetHandler() {
//列宽默认值
let cfg = $.extend(true, {}, Store.config);
if (cfg["columlen"] == null) {
cfg["columlen"] = {};
if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
}
let first_collen = cfg["columlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columlen"][Store.luckysheet_select_save[0].column[0]];
let first_collen = cfg["columnlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columnlen"][Store.luckysheet_select_save[0].column[0]];
let isSame = true;
for (let i = 0; i < Store.luckysheet_select_save.length; i++) {
@ -931,7 +931,7 @@ export default function luckysheetHandler() {
let c1 = s.column[0], c2 = s.column[1];
for (let c = c1; c <= c2; c++) {
let collen = cfg["columlen"][c] == null ? Store.defaultcollen : cfg["columlen"][c];
let collen = cfg["columnlen"][c] == null ? Store.defaultcollen : cfg["columnlen"][c];
if (collen != first_collen) {
isSame = false;
@ -2364,12 +2364,12 @@ export default function luckysheetHandler() {
let size = (x + 3) - Store.luckysheet_cols_change_size_start[0];
let firstcolumlen = Store.defaultcollen;
if (Store.config["columlen"] != null && Store.config["columlen"][Store.luckysheet_cols_change_size_start[1]] != null) {
firstcolumlen = Store.config["columlen"][Store.luckysheet_cols_change_size_start[1]];
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]] != null) {
firstcolumnlen = Store.config["columnlen"][Store.luckysheet_cols_change_size_start[1]];
}
if (Math.abs(size - firstcolumlen) < 3) {
if (Math.abs(size - firstcolumnlen) < 3) {
return;
}
if ((x + 3) - Store.luckysheet_cols_change_size_start[0] < 30) {
@ -2381,11 +2381,11 @@ export default function luckysheetHandler() {
}
let cfg = $.extend(true, {}, Store.config);
if (cfg["columlen"] == null) {
cfg["columlen"] = {};
if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
}
cfg["columlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size);
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size);
if (Store.clearjfundo) {
Store.jfundo = [];
@ -2403,7 +2403,7 @@ export default function luckysheetHandler() {
Store.config = cfg;
Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config;
server.saveParam("cg", Store.currentSheetIndex, cfg["columlen"], { "k": "columlen" });
server.saveParam("cg", Store.currentSheetIndex, cfg["columnlen"], { "k": "columnlen" });
jfrefreshgrid_rhcw(null, Store.flowdata[0].length);

4
src/controllers/menuButton.js

@ -3816,8 +3816,8 @@ const menuButton = {
else{
let config = getluckysheetfile()[getSheetIndex(Store.currentSheetIndex)]["config"];
if (config["columlen"] != null && config["columlen"][cell_c] != null) {
width = config["columlen"][cell_c];
if (config["columnlen"] != null && config["columnlen"][cell_c] != null) {
width = config["columnlen"][cell_c];
}
if (config["rowlen"] != null && config["rowlen"][cell_r] != null) {

30
src/controllers/rowColumnOperation.js

@ -776,11 +776,11 @@ export function rowColumnOperationInitial(){
//列宽默认值
let cfg = $.extend(true, {}, Store.config);
if(cfg["columlen"] == null){
cfg["columlen"] = {};
if(cfg["columnlen"] == null){
cfg["columnlen"] = {};
}
let first_collen = cfg["columlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columlen"][Store.luckysheet_select_save[0].column[0]];
let first_collen = cfg["columnlen"][Store.luckysheet_select_save[0].column[0]] == null ? Store.defaultcollen : cfg["columnlen"][Store.luckysheet_select_save[0].column[0]];
let isSame = true;
for(let i = 0; i < Store.luckysheet_select_save.length; i++){
@ -788,7 +788,7 @@ export function rowColumnOperationInitial(){
let c1 = s.column[0], c2 = s.column[1];
for(let c = c1; c <= c2; c++){
let collen = cfg["columlen"][c] == null ? Store.defaultcollen : cfg["columlen"][c];
let collen = cfg["columnlen"][c] == null ? Store.defaultcollen : cfg["columnlen"][c];
if(collen != first_collen){
isSame = false;
@ -1443,8 +1443,8 @@ export function rowColumnOperationInitial(){
else if(Store.luckysheetRightHeadClickIs == "column"){
type = "resizeC";
if(cfg["columlen"] == null){
cfg["columlen"] = {};
if(cfg["columnlen"] == null){
cfg["columnlen"] = {};
}
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
@ -1452,7 +1452,7 @@ export function rowColumnOperationInitial(){
let c2 = Store.luckysheet_select_save[s].column[1];
for(let c = c1; c <= c2; c++){
cfg["columlen"][c] = size;
cfg["columnlen"][c] = size;
}
}
}
@ -1477,7 +1477,7 @@ export function rowColumnOperationInitial(){
jfrefreshgrid_rhcw(Store.flowdata.length, null);
}
else if(Store.luckysheetRightHeadClickIs == "column"){
server.saveParam("cg", Store.currentSheetIndex, cfg["columlen"], { "k": "columlen" });
server.saveParam("cg", Store.currentSheetIndex, cfg["columnlen"], { "k": "columnlen" });
jfrefreshgrid_rhcw(null, Store.flowdata[0].length);
}
});
@ -1557,11 +1557,11 @@ function luckysheetcolsdbclick() {
size = winW - 100 + scrollLeft;
}
if (cfg["columlen"] == null) {
cfg["columlen"] = {};
if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
}
cfg["columlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size);
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size);
matchColumn[col_index] = 1;
}
@ -1607,17 +1607,17 @@ function luckysheetcolsdbclick() {
size = winW - 100 + scrollLeft;
}
if (cfg["columlen"] == null) {
cfg["columlen"] = {};
if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
}
cfg["columlen"][c] = Math.ceil(size);
cfg["columnlen"][c] = Math.ceil(size);
matchColumn[c] = 1;
}
}
}
jfrefreshgridall(Store.flowdata[0].length, Store.flowdata.length, Store.flowdata, cfg, Store.luckysheet_select_save, "resizeC", "columlen");
jfrefreshgridall(Store.flowdata[0].length, Store.flowdata.length, Store.flowdata, cfg, Store.luckysheet_select_save, "resizeC", "columnlen");
}
/**

8
src/controllers/selection.js

@ -183,11 +183,11 @@ const selection = {
let style = "", span = "";
if(r == minR){
if(Store.config == null || Store.config["columlen"] == null || Store.config["columlen"][c.toString()] == null){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>';
}
else {
colgroup += '<colgroup width="'+ Store.config["columlen"][c.toString()] +'px"></colgroup>';
colgroup += '<colgroup width="'+ Store.config["columnlen"][c.toString()] +'px"></colgroup>';
}
}
@ -471,11 +471,11 @@ const selection = {
column += "";
if(r == minR){
if(Store.config == null || Store.config["columlen"] == null || Store.config["columlen"][c.toString()] == null){
if(Store.config == null || Store.config["columnlen"] == null || Store.config["columnlen"][c.toString()] == null){
colgroup += '<colgroup width="72px"></colgroup>';
}
else {
colgroup += '<colgroup width="'+ Store.config["columlen"][c.toString()] +'px"></colgroup>';
colgroup += '<colgroup width="'+ Store.config["columnlen"][c.toString()] +'px"></colgroup>';
}
}

4
src/controllers/server.js

@ -280,7 +280,7 @@ const server = {
}, 1);
}
}
else if(type == "cg"){ //config更新(rowhidden,rowlen,columlen,merge,borderInfo)
else if(type == "cg"){ //config更新(rowhidden,rowlen,columnlen,merge,borderInfo)
let k = item.k;
if(k == "borderInfo"){
@ -299,7 +299,7 @@ const server = {
if(index == Store.currentSheetIndex){//更新数据为当前表格数据
Store.config = file["config"];
if(k == "rowlen" || k == "columlen" || k == "rowhidden"){
if(k == "rowlen" || k == "columnlen" || k == "rowhidden"){
jfrefreshgrid_rhcw(Store.flowdata.length, Store.flowdata[0].length);
}

2
src/demoData/sheetCell.js

@ -1146,7 +1146,7 @@ const sheetCell = {
"27": 20,
"28": 80
},
"columlen": {
"columnlen": {
"0": 97,
"2": 115,
"3": 128,

2
src/demoData/sheetComment.js

@ -2,7 +2,7 @@ const sheetComment = {
"name": "Comment",
"color": "",
"config": {
"columlen": {
"columnlen": {
"2": 102
}
},

2
src/demoData/sheetConditionFormat.js

@ -138,7 +138,7 @@ const sheetConditionFormat = {
"28": 20,
"29": 20
},
"columlen": {
"columnlen": {
"0": 30,
"1": 30,
"2": 86,

2
src/demoData/sheetFormula.js

@ -71,7 +71,7 @@ const sheetFormula = {
}
},
"rowlen": {},
"columlen": {
"columnlen": {
"0": 111,
"2": 105,
"3": 82,

2
src/demoData/sheetSparkline.js

@ -355,7 +355,7 @@ const sheetSparkline = {
"56": 20,
"57": 20
},
"columlen": {
"columnlen": {
"0": 101,
"2": 131,
"3": 30,

8
src/function/functionImplementation.js

@ -23379,8 +23379,8 @@ const functionImplementation = {
case "width":
var cfg = file.config;
if(cfg["columlen"] != null && col_index in cfg["columlen"]){
return cfg["columlen"][col_index];
if(cfg["columnlen"] != null && col_index in cfg["columnlen"]){
return cfg["columnlen"][col_index];
}
return Store.defaultcollen;
@ -25482,7 +25482,7 @@ const functionImplementation = {
return temp1;
// {
// height:rowlen,
// width:firstcolumlen,
// width:firstcolumnlen,
// normalRangeMin:6,
// normalRangeMax:6,
// normalRangeColor:"#000"
@ -25627,7 +25627,7 @@ const functionImplementation = {
return temp1;
// {
// height:rowlen,
// width:firstcolumlen,
// width:firstcolumnlen,
// normalRangeMin:6,
// normalRangeMax:6,
// normalRangeColor:"#000"

16
src/global/draw.js

@ -405,9 +405,9 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
}
else {
let firstcolumlen = Store.defaultcollen;
if (Store.config["columlen"] != null && Store.config["columlen"][c] != null) {
firstcolumlen = Store.config["columlen"][c];
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
firstcolumnlen = Store.config["columnlen"][c];
}
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null) {
@ -438,7 +438,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
"start_r": start_r,
"end_r": end_r,
"end_c": end_c,
"firstcolumlen": firstcolumlen,
"firstcolumnlen": firstcolumnlen,
});
}
else{
@ -448,7 +448,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
if(margeMain.r == r){
margeMain.end_c += (end_c - start_c);
margeMain.firstcolumlen += firstcolumlen;
margeMain.firstcolumnlen += firstcolumnlen;
}
}
@ -464,7 +464,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
"start_c": start_c,
"end_r": end_r,
"end_c": end_c,
"firstcolumlen": firstcolumlen,
"firstcolumnlen": firstcolumnlen,
});
borderOffset[r + "_" + c] = {
"start_r": start_r,
@ -498,7 +498,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
start_c = item.start_c,
end_r = item.end_r,
end_c = item.end_c;
let firstcolumlen = item.firstcolumlen;
let firstcolumnlen = item.firstcolumnlen;
if(Store.flowdata[r] == null){
continue;
@ -582,7 +582,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of
start_c = item.start_c,
end_r = item.end_r,
end_c = item.end_c;
let firstcolumlen = item.firstcolumlen;
let firstcolumnlen = item.firstcolumnlen;
let cell = Store.flowdata[r][c];
let value = null, er = r, ec = c, end_ec = end_c;

30
src/global/extend.js

@ -590,29 +590,29 @@ function luckysheetextendtable(type, index, value, direction) {
type1 = "c";
//行高配置变动
if(cfg["columlen"] != null){
let columlen_new = {};
if(cfg["columnlen"] != null){
let columnlen_new = {};
for(let c in cfg["columlen"]){
for(let c in cfg["columnlen"]){
c = parseFloat(c);
if(c < index){
columlen_new[c] = cfg["columlen"][c];
columnlen_new[c] = cfg["columnlen"][c];
}
else if(c == index){
if(direction == "lefttop"){
columlen_new[(c + value)] = cfg["columlen"][c];
columnlen_new[(c + value)] = cfg["columnlen"][c];
}
else if(direction == "rightbottom"){
columlen_new[c] = cfg["columlen"][c];
columnlen_new[c] = cfg["columnlen"][c];
}
}
else{
columlen_new[(c + value)] = cfg["columlen"][c];
columnlen_new[(c + value)] = cfg["columnlen"][c];
}
}
cfg["columlen"] = columlen_new;
cfg["columnlen"] = columnlen_new;
}
//空列模板
@ -1377,21 +1377,21 @@ function luckysheetdeletetable(type, st, ed) {
type1 = "c";
//列宽配置变动
if(cfg["columlen"] == null){
cfg["columlen"] = {};
if(cfg["columnlen"] == null){
cfg["columnlen"] = {};
}
let columlen_new = {};
for(let c in cfg["columlen"]){
let columnlen_new = {};
for(let c in cfg["columnlen"]){
if(c < st){
columlen_new[c] = cfg["columlen"][c];
columnlen_new[c] = cfg["columnlen"][c];
}
else if(c > ed){
columlen_new[c - slen] = cfg["columlen"][c];
columnlen_new[c - slen] = cfg["columnlen"][c];
}
}
cfg["columlen"] = columlen_new;
cfg["columnlen"] = columnlen_new;
//边框配置变动
if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){

6
src/global/refresh.js

@ -652,14 +652,14 @@ function jfrefreshgrid_rhcw(rowheight, colwidth, isRefreshCanvas=true){
Store.config["rowlen"] = {};
}
if(Store.config["columlen"] == null){
Store.config["columlen"] = {};
if(Store.config["columnlen"] == null){
Store.config["columnlen"] = {};
}
for(let i = 0; i < calcChain.length; i++){
let r = calcChain[i].r, c = calcChain[i].c, index = calcChain[i].index;
if(index == Store.currentSheetIndex && Store.flowdata[r][c] != null && Store.flowdata[r][c].spl != null && ((r in Store.config["rowlen"]) || (c in Store.config["columlen"]))){
if(index == Store.currentSheetIndex && Store.flowdata[r][c] != null && Store.flowdata[r][c].spl != null && ((r in Store.config["rowlen"]) || (c in Store.config["columnlen"]))){
window.luckysheetCurrentRow = r;
window.luckysheetCurrentColumn = c;
window.luckysheetCurrentFunction = Store.flowdata[r][c].f;

32
src/global/rhchInit.js

@ -33,43 +33,43 @@ export default function rhchInit(rowheight, colwidth) {
Store.visibledatacolumn = [];
Store.ch_width = 0;
let maxColumlen = 120;
let maxColumnlen = 120;
for (let i = 0; i < colwidth; i++) {
let firstcolumlen = Store.defaultcollen;
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columlen"] != null && Store.config["columlen"][i] != null) {
firstcolumlen = Store.config["columlen"][i];
if (Store.config["columnlen"] != null && Store.config["columnlen"][i] != null) {
firstcolumnlen = Store.config["columnlen"][i];
}
else {
if (Store.flowdata[0] != null && Store.flowdata[0][i] != null) {
if (firstcolumlen > 300) {
firstcolumlen = 300;
if (firstcolumnlen > 300) {
firstcolumnlen = 300;
}
else if (firstcolumlen < Store.defaultcollen) {
firstcolumlen = Store.defaultcollen;
else if (firstcolumnlen < Store.defaultcollen) {
firstcolumnlen = Store.defaultcollen;
}
if (firstcolumlen != Store.defaultcollen) {
if (Store.config["columlen"] == null) {
Store.config["columlen"] = {};
if (firstcolumnlen != Store.defaultcollen) {
if (Store.config["columnlen"] == null) {
Store.config["columnlen"] = {};
}
Store.config["columlen"][i] = firstcolumlen;
Store.config["columnlen"][i] = firstcolumnlen;
}
}
}
Store.ch_width += firstcolumlen + 1;
Store.ch_width += firstcolumnlen + 1;
Store.visibledatacolumn.push(Store.ch_width);//列的临时长度分布
if(maxColumlen < firstcolumlen + 1){
maxColumlen = firstcolumlen + 1;
if(maxColumnlen < firstcolumnlen + 1){
maxColumnlen = firstcolumnlen + 1;
}
}
// Store.ch_width += 120;
Store.ch_width += maxColumlen;
Store.ch_width += maxColumnlen;
}
}
Loading…
Cancel
Save