DiskAlbumIndex.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <el-row style="padding: 5px">
  4. <el-button
  5. style="float: left; padding: 5px"
  6. icon="el-icon-plus"
  7. type="text"
  8. @click="onCreateAlbum"
  9. >创建相册</el-button>
  10. </el-row>
  11. <el-row style="padding: 5px">
  12. <el-col
  13. v-for="(album, index) in dataList"
  14. :key="index"
  15. :md="6"
  16. :sm="12"
  17. :xs="12"
  18. style="padding: 5px"
  19. >
  20. <el-card :body-style="{ padding: '1px' }">
  21. <router-link style="text-decoration-line: none" target="_blank" :to="`/disk/album/${album.albumId}`">
  22. <div>
  23. <el-image
  24. lazy
  25. fit="cover"
  26. :src="album.coverUrl"
  27. class="coverImg"
  28. />
  29. </div>
  30. </router-link>
  31. <div style="padding: 14px">
  32. <el-row style="padding: 1px">
  33. <span style="color: black">
  34. {{ album.albumName }}
  35. </span>
  36. <span style="color: black">
  37. <i class="el-icon-picture-outline">{{ album.num }}</i>
  38. </span>
  39. </el-row>
  40. <el-row style="padding: 1px">
  41. <el-button style="float: right; padding: 5px;" icon="el-icon-share" type="text" @click="onShareAlbum">分享</el-button>
  42. <router-link style="text-decoration-line: none" target="_blank" :to="`/disk/album/${album.albumId}`">
  43. <el-button style="float: right; padding: 5px" icon="el-icon-view" type="text" @click="true">查看</el-button>
  44. </router-link>
  45. <router-link style="text-decoration-line: none" target="_blank" :to="`/disk/album/edit/${album.albumId}`">
  46. <el-button style="float: right; padding: 5px" icon="el-icon-edit" type="text" @click="true">管理</el-button>
  47. </router-link>
  48. </el-row>
  49. </div>
  50. </el-card>
  51. </el-col>
  52. </el-row>
  53. <el-row>
  54. <el-pagination
  55. :small="screenWidth <= 768"
  56. hide-on-single-page
  57. layout="prev, pager, next"
  58. :page-size="pageSize"
  59. :current-page="currentPage"
  60. :total="totalSize"
  61. @current-change="handleCurrentChange"
  62. @prev-click="handleCurrentChange"
  63. @next-click="handleCurrentChange"
  64. />
  65. </el-row>
  66. <el-dialog
  67. :visible.sync="showCreateAlbumDialog"
  68. center
  69. >
  70. <div>
  71. <el-form ref="createAlbumForm" :model="createAlbumForm">
  72. <el-form-item label="相册名" label-width="120px" prop="title">
  73. <el-input
  74. v-model="createAlbumForm.albumName"
  75. style="margin-left: 5px"
  76. clearable
  77. />
  78. </el-form-item>
  79. <el-button
  80. type="primary"
  81. plain
  82. size="small"
  83. icon="el-icon-plus"
  84. style="margin-left: 10px"
  85. @click="createAlbum"
  86. >
  87. 创建相册
  88. </el-button>
  89. </el-form>
  90. </div>
  91. </el-dialog>
  92. </div>
  93. </template>
  94. <script>
  95. import { createAlbum, getAlbumList } from '@/api/disk'
  96. export default {
  97. name: 'DiskAlbumIndex',
  98. data() {
  99. return {
  100. // 屏幕宽度, 为了控制分页条的大小
  101. screenWidth: document.body.clientWidth,
  102. currentPage: 1,
  103. pageSize: 12,
  104. totalSize: 0,
  105. dataList: [],
  106. // ****************************************************************************************************************
  107. showCreateAlbumDialog: false,
  108. createAlbumForm: {
  109. albumName: null,
  110. fileType: 1001
  111. }
  112. }
  113. },
  114. mounted() {
  115. // 当窗口宽度改变时获取屏幕宽度
  116. window.onresize = () => {
  117. return () => {
  118. window.screenWidth = document.body.clientWidth
  119. this.screenWidth = window.screenWidth
  120. }
  121. }
  122. },
  123. created() {
  124. document.title = '相册'
  125. this.getData()
  126. },
  127. methods: {
  128. handleCurrentChange(pageNumber) {
  129. this.currentPage = pageNumber
  130. this.dataList = []
  131. this.getData()
  132. // 回到顶部
  133. scrollTo(0, 0)
  134. },
  135. getData() {
  136. getAlbumList(this.currentPage).then(resp => {
  137. if (resp.code === 0) {
  138. this.dataList = resp.data
  139. }
  140. })
  141. },
  142. onCreateAlbum() {
  143. this.showCreateAlbumDialog = true
  144. },
  145. createAlbum() {
  146. this.showCreateAlbumDialog = false
  147. createAlbum(this.createAlbumForm).then(resp => {
  148. this.$message.info(resp.msg)
  149. })
  150. },
  151. onShareAlbum() {
  152. this.$message.info('share album')
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. /*处于手机屏幕时*/
  159. @media screen and (max-width: 768px){
  160. .coverImg {
  161. height: 120px !important;
  162. }
  163. }
  164. .coverImg {
  165. width: 100%;
  166. height: 180px;
  167. display: block;
  168. }
  169. </style>