TraceComment.vue 3.2 KB

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