lj-fj.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <div>
  3. <mu-row align-items="start" style="height: 30px;line-height: 30px;">
  4. <mu-col span="1" style="text-align:center">
  5. <svg class="icon" aria-hidden="true" @click="handleClick">
  6. <use :xlink:href="icon"></use>
  7. </svg>
  8. </mu-col>
  9. <mu-col :span="deletable?8:9">
  10. <span class="lj-card-tertiary-content text-ellipsis-one_2" style="overflow:hidden;"
  11. @click="handleClick">{{realFileName}}</span>
  12. </mu-col>
  13. <mu-col span="2" style="text-align:right">
  14. <span
  15. class="lj-card-quaternary-content lj-card-summary-light-text">{{realFileSize | numberUnitFilter}}</span>
  16. </mu-col>
  17. <mu-col span="1" style="text-align:center">
  18. <span v-if="deletable" @click="handleDelete">
  19. <i class="iconfont icon-guanbi" style="font-size: 15px;color: #fc4e2c;"></i>
  20. </span>
  21. </mu-col>
  22. </mu-row>
  23. </div>
  24. </template>
  25. <script>
  26. export default {
  27. name: "lj-fj",
  28. props: {
  29. fileFj: {
  30. type: Object
  31. },
  32. fileName: String,
  33. fileType: String,
  34. fileSize: Number,
  35. md5: String,
  36. fileid: Number,
  37. url: String,
  38. // 使用默认的点击事件
  39. clickEventDefault: {
  40. Type: Boolean,
  41. default: true
  42. },
  43. deletable: Boolean,
  44. requestType: String, //请求附件,可选项:MailAnnex,OADocAnnex,OADemoAnnex,OAFlowDefAnnex,UFile(默认)
  45. },
  46. data() {
  47. return {}
  48. },
  49. methods: {
  50. handleClick() {
  51. if (!this.clickEventDefault) {
  52. return;
  53. }
  54. this.openFile();
  55. },
  56. openFile() {
  57. let requestType = 'UFile'
  58. if (this.requestType) {
  59. requestType = this.requestType
  60. }
  61. if (this.realFileMd5) {
  62. // let abc = {
  63. // realFileName: this.realFileName,
  64. // realFileType: this.realFileType,
  65. // realFileMd5: this.realFileMd5,
  66. // realFileId: this.realFileId,
  67. // requestType: requestType,
  68. // }
  69. // alert(JSON.stringify(abc));
  70. $lj.openFile(this.realFileName.trim(), this.realFileType, this.realFileMd5, this.realFileId, requestType);
  71. } else if (this.url) {
  72. $lj.openFileByUrl(this.url);
  73. }
  74. },
  75. handleDelete() {
  76. this.$emit("on-delete");
  77. },
  78. },
  79. computed: {
  80. realFileName() {
  81. return this.fileName || (this.fileFj ? this.fileFj.fileName : "");
  82. },
  83. realFileType() {
  84. let type = this.fileType || (this.fileFj ? this.fileFj.fileType : "");
  85. if (type) {
  86. let dotIndex = type.indexOf('.');
  87. if (dotIndex >= 0) {
  88. type = type.substring(type.indexOf('.') + 1);
  89. }
  90. }
  91. return type.replace(/^\s+|\s+$/g,"");
  92. },
  93. realFileMd5() {
  94. return this.md5 || (this.fileFj ? this.fileFj.filemd5 : "");
  95. },
  96. realFileSize() {
  97. return this.fileSize || (this.fileFj ? this.fileFj.fileSize : "");
  98. },
  99. realFileId() {
  100. return this.fileid;
  101. },
  102. icon() {
  103. let type = this.realFileType.trim().toLowerCase();
  104. if (type) {
  105. switch (type) {
  106. case "jpg":
  107. case "jpeg":
  108. case "png":
  109. case "gif":
  110. case "bmp":
  111. return "#icon-tupian";
  112. case "xls":
  113. case "xlsx":
  114. return "#icon-excel";
  115. case "doc":
  116. case "docx":
  117. return "#icon-WORD";
  118. case "txt":
  119. return "#icon-txt";
  120. case "pdf":
  121. return "#icon-PDF";
  122. }
  123. }
  124. return "#icon-yasuobao";
  125. }
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. </style>