ProcessReport.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div>
  3. <ProcessReportDynamic
  4. v-if="reportType == 'DYNAMIC'"
  5. :process-report-dto="processReportDto"
  6. @value-changed="valueChanged"
  7. />
  8. <ProcessReportStatic
  9. v-if="reportType == 'STATIC'"
  10. :process-report-dto="processReportDto"
  11. @value-changed="valueChanged"
  12. />
  13. </div>
  14. </template>
  15. <script>
  16. var Common = require('../../common/Common.js').default;
  17. var ProcessReportDynamic = require('./ProcessReportDynamic.vue').default;
  18. var ProcessReportStatic = require('./ProcessReportStatic.vue').default;
  19. export default {
  20. name: 'ProcessReport',
  21. components: {
  22. ProcessReportDynamic,
  23. ProcessReportStatic,
  24. },
  25. data: function () {
  26. return {
  27. 'reportType': '',
  28. 'processReportDto': {},
  29. };
  30. },
  31. watch: {
  32. '$route': function (to, from) {
  33. this.processReportNo = this.$route.params.no;
  34. this.loadData();
  35. },
  36. },
  37. mounted: function () {
  38. this.processReportNo = this.$route.params.no;
  39. this.loadData();
  40. },
  41. methods: {
  42. /**
  43. * 根据流程报表ID加载流程报表数据
  44. * @return {void}
  45. */
  46. loadData: function () {
  47. var _self = this;
  48. $.ajax({
  49. url: Common.getApiURL('ProcessReportResource/uniqueByNo'),
  50. type: 'get',
  51. dataType: 'json',
  52. beforeSend: function (request) {
  53. Common.addTokenToRequest(request);
  54. },
  55. data: {
  56. no: _self.processReportNo,
  57. },
  58. success: function (data) {
  59. console.log('参数结果' + data.reportType);
  60. _self.reportType = data.reportType;
  61. if (data.processReportParameters) {
  62. data.processReportParameters.forEach(function (item) {
  63. if (item.fieldValue == undefined) {
  64. item.fieldValue = {
  65. id: '',
  66. displayValue: [],
  67. fieldType: 'String',
  68. };
  69. }
  70. });
  71. }
  72. _self.processReportDto = data;
  73. },
  74. error: function (XMLHttpRequest, textStatus, errorThrown) {
  75. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  76. },
  77. });
  78. },
  79. // 值改变事件
  80. valueChanged: function (processReportParameter) {
  81. var _self = this;
  82. console.log('processReportParameter:' + JSON.stringify(processReportParameter));
  83. if (_self.processReportDto && _self.processReportDto.processReportParameters) {
  84. for (let i = 0; i < _self.processReportDto.processReportParameters.length; i++) {
  85. if (_self.processReportDto.processReportParameters[i].fieldName == processReportParameter.fieldName) {
  86. _self.processReportDto.processReportParameters[i].fieldValue = processReportParameter.fieldValue;
  87. }
  88. }
  89. }
  90. if (processReportParameter.calloutProcessNo && processReportParameter.calloutProcessNo != '') {
  91. _self.callout(processReportParameter.calloutProcessNo);
  92. }
  93. if (_self.processReportDto != null && _self.processReportDto.processReportParameters != null) {
  94. for (let i = 0; i < _self.processReportDto.processReportParameters.length; i++) {
  95. var item = _self.processReportDto.processReportParameters[i];
  96. if (item.fieldName != processReportParameter.fieldName
  97. && item.whereClause != null
  98. && item.whereClause.indexOf(':' + processReportParameter.fieldName) >= 0) {
  99. item.fieldValue.id = '';
  100. item.fieldValue.displayValue.splice(0, item.fieldValue.displayValue.length);
  101. _self.processReportDto.processReportParameters[i]=item;
  102. }
  103. }
  104. }
  105. },
  106. callout: function (calloutProcessNo) {
  107. var _self = this;
  108. $.ajax({
  109. url: Common.getApiURL('ProcessReportResource/runProcessReportCallout/') + calloutProcessNo,
  110. type: 'POST',
  111. beforeSend: function (request) {
  112. Common.addTokenToRequest(request);
  113. },
  114. contentType: 'application/json',
  115. data: JSON.stringify(_self.processReportDto),
  116. success: function (data) {
  117. if (data && data.processReportParameterDtos) {
  118. var processReportParameterDtos = data.processReportParameterDtos;
  119. for (var i = 0; i < data.processReportParameterDtos.length; i++) {
  120. var fieldName = data.processReportParameterDtos[i].fieldName;
  121. for (var j = 0; j < _self.processReportDto.processReportParameters.length; j++) {
  122. if (_self.processReportDto.processReportParameters[j].fieldName == fieldName) {
  123. var parameter = _self.processReportDto.processReportParameters[j];
  124. var cloneObject = {
  125. 'index': 1,
  126. 'isMandatory': false,
  127. 'id': parameter.id,
  128. 'fieldName': parameter.fieldName,
  129. 'name': parameter.name,
  130. 'help': parameter.help,
  131. 'displayType': parameter.displayType,
  132. 'listDisplayFieldNames': parameter.listDisplayFieldNames,
  133. 'infoWindowId': parameter.infoWindowId,
  134. 'sortNo': parameter.sortNo,
  135. 'isShow': parameter.isShow,
  136. 'constraintEnum': parameter.constraintEnum,
  137. 'whereClause': parameter.whereClause,
  138. 'enumClass': parameter.enumClass,
  139. 'fieldValue': data.processReportParameterDtos[i].fieldValue,
  140. 'calloutProcessNo': parameter.calloutProcessNo,
  141. 'mandatory': parameter.mandatory,
  142. 'listDisplayFieldName': parameter.listDisplayFieldName,
  143. 'displayName': parameter.displayName,
  144. };
  145. _self.processReportDto.processReportParameters[j]=cloneObject;
  146. }
  147. }
  148. }
  149. }
  150. },
  151. error: function (XMLHttpRequest, textStatus, errorThrown) {
  152. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  153. },
  154. });
  155. },
  156. },
  157. };
  158. </script>
  159. <style scoped>
  160. .control-label {
  161. font-size: 15px;
  162. }
  163. .processResult-textarea {
  164. width: 100%;
  165. height: 200px;
  166. }
  167. </style>