list.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div>
  3. <div class="flex-align-center flex-between border-bottom container normal-panel">
  4. <div class="flex-align-center">
  5. <slot name="upload"></slot>
  6. <slot name="add"></slot>
  7. <slot name="btngroup"></slot>
  8. </div>
  9. <div class="flex-align-center">
  10. <el-input size="small" style="width:160px;margin-right:16px" prefix-icon="el-icon-search" v-model="params.content.where.condition" @keyup.enter.native="queryAttachment(params.content.pageNumber = 1)" @clear="queryAttachment(params.content.pageNumber = 1)" placeholder="搜索全部" clearable></el-input>
  11. <sort :sort="sort" @onSort="onSort"></sort>
  12. <i class="el-icon-refresh" style="margin-left:16px" @click="queryAttachment(params.content.where.condition = '')"></i>
  13. </div>
  14. </div>
  15. <div ref="ele" id="scroll" style="height:calc(100vh - 255px);overflow-y:scroll" class="container normal-panel">
  16. <el-row :gutter="10" class="folder-list">
  17. <el-col :span="2" v-for="folder in list" :key="folder.id" @click.native="folderDetails(folder)">
  18. <div class="folder-item" :class="folder.ischeck?'checked':''">
  19. <el-checkbox class="folder-checkbox" v-model="folder.ischeck" @change="onChange(folder)"></el-checkbox>
  20. <div class="img-panel">
  21. <img v-if="folder.postfix === 'DOC' || folder.postfix === 'DOCX'" src="../../../assets/file_icons/word.png" alt="">
  22. <img v-else-if="folder.postfix === 'PDF'" src="../../../assets/file_icons/PDF.png" alt="">
  23. <img v-else-if="folder.postfix === 'MP4' || folder.postfix === 'AVI'" src="../../../assets/file_icons/video.png" alt="">
  24. <img v-else-if="folder.postfix === 'XLS' || folder.postfix === 'XLSX'" src="../../../assets/file_icons/excel.png" alt="">
  25. <img v-else-if="folder.postfix === 'PNG' || folder.postfix === 'JPG'|| folder.postfix === 'JPEG'" src="../../../assets/file_icons/image.png" alt="">
  26. <img v-else-if="folder.postfix === 'PPT' || folder.postfix === 'PPTX'" src="../../../assets/file_icons/PPT.png" alt="">
  27. <img v-else-if="folder.postfix === 'FOLDER'" src="../../../assets/file_icons/folder.png" alt="">
  28. <img v-else src="../../../assets/file_icons/unknow.png" alt="">
  29. </div>
  30. <input v-if="folder.newfolder" type="text" v-model="folder.document" autofocus size="mini" @blur="changeFolderName(folder)">
  31. <!-- <p v-else>{{folder.document}}</p> -->
  32. <p v-else>{{folder.document}}</p>
  33. </div>
  34. </el-col>
  35. </el-row>
  36. <div v-if="list.length === 0" class="flex-align-center" style="height:calc(100vh - 200px);justify-content:space-around">
  37. <el-empty description="暂无文件,请点击左上角的“上传”按钮添加"></el-empty>
  38. </div>
  39. </div>
  40. <div style="margin:16px 0;text-align:right">
  41. <el-pagination
  42. background
  43. small
  44. @size-change="handleSizeChange"
  45. @current-change="handleCurrentChange"
  46. :current-page="currentPage"
  47. :page-size="params.content.pageSize"
  48. layout="total, prev, pager, next, jumper"
  49. :total="total">
  50. </el-pagination>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. export default {
  56. data () {
  57. return {
  58. params:{
  59. "classname": "webmanage.saletool.salematerial.salematerial",
  60. "method": "selectList",
  61. "content": {
  62. "parentid":0,
  63. "pageNumber":1,
  64. "pageSize":20,
  65. "where":{
  66. "condition":""
  67. }
  68. }
  69. },
  70. list:[],
  71. sort:[],
  72. total:0,
  73. currentPage:0,
  74. isLoad:true,
  75. msg:"正在加载"
  76. }
  77. },
  78. methods:{
  79. // 排序
  80. onSort (sort) {
  81. this.params.content.sort = [sort]
  82. this.queryAttachment(this.params.content.parentid)
  83. },
  84. async queryAttachment () {
  85. this.params.content.parentid = this.$route.query.id?this.$route.query.id:JSON.parse(sessionStorage.getItem('folderid')).appfolderid
  86. const res = await this.$api.requested(this.params)
  87. res.data.map(e=>{
  88. e.postfix = e.postfix.toUpperCase()
  89. e.ischeck = false
  90. })
  91. this.list = res.data
  92. this.total = res.total
  93. this.currentPage = res.pageNumber
  94. this.sort = res.sort
  95. },
  96. handleSizeChange(val) {
  97. // console.log(`每页 ${val} 条`);
  98. this.params.content.pageSize = val
  99. this.queryAttachment(this.params.content.parentid)
  100. },
  101. handleCurrentChange(val) {
  102. // console.log(`当前页: ${val}`);
  103. this.params.content.pageNumber = val
  104. this.queryAttachment(this.params.content.parentid)
  105. },
  106. changeFolderName (folder) {
  107. this.$emit('onNameChange',folder)
  108. },
  109. onChange (folder) {
  110. let checkArray = []
  111. this.list.forEach((e,index)=>{
  112. if (e.ischeck === true) {
  113. checkArray.push(e)
  114. }
  115. })
  116. this.$emit('folderChecked',checkArray)
  117. },
  118. folderDetails (folder) {
  119. if (folder.postfix === 'FOLDER') {
  120. this.$router.push({path:'/archvies_mag',query:{id:folder.attachmentid}})
  121. this.$emit('toFolderDetail',folder.attachmentid)
  122. this.queryAttachment(folder.attachmentid)
  123. }
  124. },
  125. restChecked () {
  126. this.list.forEach((e,index)=>{
  127. e.ischeck = false
  128. })
  129. },
  130. },
  131. mounted () {
  132. // 根据容器高度计算需要的数据条数
  133. var heightCss = window.getComputedStyle(this.$refs.ele).height
  134. this.params.content.pageSize = Math.ceil((heightCss.match(/\d+/g) / 114)) *12
  135. this.queryAttachment()
  136. },
  137. // 离开这个页面销毁滚动条事件,不然会给每一个页面都触发
  138. beforeDestroy() {
  139. },
  140. watch:{
  141. $route () {
  142. this.queryAttachment()
  143. // 路由发生变化的时候初始化选择数组
  144. this.$emit('folderChecked',[])
  145. }
  146. }
  147. }
  148. </script>
  149. <style>
  150. .folder-item {
  151. position: relative;
  152. padding:10px 5px;
  153. text-align: center;
  154. color:#333;
  155. margin-bottom: 15px;
  156. cursor: pointer;
  157. font-size: 14px;
  158. /* min-height: 110px; */
  159. }
  160. .folder-item p{
  161. line-height: 25px;
  162. width: calc(100% - 20px);
  163. padding: 0 10px;
  164. /* margin-top:10px; */
  165. word-break: break-all;
  166. text-overflow: ellipsis;
  167. display: -webkit-box;
  168. -webkit-box-orient: vertical;
  169. -webkit-line-clamp: 1; /* 这里是超出几行省略 */
  170. overflow: hidden;
  171. }
  172. .folder-item input{
  173. width: calc(100% - 8px);
  174. padding: 2px;
  175. margin-top:10px;
  176. }
  177. .img-panel {
  178. width: 64px;
  179. /* height: 64px; */
  180. margin:0 auto;
  181. text-align: center;
  182. }
  183. .img-panel > img{
  184. width: 80%;
  185. }
  186. .folder-checkbox{
  187. display: none;
  188. position: absolute;
  189. top:5px;
  190. left: 5px;
  191. }
  192. .checked{
  193. background: #f1f2f3;
  194. border-radius: 3px;
  195. }
  196. .checked .folder-checkbox {
  197. display: block;
  198. }
  199. .folder-item:hover .folder-checkbox {
  200. display: block;
  201. }
  202. .folder-item:hover {
  203. background: #f1f2f3;
  204. border-radius: 3px;
  205. }
  206. </style>
  207. <style scoped>
  208. .border-bottom{
  209. border-bottom: 1px solid #f1f2f3;
  210. }
  211. </style>