|
@@ -189,6 +189,8 @@ var TREE_SHEET_HELPER = {
|
|
|
if (colSetting.data.cellType && Object.prototype.toString.apply(colSetting.data.cellType) !== "[object String]") {
|
|
|
cell.cellType(colSetting.data.cellType(node,setting));
|
|
|
}
|
|
|
+ //树节点显示列
|
|
|
+ if(iCol == setting.treeCol) cell.cellType(TREE_SHEET_HELPER.getTreeNodeCellType(setting, sheet, node.tree,node));
|
|
|
if(colSetting.data.autoHeight == true){
|
|
|
colSetting.setAutoHeight(cell,node);
|
|
|
}
|
|
@@ -225,14 +227,94 @@ var TREE_SHEET_HELPER = {
|
|
|
sheet.invalidateLayout();
|
|
|
},
|
|
|
showTreeData: function (setting, sheet, tree) {
|
|
|
+ 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);
|
|
|
+ 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 dataField = setting.cols[hitinfo.col].data.field;
|
|
|
+
|
|
|
+ if((tag==undefined||tag=='')&&hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).wordWrap()==true){//显示其它列的标记为空并且设置了自动换行
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if(dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'||dataField=="name"){
|
|
|
+ if((hitinfo.sheet.getParent() === projectObj.mainSpread||hitinfo.sheet.getParent() === tender_obj.tenderSpread) && textLength <= cellWidth)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(hitinfo.sheet.name()=="mainSheet"){
|
|
|
+ if(dataField=="quantity"){//显示工程量明细
|
|
|
+ text = tag;
|
|
|
+ }/*if(dataField=="name"){//项目特征及内容隐藏时,显示特征及内容
|
|
|
+ if(projectObj.ifItemCharHiden(setting)&&tag!=''){
|
|
|
+ text = tag;
|
|
|
+ }else if(textLength <= cellWidth){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ else if(tag !== undefined && tag) {
|
|
|
+ text = tag;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ TREE_SHEET_HELPER.showTipsDiv(text,setting,hitinfo);
|
|
|
+ };
|
|
|
+ TipCellType.prototype.processMouseLeave = function (hitinfo) {
|
|
|
+ TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
+ }
|
|
|
+
|
|
|
+ TREE_SHEET_HELPER.protectdSheet(sheet);
|
|
|
+ TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
|
|
|
+ sheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
|
|
|
+ sheet.showRowOutline(false);
|
|
|
+ if (setting.defaultRowHeight) {
|
|
|
+ sheet.defaults.rowHeight = setting.defaultRowHeight;
|
|
|
+ }
|
|
|
+ sheet.setRowCount(tree.count() + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ sheet.getRange(tree.count(), -1, setting.emptyRows, -1).locked(true);
|
|
|
+ setting.cols.forEach(function (colSetting, iCol) {
|
|
|
+ sheet.setStyle(-1, iCol, TREE_SHEET_HELPER.getSheetCellStyle(colSetting));
|
|
|
+ if (colSetting.showHint) {
|
|
|
+ sheet.getRange(-1, iCol, -1, 1).cellType(new TipCellType());
|
|
|
+ }
|
|
|
+ if(colSetting.formatter){
|
|
|
+ sheet.setFormatter(-1, iCol, colSetting.formatter, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //sheet.getRange(-1, setting.treeCol, -1, 1).cellType(new TreeNodeCellType());
|
|
|
+ TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, tree.roots, true);
|
|
|
+ TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, sheet, true);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getTreeNodeCellType:function(setting, sheet,tree,initNode){
|
|
|
let indent = 20;
|
|
|
let levelIndent = -5;
|
|
|
let halfBoxLength = 5;
|
|
|
let halfExpandLength = 3;
|
|
|
+ let isRationNode = sheet.name()=="mainSheet" && initNode.sourceType == ModuleNames.ration;
|
|
|
+
|
|
|
|
|
|
let TreeNodeCellType = function () {
|
|
|
+ this.clickDropDown = false; //如果是点击下拉框的三角形的时候,默认展开下拉框
|
|
|
};
|
|
|
- TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
+ TreeNodeCellType.prototype =isRationNode? new GC.Spread.Sheets.CellTypes.Base(): new GC.Spread.Sheets.CellTypes.Text();//new GC.Spread.Sheets.CellTypes.Text();
|
|
|
TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
if (style.backColor) {
|
|
|
ctx.save();
|
|
@@ -332,10 +414,17 @@ var TREE_SHEET_HELPER = {
|
|
|
parentCenterX -= (indent + levelIndent);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
// Draw Text
|
|
|
x = x + (node.depth() + 1) * indent + node.depth() * levelIndent;
|
|
|
w = w - (node.depth() + 1) * indent - node.depth() * levelIndent;
|
|
|
GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
|
|
|
+ //画下拉框三角形
|
|
|
+ let sheet = options.sheet;
|
|
|
+ if (isRationNode&& options.row === sheet.getActiveRowIndex() && options.col === sheet.getActiveColumnIndex()) {
|
|
|
+ sheetCommonObj.drowTriangle(ctx,x+w-12,y+h/2+2);
|
|
|
+ }
|
|
|
+
|
|
|
};
|
|
|
TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
return {
|
|
@@ -352,6 +441,13 @@ var TREE_SHEET_HELPER = {
|
|
|
let offset = -1;
|
|
|
let node = tree.items[hitinfo.row];
|
|
|
tree.selected = node;
|
|
|
+ if(isRationNode &&hitinfo.row === hitinfo.sheet.getActiveRowIndex() && hitinfo.col === hitinfo.sheet.getActiveColumnIndex()){
|
|
|
+ if( hitinfo.x > hitinfo.cellRect.x + hitinfo.cellRect.width - 17){
|
|
|
+ this.clickDropDown = true;
|
|
|
+ setTimeout(function () {hitinfo.sheet.startEdit();},10);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
if (!node || node.children.length === 0) { return; }
|
|
|
let centerX = hitinfo.cellRect.x + offset + node.depth() * indent + node.depth() * levelIndent + indent / 2;
|
|
|
let centerY = (hitinfo.cellRect.y + offset + (hitinfo.cellRect.y + offset + hitinfo.cellRect.height)) / 2;
|
|
@@ -378,10 +474,10 @@ var TREE_SHEET_HELPER = {
|
|
|
});
|
|
|
hitinfo.sheet.repaint();
|
|
|
}
|
|
|
+
|
|
|
};
|
|
|
TreeNodeCellType.prototype.processMouseEnter = function(hitinfo){
|
|
|
if(hitinfo.sheet.name() === 'stdBillsGuidance_bills'){
|
|
|
-
|
|
|
TREE_SHEET_HELPER.delayShowTips(hitinfo,setting);
|
|
|
}
|
|
|
};
|
|
@@ -399,81 +495,70 @@ var TREE_SHEET_HELPER = {
|
|
|
TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
};
|
|
|
|
|
|
- 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
|
|
|
+ if(isRationNode){
|
|
|
+ TreeNodeCellType.prototype.createEditorElement = function (context) {
|
|
|
+ return document.createElement("div");
|
|
|
};
|
|
|
- };
|
|
|
- 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 dataField = setting.cols[hitinfo.col].data.field;
|
|
|
|
|
|
- if((tag==undefined||tag=='')&&hitinfo.sheet.getCell(hitinfo.row,hitinfo.col).wordWrap()==true){//显示其它列的标记为空并且设置了自动换行
|
|
|
- return;
|
|
|
- }
|
|
|
- if(dataField === 'itemCharacterText' || dataField === 'jobContentText' || dataField === 'adjustState'||dataField=="name"){
|
|
|
- if((hitinfo.sheet.getParent() === projectObj.mainSpread||hitinfo.sheet.getParent() === tender_obj.tenderSpread) && textLength <= cellWidth)
|
|
|
- return;
|
|
|
- }
|
|
|
+ TreeNodeCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect, context) {
|
|
|
+ $editor = $(editorContext);
|
|
|
+ $editor.css("position", "fixed");
|
|
|
+ $editor.css("background", 'white');
|
|
|
+ $editor.css("width", cellRect.width);
|
|
|
+ $editor.css("height", cellRect.height);
|
|
|
+ $editor.attr("gcUIElement", "gcEditingInput");//padding:0 //value="${context.sheet.getValue(context.row,context.col)}"
|
|
|
+ $editor.html(` <div class="input-group input-group-sm">
|
|
|
+ <input type="text" id="esInput" class="form-control" aria-label="Text input with dropdown button" autocomplete="off" style="background-color:${cellStyle.backColor}">
|
|
|
+ <div class="">
|
|
|
+ <div class="triangle-border_dropdown tb-border_dropdown" id="esBtn" style="left: ${cellRect.width - 15+"px"}"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ `);
|
|
|
+ // <div class = "input-group-append"><button class="btn btn-outline-secondary dropdown-toggle" id="esBtn" type="button" aria-haspopup="true" aria-expanded="false"></button></div>
|
|
|
+ $editor.children('div').height(cellRect.height+2);
|
|
|
+ return $editor;
|
|
|
+ };
|
|
|
|
|
|
- if(hitinfo.sheet.name()=="mainSheet"){
|
|
|
- if(dataField=="quantity"){//显示工程量明细
|
|
|
- text = tag;
|
|
|
- }/*if(dataField=="name"){//项目特征及内容隐藏时,显示特征及内容
|
|
|
- if(projectObj.ifItemCharHiden(setting)&&tag!=''){
|
|
|
- text = tag;
|
|
|
- }else if(textLength <= cellWidth){
|
|
|
- return;
|
|
|
- }
|
|
|
- }*/
|
|
|
- else if(tag !== undefined && tag) {
|
|
|
- text = tag;
|
|
|
- }
|
|
|
- }
|
|
|
+ TreeNodeCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect, context) {
|
|
|
+ let me = this;
|
|
|
+ $(editorContext).append(`<div><ul class="es-list" style="display: block;background-color:${cellStyle.backColor}"></ul></div>`);//<li class="" data-value="" style=""> <br></li>
|
|
|
+ $('#esInput').val(context.sheet.getValue(context.row,context.col));
|
|
|
+ $('#esInput').select();
|
|
|
+ projectObj.project.Ration.getNearRations(initNode.data,function(rations){
|
|
|
+ if(rations.length > 0){
|
|
|
+ let li_html = "";
|
|
|
+ for(let r of rations){
|
|
|
+ if(r.code==initNode.data.code) continue; //排除自已
|
|
|
+ li_html += `<li class="es_li" data-value="${r.code}" >${r.code} ${r.name} ${r.unit}</li>`;//定额编码+空格+定额名称+空格+定额单位。
|
|
|
+ }
|
|
|
+ $(".es-list").html(li_html);
|
|
|
+ $(".es-list").css("min-width",cellRect.width);
|
|
|
+ }
|
|
|
+ if(me.clickDropDown == false) $(".es-list").hide();
|
|
|
|
|
|
- TREE_SHEET_HELPER.showTipsDiv(text,setting,hitinfo);
|
|
|
- };
|
|
|
- TipCellType.prototype.processMouseLeave = function (hitinfo) {
|
|
|
- TREE_SHEET_HELPER.hideTipsDiv();
|
|
|
+ $(".es-list").children(".es_li").bind('click',function (e) {
|
|
|
+ $('#esInput').val(this.dataset.value);
|
|
|
+ $(".es-list").hide();
|
|
|
+ context.sheet.endEdit();
|
|
|
+ })
|
|
|
+ $("#esBtn").bind('click',function(e){
|
|
|
+ $(".es-list").toggle();
|
|
|
+ });
|
|
|
+ if( $('#esInput').val()) setCursor( $("#esInput")[0], $('#esInput').val().length)
|
|
|
+ });
|
|
|
+ };
|
|
|
+ TreeNodeCellType.prototype.setEditorValue = function (editor, value, context) {
|
|
|
+
|
|
|
+ $('#esInput').val(value);
|
|
|
+ };
|
|
|
+ TreeNodeCellType.prototype.getEditorValue = function (editor, context) {
|
|
|
+ this.isEscKey = false;
|
|
|
+ console.log($('#esInput').val());
|
|
|
+ return $('#esInput').val()!==''? $('#esInput').val():null;
|
|
|
+ };
|
|
|
}
|
|
|
+ return new TreeNodeCellType();
|
|
|
|
|
|
- TREE_SHEET_HELPER.protectdSheet(sheet);
|
|
|
- TREE_SHEET_HELPER.massOperationSheet(sheet, function () {
|
|
|
- sheet.rowOutlines.direction(GC.Spread.Sheets.Outlines.OutlineDirection.backward);
|
|
|
- sheet.showRowOutline(false);
|
|
|
- if (setting.defaultRowHeight) {
|
|
|
- sheet.defaults.rowHeight = setting.defaultRowHeight;
|
|
|
- }
|
|
|
- sheet.setRowCount(tree.count() + setting.emptyRows, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- sheet.getRange(tree.count(), -1, setting.emptyRows, -1).locked(true);
|
|
|
- setting.cols.forEach(function (colSetting, iCol) {
|
|
|
- sheet.setStyle(-1, iCol, TREE_SHEET_HELPER.getSheetCellStyle(colSetting));
|
|
|
- if (colSetting.showHint) {
|
|
|
- sheet.getRange(-1, iCol, -1, 1).cellType(new TipCellType());
|
|
|
- }
|
|
|
- if(colSetting.formatter){
|
|
|
- sheet.setFormatter(-1, iCol, colSetting.formatter, GC.Spread.Sheets.SheetArea.viewport);
|
|
|
- }
|
|
|
- });
|
|
|
- sheet.getRange(-1, setting.treeCol, -1, 1).cellType(new TreeNodeCellType());
|
|
|
- TREE_SHEET_HELPER.refreshTreeNodeData(setting, sheet, tree.roots, true);
|
|
|
- TREE_SHEET_HELPER.refreshNodesVisible(tree.roots, sheet, true);
|
|
|
- });
|
|
|
},
|
|
|
showTipsDiv:function (text,setting,hitinfo) {
|
|
|
if (setting.pos && text && text !== '') {
|