|
|
@@ -19,14 +19,92 @@ let indexObj= {
|
|
|
],
|
|
|
view:{ lockColumns: [0]}
|
|
|
},
|
|
|
+ engineerCostSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "名称", headerWidth: 200, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "金额", headerWidth: 160, dataCode: "cost", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "单方造价", headerWidth: 160, dataCode: "unitCost", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "占造价比例", headerWidth: 160, dataCode: "per", dataType: "String", hAlign: "right"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["name","cost","unitCost","per"]}
|
|
|
+ },
|
|
|
+ mainMaterialSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "名称", headerWidth: 200, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "单位", headerWidth: 200, dataCode: "unit", dataType: "String"},
|
|
|
+ {headerName: "综合单价", headerWidth: 160, dataCode: "unitPrice", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "数量", headerWidth: 160, dataCode: "quantity", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "单方指标", headerWidth: 160, dataCode: "unitIndex", dataType: "String", hAlign: "right"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["name","unit","unitPrice","quantity","unitIndex"]}
|
|
|
+ },
|
|
|
+ economicSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "分部分项", headerWidth: 200, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "分部工程造价", headerWidth: 160, dataCode: "cost", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "单方指标", headerWidth: 160, dataCode: "unitCost", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "占造价比例", headerWidth: 160, dataCode: "per", dataType: "String", hAlign: "right"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["name","cost","unitCost","per"]}
|
|
|
+ },
|
|
|
+ quantitySetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "名称", headerWidth: 200, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "工程量指标", headerWidth: 160, dataCode: "quantity", dataType: "String", hAlign: "right"},
|
|
|
+ {headerName: "单位", headerWidth: 160, dataCode: "quantityIndexUnit", dataType: "String", hAlign: "center"}
|
|
|
+ ],
|
|
|
+ view:{ lockColumns: ["name","quantity","quantityIndexUnit"]}
|
|
|
+ },
|
|
|
+ materialSetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String",cellType:'tipsCell'},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "数量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
+ {headerName: "市场价合价", headerWidth: 120, dataCode: "totalPrice", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
+ {headerName: "工料指标", headerWidth: 120, dataCode: "materialIndexType", hAlign: "center", dataType: "String",cellType:'comboBox',options:[]},
|
|
|
+ {headerName: "工料指标单位", headerWidth: 150, dataCode: "materialIndexUnit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "单位转换系数", headerWidth: 150, dataCode: "materialIndexCoe", hAlign: "center", dataType: "String",validator:"number"}
|
|
|
+ ],
|
|
|
+ view: {
|
|
|
+ lockColumns: ["code","name","specs","unit","marketPrice","quantity","materialIndexUnit"]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ecoQuantitySetting:{
|
|
|
+ header: [
|
|
|
+ {headerName: "编码", headerWidth: 200, dataCode: "code", dataType: "String"},
|
|
|
+ {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
|
|
|
+ {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "工程量", headerWidth: 90, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
|
|
|
+ {headerName: "综合单价", headerWidth: 70, dataCode: "unitFee", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
+ {headerName: "综合合价", headerWidth: 120, dataCode: "totalFee", hAlign: "right", dataType: "Number",validator:"number"},//,decimalField:"glj.unitPrice"
|
|
|
+ {headerName: "工程经济指标类别", headerWidth: 120, dataCode: "economicType", hAlign: "center", dataType: "String",cellType:'comboBox',options:[]},
|
|
|
+ {headerName: "工程量指标类别", headerWidth: 150, dataCode: "quantityIndexType", hAlign: "center", dataType: "String",cellType:'comboBox',options:[]},
|
|
|
+ {headerName: "工程量指标单位", headerWidth: 150, dataCode: "quantityIndexUnit", hAlign: "center", dataType: "String"},
|
|
|
+ {headerName: "单位转换系数", headerWidth: 150, dataCode: "quantityIndexCoe", hAlign: "center", dataType: "String",validator:"number"}
|
|
|
+ ],
|
|
|
+ view: {
|
|
|
+ lockColumns: ["code","name","unit","quantity","unitFee","totalFee","quantityIndexUnit"]
|
|
|
+ }
|
|
|
+ },
|
|
|
engineerInfoDatas:[],
|
|
|
engineerFeatureDatas:[],
|
|
|
+ materialDatas:[],
|
|
|
+ ecoQuantityDatas:[],
|
|
|
initSpread:function () {
|
|
|
if(!this.spread){
|
|
|
this.spread = SheetDataHelper.createNewSpread($("#indexSpread")[0],8);
|
|
|
sheetCommonObj.spreadDefaultStyle(this.spread);
|
|
|
this.initEngineerInfoSheet();
|
|
|
this.initEngineerFeatureSheet();
|
|
|
+ this.initEngineerCostSheet();
|
|
|
+ this.initMainMaterialSheet();
|
|
|
+ this.initEconomicSheet();
|
|
|
+ this.initQuantitySheet();
|
|
|
+ this.initEcoQuantitySheet();
|
|
|
+ this.initMaterialSheet();
|
|
|
}
|
|
|
// disableRightMenu("glj_from_sheet",this.spread);
|
|
|
if(projectReadOnly){
|
|
|
@@ -58,17 +136,72 @@ let indexObj= {
|
|
|
name:f.name,
|
|
|
value:f.value,
|
|
|
ParentID:f.ParentID,
|
|
|
+ required:f.required,
|
|
|
collapsed:false
|
|
|
};
|
|
|
+ if(f.required == true) tem.foreColor = "#ff2a23";
|
|
|
datas.push(tem);
|
|
|
}
|
|
|
}
|
|
|
return datas;
|
|
|
}
|
|
|
},
|
|
|
+ initEngineerCostSheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(2);
|
|
|
+ sheetCommonObj.initSheet(sheet,this.engineerCostSetting,30);
|
|
|
+ sheet.name('engineerCost');
|
|
|
+ //sheet.setRowHeight(0, 36, 1);
|
|
|
+ },
|
|
|
+ initMainMaterialSheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(3);
|
|
|
+ this.setHeaderUnit(this.mainMaterialSetting,"unitIndex");
|
|
|
+ sheetCommonObj.initSheet(sheet,this.mainMaterialSetting,30);
|
|
|
+ sheet.name('mainMaterial');
|
|
|
+ //sheet.setRowHeight(0, 36, 1);
|
|
|
+ },
|
|
|
+ initEconomicSheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(4);
|
|
|
+ sheetCommonObj.initSheet(sheet,this.economicSetting,30);
|
|
|
+ sheet.name('economic');
|
|
|
+ //sheet.setRowHeight(0, 36, 1);
|
|
|
+ },
|
|
|
+ initQuantitySheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(5);
|
|
|
+ this.setHeaderUnit(this.quantitySetting,"quantity");
|
|
|
+ sheetCommonObj.initSheet(sheet,this.quantitySetting,30);
|
|
|
+ sheet.name('quantity');
|
|
|
+ },
|
|
|
+ initEcoQuantitySheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(6);
|
|
|
+ this.setComboOptions(projectObj.project.property.economics,this.ecoQuantitySetting,"economicType");
|
|
|
+ this.setComboOptions(projectObj.project.property.mainQuantities,this.ecoQuantitySetting,"quantityIndexType");
|
|
|
+ sheetCommonObj.initSheet(sheet,this.ecoQuantitySetting,1);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onEcoQuantityValueChange);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onEcoQuantityRangeChange);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onSelectionChange);
|
|
|
+ sheet.name('ecoQuantity');
|
|
|
+ },
|
|
|
+ initMaterialSheet:function () {
|
|
|
+ let sheet = this.spread.getSheet(7);
|
|
|
+ this.setComboOptions(projectObj.project.property.materials,this.materialSetting,"materialIndexType");
|
|
|
+ sheetCommonObj.initSheet(sheet,this.materialSetting,30);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onSelectionChange);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.ValueChanged, this.onMaterialChange);
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.RangeChanged, this.onMaterialRangeChange);
|
|
|
+ sheet.name('material');
|
|
|
+
|
|
|
+ },
|
|
|
showDatas:function(){
|
|
|
- if(this.nav_text == "工程信息指标") this.showEngineerInfo();
|
|
|
- if(this.nav_text == "工程特征指标") this.showEngineerFeature();
|
|
|
+ let me = indexObj;
|
|
|
+ if(me.nav_text == "工程信息指标") me.showEngineerInfo();
|
|
|
+ if(me.nav_text == "工程特征指标") me.showEngineerFeature();
|
|
|
+ if(me.nav_text == "工程造价指标") me.showEngineerCost();
|
|
|
+ if(me.nav_text == "主要工料指标") me.showMainMaterial();
|
|
|
+ if(me.nav_text == "主要经济指标") me.showEconomic();
|
|
|
+ if(me.nav_text == "主要工程量指标") me.showQuantity();
|
|
|
+ if(me.nav_text == "设置主要经济、工程量指标") me.showEcoQuantity();
|
|
|
+ if(me.nav_text == "设置主要工料指标") me.showMaterial();
|
|
|
+
|
|
|
},
|
|
|
showEngineerInfo:function () {
|
|
|
this.spread.setActiveSheetIndex(0);
|
|
|
@@ -108,8 +241,373 @@ let indexObj= {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ showEngineerCost:function () {
|
|
|
+ this.spread.setActiveSheetIndex(2);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let costDatas = getEngineerCostData();
|
|
|
+ sheetCommonObj.showData(sheet, this.engineerCostSetting,costDatas);
|
|
|
+ sheet.setRowCount(costDatas.length);
|
|
|
+ function getEngineerCostData() {
|
|
|
+ let datas = [];
|
|
|
+ let priceIndex = exportUtil.setEngineerPriceIndex({property:projectObj.project.property},{bills:projectObj.project.Bills.datas});
|
|
|
+ for(let c of priceIndex.children){
|
|
|
+ let tem = {
|
|
|
+ name:c.name,
|
|
|
+ cost:parseFloat(c.attrs[0].value),
|
|
|
+ unitCost:parseFloat(c.attrs[1].value),
|
|
|
+ per:parseFloat(c.attrs[2].value)
|
|
|
+ }
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showMainMaterial:function(){
|
|
|
+ this.spread.setActiveSheetIndex(3);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let mainDatas = this.getMainMaterialDatas();
|
|
|
+ sheetCommonObj.showData(sheet, this.mainMaterialSetting,mainDatas);
|
|
|
+ sheet.setRowCount(mainDatas.length);
|
|
|
+ },
|
|
|
+ showEconomic:function () {
|
|
|
+ this.spread.setActiveSheetIndex(4);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let economicDatas = this.getEconomicDatas();
|
|
|
+ sheetCommonObj.showData(sheet, this.economicSetting,economicDatas);
|
|
|
+ sheet.setRowCount(economicDatas.length);
|
|
|
+ },
|
|
|
+ showQuantity:function () {
|
|
|
+ this.spread.setActiveSheetIndex(5);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let quantityDatas = this.getQuantityDatas();
|
|
|
+ sheetCommonObj.showData(sheet, this.quantitySetting,quantityDatas);
|
|
|
+ sheet.setRowCount(quantityDatas.length);
|
|
|
+ },
|
|
|
+ getQuantityDatas:function () {
|
|
|
+ let datas = [];
|
|
|
+ let mainQuantities = projectObj.project.property.mainQuantities;
|
|
|
+ let bills = this.getIndexBillsData({});
|
|
|
+ let billsGroup = _.groupBy(bills,'quantityIndexType');
|
|
|
+ if(!mainQuantities) return datas;
|
|
|
+ for(let m of mainQuantities){
|
|
|
+ let tem = {
|
|
|
+ name : m.name,
|
|
|
+ quantityIndexUnit:m.unit,
|
|
|
+ quantity:0
|
|
|
+ };
|
|
|
+ if(billsGroup[m.name]) setQuantities(billsGroup[m.name],tem);
|
|
|
+
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+
|
|
|
+ function setQuantities(items,data) {
|
|
|
+ let quantity = 0;
|
|
|
+ for (let i of items){
|
|
|
+ let coe = i.quantityIndexCoe && i.quantityIndexCoe!=""?parseFloat(i.quantityIndexCoe):1;
|
|
|
+ i.quantity = scMathUtil.roundForObj(parseFloat(i.quantity)*coe,getDecimal("process"));
|
|
|
+ quantity = scMathUtil.roundForObj(quantity + i.quantity,getDecimal("process"));
|
|
|
+ }
|
|
|
+ data.quantity = exportUtil.calUnitWidthCoe(quantity);
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
+ getEconomicDatas:function () {
|
|
|
+ let datas = [];
|
|
|
+ let economics = projectObj.project.property.economics;
|
|
|
+ let bills = this.getIndexBillsData({});
|
|
|
+ let billsGroup = _.groupBy(bills,'economicType');
|
|
|
+ let totalFee = projectObj.project.Bills.getEngineeringCost();
|
|
|
+ if(!economics) return datas;
|
|
|
+ for(let e of economics){
|
|
|
+ let tem = {
|
|
|
+ name:e.name,
|
|
|
+ cost:0,
|
|
|
+ unitCost:0,
|
|
|
+ per:0
|
|
|
+ };
|
|
|
+ if(billsGroup[e.name]) setEconomics(billsGroup[e.name],totalFee,tem);
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+ function setEconomics(items,engineerCost,data) {
|
|
|
+ let cost = 0;
|
|
|
+ let priceDe = getDecimal("bills.totalPrice");
|
|
|
+ for(let i of items){
|
|
|
+ i.totalFee = scMathUtil.roundForObj(i.totalFee,priceDe);
|
|
|
+ cost = scMathUtil.roundForObj(cost + i.totalFee,getDecimal("process"));
|
|
|
+ }
|
|
|
+ data.cost = scMathUtil.roundForObj(cost,priceDe);
|
|
|
+ data.unitCost = exportUtil.calUnitWidthCoe(data.cost);
|
|
|
+ data.per = engineerCost?scMathUtil.roundForObj(data.cost/engineerCost * 100,2):0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
+
|
|
|
+ getMainMaterialDatas:function () {
|
|
|
+ let datas = [];
|
|
|
+ let materials = projectObj.project.property.materials;
|
|
|
+ let gljList = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ let materialGroup = _.groupBy(gljList,'materialIndexType');
|
|
|
+ if(!materials) return datas;
|
|
|
+ for(let m of materials){
|
|
|
+ let tem = {
|
|
|
+ name:m.name,
|
|
|
+ unit:m.unit,
|
|
|
+ unitPrice:0,
|
|
|
+ quantity:0,
|
|
|
+ unitIndex:0
|
|
|
+ };
|
|
|
+ if(materialGroup[m.name]) setMainMaterial(materialGroup[m.name],tem);
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function setMainMaterial(gljs,data) {
|
|
|
+ let quantity = 0 ,unitPrice=0;
|
|
|
+ for(let g of gljs){
|
|
|
+ if(!g.quantity || g.quantity=="") continue;
|
|
|
+ let tem = {};
|
|
|
+ gljOprObj.setGLJPrice(tem,g);
|
|
|
+ let materialIndexCoe = g.materialIndexCoe?scMathUtil.roundForObj(g.materialIndexCoe,getDecimal("process")):1;
|
|
|
+ let t_quantity = scMathUtil.roundForObj(g.quantity * materialIndexCoe,getDecimal("process"));
|
|
|
+ quantity = scMathUtil.roundForObj(t_quantity + quantity,getDecimal("process"));
|
|
|
+ let temPrice = scMathUtil.roundForObj(g.quantity * tem.marketPrice,getDecimal("process"));
|
|
|
+ unitPrice = scMathUtil.roundForObj(temPrice + unitPrice,getDecimal("process"));
|
|
|
+ }
|
|
|
+ data.quantity = scMathUtil.roundForObj(quantity,2);
|
|
|
+ if(data.quantity) data.unitPrice = scMathUtil.roundForObj(unitPrice/data.quantity,2);
|
|
|
+ data.unitIndex = exportUtil.calUnitWidthCoe(data.quantity);
|
|
|
+ }
|
|
|
+
|
|
|
+ return datas;
|
|
|
+ },
|
|
|
+ showEcoQuantity:function () {
|
|
|
+ let parentMap = {};
|
|
|
+ this.spread.setActiveSheetIndex(6);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let sel = sheet.getSelections()[0];
|
|
|
+ let oldData = sel.row<this.ecoQuantityDatas.length?this.ecoQuantityDatas[sel.row]:"";
|
|
|
+ this.ecoQuantityDatas = this.getIndexBillsData(parentMap);
|
|
|
+ sheet.setRowCount(0);
|
|
|
+ sheet.setRowCount(this.ecoQuantityDatas.length);
|
|
|
+ sheetCommonObj.showTreeData(sheet, this.ecoQuantitySetting,this.ecoQuantityDatas);
|
|
|
+ sel.row = oldData?_.findIndex(this.ecoQuantityDatas,{'ID':oldData.ID}):'';
|
|
|
+ sheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
+
|
|
|
+ for(let row =0 ;row < this.ecoQuantityDatas.length;row ++){//锁定父清单
|
|
|
+ if(parentMap[this.ecoQuantityDatas[row].ID]) sheet.getRange(row,-1 -1, 1, GC.Spread.Sheets.SheetArea.viewport).locked(true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getIndexBillsData:function (parentMap,old) {
|
|
|
+ let datas = [],allNodes=[];
|
|
|
+ let controller = projectObj.mainController, project = projectObj.project;
|
|
|
+ let FBFX = project.Bills.getFBFXNode(controller);
|
|
|
+ if(FBFX){
|
|
|
+ allNodes.push(FBFX);
|
|
|
+ controller.tree.getAllSubNode(FBFX.source,allNodes);
|
|
|
+ }
|
|
|
+ let org = project.Bills.getOrgNode();
|
|
|
+ let mNode = project.Bills.getMeasureNode(controller);
|
|
|
+ if(mNode){
|
|
|
+ allNodes.push(mNode);
|
|
|
+ controller.tree.getAllSubNode(mNode.source,allNodes,org?org.data.ID:null);
|
|
|
+ }
|
|
|
+ for(let a of allNodes){
|
|
|
+ let d = a.data;
|
|
|
+ let tem = {
|
|
|
+ ID:d.ID,
|
|
|
+ ParentID:d.ParentID,
|
|
|
+ code:d.code,
|
|
|
+ name:d.name,
|
|
|
+ unit:d.unit,
|
|
|
+ quantity:d.quantity,
|
|
|
+ totalFee:d.feesIndex && d.feesIndex.common && d.feesIndex.common.totalFee?d.feesIndex.common.totalFee:0,
|
|
|
+ unitFee:d.feesIndex && d.feesIndex.common && d.feesIndex.common.unitFee?d.feesIndex.common.unitFee:0,
|
|
|
+ economicType:d.economicType,
|
|
|
+ quantityIndexType:d.quantityIndexType,
|
|
|
+ quantityIndexUnit:d.quantityIndexUnit,
|
|
|
+ quantityIndexCoe:d.quantityIndexCoe,
|
|
|
+ collapsed:false
|
|
|
+ };
|
|
|
+ parentMap[d.ParentID] = tem;
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+ for(let td of datas){
|
|
|
+ if(parentMap[td.ID]){
|
|
|
+ td.economicType = "";
|
|
|
+ td.quantityIndexType = "";
|
|
|
+ td.quantityIndexUnit = "";
|
|
|
+ td.quantityIndexCoe = "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+
|
|
|
+ },
|
|
|
+ showMaterial:function(){
|
|
|
+ this.spread.setActiveSheetIndex(7);
|
|
|
+ let sheet = this.spread.getActiveSheet();
|
|
|
+ let sel = sheet.getSelections()[0];
|
|
|
+ let oldData = sel.row<this.materialDatas.length?this.materialDatas[sel.row]:"";
|
|
|
+ this.materialDatas = getMaterialData();
|
|
|
+ sheetCommonObj.showData(sheet, this.materialSetting,this.materialDatas );
|
|
|
+ sheet.setRowCount(this.materialDatas .length);
|
|
|
+
|
|
|
+ sel.row = oldData?_.findIndex(this.materialDatas,{'id':oldData.id}):'';
|
|
|
+ sheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
|
|
|
+ function getMaterialData() {
|
|
|
+ let datas = [];
|
|
|
+ let gljList = projectObj.project.projectGLJ.datas.gljList;
|
|
|
+ gljList = _.filter(gljList,function(item){
|
|
|
+ return item.quantity !== 0 && item.quantity !== '0'
|
|
|
+ });
|
|
|
+ gljList = sortProjectGLJ(gljList);
|
|
|
+ for(let glj of gljList){
|
|
|
+ let tem = {
|
|
|
+ id:glj.id,
|
|
|
+ code:glj.code,
|
|
|
+ name:glj.name,
|
|
|
+ specs:glj.specs,
|
|
|
+ unit:glj.unit,
|
|
|
+ type:glj.type,
|
|
|
+ quantity:glj.quantity,
|
|
|
+ materialIndexType:glj.materialIndexType,
|
|
|
+ materialIndexUnit:glj.materialIndexUnit,
|
|
|
+ materialIndexCoe:glj.materialIndexCoe
|
|
|
+ };
|
|
|
+ gljOprObj.setGLJPrice(tem,glj);
|
|
|
+ tem.totalPrice = scMathUtil.roundForObj(tem.marketPrice * glj.quantity,getDecimal("glj.unitPrice"))
|
|
|
+ datas.push(tem);
|
|
|
+ }
|
|
|
+ return datas;
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ setComboOptions:function (property,setting,field) {
|
|
|
+ if(!property) return;
|
|
|
+ let options = [];
|
|
|
+ for(let p of property){
|
|
|
+ options.push(p.name);
|
|
|
+ }
|
|
|
+ let h = _.find(setting.header,{dataCode:field});
|
|
|
+ if(h) h.options = options;
|
|
|
+ },
|
|
|
onSelectionChange:function (sender, args) {
|
|
|
args.sheet.repaint();
|
|
|
+ },
|
|
|
+ onEcoQuantityValueChange:function (sender,info) {
|
|
|
+ let value = info.newValue;
|
|
|
+ let dataCode = indexObj.ecoQuantitySetting.header[info.col].dataCode;
|
|
|
+ if(!info.newValue){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (value&&!sheetCommonObj.checkData(info.col,indexObj.ecoQuantitySetting, value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ return indexObj.showDatas();
|
|
|
+ }
|
|
|
+ let recode = indexObj.ecoQuantityDatas[info.row];
|
|
|
+ let data = indexObj.getEcoQuantityUpdateData(recode,dataCode,value);
|
|
|
+ projectObj.project.updateNodesAndRefresh([data],indexObj.showDatas)
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ onMaterialChange:function (sender,info) {
|
|
|
+ let value = info.newValue,updateMap = {};
|
|
|
+ let dataCode = indexObj.materialSetting.header[info.col].dataCode;
|
|
|
+ if(!info.newValue){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (value&&!sheetCommonObj.checkData(info.col,indexObj.materialSetting, value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ return indexObj.showDatas();
|
|
|
+ }
|
|
|
+ let recode = indexObj.materialDatas[info.row];
|
|
|
+ let data = indexObj.getMaterialUpdateData(recode,dataCode,value);
|
|
|
+ if(!data) return indexObj.showDatas() ;
|
|
|
+ updateMap[recode.id] = data;
|
|
|
+ projectObj.project.projectGLJ.batchUpdateGLJProperty(updateMap,indexObj.showDatas);
|
|
|
+
|
|
|
+ },
|
|
|
+ onEcoQuantityRangeChange:function (sender,info) {
|
|
|
+ let nodes = [];
|
|
|
+ for(let c of info.changedCells){
|
|
|
+ let dataCode = indexObj.ecoQuantitySetting.header[c.col].dataCode;
|
|
|
+ let value= info.sheet.getCell(c.row, c.col).text();
|
|
|
+ if (value&&!sheetCommonObj.checkData(c.col,indexObj.ecoQuantitySetting, value)) {
|
|
|
+ alert('输入的数据类型不对,请重新输入!');
|
|
|
+ return indexObj.showDatas();
|
|
|
+ }
|
|
|
+ let recode = indexObj.ecoQuantityDatas[c.row];
|
|
|
+ let data = indexObj.getEcoQuantityUpdateData(recode,dataCode,value);
|
|
|
+ if(data) nodes.push(data);
|
|
|
+ }
|
|
|
+ if(_.isEmpty(nodes)) return indexObj.showDatas();
|
|
|
+ projectObj.project.updateNodesAndRefresh(nodes,indexObj.showDatas)
|
|
|
+ },
|
|
|
+ onMaterialRangeChange:function (sender,info) {
|
|
|
+ let updateMap = {};
|
|
|
+ for(let c of info.changedCells){
|
|
|
+ let value= info.sheet.getCell(c.row, c.col).text();
|
|
|
+ let recode = indexObj.materialDatas[c.row];
|
|
|
+ let tem = indexObj.getMaterialUpdateData(recode,value);
|
|
|
+ if(tem) updateMap[recode.id] = tem;
|
|
|
+ }
|
|
|
+ if(_.isEmpty(updateMap)) return indexObj.showDatas();
|
|
|
+ projectObj.project.projectGLJ.batchUpdateGLJProperty(updateMap,indexObj.showDatas);
|
|
|
+ },
|
|
|
+ getEcoQuantityUpdateData:function (recode,dataCode,newValue) {
|
|
|
+ let tem = {
|
|
|
+ type:ModuleNames.bills,
|
|
|
+ data:{ID:recode.ID}
|
|
|
+ };
|
|
|
+ tem.data[dataCode] = newValue;
|
|
|
+ if(!recode) return null;
|
|
|
+ if(dataCode == "quantityIndexType"){
|
|
|
+ let mainQuantities = projectObj.project.property.mainQuantities;
|
|
|
+ if (!mainQuantities) return null;
|
|
|
+ let m = _.find(mainQuantities,{name:newValue});
|
|
|
+ if(!m) return null;
|
|
|
+ tem.data["quantityIndexUnit"] = m.unit;
|
|
|
+ tem.data["quantityIndexCoe"] = recode.unit == m.unit? 1:null;
|
|
|
+ }
|
|
|
+ if(dataCode == "economicType"){//这里就主要查找输入是否是下列选项中的一个,值已经在上面设置了
|
|
|
+ let economics = projectObj.project.property.economics;
|
|
|
+ if (!economics) return null;
|
|
|
+ let m = _.find(economics,{name:newValue});
|
|
|
+ if(!m) return null;
|
|
|
+ }
|
|
|
+ return tem;
|
|
|
+
|
|
|
+ },
|
|
|
+ getMaterialUpdateData:function (recode,dataCode,newValue) {
|
|
|
+ let data = {};
|
|
|
+ data[dataCode] = newValue;
|
|
|
+ if(dataCode == "materialIndexType"){
|
|
|
+ let materials = projectObj.project.property.materials;
|
|
|
+ if (!materials) return null;
|
|
|
+ if(!recode) return null;
|
|
|
+ let m = _.find(materials,{name:newValue});
|
|
|
+ if(!m) return null;
|
|
|
+ data["materialIndexUnit"] = m.unit;
|
|
|
+ data["materialIndexCoe"] = recode.unit == m.unit ?1: null;
|
|
|
+ if(recode.name == "水泥" && m.name == "水泥") data["materialIndexCoe"] = 0.001;
|
|
|
+ }
|
|
|
+ return data
|
|
|
+ },
|
|
|
+ getIndexUnit:function () {
|
|
|
+ let features = projectObj.project.property.engineerFeatures;
|
|
|
+ if(features){
|
|
|
+ for(let f of features){
|
|
|
+ if(f.index == true && f.indexUnit && f.indexUnit!="") return f.indexUnit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+ setHeaderUnit:function (setting,dataCode) {
|
|
|
+ let header = _.find(setting.header,{dataCode:dataCode});
|
|
|
+ let unit = this.getIndexUnit();
|
|
|
+ if(!unit || !header )return;
|
|
|
+ header.headerName +=`(${unit})`
|
|
|
}
|
|
|
};
|
|
|
|