FileList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="file-list">
  3. <el-empty description="暂无文件" v-if="fileData.length == 0"></el-empty>
  4. <div
  5. v-for="(item,index) in fileData"
  6. :key="index"
  7. class="file-item"
  8. @mouseenter="isIconShowIndex = index"
  9. @mouseleave="isIconShowIndex = 10000000000"
  10. @click="fileClick(item)">
  11. <div class="image">
  12. <el-image
  13. style="width: 100%; height: 100%"
  14. :src="item.cover || require('../../../assets/file_icons/unknow.png')"
  15. fit="fill">
  16. </el-image>
  17. </div>
  18. <p>{{item.document}}</p>
  19. <div class="icon" v-show="item.fileType != 'folder' && isCollect == true && isIconShowIndex === index || $route.path == '/archivesmag_list'">
  20. <img
  21. src="@/assets/file_icons/收藏.png"
  22. alt
  23. v-show="item.isCollect == 1 || $route.path == '/archivesmag_list'"
  24. @click.stop="collectClick(item)"
  25. />
  26. <img
  27. src="@/assets/file_icons/未收藏.png"
  28. alt
  29. v-show="item.isCollect == 0"
  30. @click.stop="collectClick(item)"
  31. />
  32. </div>
  33. </div>
  34. <!--文件信息面板-->
  35. <drawer ref="drawer"
  36. :currentSelectFile="currentSelectFile"
  37. v-show="currentSelectFile"
  38. @downLoad="dialogVisible = true">
  39. </drawer>
  40. </div>
  41. </template>
  42. <script>
  43. import Drawer from '@/SManagement/archives/components/Drawer'
  44. export default {
  45. name: "FileList",
  46. data() {
  47. return {
  48. //收藏配置
  49. params: {
  50. accesstoken: "6de4ba3e3e8967a875ae42ab24c2da48",
  51. classname: "system.attachment.MediaCenter",
  52. method: "collectAttachment",
  53. content: {
  54. collecttype: "营销物料",
  55. attachmentid: 1
  56. }
  57. },
  58. //当前悬浮在什么位置
  59. isIconShowIndex: '',
  60. //当前选中的文件
  61. currentSelectFile: '',
  62. };
  63. },
  64. components: {
  65. Drawer,
  66. },
  67. props: {
  68. fileData: {
  69. default() {
  70. return [];
  71. }
  72. },
  73. //是否显示收藏
  74. isCollect: {
  75. type: Boolean
  76. }
  77. },
  78. computed: {},
  79. watch: {},
  80. created() {
  81. },
  82. methods: {
  83. //文件单击事件
  84. fileClick(item) {
  85. if (item.postfix == "folder") {
  86. this.$emit("upFileData", item.parentid, item.document,item.attachmentid);
  87. } else {
  88. this.currentSelectFile = this.fileType.fileList(item)
  89. this.$refs.drawer.isFileInfoPanlShow = true
  90. }
  91. },
  92. //收藏
  93. collectClick(item) {
  94. let id = item.isCollect == 0 ? 1 : 0;
  95. if (item.isCollect == 0) {
  96. this.params.method = "collectAttachment";
  97. this.params.content.collecttype = "营销物料",
  98. this.params.content.attachmentid = item.attachmentid
  99. } else {
  100. this.params.method = "uncollectAttachment";
  101. this.params.content.attachmentid = item.attachmentid;
  102. }
  103. //发送收藏请求
  104. this.$api.requested(this.params).then(res => {
  105. if (res.code == 1) {
  106. this.$emit("statusChange", id, item);
  107. if(this.params.method == "collectAttachment") {
  108. this.$notify({
  109. title: "提示",
  110. message: "收藏成功",
  111. type: "success"
  112. });
  113. } else {
  114. this.$notify({
  115. title: "提示",
  116. message: "取消收藏",
  117. type: "success"
  118. });
  119. }
  120. } else {
  121. this.$notify({
  122. title: "提示",
  123. message: "操作失败",
  124. type: "error"
  125. });
  126. }
  127. })
  128. },
  129. },
  130. };
  131. </script>
  132. <style scoped>
  133. * {
  134. box-sizing: border-box;
  135. }
  136. .file-list {
  137. display: flex;
  138. flex-wrap: wrap;
  139. }
  140. .file-list .file-item {
  141. padding: 16px 0 12px 0;
  142. margin-right: 12px;
  143. cursor: pointer;
  144. border-radius: 4px;
  145. position: relative;
  146. }
  147. .file-list .file-item:hover {
  148. background: #f1f4f9;
  149. }
  150. .file-list .file-item .image {
  151. width: 64px;
  152. height: 64px;
  153. position: relative;
  154. left: 50%;
  155. transform: translateX(-50%);
  156. }
  157. .file-list .file-item .image img {
  158. width: 100%;
  159. height: 100%;
  160. }
  161. .file-list .file-item p {
  162. font-size: 14px;
  163. width: 120px;
  164. font-family: PingFang SC-Regular, PingFang SC;
  165. font-weight: 400;
  166. color: #333333;
  167. text-align: center;
  168. padding: 0 9px;
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. white-space: nowrap;
  172. }
  173. .file-list .file-item .icon {
  174. position: absolute;
  175. top: 0;
  176. right: 0;
  177. margin: 8px 8px 0 0;
  178. }
  179. /deep/.el-empty {
  180. position: absolute;
  181. top: 50%;
  182. left: 50%;
  183. transform: translate(-50%,-50%);
  184. }
  185. </style>