将换页逻辑改为改变页面url

main
wuyize 2022-07-01 14:24:37 +08:00
parent 457a3e310c
commit c644e022fb
2 changed files with 54 additions and 14 deletions

View File

@ -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) {

View File

@ -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) {