|
@@ -3,6 +3,26 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
var TREE_SHEET_HELPER = {
|
|
var TREE_SHEET_HELPER = {
|
|
|
|
+ getObjPos: function (obj) {
|
|
|
|
+ let target = obj;
|
|
|
|
+ let pos = {x: obj.offsetLeft, y: obj.offsetTop};
|
|
|
|
+
|
|
|
|
+ target = obj.offsetParent;
|
|
|
|
+ while (target) {
|
|
|
|
+ pos.x += target.offsetLeft;
|
|
|
|
+ pos.y += target.offsetTop;
|
|
|
|
+ target = target.offsetParent;
|
|
|
|
+ }
|
|
|
|
+ return pos;
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 初始化setting,需要提示单元格text时,必须先初始化setting
|
|
|
|
+ * @param obj
|
|
|
|
+ * @param setting
|
|
|
|
+ */
|
|
|
|
+ initSetting: function (obj, setting) {
|
|
|
|
+ setting.pos = this.getObjPos(obj);
|
|
|
|
+ },
|
|
createNewSpread: function (obj) {
|
|
createNewSpread: function (obj) {
|
|
var spread = new GC.Spread.Sheets.Workbook(obj, {sheetCount: 1});
|
|
var spread = new GC.Spread.Sheets.Workbook(obj, {sheetCount: 1});
|
|
spread.options.tabStripVisible = false;
|
|
spread.options.tabStripVisible = false;
|
|
@@ -10,6 +30,7 @@ var TREE_SHEET_HELPER = {
|
|
spread.options.cutCopyIndicatorVisible = false;
|
|
spread.options.cutCopyIndicatorVisible = false;
|
|
spread.options.allowCopyPasteExcelStyle = false;
|
|
spread.options.allowCopyPasteExcelStyle = false;
|
|
spread.options.allowUserDragDrop = false;
|
|
spread.options.allowUserDragDrop = false;
|
|
|
|
+ spread.options.
|
|
spread.getActiveSheet().setRowCount(3);
|
|
spread.getActiveSheet().setRowCount(3);
|
|
return spread;
|
|
return spread;
|
|
},
|
|
},
|
|
@@ -249,7 +270,7 @@ var TREE_SHEET_HELPER = {
|
|
cellRect: cellRect,
|
|
cellRect: cellRect,
|
|
sheetArea: context.sheetArea
|
|
sheetArea: context.sheetArea
|
|
};
|
|
};
|
|
- }
|
|
|
|
|
|
+ };
|
|
TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
var offset = -1;
|
|
var offset = -1;
|
|
var node = tree.items[hitinfo.row];
|
|
var node = tree.items[hitinfo.row];
|
|
@@ -273,6 +294,47 @@ var TREE_SHEET_HELPER = {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ let TipCellType = function () {};
|
|
|
|
+ TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
|
+ TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
|
+ return {
|
|
|
|
+ x: x,
|
|
|
|
+ y: y,
|
|
|
|
+ row: context.row,
|
|
|
|
+ col: context.col,
|
|
|
|
+ cellStyle: cellStyle,
|
|
|
|
+ cellRect: cellRect,
|
|
|
|
+ sheet: context.sheet,
|
|
|
|
+ sheetArea: context.sheetArea
|
|
|
|
+ };
|
|
|
|
+ };
|
|
|
|
+ TipCellType.prototype.processMouseEnter = function (hitinfo) {
|
|
|
|
+ let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
|
|
|
|
+ if (setting.pos && text && text !== '') {
|
|
|
|
+ if (!this._toolTipElement) {
|
|
|
|
+ var div = document.createElement("div");
|
|
|
|
+ $(div).css("position", "absolute")
|
|
|
|
+ .css("border", "1px #C0C0C0 solid")
|
|
|
|
+ .css("box-shadow", "1px 2px 5px rgba(0,0,0,0.4)")
|
|
|
|
+ .css("font", "9pt Arial")
|
|
|
|
+ .css("background", "white")
|
|
|
|
+ .css("padding", 5);
|
|
|
|
+
|
|
|
|
+ this._toolTipElement = div;
|
|
|
|
+ }
|
|
|
|
+ $(this._toolTipElement).text(text).css("top", setting.pos.y + hitinfo.y + 15).css("left", setting.pos.x + hitinfo.x + 15);
|
|
|
|
+ $(this._toolTipElement).hide();
|
|
|
|
+ document.body.insertBefore(this._toolTipElement, null);
|
|
|
|
+ $(this._toolTipElement).show("fast");
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ TipCellType.prototype.processMouseLeave = function (hininfo) {
|
|
|
|
+ if (this._toolTipElement) {
|
|
|
|
+ document.body.removeChild(this._toolTipElement);
|
|
|
|
+ this._toolTipElement = null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
TREE_SHEET_HELPER.protectdSheet(sheet);
|
|
TREE_SHEET_HELPER.protectdSheet(sheet);
|
|
TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
|
|
TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
|
|
sheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
|
|
sheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
|
|
@@ -283,6 +345,9 @@ var TREE_SHEET_HELPER = {
|
|
sheet.setRowCount(tree.count() + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
|
|
sheet.setRowCount(tree.count() + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
|
|
setting.cols.forEach(function (colSetting, iCol) {
|
|
setting.cols.forEach(function (colSetting, iCol) {
|
|
sheet.setStyle(-1, iCol, TREE_SHEET_HELPER.getSheetCellStyle(colSetting));
|
|
sheet.setStyle(-1, iCol, TREE_SHEET_HELPER.getSheetCellStyle(colSetting));
|
|
|
|
+ if (colSetting.showHint) {
|
|
|
|
+ sheet.getRange(-1, iCol, -1, 1).cellType(new TipCellType());
|
|
|
|
+ }
|
|
});
|
|
});
|
|
sheet.getRange(-1, setting.treeCol, -1, 1).cellType(new TreeNodeCellType());
|
|
sheet.getRange(-1, setting.treeCol, -1, 1).cellType(new TreeNodeCellType());
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, tree.roots, true);
|
|
TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, tree.roots, true);
|