@gingkoo/base-server 0.0.2-alpha.2 → 0.0.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/static/excel/excel.js +137 -32
package/package.json
CHANGED
package/static/excel/excel.js
CHANGED
|
@@ -1,23 +1,81 @@
|
|
|
1
1
|
// /fss/resources/share/1__2701fc.xlsx
|
|
2
2
|
// https://minio.cnbabylon.com/public/luckysheet/money-manager-2.xlsx
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
function getUrlParams() {
|
|
4
|
+
var params = {};
|
|
5
|
+
var url = location.href;
|
|
6
|
+
var index = url.lastIndexOf('?');
|
|
7
7
|
if (~index) {
|
|
8
8
|
url
|
|
9
9
|
.slice(index + 1)
|
|
10
10
|
.split('&')
|
|
11
11
|
.forEach((v) => {
|
|
12
|
-
|
|
12
|
+
var item = v.split('=');
|
|
13
13
|
params[item[0]] = item[1];
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
return params;
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var params = getUrlParams();
|
|
20
|
+
var fileurl = decodeURIComponent(params.url);
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
var defaultOptions = {
|
|
23
|
+
title: '',
|
|
24
|
+
lang: 'zh', // 设定表格语言
|
|
25
|
+
gridKey: 'excel-1', //
|
|
26
|
+
showinfobar: false, // 顶部信息栏
|
|
27
|
+
showtoolbar: false, // 工具栏
|
|
28
|
+
showstatisticBar: false, // 底部计数栏
|
|
29
|
+
showstatisticBarConfig: false,
|
|
30
|
+
userInfo: false,
|
|
31
|
+
enableAddRow: false,
|
|
32
|
+
enableAddCol: false,
|
|
33
|
+
addRowCount: false,
|
|
34
|
+
sheetBottomConfig: false, // sheet页下方的添加行按钮和回到顶部按钮配置
|
|
35
|
+
showtoolbar: false,
|
|
36
|
+
autoCalc: true,
|
|
37
|
+
autoCalcType: ['label'],
|
|
38
|
+
allowEdit: false, // 只读 文字
|
|
39
|
+
allowMode: false, // 只读 样式
|
|
40
|
+
enableAddRow: false, // 允许添加行
|
|
41
|
+
enableAddBackTop: false, // 允许回到顶部
|
|
42
|
+
devicePixelRatio: window.devicePixelRatio || 5, // 设备比例,比例越大表格分辨率越高
|
|
43
|
+
cellRightClickConfig: {
|
|
44
|
+
// 自定义配置单元格右击菜单
|
|
45
|
+
copy: false, // 复制
|
|
46
|
+
copyAs: false, // 复制为
|
|
47
|
+
paste: false, // 粘贴
|
|
48
|
+
insertRow: false, // 插入行
|
|
49
|
+
insertColumn: false, // 插入列
|
|
50
|
+
deleteRow: false, // 删除选中行
|
|
51
|
+
deleteColumn: false, // 删除选中列
|
|
52
|
+
deleteCell: false, // 删除单元格
|
|
53
|
+
hideRow: false, // 隐藏选中行和显示选中行
|
|
54
|
+
hideColumn: false, // 隐藏选中列和显示选中列
|
|
55
|
+
rowHeight: false, // 行高
|
|
56
|
+
columnWidth: false, // 列宽
|
|
57
|
+
clear: false, // 清除内容
|
|
58
|
+
matrix: false, // 矩阵操作选区
|
|
59
|
+
sort: false, // 排序选区
|
|
60
|
+
filter: false, // 筛选选区
|
|
61
|
+
chart: false, // 图表生成
|
|
62
|
+
image: false, // 插入图片
|
|
63
|
+
link: false, // 插入链接
|
|
64
|
+
data: false, // 数据验证
|
|
65
|
+
cellFormat: false, // 设置单元格格式
|
|
66
|
+
defaultFontSize: 11, // 默认11 默认字体大小
|
|
67
|
+
},
|
|
68
|
+
showsheetbar: true, // 是否显示底部sheet页按钮
|
|
69
|
+
showsheetbarConfig: {
|
|
70
|
+
// 自定义配置底部sheet页按钮
|
|
71
|
+
add: false, //新增sheet
|
|
72
|
+
menu: false, //sheet管理菜单
|
|
73
|
+
sheet: true, //sheet页显示
|
|
74
|
+
},
|
|
75
|
+
rowHeaderWidth: 46, // 默认 46 行标题区域的宽度,如果设置为0,则表示隐藏行标题
|
|
76
|
+
columnHeaderHeight: 20, // 默认20 列标题区域的高度,如果设置为0,则表示隐藏列标题
|
|
77
|
+
sheetFormulaBar: true, // 是否显示公式栏
|
|
78
|
+
};
|
|
21
79
|
|
|
22
80
|
var page = {
|
|
23
81
|
// 读取二进制流文件内容,转换成html
|
|
@@ -48,7 +106,7 @@ var page = {
|
|
|
48
106
|
return;
|
|
49
107
|
}
|
|
50
108
|
|
|
51
|
-
|
|
109
|
+
var suffix = '';
|
|
52
110
|
if (fileurl && /^.*\/[^/]+\.[^/]+$/.test(fileurl)) {
|
|
53
111
|
suffix = fileurl.slice(fileurl.lastIndexOf('.') + 1);
|
|
54
112
|
}
|
|
@@ -75,7 +133,70 @@ var page = {
|
|
|
75
133
|
},
|
|
76
134
|
};
|
|
77
135
|
|
|
78
|
-
|
|
136
|
+
function transform(sheet) {
|
|
137
|
+
let finalCellData = [];
|
|
138
|
+
// let sheet = data?.[0] || null;
|
|
139
|
+
let sheetCelldata = sheet?.celldata || [];
|
|
140
|
+
if (!sheetCelldata.length) return data;
|
|
141
|
+
|
|
142
|
+
let sheetColumn = sheet.column < 60 ? 60 : sheet.column;
|
|
143
|
+
let sheetRow = sheet.row < 84 ? 84 : sheet.row;
|
|
144
|
+
|
|
145
|
+
// 兼容window电脑字体 模糊问题
|
|
146
|
+
finalCellData = sheetCelldata.map((cell) => {
|
|
147
|
+
if (cell.v.fs < 12) {
|
|
148
|
+
cell.v.ff = '微软雅黑';
|
|
149
|
+
cell.v.fs = 12;
|
|
150
|
+
cell.v.tb = 2; // tb 为2会卡顿
|
|
151
|
+
cell.v.vt = 1;
|
|
152
|
+
cell.v.ht = 1;
|
|
153
|
+
if (cell.v?.ct?.s) {
|
|
154
|
+
cell.v.ct.s.map((v) => {
|
|
155
|
+
v.ff = '微软雅黑';
|
|
156
|
+
v.fs = 12;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return cell;
|
|
160
|
+
}
|
|
161
|
+
return cell;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (params.cut) {
|
|
165
|
+
// 隐藏多余空格
|
|
166
|
+
let row = 0,
|
|
167
|
+
col = 0;
|
|
168
|
+
finalCellData.forEach((cell) => {
|
|
169
|
+
if (cell.v?.m || cell.v?.v || cell.v.ct?.fa?.s) {
|
|
170
|
+
col = col < cell.c ? cell.c : col;
|
|
171
|
+
row = row < cell.r ? cell.r : row;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
finalCellData = finalCellData.filter((cell) => cell.c <= col && cell.r <= row);
|
|
175
|
+
sheetColumn = col + 1;
|
|
176
|
+
sheetRow = row + 1;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
...sheet,
|
|
181
|
+
celldata: finalCellData.map((cell) => {
|
|
182
|
+
let { v } = cell;
|
|
183
|
+
v = v || {};
|
|
184
|
+
let { tb, ...rest } = v;
|
|
185
|
+
return {
|
|
186
|
+
...cell,
|
|
187
|
+
v: {
|
|
188
|
+
...rest,
|
|
189
|
+
tb: 0,
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}),
|
|
193
|
+
data: [],
|
|
194
|
+
column: sheetColumn,
|
|
195
|
+
row: sheetRow,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
var loadLuckySheet = function (exportJson) {
|
|
79
200
|
if (exportJson.sheets == null || exportJson.sheets.length == 0) {
|
|
80
201
|
alert('无法读取excel文件的内容,当前不支持xls文件!');
|
|
81
202
|
return;
|
|
@@ -83,31 +204,15 @@ var loadLuckySheet = (exportJson) => {
|
|
|
83
204
|
|
|
84
205
|
window.luckysheet.destroy();
|
|
85
206
|
window.luckysheet.create({
|
|
207
|
+
...defaultOptions,
|
|
86
208
|
container: 'luckysheet',
|
|
87
|
-
data: exportJson.sheets,
|
|
88
|
-
|
|
89
|
-
title: '',
|
|
90
|
-
userInfo: false,
|
|
91
|
-
showinfobar: false,
|
|
92
|
-
showstatisticBar: false,
|
|
93
|
-
enableAddRow: false,
|
|
94
|
-
enableAddCol: false,
|
|
95
|
-
addRowCount: false,
|
|
96
|
-
enableAddBackTop: false,
|
|
97
|
-
sheetBottomConfig: false, // sheet页下方的添加行按钮和回到顶部按钮配置
|
|
98
|
-
allowEdit: false, // 是否允许前台编辑——edit
|
|
99
|
-
showtoolbar: false,
|
|
100
|
-
showstatisticBarConfig: false,
|
|
101
|
-
showsheetbarConfig: {
|
|
102
|
-
add: false, //新增sheet
|
|
103
|
-
menu: false, //sheet管理菜单
|
|
104
|
-
sheet: true, //sheet页显示
|
|
105
|
-
},
|
|
209
|
+
data: exportJson.sheets.map((v) => transform(v)),
|
|
210
|
+
|
|
106
211
|
hook: {
|
|
107
212
|
workbookCreateAfter() {
|
|
108
213
|
setTimeout(() => {
|
|
109
|
-
|
|
110
|
-
|
|
214
|
+
var c = document.querySelectorAll('#luckysheet-sheet-container-c>div');
|
|
215
|
+
var ids = [];
|
|
111
216
|
|
|
112
217
|
Array.from(c).forEach((v) => {
|
|
113
218
|
if (ids.includes(v.id)) {
|
|
@@ -121,7 +226,7 @@ var loadLuckySheet = (exportJson) => {
|
|
|
121
226
|
});
|
|
122
227
|
};
|
|
123
228
|
|
|
124
|
-
page.getFileInfo((file)
|
|
229
|
+
page.getFileInfo(function (file) {
|
|
125
230
|
if (file.ext == 'xlsx') {
|
|
126
231
|
LuckyExcel.transformExcelToLucky(file.content, function (exportJson, luckysheetfile) {
|
|
127
232
|
loadLuckySheet(exportJson);
|