|
@@ -6,42 +6,65 @@ var gljOprObj = {
|
|
|
sheet: null,
|
|
|
libID: null,
|
|
|
ration: null,
|
|
|
- sheetData:null,
|
|
|
+ sheetData:[],
|
|
|
+ coeSheetData:[],
|
|
|
+ checkb:null,
|
|
|
+ coeSheet:null,
|
|
|
setting: {
|
|
|
header: [
|
|
|
- {headerName: "编码", headerWidth: 60, dataCode: "code", dataType: "String", formatter: "@"},
|
|
|
- {headerName: "名称", headerWidth: 80, dataCode: "name", dataType: "String"},
|
|
|
+ {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: "String", hAlign: "right"}, // dataType: "Number", formatter: "0.00"
|
|
|
- {headerName: "自定义消耗量", headerWidth: 80, dataCode: "customQuantity", dataType: "String", hAlign: "right"},
|
|
|
- {headerName: "消耗量", headerWidth: 80, dataCode: "quantity", dataType: "String", hAlign: "right"},
|
|
|
- {headerName: "基价单价", headerWidth: 80, dataCode: "basePrice", dataType: "String", hAlign: "right"},
|
|
|
+ {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: "price", dataType: "String", hAlign: "right"},
|
|
|
- {headerName: "是否暂估", headerWidth: 80, dataCode: "isEstimate", 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}]
|
|
|
- }
|
|
|
+ lockedCells: [{row: -1, col: 3, rowCount: -1, colCount: 1}],
|
|
|
+ lockColumns:[0,1,2,3,4,5,7,8,9,10,12]
|
|
|
+ },
|
|
|
+ notEditedType: ['混凝土','砂浆','配合比','机械']
|
|
|
+ },
|
|
|
+ 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);
|
|
|
- this.loadGLJSpreadContextMenu();
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
|
|
|
},
|
|
|
|
|
|
onClipboardPasting: function(sender, args) {
|
|
@@ -57,10 +80,31 @@ var gljOprObj = {
|
|
|
// your code...
|
|
|
},
|
|
|
|
|
|
- onEditEnded: function(sender, args){
|
|
|
+ onEditEnded: function(sender,args){
|
|
|
+ //activeSheet.getCell(1, 3, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
var me = gljOprObj;
|
|
|
- if (!me.ration) {return;};
|
|
|
- // your code...
|
|
|
+ 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);
|
|
|
+ },
|
|
|
+ onCellClick: function(sender,args){
|
|
|
+ var me = gljOprObj;
|
|
|
+ if(me.setting.header[args.col].dataCode=='marketPriceAdjust'){//市场单价调整
|
|
|
+ var type = me.sheetData[args.row].gljDistType;
|
|
|
+ var index= _.indexOf(me.setting.notEditedType,type);
|
|
|
+ if(index!=-1){
|
|
|
+ me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
|
|
|
onRangeChanged: function(sender, args) {
|
|
@@ -70,7 +114,7 @@ var gljOprObj = {
|
|
|
};
|
|
|
},
|
|
|
showDataIfRationSelect:function (node) {
|
|
|
- let gljList = [];
|
|
|
+ var isShow = false;
|
|
|
if(node){
|
|
|
if(this.selectedNodeId&&this.selectedNodeId==node.getID()){
|
|
|
return;
|
|
@@ -78,18 +122,49 @@ var gljOprObj = {
|
|
|
this.selectedNodeId=node.getID();
|
|
|
}
|
|
|
if(node.sourceType=="ration"){
|
|
|
- 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.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})
|
|
|
}
|
|
|
- this.selectedNodeId=null;
|
|
|
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;
|
|
@@ -108,7 +183,7 @@ var gljOprObj = {
|
|
|
disabled: function () {
|
|
|
//var selected = project.mainTree.selected;
|
|
|
var disable = true;
|
|
|
- if(gljOprObj.sheetData!=null&&gljOprObj.sheetData.length>0&&selectedRow<gljOprObj.sheetData.length){
|
|
|
+ if(subSpread.getActiveSheetIndex()==0&&gljOprObj.sheetData!=null&&gljOprObj.sheetData.length>0&&selectedRow<gljOprObj.sheetData.length){
|
|
|
disable=false
|
|
|
}
|
|
|
return disable;
|
|
@@ -120,7 +195,34 @@ var gljOprObj = {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+ },
|
|
|
+ updateRationGLJ:function (args,updateFunction) {
|
|
|
+ if(!updateFunction){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var me = gljOprObj;
|
|
|
+ var newval = this.numberValueChecking(args.editingText);
|
|
|
+ var recode = me.sheetData[args.row];
|
|
|
+ if(newval){
|
|
|
+ updateFunction.apply(projectObj.project.ration_glj,[recode,newval]);
|
|
|
+ }else {
|
|
|
+ newval = parseFloat(recode.customQuantity).toFixed(2);
|
|
|
+ me.sheet.getCell(args.row, args.col).value(newval);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ numberValueChecking:function (val) {
|
|
|
+ var newval = Number(val);
|
|
|
+ if(number_util.isNumber(newval)){
|
|
|
+ newval = newval.toFixed(2);
|
|
|
+ }else {
|
|
|
+ if(val){
|
|
|
+ alert('您输入的数据类型不正确,请重新输入。');
|
|
|
+ }
|
|
|
+ newval = null;
|
|
|
+ }
|
|
|
+ return newval;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
}
|
|
|
|