Browse Source

optimize page AllTransactions

pull/290/head
yedf2 4 years ago
parent
commit
e9c64c879b
  1. 29
      admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue

29
admin/src/views/Dashboard/GlobalTransactions/AllTransactions.vue

@ -53,15 +53,11 @@ const columns = [
} }
] ]
const pager = ref([""]) const pages = ref([''])
const currentState = ref(1) const curPage = ref(1)
const canPrev = computed(() => { const canPrev = computed(() => {
if (currentState.value === 1) { return curPage.value > 1
return false;
}
return true;
}) })
const canNext = computed(() => { const canNext = computed(() => {
@ -83,10 +79,11 @@ const queryData = (params: IListAllTransactions) => {
return listAllTransactions<Data>(params) return listAllTransactions<Data>(params)
} }
const { data, run, current, loading, pageSize } = usePagination(queryData, { const { data, run, current, loading, pageSize } = usePagination(queryData, {
defaultParams: [ defaultParams: [
{ {
limit: 100, limit: 10,
} }
], ],
pagination: { pagination: {
@ -97,25 +94,21 @@ const { data, run, current, loading, pageSize } = usePagination(queryData, {
const dataSource = computed(() => data.value?.data.transactions || []) const dataSource = computed(() => data.value?.data.transactions || [])
const handlePrevPage = () => { const handlePrevPage = () => {
currentState.value -= 1; curPage.value -= 1;
const params = { const params = {
limit: 100 limit: pageSize.value,
} position: pages.value[curPage.value]
if (pager.value[currentState.value - 1]) {
params.position = pager.value[currentState.value - 1]
} }
run(params) run(params)
} }
const handleNextPage = () => { const handleNextPage = () => {
currentState.value += 1; curPage.value += 1;
if (currentState.value >= 2) { pages.value[curPage.value] = data.value?.data.next_position
pager.value[currentState.value - 1] = data.value?.data.next_position
}
run({ run({
position: data.value?.data.next_position, position: data.value?.data.next_position,
limit: 5 limit: pageSize.value,
}) })
} }
</script> </script>

Loading…
Cancel
Save