|
@@ -680,7 +680,7 @@ var projectObj = {
|
|
|
col.data.autoHeight = true;
|
|
|
col.showHint = true;
|
|
|
}
|
|
|
- if(col.data.field ==='quantity'){
|
|
|
+ if(col.data.field ==='quantity' || col.data.field ==='remark'){
|
|
|
col.showHint = true;
|
|
|
}
|
|
|
|
|
@@ -701,14 +701,16 @@ var projectObj = {
|
|
|
that.mainController.bind('refreshBaseActn', that.refreshBaseActn);
|
|
|
that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.beforeTreeSelectedChange, that.beforeMainTreeSelectedChange);
|
|
|
that.mainController.bind(TREE_SHEET_CONTROLLER.eventName.treeSelectedChanged, that.treeSelectedChanged);
|
|
|
-
|
|
|
+ if(!projectReadOnly){
|
|
|
+ that.bindEnterKey(that.mainSpread, 'mainEnterKey', that.mainSpreadEnterKey);
|
|
|
+ }
|
|
|
setTimeout(function () {
|
|
|
that.mainSpread.getActiveSheet().startEdit();//这两句需要挺多时间,而又需要在editend 事件前触发,而这些又不影响计算,所以这里用异步的方法
|
|
|
that.mainSpread.getActiveSheet().endEdit();
|
|
|
|
|
|
that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
|
|
|
},100);
|
|
|
- that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);
|
|
|
+ that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);//选中统计专用,节点相关操作在treeSelectedChanged里些
|
|
|
that.mainSpread.bind(GC.Spread.Sheets.Events.LeaveCell, that.mainSpreadLeaveCell);
|
|
|
that.mainSpread.bind(GC.Spread.Sheets.Events.EnterCell, that.mainSpreadEnterCell);
|
|
|
that.mainSpread.bind(GC.Spread.Sheets.Events.EditStarting, that.mainSpreadEditStarting);
|
|
@@ -739,6 +741,7 @@ var projectObj = {
|
|
|
if(projectReadOnly){
|
|
|
disableSpread(that.mainSpread);
|
|
|
}
|
|
|
+ console.log(decimalObj.decimal());
|
|
|
$.bootstrapLoading.end();
|
|
|
}
|
|
|
else {
|
|
@@ -747,6 +750,150 @@ var projectObj = {
|
|
|
});
|
|
|
|
|
|
},
|
|
|
+ mainSpreadEnterKey: function () {
|
|
|
+ let me = projectObj;
|
|
|
+ let sheet = me.mainSpread.getActiveSheet();
|
|
|
+ let orgRow = sheet.getActiveRowIndex();
|
|
|
+ let orgCol = sheet.getActiveColumnIndex();
|
|
|
+ let orgField = colSettingObj.getFieldByCol(orgCol);
|
|
|
+ let selected = me.project.mainTree.items[orgRow];
|
|
|
+ if(sheet.isEditing()){
|
|
|
+ sheet.endEdit();
|
|
|
+ }
|
|
|
+ //正常情况,焦点应该是在下一行的同一列
|
|
|
+ let newRow = orgRow + 1, newCol = orgCol;
|
|
|
+ //getColByField getVisible都不提出来,减少调用次数
|
|
|
+ if(selected){
|
|
|
+ //在分项/补项的编码单元格回车,焦点应跳动至本行的工程量单元格
|
|
|
+ if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
|
|
|
+ let quantityCol = colSettingObj.getColByField('quantity');
|
|
|
+ let quantityVisible = colSettingObj.getVisible('quantity');
|
|
|
+ if(quantityCol !== null && quantityVisible !== false){
|
|
|
+ newRow = orgRow;
|
|
|
+ newCol = quantityCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Bills.getSourceType() && [billType.FX, billType.BX].includes(selected.data.type)){
|
|
|
+ //在分项/补项的工程量单元格回车,如果其下有定额/量价/人材机,焦点应跳动至其下第一条定额/量价/人材机的工程量,如果是空行,则跳到至第一条定额xx的编码;
|
|
|
+ if(selected.children.length !== 0 && !(isDef(selected.children[0].data.code) && selected.children[0].data.code.toString().trim() !== '')){
|
|
|
+ let codeCol = colSettingObj.getColByField('code');
|
|
|
+ let codeVisible = colSettingObj.getVisible('code');
|
|
|
+ newRow = orgRow + 1;
|
|
|
+ if(codeCol !== null && codeVisible !== false){
|
|
|
+ newCol = codeCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果其下没有定额/量价/人材机,则自动在其下插入一条定额空行,在其后自动插入一条分项空行,焦点跳动至定额空行的编码单元格。
|
|
|
+ else if(selected.children.length === 0){
|
|
|
+ //在其后插入分项
|
|
|
+ if(!(projectInfoObj.projectInfo.property.lockBills && projectObj.project.withinBillsLocked(projectObj.project.mainTree.selected))){
|
|
|
+ ProjectController.addFX(me.project, me.mainController);
|
|
|
+ //将焦点行设置成原本的行,以插入定额
|
|
|
+ me.mainController.setTreeSelected(me.project.mainTree.items[orgRow]);
|
|
|
+ }
|
|
|
+ //插入定额
|
|
|
+ me.project.Ration.addNewRation(null, rationType.ration, function () {
|
|
|
+ newRow = sheet.getActiveRowIndex();
|
|
|
+ let codeCol = colSettingObj.getColByField('code');
|
|
|
+ let codeVisible = colSettingObj.getVisible('code');
|
|
|
+ if(codeCol !== null && codeVisible !== false){
|
|
|
+ newCol = codeCol;
|
|
|
+ }
|
|
|
+ sheet.setActiveCell(newRow, newCol);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //在定额/量价/人材机的编码单元格回车,焦点应跳动至本行的工程量单元格
|
|
|
+ else if(orgField && orgField === 'code' && selected.sourceType === me.project.Ration.getSourceType()){
|
|
|
+ let quantityCol = colSettingObj.getColByField('quantity');
|
|
|
+ let quantityVisible = colSettingObj.getVisible('quantity');
|
|
|
+ if(quantityCol !== null && quantityVisible !== false){
|
|
|
+ newRow = orgRow;
|
|
|
+ newCol = quantityCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //在定额/量价/人材机的工程量单元格回车
|
|
|
+ else if(orgField && orgField === 'quantity' && selected.sourceType === me.project.Ration.getSourceType()){
|
|
|
+ let nextSibling = selected.nextSibling;
|
|
|
+ //如果其后有定额/量价/人材机(空行:编码为空不算),焦点应跳动至下一行定额/量价/人材机的工程量,不需处理
|
|
|
+
|
|
|
+ //如果其后没有定额/量价/人材机(空行也没有),则自动在其后插入一行定额空行,焦点跳动至定额空行的编码单元格
|
|
|
+ if(!nextSibling){
|
|
|
+ let codeCol = colSettingObj.getColByField('code');
|
|
|
+ let codeVisible = colSettingObj.getVisible('code');
|
|
|
+ me.project.Ration.addNewRation(null, rationType.ration, function () {
|
|
|
+ newRow = sheet.getActiveRowIndex();
|
|
|
+ if(codeCol !== null && codeVisible !== false){
|
|
|
+ newCol = codeCol;
|
|
|
+ }
|
|
|
+ sheet.setActiveCell(newRow, newCol);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //如果其后有定额空行,焦点跳动至定额空行的编码单元格
|
|
|
+ else if(nextSibling && !(isDef(nextSibling.data.code) && nextSibling.data.code.toString().trim() !== '')) {
|
|
|
+ let codeCol = colSettingObj.getColByField('code');
|
|
|
+ let codeVisible = colSettingObj.getVisible('code');
|
|
|
+ if(codeCol !== null && codeVisible !== false){
|
|
|
+ newRow = orgRow + 1;
|
|
|
+ newCol = codeCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //在清单的编码单元格回车,如果清单是叶子节点,焦点跳动至本行的工程量单元格
|
|
|
+ else if(orgField && orgField === 'code' && selected.sourceType === me.project.Bills.getSourceType()
|
|
|
+ && selected.data.type === billType.BILL && selected.source.children.length === 0){
|
|
|
+ let quantityCol = colSettingObj.getColByField('quantity');
|
|
|
+ let quantityVisible = colSettingObj.getVisible('quantity');
|
|
|
+ if(quantityCol && quantityVisible){
|
|
|
+ newRow = orgRow;
|
|
|
+ newCol = quantityCol;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ //设置焦点
|
|
|
+ sheet.setActiveCell(newRow, newCol);
|
|
|
+ //触发表格事件
|
|
|
+ me.mainController.setTreeSelected(me.project.mainTree.items[newRow]);//SelectionChanged
|
|
|
+ me.mainSpreadLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
|
|
|
+ me.mainSpreadEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
|
|
|
+
|
|
|
+ },
|
|
|
+ //注册自定义回车键事件
|
|
|
+ bindEnterKey: function (workBook, registerName, operation) {
|
|
|
+ let me = this;
|
|
|
+ let sheet = workBook.getActiveSheet();
|
|
|
+ workBook.commandManager().register(registerName, operation);
|
|
|
+ /* workBook.commandManager().register(registerName, function(){
|
|
|
+ operation();
|
|
|
+ /!* let orgRow = sheet.getActiveRowIndex();
|
|
|
+ let orgCol = sheet.getActiveColumnIndex();
|
|
|
+ if(sheet.isEditing()){
|
|
|
+ sheet.endEdit();
|
|
|
+ }
|
|
|
+ let code = sheet.getValue(orgRow, 0);
|
|
|
+ let newRow, newCol;
|
|
|
+ if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
|
|
|
+ newRow = orgRow;
|
|
|
+ newCol = orgCol + 1;
|
|
|
+ sheet.setActiveCell(newRow, newCol);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newRow = orgRow + 1;
|
|
|
+ newCol = me.currentCache[orgRow + 1] ? orgCol : 0;
|
|
|
+ sheet.setActiveCell(newRow, newCol);
|
|
|
+ }*!/
|
|
|
+ //触发事件
|
|
|
+ /!*me.onLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
|
|
|
+ me.onEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
|
|
|
+ let newSels = [{row: newRow, rowCount: 1, col: newCol, colCount: 1}];
|
|
|
+ let oldSels = [{row: orgRow, rowCount: 1, col: orgRow, colCount: 1}];
|
|
|
+ me.onSelectionChanged({type: 'SelectionChanged'}, {sheet: sheet, sheetName: sheet.name(), newSelections: newSels, oldSelections: oldSels});*!/
|
|
|
+ });*/
|
|
|
+ workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
|
|
|
+ workBook.commandManager().setShortcutKey(registerName, GC.Spread.Commands.Key.enter, false, false, false, false);
|
|
|
+ },
|
|
|
loadMainSpreadContextMenu: function () {
|
|
|
var project = this.project, spread = this.mainSpread, controller = this.mainController;
|
|
|
$.contextMenu({
|