rhchInit.js
3.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import Store from '../store';
import { computeRowlenByContent,computeColWidthByContent } from './getRowlen';
import luckysheetConfigsetting from '../controllers/luckysheetConfigsetting';
export default function rhchInit(rowheight, colwidth) {
zoomSetting();//Zoom sheet on first load
//行高
if(rowheight != null){
Store.visibledatarow = [];
Store.rh_height = 0;
for (let r = 0; r < rowheight; r++) {
let rowlen = Store.defaultrowlen;
if (Store.config["rowlen"] != null && Store.config["rowlen"][r] != null) {
rowlen = Store.config["rowlen"][r];
}
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) {
Store.visibledatarow.push(Store.rh_height);
continue;
}
// 自动行高计算
if (rowlen === 'auto') {
rowlen = computeRowlenByContent(Store.flowdata, r);
}
Store.rh_height += Math.round((rowlen + 1) * Store.zoomRatio);
Store.visibledatarow.push(Store.rh_height); //行的临时长度分布
}
// 如果增加行和回到顶部按钮隐藏,则减少底部空白区域,但是预留足够空间给单元格下拉按钮
if (!luckysheetConfigsetting.enableAddRow && !luckysheetConfigsetting.enableAddBackTop) {
Store.rh_height += 29;
} else {
Store.rh_height += 80; //最底部增加空白
}
}
//列宽
if(colwidth != null){
Store.visibledatacolumn = [];
Store.ch_width = 0;
let maxColumnlen = 120;
for (let c = 0; c < colwidth; c++) {
let firstcolumnlen = Store.defaultcollen;
if (Store.config["columnlen"] != null && Store.config["columnlen"][c] != null) {
firstcolumnlen = Store.config["columnlen"][c];
}
else {
if (Store.flowdata[0] != null && Store.flowdata[0][c] != null) {
if (firstcolumnlen > 300) {
firstcolumnlen = 300;
}
else if (firstcolumnlen < Store.defaultcollen) {
firstcolumnlen = Store.defaultcollen;
}
if (firstcolumnlen != Store.defaultcollen) {
if (Store.config["columnlen"] == null) {
Store.config["columnlen"] = {};
}
Store.config["columnlen"][c] = firstcolumnlen;
}
}
}
if(Store.config["colhidden"] != null && Store.config["colhidden"][c] != null){
Store.visibledatacolumn.push(Store.ch_width);
continue;
}
// 自动行高计算
if (firstcolumnlen === 'auto') {
firstcolumnlen = computeColWidthByContent(Store.flowdata, c, rowheight);
}
Store.ch_width += Math.round((firstcolumnlen + 1)*Store.zoomRatio);
Store.visibledatacolumn.push(Store.ch_width);//列的临时长度分布
// if(maxColumnlen < firstcolumnlen + 1){
// maxColumnlen = firstcolumnlen + 1;
// }
}
// Store.ch_width += 120;
Store.ch_width += maxColumnlen;
}
}
export function zoomSetting(){
//zoom
Store.rowHeaderWidth = luckysheetConfigsetting.rowHeaderWidth * Store.zoomRatio;
Store.columnHeaderHeight = luckysheetConfigsetting.columnHeaderHeight *Store.zoomRatio;
$("#luckysheet-rows-h").width((Store.rowHeaderWidth-1.5));
$("#luckysheet-cols-h-c").height((Store.columnHeaderHeight-1.5));
$("#luckysheet-left-top").css({width:Store.rowHeaderWidth-1.5, height:Store.columnHeaderHeight-1.5});
}