ProcessReport.vue 6.3 KB

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