jpc_helper_discrete.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. 'use strict';
  2. const JV = require('../jpc_value_define');
  3. const JE = require('../jpc_rte');
  4. const JpcTextHelper = require('./jpc_helper_text');
  5. const JpcCommonOutputHelper = require('./jpc_helper_common_output');
  6. const JpcAreaHelper = require('./jpc_helper_area');
  7. const JpcFieldHelper = require('./jpc_helper_field');
  8. const JpcDiscreteHelper = {
  9. outputDiscreteInfo: function(discreteArray, bands, dataObj, unitFactor, pageStatus, segIdx, multiCols, multiColIdx, $CURRENT_RPT, customizeCfg, signatureRst, signatureDateRst) {
  10. const rst = [];
  11. if (discreteArray && dataObj) {
  12. for (let i = 0; i < discreteArray.length; i++) {
  13. const band = bands[discreteArray[i][JV.PROP_BAND_NAME]];
  14. if (band && pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
  15. if (discreteArray[i][JV.PROP_TEXT]) {
  16. rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, multiCols, multiColIdx));
  17. }
  18. if (discreteArray[i][JV.PROP_TEXTS]) {
  19. for (let j = 0; j < discreteArray[i][JV.PROP_TEXTS].length; j++) {
  20. rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, multiCols, multiColIdx));
  21. }
  22. }
  23. if (discreteArray[i][JV.PROP_DISCRETE_FIELDS]) {
  24. let flexiblePrecisionRefObj = null;
  25. let flexibleRefField = null;
  26. for (let j = 0; j < discreteArray[i][JV.PROP_DISCRETE_FIELDS].length; j++) {
  27. const df = discreteArray[i][JV.PROP_DISCRETE_FIELDS][j];
  28. if (JE.isSignature(df[JV.PROP_FIELD_ID], $CURRENT_RPT)) {
  29. // 这里输出到signatureRst
  30. if (Array.isArray(signatureRst)) {
  31. const map_data_field = JE.F(df[JV.PROP_FIELD_ID], $CURRENT_RPT);
  32. const signatureItem = { signature_name: map_data_field[JV.PROP_NAME], path: null, pic: null };
  33. signatureItem[JV.PROP_CONTROL] = df[[JV.PROP_CONTROL]];
  34. signatureItem[JV.PROP_STYLE] = df[[JV.PROP_STYLE]];
  35. signatureItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(df[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
  36. signatureRst.push(signatureItem);
  37. }
  38. } else if (JE.isDynamicParam(df[JV.PROP_PARAM_ID], $CURRENT_RPT)) {
  39. // 这里输出到signatureDateRst
  40. if (Array.isArray(signatureDateRst)) {
  41. const param = JE.P(df[JV.PROP_PARAM_ID], $CURRENT_RPT);
  42. const signatureDateItem = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(df, param[JV.PROP_DFT_VALUE], true);
  43. signatureDateRst.push(signatureDateItem);
  44. }
  45. } else {
  46. let value = '';
  47. if (df[JV.PROP_FIELD_ID]) {
  48. // let map_data_field = JE.F(df[JV.PROP_FIELD_ID], $CURRENT_RPT);
  49. const map_data_field = JE.F(df[JV.PROP_FIELD_ID], $CURRENT_RPT);
  50. if (map_data_field.DataSeq !== JV.BLANK_FIELD_INDEX) {
  51. const data = dataObj[map_data_field.DataNodeName][map_data_field.DataSeq];
  52. if (data && data.length > 0) {
  53. if (data.length > segIdx) {
  54. value = data[segIdx];
  55. } else {
  56. value = data[0];
  57. }
  58. }
  59. } else {
  60. if (map_data_field[JV.PROP_AD_HOC_DATA] && map_data_field[JV.PROP_AD_HOC_DATA].length > 0) {
  61. value = map_data_field[JV.PROP_AD_HOC_DATA][0];
  62. } else value = '';
  63. }
  64. if (map_data_field && map_data_field[JV.PROP_PRECISION] && map_data_field.flexiblePrecisionRefObj) {
  65. let pre_ref_data = null;
  66. if (flexiblePrecisionRefObj === null) {
  67. flexiblePrecisionRefObj = {};
  68. flexibleRefField = JE.F(map_data_field[JV.PROP_PRECISION][JV.PROP_FLEXIBLE_REF_FILED_ID], $CURRENT_RPT);
  69. pre_ref_data = dataObj[map_data_field.DataNodeName][flexibleRefField.DataSeq]; // 这里的引用指标必须得存在,哪怕不显示,也要存放在指标集合中!
  70. for (const decimalObj of map_data_field.flexiblePrecisionRefObj) {
  71. flexiblePrecisionRefObj['refUnit_' + decimalObj.unit] = decimalObj.decimal;
  72. }
  73. }
  74. JpcFieldHelper.resetFlexibleFormat(df, pre_ref_data, flexiblePrecisionRefObj, segIdx, customizeCfg);
  75. } else {
  76. JpcFieldHelper.resetFormat(df, map_data_field, customizeCfg);
  77. }
  78. } else if (df[JV.PROP_PARAM_ID]) {
  79. const param = JE.P(df[JV.PROP_PARAM_ID], $CURRENT_RPT);
  80. value = param[JV.PROP_DFT_VALUE];
  81. }
  82. const item = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(df, value, true);
  83. // position
  84. item[JV.PROP_AREA] = JpcAreaHelper.outputArea(df[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, multiCols, multiColIdx, false, false);
  85. rst.push(item);
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. return rst;
  93. },
  94. outputPreviewDiscreteInfo: function(discreteArray, bands, unitFactor, pageStatus) {
  95. const rst = [];
  96. for (let i = 0; i < discreteArray.length; i++) {
  97. const band = bands[discreteArray[i][JV.PROP_BAND_NAME]];
  98. if (band && pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
  99. if (discreteArray[i][JV.PROP_TEXT]) {
  100. rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, 1, 0));
  101. }
  102. if (discreteArray[i][JV.PROP_TEXTS]) {
  103. for (let j = 0; j < discreteArray[i][JV.PROP_TEXTS].length; j++) {
  104. rst.push(JpcTextHelper.outputText(discreteArray[i][JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, 1, 0));
  105. }
  106. }
  107. if (discreteArray[i][JV.PROP_DISCRETE_FIELDS]) {
  108. for (let j = 0; j < discreteArray[i][JV.PROP_DISCRETE_FIELDS].length; j++) {
  109. const df = discreteArray[i][JV.PROP_DISCRETE_FIELDS][j];
  110. let value = '';
  111. if (df[JV.PROP_DFT_VALUE]) {
  112. value = df[JV.PROP_DFT_VALUE];
  113. }
  114. const item = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(df, value, null);
  115. // position
  116. item[JV.PROP_AREA] = JpcAreaHelper.outputArea(df[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
  117. rst.push(item);
  118. }
  119. }
  120. }
  121. }
  122. return rst;
  123. },
  124. outputPreviewSumInfoOutput: function(band, unitFactor, tab) {
  125. const rst = [];
  126. if (tab[JV.PROP_TEXT]) {
  127. rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXT], band, unitFactor, 1, 0, 1, 0, 1, 0));
  128. }
  129. if (tab[JV.PROP_TEXTS]) {
  130. for (let j = 0; j < tab[JV.PROP_TEXTS].length; j++) {
  131. rst.push(JpcTextHelper.outputText(tab[JV.PROP_TEXTS][j], band, unitFactor, 1, 0, 1, 0, 1, 0));
  132. }
  133. }
  134. if (tab[JV.PROP_SUM_FIELDS]) {
  135. for (let i = 0; i < tab[JV.PROP_SUM_FIELDS].length; i++) {
  136. const tab_field = tab[JV.PROP_SUM_FIELDS][i];
  137. if (!(tab_field[JV.PROP_HIDDEN])) {
  138. // rst.push(me.outputTabField(band, tab_field, null, -1, -1, 1, 0, 1, 0, unitFactor, true, controls, 0));
  139. const value = '';
  140. const item = JpcCommonOutputHelper.createCommonOutputWithoutDecorate(tab_field, value, null);
  141. // position
  142. item[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, 1, 0, 1, 0, false, false);
  143. rst.push(item);
  144. }
  145. }
  146. }
  147. return rst;
  148. },
  149. }
  150. module.exports = JpcDiscreteHelper;