jpc_helper_discrete.js 9.7 KB

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