calc_program.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * Created by CSL on 2017-07-19.
  3. * dispExpr: F8*(L-1); expression: "@('8') * (L-1)";
  4. * 说明:F后跟行号,L替换人工系数值,@后跟ID。用到L的规则必须有labourCoeID属性(反过来不要求),
  5. * 用到费率的规则必须有feeRateID属性,当有该属性时,会自动显示费率值。
  6. */
  7. class CalcProgram {
  8. constructor(project){
  9. this.project = project;
  10. this.datas = [];
  11. this.calc = new Calculation();
  12. project.registerModule(ModuleNames.calc_program, this);
  13. };
  14. getSourceType () {
  15. return ModuleNames.calc_program;
  16. };
  17. loadData (datas) {
  18. this.datas = datas;
  19. };
  20. doAfterUpdate (err, data) {
  21. if(!err){
  22. // do
  23. }
  24. };
  25. // 经测试,全部编译一次耗时0.003~0.004秒。耗时基本忽略不计。
  26. compileAllTemps(){
  27. let calcFeeRates = this.project.FeeRate.datas.rates;
  28. let calcLabourCoes = this.project.labourCoe.datas.coes;
  29. let calcTemplates = this.project.calcProgram.datas.templates;
  30. this.calc.compilePublics(calcFeeRates, calcLabourCoes, feeType, rationCalcBase);
  31. for (let ct of calcTemplates){
  32. this.calc.compileTemplate(ct);
  33. };
  34. };
  35. calculate(treeNode){
  36. treeNode.data.gljList = this.project.ration_glj.getGljArrByRation(treeNode.data.ID);
  37. this.calc.calculate(treeNode);
  38. projectObj.mainController.refreshTreeNode([treeNode]);
  39. };
  40. }