解决分页排序问题
parent
6be4f0f9a5
commit
3a7b41876a
|
@ -70,10 +70,13 @@ const tableData = ref([])
|
|||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
const sortBy = ref(null)
|
||||
const asc = ref(null)
|
||||
const redirect = () => {
|
||||
router.push({path: '/project/closed', query: {currentPage: currentPage.value, pageSize: pageSize.value}})
|
||||
router.push({path: '/project/closed', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}})
|
||||
}
|
||||
const getClosedProjects = () => {
|
||||
proxy.dialogFormVisible = false
|
||||
const that = this;
|
||||
request({
|
||||
url: 'project',
|
||||
|
@ -81,8 +84,8 @@ const getClosedProjects = () => {
|
|||
params: {
|
||||
pageCurrent: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
sortBy: 'projectClosedDate',
|
||||
asc: false,
|
||||
sortBy: asc.value ? sortBy.value : 'projectClosedDate',
|
||||
asc: asc.value === 'ascending',
|
||||
paramMap: {
|
||||
completed: true
|
||||
}
|
||||
|
@ -97,30 +100,11 @@ const getClosedProjects = () => {
|
|||
console.log(error)
|
||||
})
|
||||
}
|
||||
|
||||
const onSortChange = (val) => {
|
||||
console.log(val)
|
||||
const that = this;
|
||||
request({
|
||||
url: 'project',
|
||||
method: 'get',
|
||||
params: {
|
||||
pageCurrent: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
sortBy: val.order ? val.prop : 'projectClosedDate',
|
||||
asc: val.order === 'ascending',
|
||||
paramMap: {
|
||||
completed: true
|
||||
}
|
||||
}
|
||||
}).then(response => {
|
||||
if (response.data.code === 200) {
|
||||
//console.log(response.data.data.records)
|
||||
total.value = response.data.data.total
|
||||
tableData.value = response.data.data.records
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
sortBy.value = val.prop
|
||||
asc.value = val.order
|
||||
redirect()
|
||||
}
|
||||
|
||||
// 选择一页显示多少条数据
|
||||
|
|
|
@ -85,8 +85,10 @@ const tableData = ref([])
|
|||
const currentPage = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
const sortBy = ref(null)
|
||||
const asc = ref(null)
|
||||
const redirect = () => {
|
||||
router.push({path: '/', query: {currentPage: currentPage.value, pageSize: pageSize.value}})
|
||||
router.push({path: '/', query: {currentPage: currentPage.value, pageSize: pageSize.value, sortBy: sortBy.value, asc: asc.value}})
|
||||
}
|
||||
const getProjects = () => {
|
||||
proxy.dialogFormVisible = false
|
||||
|
@ -97,8 +99,8 @@ const getProjects = () => {
|
|||
params: {
|
||||
pageCurrent: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
sortBy: 'projectCreatedTime',
|
||||
asc: false,
|
||||
sortBy: asc.value ? sortBy.value : 'projectCreatedTime',
|
||||
asc: asc.value === 'ascending',
|
||||
paramMap: {
|
||||
completed: false
|
||||
}
|
||||
|
@ -115,29 +117,9 @@ const getProjects = () => {
|
|||
}
|
||||
|
||||
const onSortChange = (val) => {
|
||||
console.log(val)
|
||||
const that = this;
|
||||
request({
|
||||
url: 'project',
|
||||
method: 'get',
|
||||
params: {
|
||||
pageCurrent: currentPage.value,
|
||||
pageSize: pageSize.value,
|
||||
sortBy: val.order ? val.prop : 'projectCreatedTime',
|
||||
asc: val.order === 'ascending',
|
||||
paramMap: {
|
||||
completed: false
|
||||
}
|
||||
}
|
||||
}).then(response => {
|
||||
if (response.data.code === 200) {
|
||||
//console.log(response.data.data.records)
|
||||
total.value = response.data.data.total
|
||||
tableData.value = response.data.data.records
|
||||
}
|
||||
}).catch(function (error) {
|
||||
console.log(error)
|
||||
})
|
||||
sortBy.value = val.prop
|
||||
asc.value = val.order
|
||||
redirect()
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue