|
@@ -307,6 +307,8 @@ var gljOprObj = {
|
|
|
var index= _.indexOf(me.setting.notEditedType,type);
|
|
|
if(index!=-1){
|
|
|
me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
+ }else {
|
|
|
+ me.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).locked(false);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -487,7 +489,6 @@ var gljOprObj = {
|
|
|
return rowstr;
|
|
|
|
|
|
},
|
|
|
-
|
|
|
showDataIfRationSelect:function (node) {
|
|
|
var isShow = false;
|
|
|
if(node){
|
|
@@ -526,9 +527,25 @@ var gljOprObj = {
|
|
|
this.showInSheet(gljList);
|
|
|
}
|
|
|
},
|
|
|
- showRationGLJSheetData:function () {
|
|
|
- this.sheetData=_.sortBy(this.sheetData,'type');
|
|
|
+ showRationGLJSheetData:function (init) {
|
|
|
+ this.sheet.getRange(0,-1,this.sheet.getRowCount(),-1).visible(true);
|
|
|
+ if(init){
|
|
|
+ this.sheetData=_.sortBy(this.sheetData,'type');
|
|
|
+ this.addMixRatioToShow();
|
|
|
+ this.initRationTree();
|
|
|
+ }
|
|
|
sheetCommonObj.showData(this.sheet,this.setting,this.sheetData);
|
|
|
+
|
|
|
+ },
|
|
|
+ initRationTree:function () {
|
|
|
+ this.sheet.getRange(-1, 0, -1, 1).cellType(this.getTreeNodeCellType(this.sheetData));
|
|
|
+ for(var i =0;i<this.sheetData.length;i++){
|
|
|
+ if(this.sheetData[i].hasOwnProperty('subList')){
|
|
|
+ this.sheet.setTag(i,0,true);
|
|
|
+ this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).visible(false);
|
|
|
+ this.sheet.getRange(i+1, -1, this.sheetData[i].subList.length, -1).locked(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
filterGljByRation:function (ration,datas) {
|
|
|
var gljList=[];
|
|
@@ -539,24 +556,62 @@ var gljOprObj = {
|
|
|
},
|
|
|
showInSheet:function(gljList){
|
|
|
this.sheetData=this.combineWithProjectGlj(gljList);
|
|
|
- this.showRationGLJSheetData();
|
|
|
+ this.showRationGLJSheetData(true);
|
|
|
+ },
|
|
|
+ addMixRatioToShow:function () {
|
|
|
+ var newList=[];
|
|
|
+ for(var i =0;i<this.sheetData.length;i++){
|
|
|
+ newList.push(this.sheetData[i]);
|
|
|
+ if(this.sheetData[i].hasOwnProperty('subList')){
|
|
|
+ newList = newList.concat(this.sheetData[i].subList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.sheetData= newList;
|
|
|
},
|
|
|
combineWithProjectGlj:function (ration_gljs) {
|
|
|
- var projectGljs = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ var projectGLJData = projectObj.project.projectGLJ.datas;
|
|
|
+ var projectGljs = projectGLJData.gljList;
|
|
|
+ var mixRatioMap = projectGLJData.mixRatioMap;
|
|
|
if(ration_gljs&&ration_gljs.length>0&&projectGljs&&projectGljs.length>0){
|
|
|
- ration_gljs.forEach(function (a) {
|
|
|
- var glj = _.find(projectGljs,{id:a.projectGLJID});
|
|
|
+ for(var i =0;i<ration_gljs.length;i++){
|
|
|
+ var glj = _.find(projectGljs,{'id':ration_gljs[i].projectGLJID});
|
|
|
if(glj){
|
|
|
- a.basePrice=glj.unit_price.base_price;
|
|
|
- a.marketPrice=glj.unit_price.market_price;
|
|
|
- a.adjustPrice=glj.adjust_price;
|
|
|
- a.isEstimate=glj.is_evaluate;
|
|
|
+ ration_gljs[i].basePrice=glj.unit_price.base_price;
|
|
|
+ ration_gljs[i].marketPrice=glj.unit_price.market_price;
|
|
|
+ ration_gljs[i].adjustPrice=glj.adjust_price;
|
|
|
+ ration_gljs[i].isEstimate=glj.is_evaluate;
|
|
|
+ if(mixRatioMap.hasOwnProperty(glj.code)){
|
|
|
+ var mixRatios = this.getMixRationShowDatas(mixRatioMap[glj.code],projectGljs);
|
|
|
+ ration_gljs[i].subList = mixRatios;
|
|
|
+ }
|
|
|
}
|
|
|
- })
|
|
|
+ }
|
|
|
}
|
|
|
return ration_gljs;
|
|
|
- }
|
|
|
- ,
|
|
|
+ },
|
|
|
+ getMixRationShowDatas:function (mixRatioList,projectGljs) {
|
|
|
+ var temRationGLJs = [];
|
|
|
+ for(var i =0;i<mixRatioList.length;i++){
|
|
|
+ var pg = _.find(projectGljs,{'code':mixRatioList[i].code});
|
|
|
+ var tem = {
|
|
|
+ code:pg.code,
|
|
|
+ name:pg.name,
|
|
|
+ specs:pg.specs,
|
|
|
+ unit:pg.unit,
|
|
|
+ shortName:pg.unit_price.short_name,
|
|
|
+ rationItemQuantity:mixRatioList[i].consumption,
|
|
|
+ // quantity:mixRatioList[i].consumption,
|
|
|
+ basePrice:pg.unit_price.base_price,
|
|
|
+ marketPrice:pg.unit_price.market_price,
|
|
|
+ adjustPrice:pg.adjust_price,
|
|
|
+ isEstimate:pg.is_evaluate,
|
|
|
+ isMixRatio:true
|
|
|
+ }
|
|
|
+ temRationGLJs.push(tem);
|
|
|
+ }
|
|
|
+ temRationGLJs=_.sortBy(temRationGLJs,'code');
|
|
|
+ return temRationGLJs;
|
|
|
+ },
|
|
|
showRationCoeData:function (node) {
|
|
|
var coeList = [];
|
|
|
var ration_coe= projectObj.project.ration_coe;
|
|
@@ -874,6 +929,111 @@ var gljOprObj = {
|
|
|
},
|
|
|
refreshView:function () {
|
|
|
this.showRationGLJData();
|
|
|
+ },
|
|
|
+ getTreeNodeCellType:function (data) {
|
|
|
+ var ns = GC.Spread.Sheets;
|
|
|
+ var rectW = 10;
|
|
|
+ var rectH = 10;
|
|
|
+ var margin = 3;
|
|
|
+ function TreeNodeCellType() {
|
|
|
+ }
|
|
|
+
|
|
|
+ function drowRect(ctx,x,y,w,h) {
|
|
|
+ ctx.save();
|
|
|
+ ctx.strokeStyle = "gray";
|
|
|
+ ctx.translate(0.5,0.5);
|
|
|
+ ctx.beginPath();
|
|
|
+ var rectX = x+margin;
|
|
|
+ var rectY = y+ Math.round(h/2)-rectH/2;
|
|
|
+ ctx.moveTo(rectX, rectY);
|
|
|
+ ctx.lineTo(rectX, rectY+rectH);
|
|
|
+ ctx.lineTo(rectX+rectW, rectY+rectH);
|
|
|
+ ctx.lineTo(rectX+rectW, rectY);
|
|
|
+ ctx.lineTo(rectX, rectY);
|
|
|
+ ctx.moveTo(rectX+rectW, y+Math.round(h/2));
|
|
|
+ ctx.lineTo(rectX+rectW+5, y+Math.round(h/2));
|
|
|
+ ctx.stroke();
|
|
|
+ ctx.restore();
|
|
|
+ }
|
|
|
+
|
|
|
+ function drowSymbol(ctx,x,y,w,h,collapsed) {
|
|
|
+ ctx.save();
|
|
|
+ ctx.strokeStyle = "#000000";
|
|
|
+ ctx.translate(0.5, 0.5);
|
|
|
+ ctx.beginPath();
|
|
|
+ ctx.moveTo(x+margin+2, y+Math.round(h/2));
|
|
|
+ ctx.lineTo(x+margin+8, y+Math.round(h/2));
|
|
|
+ var rectY = y+ Math.round(h/2)-rectH/2;
|
|
|
+ if(collapsed){
|
|
|
+ ctx.moveTo(x+margin+rectW/2,rectY+2);
|
|
|
+ ctx.lineTo(x+margin+rectW/2,rectY+2+6);
|
|
|
+ }
|
|
|
+ ctx.stroke();
|
|
|
+ ctx.restore();
|
|
|
+ }
|
|
|
+
|
|
|
+ function drowSubItem(ctx,x,y,w,h,offset,nextItem) {
|
|
|
+ offset+=6;
|
|
|
+ ctx.save();
|
|
|
+ ctx.strokeStyle = "gray";
|
|
|
+ ctx.translate(0.5, 0.5);
|
|
|
+ ctx.beginPath();
|
|
|
+ ctx.moveTo(x+offset, y);
|
|
|
+ ctx.lineTo(x+offset, y+Math.round(h/2));
|
|
|
+ offset+=9;
|
|
|
+ ctx.lineTo(x+offset, y+Math.round(h/2));
|
|
|
+ if(nextItem&&nextItem.isMixRatio){
|
|
|
+ ctx.moveTo(x+offset-9, y+Math.round(h/2));
|
|
|
+ ctx.lineTo(x+offset-9, y+h);
|
|
|
+ }
|
|
|
+ ctx.stroke();
|
|
|
+ ctx.restore();
|
|
|
+ return offset;
|
|
|
+ }
|
|
|
+
|
|
|
+ TreeNodeCellType.prototype = new ns.CellTypes.Text();
|
|
|
+ TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
+ if(value!=null){
|
|
|
+ var offset = margin+rectW+6;
|
|
|
+ var recode = data[options.row];
|
|
|
+ if(recode&&recode.hasOwnProperty('subList')){
|
|
|
+ drowRect(ctx,x,y,w,h);
|
|
|
+ var collapsed = options.sheet.getTag(options.row,options.col);
|
|
|
+ drowSymbol(ctx,x,y,w,h,collapsed);
|
|
|
+ }else if(recode&&recode.isMixRatio){
|
|
|
+ offset= drowSubItem(ctx,x,y,w,h,offset,data[options.row+1]);
|
|
|
+ offset+=1;
|
|
|
+ }
|
|
|
+ ctx.fillText(value,x+offset+ctx.measureText(value).width,y+h-5);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ // override getHitInfo to allow cell type get mouse messages
|
|
|
+ TreeNodeCellType.prototype.getHitInfo = function (x, y, cellStyle, cellRect, context) {
|
|
|
+ return {
|
|
|
+ x: x,
|
|
|
+ y: y,
|
|
|
+ row: context.row,
|
|
|
+ col: context.col,
|
|
|
+ cellStyle: cellStyle,
|
|
|
+ cellRect: cellRect,
|
|
|
+ sheetArea: context.sheetArea
|
|
|
+ };
|
|
|
+ }
|
|
|
+ TreeNodeCellType.prototype.processMouseDown = function (hitinfo) {
|
|
|
+ var recode = data[hitinfo.row];
|
|
|
+ if(recode&&recode.hasOwnProperty('subList')){
|
|
|
+ var hoffset= hitinfo.cellRect.x+3;
|
|
|
+ if (hitinfo.x > hoffset && hitinfo.x < hoffset + 10){
|
|
|
+ var collapsed = hitinfo.sheet.getTag(hitinfo.row,hitinfo.col,hitinfo.sheetArea);
|
|
|
+ collapsed = !collapsed;
|
|
|
+ hitinfo.sheet.setTag(hitinfo.row,hitinfo.col,collapsed);
|
|
|
+ hitinfo.sheet.getRange(hitinfo.row+1, -1, recode.subList.length, -1).visible(!collapsed);
|
|
|
+ hitinfo.sheet.invalidateLayout();
|
|
|
+ hitinfo.sheet.repaint();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return new TreeNodeCellType()
|
|
|
}
|
|
|
}
|
|
|
|