FileNameDisplay.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="file-name-display" :class="{'file-name-pdf': is_pdf, 'file-name-others': !is_pdf}">
  3. <span class="file-name-icon"><img :src="img_src"/></span>
  4. <span class="file-name-label">{{file_name}}</span>
  5. </div>
  6. </template>
  7. <script setup>
  8. import icon_excel from '../../assets/files/excel.svg';
  9. import icon_word from '../../assets/files/word-01.svg';
  10. import icon_pdf from '../../assets/files/pdf.44344347.svg';
  11. const props = defineProps({
  12. file_name: String,
  13. file_id: String,
  14. });
  15. /**
  16. * 文件后缀名
  17. */
  18. const file_endfix = (function(){
  19. const arr = props.file_name.split('.');
  20. const str = arr[arr.length - 1]
  21. return str;
  22. })();
  23. const is_pdf = file_endfix === 'pdf';
  24. const icon_map = {
  25. docx: icon_word,
  26. doc: icon_word,
  27. pdf: icon_pdf,
  28. }
  29. const img_src = icon_map[file_endfix];
  30. </script>
  31. <style scoped>
  32. .file-name-display{
  33. display: flex;
  34. justify-content: flex-start;
  35. align-items: center;
  36. }
  37. .file-name-pdf{
  38. cursor: pointer;
  39. }
  40. .file-name-others{
  41. cursor: default;
  42. }
  43. .file-name-icon{
  44. display: inline-block;
  45. margin-right: 3px;
  46. /* height: 22px; */
  47. width: 22px
  48. }
  49. .file-name-icon img{
  50. width: 100%;
  51. }
  52. .file-name-label{
  53. color: blue;
  54. }
  55. </style>