ProcessReportArchive.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div>
  3. <div v-show="archiveAuthority">
  4. <div>
  5. <label>报表归档:</label>
  6. <button
  7. v-show="startArchive == false"
  8. class="btn btn-success"
  9. @click="startArchive = true"
  10. >
  11. 归档
  12. </button>
  13. <button
  14. v-show="startArchive == false"
  15. class="btn btn-success"
  16. @click="searchArchiveRecord"
  17. >
  18. 归档查询
  19. </button>
  20. <button
  21. v-show="startArchive == true"
  22. class="btn btn-success"
  23. @click="archive()"
  24. >
  25. 保存
  26. </button>
  27. <button
  28. v-show="startArchive == true"
  29. class="btn btn-warning"
  30. @click="startArchive = false"
  31. >
  32. 取消
  33. </button>
  34. </div>
  35. <div v-show="startArchive == true">
  36. <div class="form-group">
  37. <label>标题</label>
  38. <input
  39. v-model="title"
  40. autocomplete="off"
  41. type="text"
  42. class="form-control"
  43. />
  44. </div>
  45. <div class="form-group">
  46. <label>业务日期</label>
  47. <DateTime
  48. v-model="businessDate"
  49. class="form-control"
  50. />
  51. </div>
  52. <div class="form-group">
  53. <label>备注</label>
  54. <input
  55. v-model="description"
  56. autocomplete="off"
  57. type="description"
  58. class="form-control"
  59. />
  60. </div>
  61. <div class="form-group">
  62. <label>归档日期</label>
  63. <input
  64. v-model="archiveDate"
  65. autocomplete="off"
  66. type="text"
  67. class="form-control"
  68. :readonly="true"
  69. />
  70. </div>
  71. <div class="form-group">
  72. <label>归档人</label>
  73. <input
  74. v-model="userName"
  75. autocomplete="off"
  76. type="text"
  77. class="form-control"
  78. :readonly="true"
  79. />
  80. </div>
  81. <div
  82. v-for="item,index in processReportResult.reportResults"
  83. :key="'reportResult-' + index"
  84. class="form-group"
  85. >
  86. <label>报表路径{{ index + 1 }}</label>
  87. <input
  88. v-model="item.htmlPreviewUrl"
  89. autocomplete="off"
  90. type="text"
  91. class="form-control"
  92. :readonly="true"
  93. />
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import Common from '../../common/Common.js';
  101. import Notify from '../../common/Notify.js';
  102. import DateTime from '../../datetime/src/DateTime.vue';
  103. export default {
  104. components: {
  105. DateTime,
  106. },
  107. props: {
  108. 'processReportResult':{
  109. type: Object,
  110. default: null,
  111. }},
  112. data: function () {
  113. return {
  114. archiveAuthority: '',
  115. startArchive: false,
  116. title: '',
  117. businessDate: '',
  118. description: '',
  119. userName: '',
  120. archiveDate: '',
  121. interval: '',
  122. };
  123. },
  124. watch: {
  125. 'processReportResult': function () {
  126. this.initArchiveAuthority();
  127. },
  128. },
  129. mounted: function () {
  130. var _self = this;
  131. this.initArchiveAuthority();
  132. this.interval = window.setInterval(function () {
  133. _self.updateDate();
  134. }, 1000);
  135. },
  136. beforeUnmount: function () {
  137. clearInterval(this.interval);
  138. },
  139. methods: {
  140. initArchiveAuthority: function () {
  141. var _self = this;
  142. if (this.processReportResult) {
  143. this.title = this.processReportResult.processReportName;
  144. }
  145. var loginInfoJson = localStorage.getItem('json_LoginInfo');
  146. var loginInfo = JSON.parse(loginInfoJson);
  147. if (loginInfo != null) {
  148. _self.userName = loginInfo.userName;
  149. }
  150. if (_self.processReportResult == null || _self.processReportResult.processReportNo == null) {
  151. _self.archiveAuthority = false;
  152. return;
  153. }
  154. $.ajax({
  155. url: Common.getApiURL('ProcessReportResource/getArchiveAuthority'),
  156. type: 'get',
  157. dataType: 'json',
  158. data: {
  159. 'processReportNo': _self.processReportResult.processReportNo,
  160. },
  161. beforeSend: function (request) {
  162. Common.addTokenToRequest(request);
  163. },
  164. success: function (data) {
  165. _self.archiveAuthority = data;
  166. },
  167. error: function (XMLHttpRequest, textStatus, errorThrown) {
  168. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  169. },
  170. });
  171. },
  172. archive: function () {
  173. var _self = this;
  174. var url = '';
  175. var reportNames = '';
  176. var reportResults = this.processReportResult.reportResults;
  177. for (var i = 0; i < reportResults.length; i++) {
  178. var reportResult = reportResults[i];
  179. var pdfDownLoadUrl = reportResult.pdfDownLoadUrl;
  180. if (pdfDownLoadUrl && pdfDownLoadUrl.length > 4) {
  181. url += pdfDownLoadUrl.substring(0, pdfDownLoadUrl.length - 4);
  182. reportNames += reportResult.reportName;
  183. }
  184. if (i + 1 < reportResults.length) {
  185. url += ',';
  186. reportNames += ',';
  187. }
  188. }
  189. $.ajax({
  190. url: Common.getApiURL('ArchiveResource/archive'),
  191. type: 'get',
  192. dataType: 'json',
  193. data: {
  194. 'help': _self.title,
  195. 'businessDate': _self.businessDate,
  196. 'description': _self.description,
  197. 'url': url,
  198. 'reportNames': reportNames,
  199. },
  200. beforeSend: function (request) {
  201. Common.addTokenToRequest(request);
  202. },
  203. success: function (data) {
  204. Notify.success('归档成功', '归档成功,可以在【归档查询】页面查询所有归档信息', 1500);
  205. _self.startArchive = false;
  206. },
  207. error: function (XMLHttpRequest, textStatus, errorThrown) {
  208. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  209. },
  210. });
  211. },
  212. //格式化日期成 "yyyy-MM-dd HH-mm-SS"格式
  213. updateDate: function () {
  214. var date = new Date();
  215. var seperator1 = '-';
  216. var seperator2 = ':';
  217. var month = date.getMonth() + 1;
  218. var strDate = date.getDate();
  219. if (month >= 1 && month <= 9) {
  220. month = '0' + month;
  221. }
  222. if (strDate >= 0 && strDate <= 9) {
  223. strDate = '0' + strDate;
  224. }
  225. var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
  226. + ' ' + date.getHours() + seperator2 + date.getMinutes() + seperator2
  227. + (date.getSeconds() < 10 ? '0' : '') + date.getSeconds();
  228. this.archiveDate = currentdate;
  229. },
  230. searchArchiveRecord: function () {
  231. this.$router.push('/desktop/archive');
  232. },
  233. },
  234. };
  235. </script>