CooperationActiceResults.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div style="padding:20px 20px">
  3. <div class="result" v-for="(item,index) in countryList">
  4. <div style="height:20px">
  5. <img src="@/assets/img/cooperationExchange/20200608_03.gif" alt="" style="height: 100%;vertical-align: middle;">
  6. <span style="margin-left: 10px;font-weight: 700;color: #000;font-size: 18px;">PPT</span>
  7. </div>
  8. <div class="content">
  9. <i></i>
  10. <div>
  11. <img v-if="state==1" :src="'./api/file/pub/${item.attachmentSavePath}'" alt="" style="width: 20%;height: 20%;" />
  12. <img v-if="state==2" src="@/assets/img/cooperationExchange/txt.png" alt="" class="Messicon" />
  13. <img v-if="state==3" src="@/assets/img/cooperationExchange/excel.png" alt="" class="Messicon" />
  14. <img v-if="state==6" src="@/assets/img/cooperationExchange/powerpoint.png" alt="" class="Messicon"/>
  15. <img v-if="state==5" src="@/assets/img/cooperationExchange/pdf.png" alt="" class="Messicon"/>
  16. <img v-if="state==4" src="@/assets/img/cooperationExchange/word.png" alt="" class="Messicon"/>
  17. <p style="display: inline-block;margin-right:150px">{{item.attachmentName}}</p>
  18. <a class="func example" @click="downloads(item.attachmentSavePath,item.attachmentName)">{{$t('common.download')}}</a>
  19. <a class="func" @click="download(item.attachmentSavePath)">{{$t('common.preview')}}</a>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import {sysAttachmentInfos} from '@/api/cooperation/baseCooperationUnit'
  27. export default {
  28. name:"CooperationActiceResults",
  29. props:["id"],
  30. data () {
  31. return {
  32. i:0,
  33. countryList:[],
  34. MessType:null,
  35. state:null,
  36. }
  37. },
  38. mounted(){
  39. this.getList();
  40. },
  41. methods:{
  42. getList(){
  43. let list = {
  44. attachmentBusinessId:this.id,
  45. attachmentBusinessType:'activityInfo'
  46. };
  47. sysAttachmentInfos(list).then(res=>{
  48. this.countryList=res.data.attachmentInfos;
  49. //进行上传文件的判断
  50. let messName = this.countryList[0].attachmentName;
  51. let suffix='';
  52. let result='';
  53. try{
  54. let splitArr = this.countryList[0].attachmentName.split('.');
  55. suffix = splitArr[splitArr.length-1];
  56. }catch(err){
  57. suffix='';
  58. }
  59. console.log(suffix);
  60. const imglist = ['png', 'jpg', 'jpeg', 'bmp', 'gif'];
  61. // 进行图片匹配
  62. result = imglist.find(item => item === suffix);
  63. for(let i=0;i<imglist.length;i++){
  64. if(suffix === imglist[i]){
  65. this.state=1;
  66. }
  67. }
  68. // 匹配txt
  69. const txtlist = ['txt'];
  70. result = txtlist.find(item => item === suffix);
  71. for(let i=0;i<txtlist.length;i++){
  72. if(suffix === txtlist[i]){
  73. this.state=2;
  74. }
  75. }
  76. // 匹配excel
  77. const excelist = ['xls', 'xlsx'];
  78. result = excelist.find(item => item === suffix);
  79. for(let i=0;i<excelist.length;i++){
  80. if(suffix === excelist[i]){
  81. this.state=3;
  82. }
  83. }
  84. // 匹配 word
  85. const wordlist = ['doc', 'docx'];
  86. result = wordlist.find(item => item === suffix);
  87. for(let i=0;i<wordlist.length;i++){
  88. if(suffix === wordlist[i]){
  89. this.state=4;
  90. }
  91. }
  92. // 匹配 pdf
  93. const pdflist = ['pdf'];
  94. result = pdflist.find(item => item === suffix);
  95. for(let i=0;i<pdflist.length;i++){
  96. if(suffix === pdflist[i]){
  97. this.state=5;
  98. }
  99. }
  100. // 匹配 ppt
  101. const pptlist = ['ppt', 'pptx'];
  102. result = pptlist.find(item => item === suffix);
  103. for(let i=0;i<pptlist.length;i++){
  104. if(suffix === pptlist[i]){
  105. this.state=6;
  106. }
  107. }
  108. // let Messname = this.countruList[index].attachmentName;
  109. // this.MessType = Messname
  110. })
  111. },
  112. typemess(){
  113. console.log(this.MessType)
  114. },
  115. downloads(path,fileName){
  116. const link = document.createElement('a');
  117. link.href = "api/file/pub/" + path;
  118. link.download = fileName; //下载的文件名
  119. link.click();
  120. },
  121. download(url){
  122. let a = document.createElement('a');
  123. a.href ="api/file/pub/" + url;
  124. a.click();
  125. },
  126. }
  127. }
  128. </script>
  129. <style scoped>
  130. .result{
  131. height: 100px;
  132. width: 100%;
  133. margin-top: 20px;
  134. }
  135. .content{
  136. height: 80px;
  137. vertical-align: center;
  138. margin-top: 20px;
  139. padding:0 30px;
  140. cursor: pointer;
  141. width: 100%;
  142. }
  143. .func{
  144. color: rgb(10, 15, 255);
  145. margin-right: 20px;
  146. cursor: pointer;
  147. float: right;
  148. margin-right: 100px;
  149. line-height: 50px;
  150. }
  151. .Messicon{
  152. height: 30px;
  153. margin-top: 12px;
  154. float: left;
  155. margin-right: 10px;
  156. }
  157. </style>