workspace page limit

This commit is contained in:
Captain.B 2020-02-18 13:49:06 +08:00
parent d347a6dbe8
commit 16a152e5ea
3 changed files with 50 additions and 10 deletions

View File

@ -1,6 +1,10 @@
package io.metersphere.controller; package io.metersphere.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.metersphere.base.domain.Workspace; import io.metersphere.base.domain.Workspace;
import io.metersphere.commons.utils.PageUtils;
import io.metersphere.commons.utils.Pager;
import io.metersphere.service.WorkspaceService; import io.metersphere.service.WorkspaceService;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,8 +27,9 @@ public class WorkspaceController {
workspaceService.deleteWorkspace(workspaceId); workspaceService.deleteWorkspace(workspaceId);
} }
@PostMapping("list") @PostMapping("list/{goPage}/{pageSize}")
public List<Workspace> getWorkspaceList() { public Pager<List<Workspace>> getWorkspaceList(@PathVariable int goPage, @PathVariable int pageSize) {
return workspaceService.getWorkspaceList(); Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
return PageUtils.setPageInfo(page, workspaceService.getWorkspaceList());
} }
} }

View File

@ -4,7 +4,10 @@
<el-card> <el-card>
<div slot="header"> <div slot="header">
<el-row type="flex" justify="space-between" align="middle"> <el-row type="flex" justify="space-between" align="middle">
<span class="title">项目</span> <span class="title">
项目
<ms-create-box :tips="btnTips" :exec="create"/>
</span>
<span class="search"> <span class="search">
<el-input type="text" size="small" placeholder="根据名称搜索" prefix-icon="el-icon-search" <el-input type="text" size="small" placeholder="根据名称搜索" prefix-icon="el-icon-search"
maxlength="60" v-model="condition" clearable/> maxlength="60" v-model="condition" clearable/>
@ -22,7 +25,6 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</el-card> </el-card>
<ms-create-box :tips="btnTips" :exec="create"/>
<el-dialog title="创建项目" :visible.sync="createVisible"> <el-dialog title="创建项目" :visible.sync="createVisible">
<el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small"> <el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small">

View File

@ -3,7 +3,10 @@
<el-card> <el-card>
<div slot="header"> <div slot="header">
<el-row type="flex" justify="space-between" align="middle"> <el-row type="flex" justify="space-between" align="middle">
<span class="title">工作空间</span> <span class="title">
工作空间
<ms-create-box :tips="btnTips" :exec="create"/>
</span>
<span class="search"> <span class="search">
<el-input type="text" size="small" placeholder="根据名称搜索" prefix-icon="el-icon-search" <el-input type="text" size="small" placeholder="根据名称搜索" prefix-icon="el-icon-search"
maxlength="60" v-model="condition" clearable/> maxlength="60" v-model="condition" clearable/>
@ -20,8 +23,25 @@
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div>
<el-row>
<el-col :span="22" :offset="1">
<div class="table-page">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="currentPage"
:page-sizes="[5, 10, 20, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</el-col>
</el-row>
</div>
</el-card> </el-card>
<ms-create-box :tips="btnTips" :exec="create"/>
<el-dialog title="创建工作空间" :visible.sync="createVisible" width="30%"> <el-dialog title="创建工作空间" :visible.sync="createVisible" width="30%">
<el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small"> <el-form :model="form" :rules="rules" ref="form" label-position="left" label-width="100px" size="small">
<el-form-item label="名称" prop="name"> <el-form-item label="名称" prop="name">
@ -96,10 +116,20 @@
}); });
}, },
list() { list() {
this.$post('/workspace/list', {}, response => { let url = '/workspace/list/' + this.currentPage + '/' + this.pageSize;
this.items = response.data; this.$post(url, {}, response => {
let data = response.data;
this.items = data.listObject;
this.total = data.itemCount;
}) })
} },
handleSizeChange(size) {
this.pageSize = size;
},
handleCurrentChange(current) {
this.currentPage = current;
},
}, },
data() { data() {
return { return {
@ -108,6 +138,9 @@
btnTips: "添加工作空间", btnTips: "添加工作空间",
condition: "", condition: "",
items: [], items: [],
currentPage: 1,
pageSize: 5,
total: 0,
form: { form: {
// name: "", // name: "",
// description: "" // description: ""