Commit 26c04f5d authored by daniel's avatar daniel

feat(bag): 分页数据请求的特殊处理,默认page是从0开始的

parent f9cf905e
......@@ -10,6 +10,7 @@ import com.dlbridge.jadp.plugins.partner.bean.BagDelivery;
import com.dlbridge.jadp.plugins.partner.bean.BagParam;
import com.dlbridge.jadp.plugins.partner.service.BagDeliveryService;
import com.neusoft.www.utils.web.Result;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......@@ -46,7 +47,11 @@ public class BagDeliveryController {
@ResponseBody
@RequestMapping(value = "/delivery/list")
public Page<List<BagDelivery>> queryBagDeliveryByPage(@ApiIgnore Pageable page, BagParam param) {
Page<List<BagDelivery>> result = bagDeliveryService.queryBagDeliveryByPage(page, param);
// 获取前端传来的页码,减 1 后得到实际需要的页码
int zeroBasedPage = Math.max(0, page.getPageNumber() - 1);
// 构建新的 Pageable 对象
Pageable adjustedPage = PageRequest.of(zeroBasedPage, page.getPageSize(), page.getSort());
Page<List<BagDelivery>> result = bagDeliveryService.queryBagDeliveryByPage(adjustedPage, param);
result.setCode(200);
return result;
}
......
......@@ -9,6 +9,7 @@ import com.dlbridge.jadp.plugins.partner.bean.BagParam;
import com.dlbridge.jadp.plugins.partner.bean.InvoiceParam;
import com.dlbridge.jadp.plugins.partner.service.InvoiceService;
import com.neusoft.www.utils.web.Result;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
......@@ -46,7 +47,11 @@ public class InvoiceController {
@ResponseBody
@RequestMapping(value = "/list")
public Page<List<Invoice>> queryInvoiceByPage(@ApiIgnore Pageable page, InvoiceParam param) {
Page<List<Invoice>> result = invoiceService.queryInvoiceByPage(page, param);
// 获取前端传来的页码,减 1 后得到实际需要的页码
int zeroBasedPage = Math.max(0, page.getPageNumber() - 1);
// 构建新的 Pageable 对象
Pageable adjustedPage = PageRequest.of(zeroBasedPage, page.getPageSize(), page.getSort());
Page<List<Invoice>> result = invoiceService.queryInvoiceByPage(adjustedPage, param);
result.setCode(200);
return result;
}
......
......@@ -52,6 +52,12 @@
color: white;
}
.right {
height: auto !important;
width: 80%;
margin: 0px 0px 0px 40px;
}
.action {
display: flex;
flex-direction: row;
......@@ -151,6 +157,8 @@
background: rgba(255, 255, 255, 1);
border-radius: 4px;
flex-direction: column;
margin-bottom: 10px !important;
margin-top: 0px !important;
}
.tip {
......@@ -256,7 +264,7 @@
<jsp:include page="../common/header.jsp"></jsp:include>
<div class="page-content d-flex align-items-stretch main-body">
<jsp:include page="../common/menu.jsp"></jsp:include>
<div class="rght" id="module">
<div class="right" id="module">
<div class="section">
<div class="flex flex-row items-center justify-between">
<h3 class="title">赛包邮寄</h3>
......@@ -284,7 +292,7 @@
</div>
</div>
<div style="margin-top: -10px;margin-bottom: 50px">
<div style="margin-bottom: 50px">
<table style="width: 100%" class="rule-field">
<colgroup>
<col style="width:25%;">
......@@ -360,6 +368,31 @@
</tr>
</tbody>
</table>
<nav class="mt-2" v-if="list.length>pageSize" aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" v-if="page!==1" @click="preview"><a class="page-link"
href="#">Previous</a></li>
<li @click="changePage(item+1)" v-for="item,index in totalPage"
:key="item+'page'" class="page-item" :class="{active:(index+1)==page}">
<a class="page-link" href="#">{{item}}</a>
</li>
<li class="page-item" v-if="list.length===pageSize" @click="next"><a
class="page-link" href="#">Next</a></li>
<div class="ml-2 flex flex-row items-center gap-x-2">
<span>每页条数</span>
<select v-model="pageSize" @change="refresh" style="width: 50px;">
<option :value="10">10</option>
<option :value="20">20</option>
<option :value="50">50</option>
<option :value="100">100</option>
<option :value="500">500</option>
</select>
<span>共{{total}}条数据</span>
</div>
</ul>
</nav>
</div>
......@@ -474,6 +507,10 @@
title: '赛包邮寄',
statusIndex: 0,
keyword: '',
page: 1,
pageSize: 10,
totalPage: 1,
total: 0,
statusOptions: [
{
name: "全部",
......@@ -514,8 +551,14 @@
}
},
methods: {
// 页面刷新
refresh() {
this.page = 1;
this.fetchData()
},
changeStatus(index) {
this.statusIndex = index;
this.page = 1;
this.fetchData()
},
changePage(page) {
......@@ -603,7 +646,14 @@
// 查询所有
fetchData() {
if (!getCId()) return
const url = '/gk/bag/delivery/list?status=' + this.statusOptions[this.statusIndex].value + '&cmptId=' + getCId() + '&keyword=' + this.keyword
let params = {
status: this.statusOptions[this.statusIndex].value,
page: this.page,
size: this.pageSize,
keyword: this.keyword,
cmptId: getCId()
}
const url = '/gk/bag/delivery/list?' + new URLSearchParams(params).toString()
$.ajax({
type: 'GET',
contentType: 'application/json',
......@@ -614,8 +664,14 @@
complete: () => {
layer.closeAll()
},
success: (data) => {
this.list = data.content
success: (res) => {
this.list = res.content
if (res.content.length === this.pageSize) {
this.totalPage = this.page + 1
} else {
this.totalPage = this.page
}
this.total = res.total
}
})
},
......
......@@ -52,6 +52,12 @@
color: white;
}
.right {
height: auto !important;
width: 80%;
margin: 0px 0px 0px 40px;
}
.action {
display: flex;
flex-direction: row;
......@@ -222,6 +228,8 @@
width: 100% !important;
display: flex;
flex-direction: column;
margin-bottom: 10px !important;
margin-top: 0px !important;
}
......@@ -256,7 +264,7 @@
<jsp:include page="../common/header.jsp"></jsp:include>
<div class="page-content d-flex align-items-stretch main-body">
<jsp:include page="../common/menu.jsp"></jsp:include>
<div class="rght" id="module">
<div class="right" id="module">
<div class="section">
<div class="flex flex-row items-center justify-between">
<h3 class="title">发票管理</h3>
......@@ -300,7 +308,7 @@
</div>
</div>
<div style="margin-top: -10px;margin-bottom: 50px">
<div style="margin-bottom: 50px">
<table style="width: 100%" class="rule-field">
<colgroup>
<col style="width:25%;">
......@@ -397,6 +405,31 @@
</tr>
</tbody>
</table>
<nav class="mt-2" v-if="list.length>pageSize" aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" v-if="page!==1" @click="preview"><a class="page-link"
href="#">Previous</a></li>
<li @click="changePage(item+1)" v-for="item,index in totalPage"
:key="item+'page'" class="page-item" :class="{active:(index+1)==page}">
<a class="page-link" href="#">{{item}}</a>
</li>
<li class="page-item" v-if="list.length===pageSize" @click="next"><a
class="page-link" href="#">Next</a></li>
<div class="ml-2 flex flex-row items-center gap-x-2">
<span>每页条数</span>
<select v-model="pageSize" @change="refresh" style="width: 50px;">
<option :value="10">10</option>
<option :value="20">20</option>
<option :value="50">50</option>
<option :value="100">100</option>
<option :value="500">500</option>
</select>
<span>共{{total}}条数据</span>
</div>
</ul>
</nav>
</div>
......@@ -561,6 +594,10 @@
list: [],
dialog: false,
title: '发票管理',
page: 1,
pageSize: 10,
totalPage: 1,
total: 0,
// 发票方式
invoiceTypeIndex: 0,
invoiceTypes: [
......@@ -646,17 +683,25 @@
},
methods: {
changeStatus(index) {
this.page = 1
this.statusIndex = index;
this.fetchData()
},
changeInvoice(index) {
this.page = 1
this.invoiceTypeIndex = index;
this.fetchData()
},
changePaper(index) {
this.page = 1
this.paperTypeIndex = index;
this.fetchData()
},
// 页面刷新
refresh() {
this.page = 1;
this.fetchData()
},
changePage(page) {
this.page = page
this.fetchData()
......@@ -742,7 +787,15 @@
// 查询所有
fetchData() {
if (!getCId()) return
const url = '/gk/invoice/list?status=' + this.statusOptions[this.statusIndex].value + '&cmptId=' + getCId() + '&invoiceType=' + this.invoiceTypes[this.invoiceTypeIndex].value + '&paperInvoice=' + this.paperTypes[this.paperTypeIndex].value
let params = {
status: this.statusOptions[this.statusIndex].value,
page: this.page - 1,
size: this.pageSize,
invoiceType: this.invoiceTypes[this.invoiceTypeIndex].value,
paperInvoice: this.paperTypes[this.paperTypeIndex].value,
cmptId: getCId()
}
const url = '/gk/invoice/list?' + new URLSearchParams(params).toString()
$.ajax({
type: 'GET',
contentType: 'application/json',
......@@ -753,8 +806,14 @@
complete: () => {
layer.closeAll()
},
success: (data) => {
this.list = data.content
success: (res) => {
this.list = res.content
if (res.content.length === this.pageSize) {
this.totalPage = this.page + 1
} else {
this.totalPage = this.page
}
this.total = res.total
}
})
},
......
......@@ -371,7 +371,7 @@
</tr>
</tbody>
</table>
<nav class="mt-2" aria-label="Page navigation">
<nav class="mt-2" v-if="list.length>pageSize" aria-label="Page navigation">
<ul class="pagination">
<li class="page-item" v-if="page!==1" @click="preview"><a class="page-link"
href="#">Previous</a></li>
......@@ -624,10 +624,11 @@
fetchData() {
if (!getCId()) return
const url = eccUrl + (this.isEnroll ? '/api-pick/v1/enroll-page' : '/api-pick/v1/mark-list')
let isPickUp = this.statusOptions[this.statusIndex].value
let params = {
cmptId: gtCmptId,
keyword: this.keyword,
isPickUp: this.statusOptions[this.statusIndex].value,
keyword: this.keyword ?? undefined,
isPickUp: isPickUp === '' ? undefined : isPickUp,
current: this.page,
size: this.pageSize
}
......@@ -671,7 +672,7 @@
'Content-Type': 'application/json'
},
body: JSON.stringify({
cmptId: 27262,
cmptId: gtCmptId,
isPickUp: v,
current: this.page,
size: this.pageSize
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment