TraceComment.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <!--
  2. 作者:yangzhijie1488@163.com
  3. 时间:2017-12-12
  4. 描述:追踪日志
  5. -->
  6. <template>
  7. <div>
  8. <div v-for="items in traceComments" :key="items" class="media">
  9. <h4 class="media-heading">
  10. {{ items.createdName
  11. }}<a class="fa-pull-right" @click="edit(items)">编辑</a>
  12. </h4>
  13. <div class="media-body">
  14. <div>
  15. <div v-dompurify-html="items.content" />
  16. <br />
  17. {{ items.created }}
  18. </div>
  19. <div v-if="items.attachments != '' && items.attachments != undefined">
  20. <div
  21. v-for="item in split(items.attachments)"
  22. :key="item"
  23. @click="download(item)"
  24. >
  25. <a>{{ item }}</a>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </template>
  32. <script>
  33. var Common = require('../common/Common.js');
  34. var DownloadService = require('pc-component-v3').default.DownloadService;
  35. export default {
  36. components: {
  37. Common,
  38. DownloadService,
  39. },
  40. // props: ['traceId', 'trace'],
  41. props: {
  42. traceId: {
  43. type: String,
  44. default: null,
  45. },
  46. trace: {
  47. type: String,
  48. default: null,
  49. },
  50. },
  51. data: function () {
  52. return {
  53. traceComments: [],
  54. className: 'com.leanwo.prodog.trace.model.TraceComment',
  55. uuid: '',
  56. };
  57. },
  58. watch: {
  59. traceId: function (curVal, oldVal) {
  60. if (curVal != undefined) {
  61. this.getTraceComment();
  62. }
  63. },
  64. },
  65. mounted: function () {
  66. this.uuid = this.$route.params.uuid;
  67. if (this.traceId != undefined) {
  68. this.getTraceComment();
  69. }
  70. },
  71. methods: {
  72. /**
  73. * 根据追踪表Id获取评论
  74. * @author GuoZhiBo 20171201
  75. */
  76. getTraceComment: function () {
  77. var _self = this;
  78. $.ajax({
  79. url: Common.getApiURL('TraceCommentResource/queryTraceComment'),
  80. type: 'get',
  81. dataType: 'json',
  82. async: false,
  83. data: {
  84. traceId: _self.traceId,
  85. },
  86. beforeSend: function (request) {
  87. Common.addTokenToRequest(request);
  88. },
  89. success: function (data) {
  90. _self.traceComments = data;
  91. },
  92. error: function (XMLHttpRequest, textStatus, errorThrown) {
  93. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  94. },
  95. });
  96. },
  97. /**
  98. * 将字符串以”,“进行分割成字符串
  99. * @author GuoZhiBo 20171201
  100. */
  101. split: function (items) {
  102. if (items != null && items != '') {
  103. return items.split(',');
  104. } else {
  105. return null;
  106. }
  107. },
  108. /**
  109. * 下载文件
  110. * @param {String} fileName 文件名
  111. * @return {void}
  112. */
  113. download: function (fileName) {
  114. var _self = this;
  115. DownloadService.fileDownload(_self.className, fileName);
  116. },
  117. /**
  118. * 获取图片地址
  119. * @param {String} item 图片名称
  120. * @return {String} 图片URL地址
  121. */
  122. getImageSrc: function (item) {
  123. var _self = this;
  124. if (item != undefined && item != null) {
  125. return Common.getImageSrc(
  126. 'com.leanwo.prodog.trace.model.TraceComment',
  127. item,
  128. );
  129. } else {
  130. return '';
  131. }
  132. },
  133. /**
  134. * 获取图片地址
  135. */
  136. getImageSrcName: function (imageName) {
  137. return Common.getImageSrc('com.leanwo.prodog.model.base.User', imageName);
  138. },
  139. /**
  140. * 打开评论界面进行评论
  141. * @author GuoZhiBo 20171201
  142. */
  143. edit: function (item) {
  144. this.$router.push('/trace/traceCommentEdit/' + item.id);
  145. },
  146. },
  147. };
  148. </script>
  149. <style>
  150. </style>