将换页逻辑改为改变页面url
parent
457a3e310c
commit
c644e022fb
|
@ -60,6 +60,7 @@ onMounted(() => {
|
||||||
<script>
|
<script>
|
||||||
import request from "../utils/request";
|
import request from "../utils/request";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import router from "../router";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ClosedProject",
|
name: "ClosedProject",
|
||||||
|
@ -73,17 +74,35 @@ export default {
|
||||||
tableData: []
|
tableData: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
created() {
|
||||||
this.getClosedProjects();
|
// watch 路由的参数,以便再次获取数据
|
||||||
|
this.$watch(
|
||||||
|
() => this.$route.query,
|
||||||
|
() => {
|
||||||
|
if(this.$route.query.currentPage)
|
||||||
|
this.currentPage = parseInt(this.$route.query.currentPage)
|
||||||
|
if(this.$route.query.pageSize)
|
||||||
|
this.pageSize = parseInt(this.$route.query.pageSize)
|
||||||
|
|
||||||
|
this.getClosedProjects()
|
||||||
|
},
|
||||||
|
// 组件创建完后获取数据,
|
||||||
|
// 此时 data 已经被 observed 了
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
// 选择一页显示多少条数据
|
// 选择一页显示多少条数据
|
||||||
handleSizeChange(val) {
|
handleSizeChange(val) {
|
||||||
this.getClosedProjects()
|
this.redirect()
|
||||||
},
|
},
|
||||||
// 选择当前的是第几页
|
// 选择当前的是第几页
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
this.getClosedProjects()
|
this.redirect()
|
||||||
|
},
|
||||||
|
redirect() {
|
||||||
|
router.push({path: '/ClosedProject', query: { currentPage: this.currentPage, pageSize: this.pageSize }})
|
||||||
},
|
},
|
||||||
getClosedProjects() {
|
getClosedProjects() {
|
||||||
const that = this;
|
const that = this;
|
||||||
|
@ -93,7 +112,9 @@ export default {
|
||||||
params: {
|
params: {
|
||||||
pageCurrent: this.currentPage,
|
pageCurrent: this.currentPage,
|
||||||
pageSize: this.pageSize,
|
pageSize: this.pageSize,
|
||||||
completed: true
|
paramMap: {
|
||||||
|
completed: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if(response.data.code===200) {
|
if(response.data.code===200) {
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column min-width="10%" align="right">
|
<el-table-column min-width="10%" align="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button :v-show="staffId===scope.row.projectCreator" type="primary" plain @click="onCloseProject(scope.row)">结项</el-button>
|
<el-button :v-show=" this.$store.state.staff.staffId===scope.row.projectCreator" type="primary" plain @click="onCloseProject(scope.row)">结项</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -71,6 +71,7 @@ export default {
|
||||||
name: "OngoingProject",
|
name: "OngoingProject",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
||||||
total: 0,
|
total: 0,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
|
@ -81,22 +82,34 @@ export default {
|
||||||
staffId: Number
|
staffId: Number
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created() {
|
||||||
|
// watch 路由的参数,以便再次获取数据
|
||||||
|
this.$watch(
|
||||||
|
() => this.$route.query,
|
||||||
|
() => {
|
||||||
|
if(this.$route.query.currentPage)
|
||||||
|
this.currentPage = parseInt(this.$route.query.currentPage)
|
||||||
|
if(this.$route.query.pageSize)
|
||||||
|
this.pageSize = parseInt(this.$route.query.pageSize)
|
||||||
|
|
||||||
|
this.getProjects()
|
||||||
|
},
|
||||||
|
// 组件创建完后获取数据,
|
||||||
|
// 此时 data 已经被 observed 了
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.staffId = localStorage.getItem('staffId');
|
|
||||||
this.getProjects();
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
// 选择一页显示多少条数据
|
// 选择一页显示多少条数据
|
||||||
handleSizeChange(val) {
|
handleSizeChange(val) {
|
||||||
console.log('handleSizeChange:'+val)
|
this.redirect()
|
||||||
this.getProjects();
|
|
||||||
},
|
},
|
||||||
// 选择当前的是第几页
|
// 选择当前的是第几页
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
this.getProjects();
|
this.redirect()
|
||||||
},
|
},
|
||||||
onCloseProject(row) {
|
onCloseProject(row) {
|
||||||
request({
|
request({
|
||||||
|
@ -118,6 +131,9 @@ export default {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
redirect() {
|
||||||
|
router.push({path: '/', query: { currentPage: this.currentPage, pageSize: this.pageSize }})
|
||||||
|
},
|
||||||
getProjects() {
|
getProjects() {
|
||||||
const that = this;
|
const that = this;
|
||||||
request({
|
request({
|
||||||
|
@ -125,7 +141,10 @@ export default {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {
|
params: {
|
||||||
pageCurrent: this.currentPage,
|
pageCurrent: this.currentPage,
|
||||||
pageSize: this.pageSize
|
pageSize: this.pageSize,
|
||||||
|
paramMap: {
|
||||||
|
completed: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
if(response.data.code===200) {
|
if(response.data.code===200) {
|
||||||
|
|
Loading…
Reference in New Issue