david 2 лет назад
Родитель
Сommit
c467882a13
1 измененных файлов с 12 добавлено и 2 удалено
  1. 12 2
      src/views/ad/list.vue

+ 12 - 2
src/views/ad/list.vue

@@ -113,7 +113,7 @@
           </el-dropdown-menu>
         </el-dropdown>
         <el-button v-if="permission.hasPermission(`ad/ad-add`)" type="primary" size="small" icon="el-icon-plus" @click="handleAdd">{{ $t('ad.add') }}</el-button>
-        <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
+        <pagination v-show="total>0" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" :page.sync="listQuery.page" :limit.sync="listQuery.pageSize" @pagination="getList" />
       </div>
 
       </el-table></div>
@@ -167,6 +167,7 @@ export default {
       tool: tool,
       permission: permission,
       multipleSelection: null,
+      pageSize: 20,
       listQuery: {
         page: 1,
         pageSize: 20,
@@ -218,15 +219,24 @@ export default {
     handleSelectionChange(val) {
       this.multipleSelection = val
     },
-    getList() {
+    handleSizeChange (pageSize) {
+      this.getList(this.currentPage, pageSize)
+    },
+    handleCurrentChange (page) {
+      this.getList(page, this.pageSize)
+    },
+    getList(page, pageSize) {
       this.listLoading = true
       this.listQuery.adId = this.$route.params
+      this.listQuery.page = (page === null || page == undefined) ? 1 : page
+      this.listQuery.pageSize = (pageSize === null || pageSize == undefined) ? this.pageSize : pageSize
       fetchAdList(this.listQuery).then(response => {
         this.list = response.data.list
         this.total = response.data.totalCount
         this.allArticle = response.data.allArticle
         const ad_id = this.listQuery.adId.ID
         this.allLocation = response.data.allLocation[ad_id]
+        this.pageSize = pageSize
         // Just to simulate the time of the request
         setTimeout(() => {
           this.listLoading = false