ProcessReportArchive.vue 6.6 KB

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