uploadDown.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="back-box">
  3. <div v-for="item in infolist" :key="item.id" @click="downcheck(item)">
  4. <i class="iconfont icon-word" v-if="item.type==='word'"></i>
  5. <i class="iconfont icon-excel" v-if="item.type==='excel'"></i>
  6. <i class="iconfont icon-ppt" v-if="item.type==='ppt'"></i>
  7. <i class="iconfont icon-wenjian" v-if="item.type==='wenjian'"></i>
  8. <i class="el-icon-picture" v-if="item.type==='png'"></i>
  9. <el-tooltip class="item" effect="dark" :content="item.fileName" placement="right" :enterable="false">
  10. <span class="tab-long">{{item.fileName}}</span>
  11. </el-tooltip>
  12. <div class="seedown" v-if="datalist.type===2">
  13. <a @click="uploaddown(item)">下载</a>
  14. </div>
  15. </div>
  16. <div class="if-box-top" v-if="ifrshow" @keyup.esc="ifrshow=false">
  17. <i class="el-icon-close" @click="ifrshow=false"></i>
  18. <iframe
  19. height="100%"
  20. width="100%"
  21. :src="srcsc">
  22. </iframe>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. props: ['datalist', 'dialogStatus'],
  29. data() {
  30. return {
  31. infolist: [],
  32. status: false,
  33. srcsc: '',
  34. ifrshow:false,
  35. }
  36. },
  37. methods: {
  38. downcheck(v) {
  39. if (this.datalist.type === 1) {
  40. this.uploaddown(v);
  41. }
  42. },
  43. uploadsee(v) {
  44. let url = encodeURIComponent(Base64.encode(v.callPath));
  45. this.srcsc = 'http://10.230.15.228:8012/onlinePreview?url=' + url;
  46. this.ifrshow=true;
  47. // window.open('http://114.215.71.182:8012/onlinePreview?url=' + url);
  48. },
  49. //下载e
  50. uploaddown(v) {
  51. let fileData = v;
  52. this.$http({
  53. url: this.datalist.url,
  54. method: "post",
  55. headers: {
  56. "Content-Type": "application/json",
  57. },
  58. responseType: "blob",
  59. data: {"id": fileData.id, "fileName": fileData.fileName},
  60. }).then((response) => {
  61. if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  62. let blob = new Blob([response.data], {
  63. type: 'application/vnd.ms-excel'
  64. });
  65. window.navigator.msSaveOrOpenBlob(blob, fileData.fileName);
  66. } else {
  67. /* 火狐谷歌的文件下载方式 */
  68. var blob = new Blob([response.data])
  69. var downloadElement = document.createElement('a')
  70. var href = window.URL.createObjectURL(blob);
  71. downloadElement.href = href;
  72. downloadElement.download = fileData.fileName;
  73. document.body.appendChild(downloadElement);
  74. downloadElement.click();
  75. document.body.removeChild(downloadElement);
  76. window.URL.revokeObjectURL(href);
  77. }
  78. });
  79. },
  80. dataHandle() {
  81. this.infolist = this.datalist.attList;
  82. if (this.infolist) {
  83. for (let i = 0; i < this.infolist.length; i++) {
  84. let f = this.infolist[i].fileName.split(".");
  85. let type = f[f.length - 1];
  86. if (type === 'doc' || type === 'docx') {
  87. this.infolist[i].type = 'word';
  88. } else if (type === 'ppt') {
  89. this.infolist[i].type = 'ppt';
  90. } else if (type === 'xlsx' || type === 'xls') {
  91. this.infolist[i].type = 'excel';
  92. } else if (type === 'png' || type === 'jpg' || type === 'svg' || type === 'gif' || type === 'psd') {
  93. this.infolist[i].type = 'png';
  94. } else {
  95. this.infolist[i].type = 'wenjian';
  96. }
  97. }
  98. }
  99. }
  100. },
  101. mounted() {
  102. },
  103. created() {
  104. this.dataHandle();
  105. },
  106. watch: {
  107. dialogStatus() {
  108. this.$forceUpdate()
  109. let _this = this;
  110. _this.dataHandle();
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped lang="scss">
  116. .if-box-top{
  117. background: #fff;
  118. width: 80vw;
  119. height: 80vh;
  120. margin-top: 10vh;
  121. margin-left: 10vw;
  122. }
  123. .iconfont {
  124. font-size: 42px;
  125. }
  126. .icon-excel {
  127. color: #67DB63;
  128. }
  129. .icon-word {
  130. color: #FF654E;
  131. }
  132. .icon-ppt {
  133. color: #FF8943;
  134. }
  135. .icon-wenjian {
  136. color: #ccc;
  137. }
  138. .el-icon-picture {
  139. font-size: 36px;
  140. color: #ccc;
  141. background: #fff;
  142. padding: 4px 2px;
  143. margin-bottom: 2px;
  144. border-radius: 3px;
  145. }
  146. .back-box {
  147. margin-top: 20px;
  148. background: #F2F2F2;
  149. padding: 20px;
  150. div {
  151. display: inline-block;
  152. text-align: center;
  153. margin-right: 20px;
  154. cursor: pointer;
  155. span {
  156. display: block;
  157. width: 80px;
  158. overflow: hidden;
  159. padding-top: 5px;
  160. margin: 0 10px;
  161. overflow: hidden;
  162. text-overflow: ellipsis;
  163. display: -webkit-box; /* 将对象作为弹性伸缩盒子模型显示 */
  164. -webkit-line-clamp: 1; /* 控制最多显示几行 */
  165. -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 */
  166. }
  167. }
  168. .seedown {
  169. margin: 0;
  170. margin-top: 5px;
  171. a {
  172. font-size: 12px;
  173. padding: 2px 5px;
  174. border: 1px solid transparent;
  175. color: #999;
  176. }
  177. a:hover {
  178. color: #0b82ff;
  179. }
  180. }
  181. }
  182. </style>