rpt_data_util.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * Created by Tony on 2017/7/14.
  3. * 报表数据提取class,是协助报表模板里指标字段自主提取数据的工具类
  4. */
  5. let JV = require('../rpt_component/jpc_value_define');
  6. let $JE = require('../rpt_component/jpc_rte');
  7. class Rpt_Common{
  8. initialize(Projects) {
  9. this.Projects = Projects;
  10. };
  11. getSerialNo(fieldId, $CURRENT_RPT, $CURRENT_DATA){
  12. let itemSerialNoRec = $JE.F(fieldId, $CURRENT_RPT);
  13. if (itemSerialNoRec) {
  14. itemSerialNoRec[JV.PROP_AD_HOC_DATA] = [];
  15. for (var innerFmlIdx = 0; innerFmlIdx < $CURRENT_DATA[JV.DATA_DETAIL_DATA][0].length; innerFmlIdx++) {
  16. itemSerialNoRec[JV.PROP_AD_HOC_DATA][innerFmlIdx] = (innerFmlIdx + 1);
  17. }
  18. itemSerialNoRec = null;
  19. }
  20. };
  21. };
  22. class Rpt_Data_Extractor {
  23. constructor () {
  24. this.COMMON = new Rpt_Common();
  25. };
  26. initialize(Projects) {
  27. this.Projects = Projects;
  28. //Projects对象应该从前端传送过来,无需在后端重复查询及构建
  29. /* 结构:
  30. {
  31. currentPrjId: int,
  32. topPrj: [
  33. //单项工程
  34. {
  35. subPrjName: String,
  36. subPrjId: int,
  37. detailPrj: [
  38. //单位工程
  39. {
  40. detailPrjName: String,
  41. subPrjId: int,
  42. }
  43. ...
  44. ]
  45. }
  46. ...
  47. ]
  48. }
  49. */
  50. };
  51. prepareData($CURRENT_RPT) {
  52. //在报表提取数据前的准备工作,主要有:
  53. //1. 确认指标数据的类型(离散/主/从)
  54. //2. 根据类型提取数据,排序
  55. // 2.1. header类型
  56. // 2.2. 章类型
  57. // 2.3. detail类型
  58. // 2.4. 排序
  59. };
  60. }