/** * Created by CSL on 2017-07-19. * dispExpr: F8*(L-1); expression: "@('8') * (L-1)"; * 说明:F后跟行号,L替换人工系数值,@后跟ID。用到L的规则必须有labourCoeID属性(反过来不要求), * 用到费率的规则必须有feeRateID属性,当有该属性时,会自动显示费率值。 */ class CalcProgram { constructor(project){ this.project = project; this.datas = []; this.calc = new Calculation(); project.registerModule(ModuleNames.calc_program, this); }; getSourceType () { return ModuleNames.calc_program; }; loadData (datas) { this.datas = datas; }; doAfterUpdate (err, data) { if(!err){ // do } }; // 经测试,全部编译一次耗时0.003~0.004秒。耗时基本忽略不计。 compileAllTemps(){ let calcFeeRates = this.project.FeeRate.datas.rates; let calcLabourCoes = this.project.labourCoe.datas.coes; let calcTemplates = this.project.calcProgram.datas.templates; this.calc.compilePublics(calcFeeRates, calcLabourCoes, feeType, rationCalcBase); for (let ct of calcTemplates){ this.calc.compileTemplate(ct); }; // 存储费率临时数据,报表用。 if (this.calc.saveForReports.length > 0){ let saveDatas = {}; saveDatas.projectID = projectInfoObj.projectInfo.ID; saveDatas.calcItems = this.calc.saveForReports; CommonAjax.post('/calcProgram/saveCalcItems', saveDatas, function (data) { this.calc.saveForReports = []; }); }; }; calculate(treeNode){ if (treeNode.sourceType === this.project.Ration.getSourceType()) { treeNode.data.gljList = this.project.ration_glj.getGljArrByRation(treeNode.data.ID); } else if (treeNode.sourceType === this.project.Bills.getSourceType()) { let rations = this.project.Ration.getBillsSortRation(treeNode.source.getID()); treeNode.data.gljList = this.project.ration_glj.getGatherGljArrByRations(rations); }; this.calc.calculate(treeNode); projectObj.mainController.refreshTreeNode([treeNode]); } }