|
|
@@ -179,6 +179,7 @@ var sheetCommonObj = {
|
|
|
},
|
|
|
showRowData: function (sheet, setting, row, data, distTypeTree = null) {
|
|
|
let ch = GC.Spread.Sheets.SheetArea.viewport;
|
|
|
+ this.setRowStyle(row, sheet, data[row].bgColour);
|
|
|
for (var col = 0; col < setting.header.length; col++) {
|
|
|
//var cell = sheet.getCell(row, col, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
var val = _.get(data[row],setting.header[col].dataCode);
|
|
|
@@ -211,7 +212,7 @@ var sheetCommonObj = {
|
|
|
}
|
|
|
|
|
|
if (setting.header[col].cellType === "tipsCell") {
|
|
|
- this.setTipsCell(row, col, sheet, setting.header[col]);
|
|
|
+ this.setTipsCell(row, col, sheet);
|
|
|
}
|
|
|
if (setting.owner === 'gljTree') {
|
|
|
if (setting.header[col].cellType === "checkBox") {
|
|
|
@@ -223,12 +224,18 @@ var sheetCommonObj = {
|
|
|
val = distTypeVal;
|
|
|
}
|
|
|
}
|
|
|
+ if(setting.setCellType) setting.setCellType(sheet,data[row],row,col)
|
|
|
if (setting.header[col].getText) {
|
|
|
val = setting.getText[setting.header[col].getText](data[row], val)
|
|
|
}
|
|
|
sheet.setValue(row, col, val, ch);
|
|
|
+ if(setting.getStyle && setting.getStyle(data[row],row,null,setting.header[col].dataCode)){
|
|
|
+ let cstyle = setting.getStyle(data[row],row,null,setting.header[col].dataCode);
|
|
|
+ if(cstyle){
|
|
|
+ sheet.setStyle(row, col,cstyle);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- this.setRowStyle(row, sheet, data[row].bgColour);
|
|
|
if (setting.autoFit == true) {//设置自动行高
|
|
|
if (setting.fitRow && setting.fitRow.length > 0) {//如果有设置特定的某些列才需要自动行高就按设置的来,没有设置就默认所有列
|
|
|
for (let dataCode of setting.fitRow) {
|
|
|
@@ -241,8 +248,8 @@ var sheetCommonObj = {
|
|
|
|
|
|
sheet.autoFitRow(row);
|
|
|
}
|
|
|
- if (setting.getStyle && setting.getStyle(data[row], row, sheet.getActiveRowIndex())) {
|
|
|
- sheet.setStyle(row, -1, setting.getStyle(data[row]));
|
|
|
+ if(setting.getStyle && setting.getStyle(data[row],row,sheet.getActiveRowIndex())){
|
|
|
+ sheet.setStyle(row, -1, setting.getStyle(data[row],row,sheet.getActiveRowIndex()));
|
|
|
}
|
|
|
},
|
|
|
showTreeData:function (sheet,setting,data) {
|
|
|
@@ -400,10 +407,19 @@ var sheetCommonObj = {
|
|
|
sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
|
|
|
|
|
|
},
|
|
|
- getCheckBox(threeState = false) {
|
|
|
- var c = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
- c.isThreeState(threeState);
|
|
|
- return c
|
|
|
+ getCheckBox(threeState = false){
|
|
|
+ var c = new GC.Spread.Sheets.CellTypes.CheckBox();
|
|
|
+ c.isThreeState(threeState);
|
|
|
+ return c
|
|
|
+ },
|
|
|
+ // 无法勾选的复选框
|
|
|
+ getReadOnlyCheckBox (threeState = false) {
|
|
|
+ function ReadOnlyCheckBox() {}
|
|
|
+ ReadOnlyCheckBox.prototype = this.getCheckBox(threeState);
|
|
|
+ ReadOnlyCheckBox.prototype.processMouseUp = function () {
|
|
|
+ return;
|
|
|
+ };
|
|
|
+ return new ReadOnlyCheckBox();
|
|
|
},
|
|
|
setComboBox(row, col, sheet, options, editorValueType, editable, maxDropDownItems) {
|
|
|
//let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
|
|
|
@@ -673,7 +689,7 @@ var sheetCommonObj = {
|
|
|
sheet.setCellType(row, col, cellType, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
},
|
|
|
|
|
|
- setTipsCell(row, col, sheet, header) {
|
|
|
+ setTipsCell(row, col, sheet,tips) {
|
|
|
let TipCellType = function () { };
|
|
|
TipCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
TipCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
@@ -690,16 +706,19 @@ var sheetCommonObj = {
|
|
|
};
|
|
|
TipCellType.prototype.processMouseEnter = function (hitinfo) {
|
|
|
let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
|
|
|
- let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
|
|
|
- let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
|
|
|
- let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
|
|
|
- zoom = hitinfo.sheet.zoom();
|
|
|
- let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, { sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport });
|
|
|
- let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
|
|
|
let setting = {};
|
|
|
- if (textLength <= cellWidth) {
|
|
|
- return;
|
|
|
+ if(!tips){
|
|
|
+ let value = hitinfo.sheet.getValue(hitinfo.row, hitinfo.col);
|
|
|
+ let tag = hitinfo.sheet.getTag(hitinfo.row, hitinfo.col);
|
|
|
+ let acStyle = hitinfo.sheet.getActualStyle(hitinfo.row, hitinfo.col),
|
|
|
+ zoom = hitinfo.sheet.zoom();
|
|
|
+ let textLength = this.getAutoFitWidth(value, text, acStyle, zoom, { sheet: hitinfo.sheet, row: hitinfo.row, col: hitinfo.col, sheetArea: GC.Spread.Sheets.SheetArea.viewport });
|
|
|
+ let cellWidth = hitinfo.sheet.getCell(-1, hitinfo.col).width();
|
|
|
+ if (textLength <= cellWidth) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
+ text = tips;
|
|
|
if (sheet && sheet.getParent().qo) {
|
|
|
setting.pos = SheetDataHelper.getObjPos(sheet.getParent().qo);
|
|
|
}
|
|
|
@@ -763,7 +782,59 @@ var sheetCommonObj = {
|
|
|
};
|
|
|
return new ComboCellForActiveCell();
|
|
|
},
|
|
|
- getTipsCombo: function (forLocked, tips, setting, node) {
|
|
|
+ getTipsCell: function (baseCell, cellPrototype, tips, setting, node) {
|
|
|
+ let getTipsCell = function () {
|
|
|
+ this.clickCom=false;
|
|
|
+ };
|
|
|
+ getTipsCell.prototype = baseCell;
|
|
|
+ if(tips && tips !=""){
|
|
|
+ getTipsCell.prototype.processMouseEnter = function(hitinfo){
|
|
|
+ if(this.clickCom == true){ //点击了下拉框的三角形,则不用再显示悬浮框了
|
|
|
+ this.clickCom = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let text = typeof tips == 'function'?tips(node):tips;
|
|
|
+ TREE_SHEET_HELPER.delayShowTips(hitinfo,setting,text);
|
|
|
+ };
|
|
|
+ getTipsCell.prototype.processMouseLeave = function (hitinfo) {
|
|
|
+ TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
+ };
|
|
|
+ getTipsCell.prototype.processMouseDown = function (hitinfo){
|
|
|
+ if(hitinfo.isReservedLocation == true){//这里是点击了下拉框的三角形才会有这个属性
|
|
|
+ TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
+ this.clickCom = true;
|
|
|
+ }
|
|
|
+ cellPrototype.processMouseDown.apply(this, arguments);
|
|
|
+ };
|
|
|
+
|
|
|
+ getTipsCell.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context){
|
|
|
+ TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
+ cellPrototype.updateEditor.apply(this, arguments);
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return new getTipsCell();
|
|
|
+ },
|
|
|
+ getTipsText: function (tips, setting, node) {
|
|
|
+ function baseTextCell() {}
|
|
|
+ baseTextCell.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
+ baseTextCell.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
+ return {
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ row: context.row,
|
|
|
+ col: context.col,
|
|
|
+ cellStyle: cellStyle,
|
|
|
+ cellRect: cellRect,
|
|
|
+ sheetArea: context.sheetArea
|
|
|
+ };
|
|
|
+ };
|
|
|
+ return this.getTipsCell(new baseTextCell(), GC.Spread.Sheets.CellTypes.Text.prototype, tips, setting, node);
|
|
|
+ },
|
|
|
+ getTipsCombo:function (forLocked,tips,setting,node) {
|
|
|
+ const baseCell = sheetCommonObj.getDynamicCombo(forLocked);
|
|
|
+ return this.getTipsCell(baseCell, GC.Spread.Sheets.CellTypes.ComboBox.prototype, tips, setting, node);
|
|
|
+ },
|
|
|
+ /* getTipsCombo: function (forLocked, tips, setting, node) {
|
|
|
let getTipsCombo = function () {
|
|
|
this.clickCom = false;
|
|
|
};
|
|
|
@@ -794,8 +865,8 @@ var sheetCommonObj = {
|
|
|
};
|
|
|
}
|
|
|
return new getTipsCombo();
|
|
|
- },
|
|
|
- getTreeNodeCellType: function (datas, row, parentMap,treeCol, paintFunc) {// 2018-09-26 不用spreadjs默认的树结构,自定义控件
|
|
|
+ }, */
|
|
|
+ getTreeNodeCellType: function (datas, row, parentMap,treeCol, paintFunc,tips) {// 2018-09-26 不用spreadjs默认的树结构,自定义控件
|
|
|
var ns = GC.Spread.Sheets;
|
|
|
let rectW = 10;
|
|
|
let rectH = 10;
|
|
|
@@ -860,6 +931,26 @@ var sheetCommonObj = {
|
|
|
sheetArea: context.sheetArea
|
|
|
};
|
|
|
}
|
|
|
+ if(tips){
|
|
|
+ TreeNodeCellType.prototype.processMouseEnter = function (hitinfo) {
|
|
|
+ let text = hitinfo.sheet.getText(hitinfo.row, hitinfo.col);
|
|
|
+ let setting = {};
|
|
|
+ text = tips;
|
|
|
+ if (hitinfo.sheet && hitinfo.sheet.getParent().qo) {
|
|
|
+ setting.pos = SheetDataHelper.getObjPos(hitinfo.sheet.getParent().qo);
|
|
|
+ }
|
|
|
+
|
|
|
+ TREE_SHEET_HELPER.showTipsDiv(text, setting, hitinfo);
|
|
|
+ };
|
|
|
+ TreeNodeCellType.prototype.processMouseLeave = function (hitinfo) {
|
|
|
+ TREE_SHEET_HELPER.tipDiv = 'hide';
|
|
|
+ if (TREE_SHEET_HELPER._toolTipElement) {
|
|
|
+ $(TREE_SHEET_HELPER._toolTipElement).hide();
|
|
|
+ TREE_SHEET_HELPER._toolTipElement = null;
|
|
|
+ };
|
|
|
+ TREE_SHEET_HELPER.tipDivCheck();//延时检查:当tips正在show的时候,就调用了hide方法,会导致tips一直存在,所以设置一个超时处理
|
|
|
+ };
|
|
|
+ }
|
|
|
TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
|
////方框外1像素内都有效
|
|
|
if (!_.isEmpty(this.rectInfo) && Math.floor(hitinfo.x) <= this.rectInfo.x + this.rectInfo.rectW + 2 && Math.floor(hitinfo.x) >= this.rectInfo.x - 2) {
|
|
|
@@ -909,7 +1000,7 @@ var sheetCommonObj = {
|
|
|
return new TreeNodeCellType()
|
|
|
|
|
|
function getTreeLevel(item, data) {
|
|
|
- if (item.ParentID && item.ParentID!=-1) {
|
|
|
+ if (item && item.ParentID && item.ParentID!=-1) {
|
|
|
let pitem = _.find(data, { 'ID': item.ParentID });
|
|
|
return getTreeLevel(pitem, data) + 1;
|
|
|
} else {
|
|
|
@@ -1263,6 +1354,34 @@ var sheetCommonObj = {
|
|
|
}
|
|
|
return null;
|
|
|
},
|
|
|
+ disableSpread(spread) {
|
|
|
+ spread.unbind(GC.Spread.Sheets.Events.ButtonClicked);
|
|
|
+ let sheetCount = spread.getSheetCount();
|
|
|
+ for(let i = 0; i < sheetCount; i++){
|
|
|
+ let sheet = spread.getSheet(i);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.ButtonClicked);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.EditStarting);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.EditEnded);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.RangeChanged);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanging);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.ClipboardChanged);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.CellDoubleClick);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.CellClick);
|
|
|
+ sheet.unbind(GC.Spread.Sheets.Events.ValueChanged);
|
|
|
+ sheet.suspendPaint();
|
|
|
+ sheet.suspendEvent();
|
|
|
+ sheet.options.isProtected = true;
|
|
|
+ let rowCount = sheet.getRowCount();
|
|
|
+ let colCount = sheet.getColumnCount();
|
|
|
+ for(let row = 0; row < rowCount; row++){
|
|
|
+ for(let col = 0; col < colCount; col++){
|
|
|
+ sheet.getCell(row, col).locked(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sheet.resumePaint();
|
|
|
+ sheet.resumeEvent();
|
|
|
+ }
|
|
|
+ },
|
|
|
// 延迟一段时间刷新表格,因为有的弹窗里面有表格,马上刷新可能会造成,弹窗界面还未完全显示完就完成了表格刷新,导致表格显示不完整
|
|
|
refreshWorkbookDelDefer(workbook, time) {
|
|
|
if (workbook) {
|