/** * Created by CSL on 2017-05-12. */ var gljOprObj = { sheet: null, libID: null, ration: null, sheetData:[], coeSheetData:[], checkb:null, coeSheet:null, setting: { header: [ {headerName: "编码", headerWidth: 100, dataCode: "code", dataType: "String", formatter: "@"}, {headerName: "名称", headerWidth: 120, dataCode: "name", dataType: "String"}, {headerName: "规格型号", headerWidth: 80, dataCode: "specs", dataType: "String", hAlign: "center"}, {headerName: "单位", headerWidth: 60, dataCode: "unit", dataType: "String", hAlign: "center"}, {headerName: "类别", headerWidth: 50, dataCode: "gljDistType", dataType: "String", hAlign: "center"}, {headerName: "定额消耗量", headerWidth: 80, dataCode: "rationItemQuantity", dataType: "Number", hAlign: "right"}, // dataType: "Number", formatter: "0.00" {headerName: "自定义消耗量", headerWidth: 80, dataCode: "customQuantity", dataType: "Number", hAlign: "right"}, {headerName: "消耗量", headerWidth: 80, dataCode: "quantity", dataType: "Number", hAlign: "right"}, {headerName: "基价单价", headerWidth: 80, dataCode: "basePrice", dataType: "Number", hAlign: "right"}, {headerName: "调整基价", headerWidth: 80, dataCode: "adjustPrice", dataType: "String", hAlign: "right"}, {headerName: "市场单价", headerWidth: 80, dataCode: "marketPrice", dataType: "String", hAlign: "right"}, {headerName: "市场单价调整", headerWidth: 80, dataCode: "marketPriceAdjust", dataType: "String", hAlign: "right"}, {headerName: "是否暂估", headerWidth: 80, dataCode: "isEstimate", dataType: "String", hAlign: "center",vAlign:"center",cellType:"checkBox"} ], view: { comboBox: [{row: -1, col: 12, rowCount: -1, colCount: 1}], lockedCells: [{row: -1, col: 3, rowCount: -1, colCount: 1}], lockColumns:[0,1,2,3,4,5,7,8,9,10,12] } }, coeSetting:{ header:[ {headerName: "调整", headerWidth: 100, dataCode: "isAdjust", dataType: "String",cellType:"checkBox"}, {headerName: "条件", headerWidth: 120, dataCode: "name", dataType: "String"}, {headerName: "内容", headerWidth: 260, dataCode: "content", dataType: "String", hAlign: "center"} ] }, initSheet: function(sheet) { var me = this; me.sheet = sheet; sheetCommonObj.initSheet(me.sheet, me.setting, 30); // var unit = new GC.Spread.Sheets.CellTypes.ComboBox(); //unit.items(["米","千克"]); // me.sheet.getRange(-1, 3, -1, 1).cellType(unit); me.bindSheetEvent(sheet); this.loadGLJSpreadContextMenu(); }, initCoeSheet:function (sheet) { var me = this; me.coeSheet = sheet; sheetCommonObj.initSheet(me.coeSheet, me.coeSetting, 30); me.bindSheetEvent(sheet); }, bindSheetEvent:function (sheet) { var me = this; sheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting); sheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted); sheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded); sheet.bind(GC.Spread.Sheets.Events.RangeChanged, me.onRangeChanged); }, onClipboardPasting: function(sender, args) { var me = gljOprObj; if (!me.ration) { args.cancel = true; } }, onClipboardPasted: function(e, info) { var me = gljOprObj; if (!me.ration) {return;}; // your code... }, onEditEnded: function(sender,args){ var me = gljOprObj; if(args.row>=me.sheetData.length){ return; } var ration_glj = projectObj.project.ration_glj; var updateFunction =null; if(me.setting.header[args.col].dataCode=='marketPriceAdjust'){//市场单价调整 updateFunction = ration_glj.marketPriceAdjustUpdate; } if(me.setting.header[args.col].dataCode=='customQuantity'){//自定义消耗量 updateFunction = ration_glj.customQuantityUpdate; } me.updateRationGLJ(args,updateFunction); }, onRangeChanged: function(sender, args) { if (args.action == GC.Spread.Sheets.RangeChangedAction.clear) { if (!confirm(`确定要删除选中的 ${args.rowCount} 条辅助定额吗?`)){return; } // your code... }; }, showDataIfRationSelect:function (node) { var isShow = false; if(node){ if(this.selectedNodeId&&this.selectedNodeId==node.getID()){ return; }else { this.selectedNodeId=node.getID(); } if(node.sourceType=="ration"){ this.showRationGLJData(node); this.showRationCoeData(node); isShow=true; } }else { this.selectedNodeId=null; } if(!isShow){ this.clearSheetData(); } // var activitySheet = subSpread.getActiveSheet(); //activitySheet.clear(0, 0, activitySheet.getRowCount(), activitySheet.getColumnCount(), GC.Spread.Sheets.SheetArea.viewport, GC.Spread.Sheets.StorageType.data); // ------sheetCommonObj.showData(this.sheet,this.setting,gljList); // sheetCommonObj.lockCells(this.sheet,this.setting); }, showRationGLJData:function (node) { let gljList = []; let ration_glj = projectObj.project.ration_glj; let ration = node.data; if(ration_glj.datas&&ration_glj.datas.length>0){ gljList = _.filter(ration_glj.datas,{'projectID':ration.projectID,'rationID':ration.ID}) } sheetCommonObj.showData(this.sheet,this.setting,gljList); this.sheetData=gljList; }, showRationCoeData:function (node) { let coeList = []; let ration_coe= projectObj.project.ration_coe; let ration = node.data; if(ration_coe.datas&&ration_coe.datas.length>0){ coeList = _.filter(ration_coe.datas,{'projectID':ration.projectID,'rationID':ration.ID}) } sheetCommonObj.showData(this.coeSheet,this.coeSetting,coeList); this.coeSheetData=coeList; }, clearSheetData:function () { sheetCommonObj.showData(this.sheet,this.setting,[]); sheetCommonObj.showData(this.coeSheet,this.coeSetting,[]); this.sheetData = []; this.coeSheetData = []; }, loadGLJSpreadContextMenu: function () { var project =projectObj.project, spread =subSpread; var selectedRow =null; $.contextMenu({ selector: '#subSpread', build: function ($trigger, e) { var target = SheetDataHelper.safeRightClickSelection($trigger, e, spread); selectedRow = target.row; //controller.setTreeSelected(controller.tree.items[target.row]); return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader; }, items: { "delete_glj": { name: '删除工料机', icon: 'fa-remove', disabled: function () { //var selected = project.mainTree.selected; var disable = true; if(subSpread.getActiveSheetIndex()==0&&gljOprObj.sheetData!=null&&gljOprObj.sheetData.length>0&&selectedRow