|
@@ -340,6 +340,7 @@ const SpreadJsObj = {
|
|
|
initSheet: function (sheet, setting) {
|
|
|
this.beginMassOperation(sheet);
|
|
|
setting.pos = sheet.getParent().pos;
|
|
|
+ if (!setting.tree) setting.tree = {};
|
|
|
sheet.zh_setting = setting;
|
|
|
if (sheet.zh_setting.headColWidth) {
|
|
|
for (const [i, w] of sheet.zh_setting.headColWidth.entries()) {
|
|
@@ -350,7 +351,8 @@ const SpreadJsObj = {
|
|
|
this._initSheetHeader(sheet);
|
|
|
sheet.setRowCount(sheet.zh_setting.emptyRows);
|
|
|
sheet.extendCellType = {};
|
|
|
- sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).locked(setting.readOnly);
|
|
|
+ sheet.borderLine = new spreadNS.LineBorder('#cccccc', spreadNS.LineStyle.thin);
|
|
|
+ sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).locked(setting.readOnly).setBorder(sheet.borderLine, {all: true});
|
|
|
this.endMassOperation(sheet);
|
|
|
},
|
|
|
reLoadSheetHeader: function (sheet) {
|
|
@@ -370,9 +372,17 @@ const SpreadJsObj = {
|
|
|
} else if (col.field !== '' && data[col.field]) {
|
|
|
cell.value(data[col.field]);
|
|
|
}
|
|
|
+
|
|
|
+ let font = sheet.getDefaultStyle().font;
|
|
|
+ console.log(font);
|
|
|
if (col.font) {
|
|
|
- cell.font(col.font);
|
|
|
+ font = col.font;
|
|
|
+ }
|
|
|
+ if (sheet.zh_setting.tree.getFont && Object.prototype.toString.apply(sheet.zh_setting.tree.getFont) === "[object Function]") {
|
|
|
+ font = sheet.zh_setting.tree.getFont(sheet, data, row, col, font);
|
|
|
}
|
|
|
+ cell.font(font);
|
|
|
+
|
|
|
if (col.foreColor) {
|
|
|
if (Object.prototype.toString.apply(col.foreColor) === "[object Function]") {
|
|
|
cell.foreColor(col.foreColor(data, sheet.getDefaultStyle().foreColor));
|
|
@@ -380,19 +390,29 @@ const SpreadJsObj = {
|
|
|
cell.foreColor(col.foreColor);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (col.readOnly && Object.prototype.toString.apply(col.readOnly) === "[object Function]") {
|
|
|
cell.locked(col.readOnly(data) || sheet.zh_setting.readOnly || false).vAlign(1).hAlign(col.hAlign);
|
|
|
} else {
|
|
|
cell.locked(col.readOnly || sheet.zh_setting.readOnly || false).vAlign(1).hAlign(col.hAlign);
|
|
|
}
|
|
|
+
|
|
|
if (col.formatter) {
|
|
|
cell.formatter(col.formatter);
|
|
|
} else if (col.type === 'Number') {
|
|
|
cell.formatter(SpreadJsObj.Formatter.getNumberFormatter('0.######'));
|
|
|
}
|
|
|
+
|
|
|
+ let backColor = sheet.getDefaultStyle().backColor;
|
|
|
+ if (sheet.zh_setting.tree.getColor && Object.prototype.toString.apply(sheet.zh_setting.tree.getColor) === "[object Function]") {
|
|
|
+ backColor = sheet.zh_setting.tree.getColor(sheet, data, row, col, backColor);
|
|
|
+ }
|
|
|
if (sheet.zh_setting.getColor && Object.prototype.toString.apply(sheet.zh_setting.getColor) === "[object Function]") {
|
|
|
- cell.backColor(sheet.zh_setting.getColor(sheet, data, col, sheet.getDefaultStyle().backColor));
|
|
|
+ backColor = sheet.zh_setting.getColor(sheet, data, row, col, backColor);
|
|
|
}
|
|
|
+ cell.backColor(backColor);
|
|
|
+
|
|
|
+ cell.setBorder(sheet.borderLine, {all: true});
|
|
|
});
|
|
|
|
|
|
},
|
|
@@ -591,6 +611,30 @@ const SpreadJsObj = {
|
|
|
this.endMassOperation(sheet);
|
|
|
}
|
|
|
},
|
|
|
+ reloadRowsBackColor: function (sheet, rows) {
|
|
|
+ const sortData = sheet.zh_dataType === 'tree' ? sheet.zh_tree.nodes : sheet.zh_data;
|
|
|
+
|
|
|
+ this.beginMassOperation(sheet);
|
|
|
+ try {
|
|
|
+ for (const row of rows) {
|
|
|
+ if (row < 0) { continue; }
|
|
|
+ const data = sortData[row];
|
|
|
+ for (const [iCol, col] of sheet.zh_setting.cols.entries()) {
|
|
|
+ let backColor = sheet.getDefaultStyle().backColor;
|
|
|
+ if (sheet.zh_setting.tree.getColor && Object.prototype.toString.apply(sheet.zh_setting.tree.getColor) === "[object Function]") {
|
|
|
+ backColor = sheet.zh_setting.tree.getColor(sheet, data, row, col, backColor);
|
|
|
+ }
|
|
|
+ if (sheet.zh_setting.getColor && Object.prototype.toString.apply(sheet.zh_setting.getColor) === "[object Function]") {
|
|
|
+ backColor = sheet.zh_setting.getColor(sheet, data, row, col, backColor);
|
|
|
+ }
|
|
|
+ sheet.getCell(row, iCol).backColor(backColor);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ this.endMassOperation(sheet);
|
|
|
+ } catch (err) {
|
|
|
+ this.endMassOperation(sheet);
|
|
|
+ }
|
|
|
+ },
|
|
|
/**
|
|
|
* 重新加载部分列数据
|
|
|
* @param {GC.Spread.Sheets.Worksheet} sheet
|
|
@@ -747,6 +791,7 @@ const SpreadJsObj = {
|
|
|
if (ts === undefined || ts === null) return;
|
|
|
if (ts.sel) {
|
|
|
sheet.setSelection(ts.sel.row, ts.sel.col, ts.sel.rowCount, ts.sel.colCount);
|
|
|
+ SpreadJsObj.reloadRowsBackColor(sheet, [0, ts.sel.row]);
|
|
|
}
|
|
|
if (ts.top) {
|
|
|
sheet.showRow(ts.top, spreadNS.VerticalPosition.top);
|
|
@@ -861,6 +906,9 @@ const SpreadJsObj = {
|
|
|
const levelIndent = -5;
|
|
|
const halfBoxLength = 5;
|
|
|
const halfExpandLength = 3;
|
|
|
+ const lineColor = '#515151';//'#b8b8b8';
|
|
|
+ const expandBoxColor = '#434343';//'#808080';
|
|
|
+ const dotLine = true;
|
|
|
|
|
|
/**
|
|
|
* 画一条点线段
|
|
@@ -920,7 +968,7 @@ const SpreadJsObj = {
|
|
|
canvas.lineTo(rect.right, rect.top);
|
|
|
canvas.lineTo(rect.left, rect.top);
|
|
|
canvas.stroke();
|
|
|
- canvas.fillStyle = fillColor;
|
|
|
+ canvas.fillStyle = fillColor ? fillColor : 'white';
|
|
|
canvas.fill();
|
|
|
canvas.restore();
|
|
|
};
|
|
@@ -935,7 +983,7 @@ const SpreadJsObj = {
|
|
|
* @param {Number} centerY - 按钮中央坐标
|
|
|
* @param {Boolean} expanded - 当前节点展开收起状态
|
|
|
*/
|
|
|
- const drawExpandBox = function (canvas, x, y, w, h, centerX, centerY, expanded) {
|
|
|
+ const drawExpandBox = function (canvas, x, y, w, h, centerX, centerY, expanded, style) {
|
|
|
let rect = {
|
|
|
top: centerY - halfBoxLength,
|
|
|
bottom: centerY + halfBoxLength,
|
|
@@ -947,18 +995,18 @@ const SpreadJsObj = {
|
|
|
if (rect.left < x + w) {
|
|
|
// 方框超出单元格宽度时,超出部分不画。
|
|
|
rect.right = Math.min(rect.right, x + w);
|
|
|
- drawBox(canvas, rect, '#808080', 'white');
|
|
|
+ drawBox(canvas, rect, expandBoxColor, style.backColor);
|
|
|
|
|
|
// 画中心十字
|
|
|
// 画十字横线
|
|
|
h1 = centerX - halfExpandLength;
|
|
|
h2 = Math.min(centerX + halfExpandLength, x + w);
|
|
|
if (h2 > h1) {
|
|
|
- drawLine(canvas, h1, centerY, h2, centerY, '#808080');
|
|
|
+ drawLine(canvas, h1, centerY, h2, centerY, expandBoxColor);
|
|
|
}
|
|
|
// 画十字竖线
|
|
|
if (!expanded && (centerX < x + w)) {
|
|
|
- drawLine(canvas, centerX, centerY - halfExpandLength, centerX, centerY + halfExpandLength, '#808080');
|
|
|
+ drawLine(canvas, centerX, centerY - halfExpandLength, centerX, centerY + halfExpandLength, expandBoxColor);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
@@ -1002,8 +1050,11 @@ const SpreadJsObj = {
|
|
|
// Draw Horizontal Line
|
|
|
if (centerX < x + w) {
|
|
|
const x1 = centerX + indent / 2;
|
|
|
- //drawLine(canvas, centerX, centerY, Math.min(x1, x + w), centerY, 'gray');
|
|
|
- drawDotLine(canvas, centerX, centerY, Math.min(x1, x + w), centerY, '#b8b8b8');
|
|
|
+ if (dotLine) {
|
|
|
+ drawDotLine(canvas, centerX, centerY, Math.min(x1, x + w), centerY, lineColor);
|
|
|
+ } else {
|
|
|
+ drawLine(canvas, centerX, centerY, Math.min(x1, x + w), centerY, lineColor);
|
|
|
+ }
|
|
|
}
|
|
|
// Draw Vertical Line
|
|
|
if (centerX < x + w) {
|
|
@@ -1011,17 +1062,23 @@ const SpreadJsObj = {
|
|
|
const parent = tree.getParent(node);
|
|
|
const y2 = y1 - centerY;
|
|
|
if (node.order === 1 && !parent) {
|
|
|
- //drawLine(canvas, centerX, centerY, centerX, y1, 'gray');
|
|
|
- drawDotLine(canvas, centerX, centerY, centerX, y1, '#b8b8b8');
|
|
|
+ if (dotLine) {
|
|
|
+ drawDotLine(canvas, centerX, centerY, centerX, y1, lineColor);
|
|
|
+ } else {
|
|
|
+ drawLine(canvas, centerX, centerY, centerX, y1, lineColor);
|
|
|
+ }
|
|
|
} else {
|
|
|
- //drawLine(canvas, centerX, y, centerX, y1, 'gray');
|
|
|
- drawDotLine(canvas, centerX, y, centerX, y1, '#b8b8b8');
|
|
|
+ if (dotLine) {
|
|
|
+ drawDotLine(canvas, centerX, y, centerX, y1, lineColor);
|
|
|
+ } else {
|
|
|
+ drawLine(canvas, centerX, y, centerX, y1, lineColor);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// Draw Expand Box
|
|
|
if (!node.is_leaf) {
|
|
|
- drawExpandBox(canvas, x, y, w, h, centerX, centerY, node.expanded);
|
|
|
+ drawExpandBox(canvas, x, y, w, h, centerX, centerY, node.expanded, style);
|
|
|
}
|
|
|
// Draw Parent Line
|
|
|
if (showTreeLine) {
|
|
@@ -1029,8 +1086,11 @@ const SpreadJsObj = {
|
|
|
while (parent) {
|
|
|
if (!tree.isLastSibling(parent)) {
|
|
|
if (parentCenterX < x + w) {
|
|
|
- //drawLine(canvas, parentCenterX, y, parentCenterX, y + h, 'gray');
|
|
|
- drawDotLine(canvas, parentCenterX, y, parentCenterX, y + h, '#b8b8b8');
|
|
|
+ if (dotLine) {
|
|
|
+ drawDotLine(canvas, parentCenterX, y, parentCenterX, y + h, lineColor);
|
|
|
+ } else {
|
|
|
+ drawLine(canvas, parentCenterX, y, parentCenterX, y + h, lineColor);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
parent = tree.getParent(parent);
|