rapid-spreadjs 1.0.131 → 1.0.133
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/dist/index.cjs.js +258 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +258 -19
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/utils/business.d.ts +6 -3
- package/dist/utils/echarts-all.d.ts +87 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -987,11 +987,12 @@ const BusinessUtils = {
|
|
|
987
987
|
* @param cellRange 单元格范围JSON对象,格式为:{row:0, col:0, rowCount:2, colCount:5}
|
|
988
988
|
* @param curDefaultPointCount 本次默认点数
|
|
989
989
|
* @param lastDefaultPointCount 上次默认点数,默认为:0(0代表首次创建)
|
|
990
|
-
* @param
|
|
990
|
+
* @param isClearCreateCellsValue 是否清空创建的行单元格值,默认为:false
|
|
991
|
+
* @param isAutoFillFirstCellNumber 是否自动填充第一个单元格为序号数字,默认为:false(当isClearCreateCellsValue=false时,该参数才有效)
|
|
991
992
|
* @param created 创建完成后的回调函数,第一个参数为循环后的所有单元格范围对象(格式为:{row:0, col:0, rowCount:10, colCount:5}),第二个参数为所有循环行的单元格二维数组对象
|
|
992
993
|
* @param rowHeight 创建的行高度,默认为:undefined(如果传了该参数,则新复制的行高为该参数指定的高度,否则为原始循环的行高)
|
|
993
994
|
*/
|
|
994
|
-
dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isAutoFillFirstCellNumber = false, created = null, rowHeight) => {
|
|
995
|
+
dynamicCreateCyclicRows: (GC, spread, cellRange, curDefaultPointCount, lastDefaultPointCount = 0, isClearCreateCellsValue = false, isAutoFillFirstCellNumber = false, created = null, rowHeight) => {
|
|
995
996
|
// 不进行动态创建行
|
|
996
997
|
if ((curDefaultPointCount <= 1 && lastDefaultPointCount == 0) || (curDefaultPointCount == lastDefaultPointCount && lastDefaultPointCount > 0)) {
|
|
997
998
|
return;
|
|
@@ -1055,6 +1056,14 @@ const BusinessUtils = {
|
|
|
1055
1056
|
// pasteOption: GC.Spread.Sheets.ClipboardPasteOptions.all // 粘贴全部内容(数据、样式、公式等)
|
|
1056
1057
|
// });
|
|
1057
1058
|
}
|
|
1059
|
+
// 清空创建的行单元格值
|
|
1060
|
+
if (isClearCreateCellsValue) {
|
|
1061
|
+
// 获取添加行范围的所有单元格
|
|
1062
|
+
const addCells = SheetUtils.getAllCellObjsByRange(sheet, { row: addRowIndex, col: 1, rowCount: addRowCount, colCount: 77 });
|
|
1063
|
+
addCells.forEach((cell) => {
|
|
1064
|
+
sheet.setValue(cell.row, cell.col, '');
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1058
1067
|
};
|
|
1059
1068
|
// 暂停绘制、计算、事件
|
|
1060
1069
|
sheet.suspendPaint();
|
|
@@ -1094,23 +1103,25 @@ const BusinessUtils = {
|
|
|
1094
1103
|
rowCount: cyclicCellsRangeObj.rowCount,
|
|
1095
1104
|
colCount: cyclicCellsRangeObj.colCount,
|
|
1096
1105
|
};
|
|
1097
|
-
// 自动填充第一个单元格为序号数字
|
|
1098
1106
|
const allCells = SheetUtils.getAllCellObjsByRanges(sheet, [cyclicCellsRange]);
|
|
1099
1107
|
const allCellsByRowObj = rapidUtils.groupByJson(allCells, 'row');
|
|
1100
1108
|
let allCellsByRow = [];
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
allCellsByRow.forEach((rowCells, rowIndex) => {
|
|
1107
|
-
rowCells.forEach((rowCell, cellIndex) => {
|
|
1108
|
-
if (cellIndex == 0) {
|
|
1109
|
-
number++;
|
|
1110
|
-
sheet.setValue(rowCell.row, rowCell.col, number);
|
|
1111
|
-
}
|
|
1109
|
+
// 自动填充第一个单元格为序号数字
|
|
1110
|
+
if (!isClearCreateCellsValue) {
|
|
1111
|
+
if (isAutoFillFirstCellNumber) {
|
|
1112
|
+
rapidUtils.forEachJson(allCellsByRowObj, (value, key, source) => {
|
|
1113
|
+
allCellsByRow.push(value);
|
|
1112
1114
|
});
|
|
1113
|
-
|
|
1115
|
+
let number = 0;
|
|
1116
|
+
allCellsByRow.forEach((rowCells, rowIndex) => {
|
|
1117
|
+
rowCells.forEach((rowCell, cellIndex) => {
|
|
1118
|
+
if (cellIndex == 0) {
|
|
1119
|
+
number++;
|
|
1120
|
+
sheet.setValue(rowCell.row, rowCell.col, number);
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1114
1125
|
}
|
|
1115
1126
|
// 恢复事件、计算、绘制
|
|
1116
1127
|
sheet.resumeDirty();
|
|
@@ -1359,9 +1370,11 @@ const BusinessUtils = {
|
|
|
1359
1370
|
* @param GC GC对象
|
|
1360
1371
|
* @param spread 工作簿实例
|
|
1361
1372
|
* @param dynamicLoadRangeJson 动态加载的“试验结果”JSON数组范围,格式如:[{row: 1, col: 1, rowCount: 1, colCount: 1}]
|
|
1373
|
+
* @param pageDir 页面方向(1:纵向、2:横向)
|
|
1374
|
+
* @param blankRowCellValue 空白行单元格值,默认为:空白
|
|
1362
1375
|
* @returns 返回所有需要显示和隐藏的行索引结果对象,格式如:{hasValueIndex: [1, 2, 3], noValueIndex: [4, 5, 6]},hasValueIndex代表所有显示的行索引,noValueIndex代表所有隐藏的行索引
|
|
1363
1376
|
*/
|
|
1364
|
-
dynamicLoadRows: (GC, spread, dynamicLoadRangeJson) => {
|
|
1377
|
+
dynamicLoadRows: (GC, spread, dynamicLoadRangeJson, pageDir = 1, blankRowCellValue = '空白') => {
|
|
1365
1378
|
const sheet = spread.getActiveSheet();
|
|
1366
1379
|
// 暂停绘制
|
|
1367
1380
|
sheet.suspendPaint();
|
|
@@ -1416,16 +1429,16 @@ const BusinessUtils = {
|
|
|
1416
1429
|
// 有值和没有值的行索引集合
|
|
1417
1430
|
let hasValueRows = [], noValueRows = [];
|
|
1418
1431
|
rowCells.forEach((rowObj, index) => {
|
|
1419
|
-
if (rowObj.rows.some((x) => x.hasValue)) {
|
|
1432
|
+
if (rowObj.rows.some((x) => x.hasValue) && !hasValueRows.some((x) => x == rowObj.rowSpan)) {
|
|
1420
1433
|
hasValueRows.push(rowObj.rowSpan);
|
|
1421
1434
|
}
|
|
1422
1435
|
else {
|
|
1423
1436
|
rowObj.rows.forEach((x) => {
|
|
1424
1437
|
x.cells.forEach((cell) => {
|
|
1425
|
-
noValueRows.
|
|
1438
|
+
if (!noValueRows.some((x) => x == cell.row))
|
|
1439
|
+
noValueRows.push(cell.row);
|
|
1426
1440
|
});
|
|
1427
1441
|
});
|
|
1428
|
-
noValueRows.push(rowObj.rowSpan);
|
|
1429
1442
|
}
|
|
1430
1443
|
});
|
|
1431
1444
|
hasValueRows.forEach((rowIndex, index) => {
|
|
@@ -1438,6 +1451,64 @@ const BusinessUtils = {
|
|
|
1438
1451
|
// 设置行不可见
|
|
1439
1452
|
sheet.setRowVisible(rowIndex, false);
|
|
1440
1453
|
});
|
|
1454
|
+
/** 创建空白行单元格 */
|
|
1455
|
+
const createBlackRowCell = () => {
|
|
1456
|
+
// 工作表总高度
|
|
1457
|
+
const sheetTotalHeight = pageDir ? 1055 : 615;
|
|
1458
|
+
// 获取所有可见行的总高度
|
|
1459
|
+
let allRowHeight = 0;
|
|
1460
|
+
for (let i = 0; i < sheet.getRowCount(); i++) {
|
|
1461
|
+
const curRowVisible = sheet.getRowVisible(i);
|
|
1462
|
+
const blankRowCell = sheet.getTag(i, 1);
|
|
1463
|
+
if (curRowVisible && (blankRowCell == null || blankRowCell == undefined || blankRowCell != 'BlankCell')) {
|
|
1464
|
+
allRowHeight += sheet.getRowHeight(i);
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
// 获取到最后一行动态加载区域的行索引
|
|
1468
|
+
const lastRowIndex = rowCells[rowCells.length - 1].rows[rowCells[rowCells.length - 1].rows.length - 1].row;
|
|
1469
|
+
// 创建空白行
|
|
1470
|
+
if (allRowHeight < sheetTotalHeight) {
|
|
1471
|
+
// 获取空白行单元格的标签
|
|
1472
|
+
const blankRowCell = sheet.getTag(lastRowIndex + 1, 1);
|
|
1473
|
+
if (!blankRowCell || blankRowCell !== 'BlankCell') {
|
|
1474
|
+
// 添加一行、合并单元格
|
|
1475
|
+
sheet.addRows(lastRowIndex + 1, 1);
|
|
1476
|
+
sheet.addSpan(lastRowIndex + 1, 1, 1, 77);
|
|
1477
|
+
// 设置添加这一行的行高
|
|
1478
|
+
sheet.setRowHeight(lastRowIndex + 1, sheetTotalHeight - allRowHeight);
|
|
1479
|
+
// 获取添加这一行的区域范围
|
|
1480
|
+
const addRowRange = sheet.getRange(lastRowIndex + 1, 1, 1, 77);
|
|
1481
|
+
// 设置边框线
|
|
1482
|
+
addRowRange.setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.thin), { all: true });
|
|
1483
|
+
addRowRange.setBorder(new GC.Spread.Sheets.LineBorder('#000', GC.Spread.Sheets.LineStyle.medium), {
|
|
1484
|
+
left: true,
|
|
1485
|
+
right: true,
|
|
1486
|
+
top: false,
|
|
1487
|
+
bottom: false,
|
|
1488
|
+
});
|
|
1489
|
+
// 设置单元格水平和垂直居中
|
|
1490
|
+
addRowRange.hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
1491
|
+
addRowRange.vAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
1492
|
+
sheet.setValue(lastRowIndex + 1, 1, blankRowCellValue);
|
|
1493
|
+
sheet.setTag(lastRowIndex + 1, 1, 'BlankCell');
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
// 设置添加这一行的行高
|
|
1497
|
+
sheet.setRowHeight(lastRowIndex + 1, sheetTotalHeight - allRowHeight);
|
|
1498
|
+
// 显示空白行单元格
|
|
1499
|
+
sheet.setRowVisible(lastRowIndex + 1, true);
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
// 隐藏空白行单元格
|
|
1503
|
+
else {
|
|
1504
|
+
const blankRowCell = sheet.getTag(lastRowIndex + 1, 1);
|
|
1505
|
+
// 如果空白行单元格标签存在,则隐藏
|
|
1506
|
+
if (blankRowCell && blankRowCell == 'BlankCell') {
|
|
1507
|
+
sheet.setRowVisible(lastRowIndex + 1, false);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
};
|
|
1511
|
+
createBlackRowCell();
|
|
1441
1512
|
// 恢复绘制
|
|
1442
1513
|
sheet.resumePaint();
|
|
1443
1514
|
return { hasValueIndex: hasValueRows, noValueIndex: noValueRows };
|
|
@@ -9842,6 +9913,171 @@ const EChartsUtilsAll = {
|
|
|
9842
9913
|
};
|
|
9843
9914
|
return option;
|
|
9844
9915
|
},
|
|
9916
|
+
/**
|
|
9917
|
+
* 沥青含量与磨耗值及粘附砂量关系曲线图
|
|
9918
|
+
* @param config 折线配置
|
|
9919
|
+
* @param xDataArr x轴原始数据(二维数组)
|
|
9920
|
+
* @param yDataArr y轴原始数据(二维数组)
|
|
9921
|
+
* @returns 返回ECharts配置项
|
|
9922
|
+
*/
|
|
9923
|
+
chart510: (config, xDataArr, yDataArr, sheet) => {
|
|
9924
|
+
let lineData = JSON.parse(config.chartLinesJson);
|
|
9925
|
+
// const chartExtJson = config.chartExtJson == null || config.chartExtJson == undefined ? null : JSON.parse(config.chartExtJson);
|
|
9926
|
+
let title = config.chartTitle, xName = config.chartXName, yName1 = '磨耗值(g/㎡)', yName2 = '粘附砂量(g/㎡)', color1 = lineData[0].lineColor, color2 = lineData[1].lineColor;
|
|
9927
|
+
// 原始数据
|
|
9928
|
+
const xData = xDataArr[0];
|
|
9929
|
+
const yData1 = yDataArr[0], yData2 = yDataArr[1];
|
|
9930
|
+
let yValIsAllNull1 = false, yValIsAllNull2 = false;
|
|
9931
|
+
if (xData.length == 0 ||
|
|
9932
|
+
yData1.length == 0 ||
|
|
9933
|
+
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
9934
|
+
!yData1.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
9935
|
+
yValIsAllNull1 = true;
|
|
9936
|
+
}
|
|
9937
|
+
if (xData.filter((x) => x == 0).length == xData.length || yData1.filter((x) => x == 0).length == yData1.length) {
|
|
9938
|
+
yValIsAllNull1 = true;
|
|
9939
|
+
}
|
|
9940
|
+
if (xData.length == 0 ||
|
|
9941
|
+
yData2.length == 0 ||
|
|
9942
|
+
(!xData.some((x) => x != '' && x != '/' && x != null && x != undefined) &&
|
|
9943
|
+
!yData2.some((x) => x != '' && x != '/' && x != null && x != undefined))) {
|
|
9944
|
+
yValIsAllNull2 = true;
|
|
9945
|
+
}
|
|
9946
|
+
if (xData.filter((x) => x == 0).length == xData.length || yData2.filter((x) => x == 0).length == yData2.length) {
|
|
9947
|
+
yValIsAllNull2 = true;
|
|
9948
|
+
}
|
|
9949
|
+
// 配置项
|
|
9950
|
+
const option = {
|
|
9951
|
+
// 标题配置
|
|
9952
|
+
title: [
|
|
9953
|
+
{
|
|
9954
|
+
show: true,
|
|
9955
|
+
text: title,
|
|
9956
|
+
left: 'center',
|
|
9957
|
+
top: 2,
|
|
9958
|
+
textStyle: {
|
|
9959
|
+
fontSize: 14,
|
|
9960
|
+
fontWeight: 'normal',
|
|
9961
|
+
},
|
|
9962
|
+
},
|
|
9963
|
+
{
|
|
9964
|
+
show: true,
|
|
9965
|
+
text: xName,
|
|
9966
|
+
left: 'center',
|
|
9967
|
+
bottom: 0,
|
|
9968
|
+
textStyle: {
|
|
9969
|
+
fontSize: 12,
|
|
9970
|
+
fontWeight: 'normal',
|
|
9971
|
+
},
|
|
9972
|
+
},
|
|
9973
|
+
],
|
|
9974
|
+
// 不显示图例
|
|
9975
|
+
legend: {
|
|
9976
|
+
show: false,
|
|
9977
|
+
},
|
|
9978
|
+
// 网格配置
|
|
9979
|
+
grid: {
|
|
9980
|
+
top: 25,
|
|
9981
|
+
left: 25,
|
|
9982
|
+
right: 25,
|
|
9983
|
+
bottom: yValIsAllNull1 && yValIsAllNull2 ? 25 : 20,
|
|
9984
|
+
containLabel: true,
|
|
9985
|
+
},
|
|
9986
|
+
// 提示框配置
|
|
9987
|
+
tooltip: {
|
|
9988
|
+
trigger: 'axis',
|
|
9989
|
+
axisPointer: {
|
|
9990
|
+
type: 'cross',
|
|
9991
|
+
},
|
|
9992
|
+
},
|
|
9993
|
+
// X轴配置
|
|
9994
|
+
xAxis: {
|
|
9995
|
+
type: 'category',
|
|
9996
|
+
data: xData,
|
|
9997
|
+
splitLine: {
|
|
9998
|
+
show: true,
|
|
9999
|
+
},
|
|
10000
|
+
},
|
|
10001
|
+
// Y轴配置(双Y轴)
|
|
10002
|
+
yAxis: [
|
|
10003
|
+
{
|
|
10004
|
+
// 左侧Y轴 - 磨耗值
|
|
10005
|
+
type: 'value',
|
|
10006
|
+
name: yName1,
|
|
10007
|
+
nameLocation: 'middle', // 名称居中显示
|
|
10008
|
+
nameGap: !yValIsAllNull1 ? 35 : 5, // 名称与轴线的距离
|
|
10009
|
+
max: Math.max(...yData1) + 100,
|
|
10010
|
+
// 显示横向网格线
|
|
10011
|
+
splitLine: {
|
|
10012
|
+
show: true,
|
|
10013
|
+
},
|
|
10014
|
+
axisLine: {
|
|
10015
|
+
show: true,
|
|
10016
|
+
},
|
|
10017
|
+
axisLabel: {
|
|
10018
|
+
formatter: '{value}',
|
|
10019
|
+
},
|
|
10020
|
+
axisTick: {
|
|
10021
|
+
show: true,
|
|
10022
|
+
},
|
|
10023
|
+
},
|
|
10024
|
+
{
|
|
10025
|
+
// 右侧Y轴 - 粘附砂量
|
|
10026
|
+
type: 'value',
|
|
10027
|
+
name: yName2,
|
|
10028
|
+
nameLocation: 'middle', // 名称居中显示
|
|
10029
|
+
nameGap: !yValIsAllNull2 ? 35 : 5, // 名称与轴线的距离
|
|
10030
|
+
max: Math.max(...yData2) + 100,
|
|
10031
|
+
splitLine: {
|
|
10032
|
+
show: false,
|
|
10033
|
+
},
|
|
10034
|
+
axisLine: {
|
|
10035
|
+
show: true,
|
|
10036
|
+
},
|
|
10037
|
+
axisLabel: {
|
|
10038
|
+
formatter: '{value}',
|
|
10039
|
+
},
|
|
10040
|
+
axisTick: {
|
|
10041
|
+
show: true,
|
|
10042
|
+
},
|
|
10043
|
+
},
|
|
10044
|
+
],
|
|
10045
|
+
// 数据系列配置
|
|
10046
|
+
series: [
|
|
10047
|
+
{
|
|
10048
|
+
name: '磨耗值',
|
|
10049
|
+
type: 'line',
|
|
10050
|
+
smooth: true, // 平滑曲线
|
|
10051
|
+
data: yValIsAllNull1 ? [] : yData1.filter((x) => x != 0),
|
|
10052
|
+
yAxisIndex: 0, // 使用第一个Y轴(左侧)
|
|
10053
|
+
symbol: 'circle',
|
|
10054
|
+
symbolSize: 5,
|
|
10055
|
+
lineStyle: {
|
|
10056
|
+
color: color1,
|
|
10057
|
+
},
|
|
10058
|
+
itemStyle: {
|
|
10059
|
+
color: color1,
|
|
10060
|
+
},
|
|
10061
|
+
},
|
|
10062
|
+
{
|
|
10063
|
+
name: '粘附砂量',
|
|
10064
|
+
type: 'line',
|
|
10065
|
+
smooth: true, // 平滑曲线
|
|
10066
|
+
data: yValIsAllNull2 ? [] : yData2.filter((x) => x != 0),
|
|
10067
|
+
yAxisIndex: 1, // 使用第二个Y轴(右侧)
|
|
10068
|
+
symbol: 'circle',
|
|
10069
|
+
symbolSize: 5,
|
|
10070
|
+
lineStyle: {
|
|
10071
|
+
color: color2,
|
|
10072
|
+
},
|
|
10073
|
+
itemStyle: {
|
|
10074
|
+
color: color2,
|
|
10075
|
+
},
|
|
10076
|
+
},
|
|
10077
|
+
],
|
|
10078
|
+
};
|
|
10079
|
+
return option;
|
|
10080
|
+
},
|
|
9845
10081
|
};
|
|
9846
10082
|
|
|
9847
10083
|
/**
|
|
@@ -10117,6 +10353,9 @@ const EChartsUtils = {
|
|
|
10117
10353
|
else if (config.chartType == 490) {
|
|
10118
10354
|
option = EChartsUtilsAll.chart490(config, xDataArr, yDataArr, sheet);
|
|
10119
10355
|
}
|
|
10356
|
+
else if (config.chartType == 510) {
|
|
10357
|
+
option = EChartsUtilsAll.chart510(config, xDataArr, yDataArr, sheet);
|
|
10358
|
+
}
|
|
10120
10359
|
if (option && typeof option === 'object') {
|
|
10121
10360
|
//如果是隐藏的图表,则需要禁用ECharts的动画效果
|
|
10122
10361
|
//原因是:如果ECharts使用了动画效果,图表渲染完成可能需要0.5秒,但是在导出ECharts统计图为图片的场景下时,可能在图表还没有渲染完成(动画效果还没结束)前就要获取图像了,此时可能就会造成获取到的图像内容丢失的情况
|