calc_program.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. if (this.calc.saveForReports.length > 0){
  36. let saveDatas = {};
  37. saveDatas.projectID = projectInfoObj.projectInfo.ID;
  38. saveDatas.calcItems = this.calc.saveForReports;
  39. CommonAjax.post('/calcProgram/saveCalcItems', saveDatas, function (data) {
  40. this.calc.saveForReports = [];
  41. });
  42. };
  43. };
  44. calculate(treeNode){
  45. treeNode.data.gljList = this.project.ration_glj.getGljArrByRation(treeNode.data.ID);
  46. this.calc.calculate(treeNode);
  47. projectObj.mainController.refreshTreeNode([treeNode]);
  48. }
  49. }