list.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <div class="list-box" v-if="fileData.length != 0">
  3. <div class="list" v-for="(item,index) in fileData" :key="index" @click="itemClick(item)">
  4. <div class="top">
  5. <img :src="getCover(item)" alt="">
  6. </div>
  7. <div class="bottom">
  8. <p class="title">{{item.title}}</p>
  9. <div class="icon-box">
  10. <div class="item">
  11. <img src="@/assets/see.png" alt="">
  12. <span>{{item.readcount}}</span>
  13. </div>
  14. <div class="item">
  15. <img src="@/assets/shark.png" alt="">
  16. <span>{{item.sharecount}}</span>
  17. </div>
  18. <div class="item">
  19. <img src="@/assets/refreshNum.png" alt="">
  20. <span>{{item.newcount}}</span>
  21. </div>
  22. </div>
  23. <div class="handle">
  24. <slot name="edit" :data="item"></slot>
  25. <slot name="delete" :data="item"></slot>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <el-empty description="暂无数据" v-else></el-empty>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'list',
  35. data () {
  36. return {
  37. dialogVisible: false,
  38. currentItem:[]
  39. };
  40. },
  41. props: ['fileData'],
  42. computed: {
  43. },
  44. components: {
  45. },
  46. watch: {
  47. },
  48. created () {
  49. },
  50. methods: {
  51. //获取封面
  52. getCover(item) {
  53. let result = item.attinfos.find(item1 => item1.fileType == 'image')
  54. if(result) {
  55. return item.attinfos.find(item => item == result).cover
  56. } else if(item.attinfos[0] && item.attinfos[0].subfiles[0]) {
  57. return item.attinfos[0].subfiles[0].url
  58. }else {
  59. return require('@/assets/video.png')
  60. }
  61. },
  62. itemClick (data) {
  63. this.$emit('listItemClick', data)
  64. },
  65. },
  66. };
  67. </script>
  68. <style scoped>
  69. * {
  70. box-sizing: border-box;
  71. }
  72. .list-box {
  73. width: 100%;
  74. display: flex;
  75. flex-wrap: wrap;
  76. margin-bottom: 16px;
  77. }
  78. .list-box .list {
  79. width: 168px;
  80. margin: 0 30px 30px 0;
  81. border-radius: 4px;
  82. transition: all 0.2s ease-out;
  83. cursor: pointer;
  84. }
  85. .list-box .list:hover {
  86. box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);
  87. }
  88. .list-box .list .top {
  89. width: 100%;
  90. height: 120px;
  91. border-radius: 4px 4px 0px 0px;
  92. }
  93. .list-box .list .top img {
  94. width: 100%;
  95. height: 100%;
  96. border-radius: 4px 4px 0px 0px;
  97. }
  98. .list-box .list .bottom {
  99. width: 100%;
  100. padding: 16px;
  101. background: #ffffff;
  102. border-radius: 0px 0px 4px 4px;
  103. border: 1px solid #cccccc;
  104. }
  105. .list-box .list .bottom p:nth-child(1) {
  106. font-size: 14px;
  107. font-weight: 400;
  108. color: #333333;
  109. margin-bottom: 10px;
  110. overflow: hidden;
  111. text-overflow: ellipsis;
  112. white-space: nowrap;
  113. }
  114. .list-box .list .bottom .icon-box {
  115. display: flex;
  116. justify-content: space-between;
  117. }
  118. .list-box .list .bottom .icon-box .item {
  119. }
  120. .list-box .list .bottom .icon-box .item span {
  121. font-size: 10px;
  122. font-weight: 400;
  123. color: #999999;
  124. margin-left: 5px;
  125. }
  126. .list-box .list .bottom .icon-box .item img {
  127. vertical-align: middle;
  128. }
  129. .list-box .list .bottom .handle {
  130. display: flex;
  131. justify-content: space-around;
  132. font-size: 14px;
  133. font-weight: 400;
  134. color: #3874f6;
  135. margin-top: 16px;
  136. }
  137. .list-box .list .bottom .handle span {
  138. cursor: pointer;
  139. }
  140. .el-empty {
  141. position: absolute;
  142. left: 50%;
  143. top: 50%;
  144. transform: translate(-50%,-50%);
  145. }
  146. </style>