|
@@ -106,12 +106,29 @@ var gljOprObj = {
|
|
|
subSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, me.onButtonClick);
|
|
|
if(!projectReadOnly){
|
|
|
gljContextMenu.loadGLJSpreadContextMenu();
|
|
|
+ //me.bindGLJEnterKey(subSpread,sheet);
|
|
|
}
|
|
|
sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,function (sender,args) {
|
|
|
let selected = args.newSelections[0] ? args.newSelections[0] : {row: 0, col: 0};
|
|
|
me.sheetInitSelection(selected);
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
+ bindGLJEnterKey:function (spread,sheet) {
|
|
|
+ let me = this;
|
|
|
+ subSpread.commandManager().register('myEnter', enterKeyAction);
|
|
|
+ subSpread.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
|
|
|
+ subSpread.commandManager().setShortcutKey('myEnter', GC.Spread.Commands.Key.enter, false, false, false, false);
|
|
|
+
|
|
|
+ function enterKeyAction(spd,sheeName) {
|
|
|
+ let editRow = sheet.getActiveRowIndex(),orgCol = sheet.getActiveColumnIndex();
|
|
|
+ if(sheet.isEditing()) sheet.endEdit();
|
|
|
+ //GC.Spread.Sheets.Commands.commitInputNavigationDown.execute(spd,sheeName);
|
|
|
+ //sheet.setSelection(editRow,orgCol+1,1,1);
|
|
|
+ GC.Spread.Sheets.Commands.navigationRight.execute(spd,sheeName);
|
|
|
+ //sheet.setActiveCell(editRow, orgCol+1)
|
|
|
+ }
|
|
|
+ },
|
|
|
sheetInitSelection: function (selected) {
|
|
|
let me = gljOprObj;
|
|
|
if(selected.row < me.sheetData.length){
|
|
@@ -553,12 +570,15 @@ var gljOprObj = {
|
|
|
if(priceMap){
|
|
|
for(let connectKey in priceMap){
|
|
|
let code = priceMap[connectKey].code;
|
|
|
+ let name = priceMap[connectKey].name;
|
|
|
+ let specs = priceMap[connectKey].specs;
|
|
|
if(code){
|
|
|
+ let displayText = code +" "+name +" "+specs;
|
|
|
let preCode = code.split("-")[0];
|
|
|
if(codeMap[preCode]) {
|
|
|
- codeMap[preCode].push({text:code,value:connectKey});
|
|
|
+ codeMap[preCode].push({text:displayText,value:connectKey});
|
|
|
}else {
|
|
|
- codeMap[preCode]=[{text:code ,value:connectKey}];
|
|
|
+ codeMap[preCode]=[{text:displayText ,value:connectKey}];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -571,7 +591,8 @@ var gljOprObj = {
|
|
|
this.sheet.suspendEvent();
|
|
|
this.sheet.setRowCount(this.sheetData.length >30?this.sheetData.length:30);
|
|
|
for (var i = 0; i < this.sheetData.length; i++) {
|
|
|
- this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,i,codeMap),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
+ let options = this.getCodeOptions(this.sheetData[i],codeMap);
|
|
|
+ this.sheet.setCellType(i, 0,this.getTreeNodeCellType(this.sheetData,options),GC.Spread.Sheets.SheetArea.viewport);
|
|
|
if (this.sheetData[i].hasOwnProperty('subList')) {
|
|
|
var collapsed = this.sheetData[i].collapsed == undefined ? true : this.sheetData[i].collapsed;
|
|
|
if (collapsed == true) {
|
|
@@ -582,6 +603,19 @@ var gljOprObj = {
|
|
|
this.sheet.resumeEvent();
|
|
|
this.sheet.resumePaint();
|
|
|
},
|
|
|
+ getCodeOptions:function (recode,codeMap) {
|
|
|
+ let options = [];
|
|
|
+ if(recode.isMixRatio ===true){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ let code = recode.code;
|
|
|
+ if(code) {
|
|
|
+ let preCode = code.split("-")[0];
|
|
|
+ if( codeMap[preCode]) options = codeMap[preCode];
|
|
|
+ if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(recode, gljKeyArray)})//去掉本身
|
|
|
+ }
|
|
|
+ return options;
|
|
|
+ },
|
|
|
filterGljByRation: function (ration, datas) {
|
|
|
var gljList = [];
|
|
|
if (datas && datas.length > 0) {
|
|
@@ -669,11 +703,13 @@ var gljOprObj = {
|
|
|
let decimalObj = projectInfoObj.projectInfo.property.decimal;
|
|
|
let labourCoeDatas = projectObj.project.labourCoe.datas;
|
|
|
glj = glj?glj:_.find(proGLJ.datas.gljList, {'id': data.projectGLJID});
|
|
|
- let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
|
|
|
- data.marketPrice = result.marketPrice;
|
|
|
- data.basePrice = result.basePrice;
|
|
|
- data.adjustPrice = result.adjustPrice;
|
|
|
- data.marketUnitFee = data.marketPrice;//更新树节点市场单价列的值
|
|
|
+ if(glj){
|
|
|
+ let result = gljUtil.getGLJPrice(glj,proGLJ.datas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
|
|
|
+ data.marketPrice = result.marketPrice;
|
|
|
+ data.basePrice = result.basePrice;
|
|
|
+ data.adjustPrice = result.adjustPrice;
|
|
|
+ data.marketUnitFee = data.marketPrice;//更新树节点市场单价列的值
|
|
|
+ }
|
|
|
return data;
|
|
|
|
|
|
},
|
|
@@ -1196,7 +1232,7 @@ var gljOprObj = {
|
|
|
}
|
|
|
return node;
|
|
|
},
|
|
|
- getTreeNodeCellType: function (data,index,codeMap) {
|
|
|
+ getTreeNodeCellType: function (data,comboboxOptions) {
|
|
|
var ns = GC.Spread.Sheets;
|
|
|
var rectW = 10;
|
|
|
var rectH = 10;
|
|
@@ -1258,12 +1294,17 @@ var gljOprObj = {
|
|
|
return offset;
|
|
|
}
|
|
|
|
|
|
- if(isDef(index) && data[index] && data[index].isMixRatio !==true){
|
|
|
- TreeNodeCellType.prototype = sheetCommonObj.getDynamicCombo();
|
|
|
- }else {
|
|
|
- TreeNodeCellType.prototype = new ns.CellTypes.Text();
|
|
|
- }
|
|
|
+ TreeNodeCellType.prototype = comboboxOptions?sheetCommonObj.getDynamicCombo():new ns.CellTypes.Text();
|
|
|
+
|
|
|
TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
+ if (style.backColor) {//先画背景色
|
|
|
+ ctx.save();
|
|
|
+ ctx.fillStyle = style.backColor;
|
|
|
+ ctx.fillRect(x, y, w, h);
|
|
|
+ ctx.restore();
|
|
|
+ } else {
|
|
|
+ ctx.clearRect(x, y, w, h);
|
|
|
+ }
|
|
|
if (value != null) {
|
|
|
var offset = margin + rectW + 6;
|
|
|
var recode = data[options.row];
|
|
@@ -1283,7 +1324,7 @@ var gljOprObj = {
|
|
|
}
|
|
|
};
|
|
|
TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
- if(x < cellRect.x+cellRect.width -15){
|
|
|
+ if(x < cellRect.x+cellRect.width -15){//这里要判断点击的位置来决定return的内容,不能直接用combobox的方法
|
|
|
return {
|
|
|
x: x,
|
|
|
y: y,
|
|
@@ -1317,17 +1358,9 @@ var gljOprObj = {
|
|
|
// GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
|
|
|
};
|
|
|
let cellType = new TreeNodeCellType();
|
|
|
- let options = [];
|
|
|
- if(isDef(index) && data[index] && data[index].isMixRatio !==true){
|
|
|
- let code = data[index].code;
|
|
|
- if(code) {
|
|
|
- let preCode = code.split("-")[0];
|
|
|
- if( codeMap[preCode]) options = codeMap[preCode];
|
|
|
- if(options.length>0) _.remove(options,{'value':gljOprObj.getIndex(data[index], gljKeyArray)})//去掉本身
|
|
|
-
|
|
|
- }
|
|
|
+ if(comboboxOptions){
|
|
|
cellType.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
|
|
|
- cellType.itemHeight(options.length).items(options);
|
|
|
+ cellType.itemHeight(comboboxOptions.length).items(comboboxOptions);
|
|
|
}
|
|
|
return cellType;
|
|
|
},
|