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; ...@@ -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.bean.BagParam;
import com.dlbridge.jadp.plugins.partner.service.BagDeliveryService; import com.dlbridge.jadp.plugins.partner.service.BagDeliveryService;
import com.neusoft.www.utils.web.Result; import com.neusoft.www.utils.web.Result;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -46,7 +47,11 @@ public class BagDeliveryController { ...@@ -46,7 +47,11 @@ public class BagDeliveryController {
@ResponseBody @ResponseBody
@RequestMapping(value = "/delivery/list") @RequestMapping(value = "/delivery/list")
public Page<List<BagDelivery>> queryBagDeliveryByPage(@ApiIgnore Pageable page, BagParam param) { 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); result.setCode(200);
return result; return result;
} }
......
...@@ -9,6 +9,7 @@ import com.dlbridge.jadp.plugins.partner.bean.BagParam; ...@@ -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.bean.InvoiceParam;
import com.dlbridge.jadp.plugins.partner.service.InvoiceService; import com.dlbridge.jadp.plugins.partner.service.InvoiceService;
import com.neusoft.www.utils.web.Result; import com.neusoft.www.utils.web.Result;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -46,7 +47,11 @@ public class InvoiceController { ...@@ -46,7 +47,11 @@ public class InvoiceController {
@ResponseBody @ResponseBody
@RequestMapping(value = "/list") @RequestMapping(value = "/list")
public Page<List<Invoice>> queryInvoiceByPage(@ApiIgnore Pageable page, InvoiceParam param) { 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); result.setCode(200);
return result; return result;
} }
......
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
color: white; color: white;
} }
.right {
height: auto !important;
width: 80%;
margin: 0px 0px 0px 40px;
}
.action { .action {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -151,6 +157,8 @@ ...@@ -151,6 +157,8 @@
background: rgba(255, 255, 255, 1); background: rgba(255, 255, 255, 1);
border-radius: 4px; border-radius: 4px;
flex-direction: column; flex-direction: column;
margin-bottom: 10px !important;
margin-top: 0px !important;
} }
.tip { .tip {
...@@ -256,7 +264,7 @@ ...@@ -256,7 +264,7 @@
<jsp:include page="../common/header.jsp"></jsp:include> <jsp:include page="../common/header.jsp"></jsp:include>
<div class="page-content d-flex align-items-stretch main-body"> <div class="page-content d-flex align-items-stretch main-body">
<jsp:include page="../common/menu.jsp"></jsp:include> <jsp:include page="../common/menu.jsp"></jsp:include>
<div class="rght" id="module"> <div class="right" id="module">
<div class="section"> <div class="section">
<div class="flex flex-row items-center justify-between"> <div class="flex flex-row items-center justify-between">
<h3 class="title">赛包邮寄</h3> <h3 class="title">赛包邮寄</h3>
...@@ -284,7 +292,7 @@ ...@@ -284,7 +292,7 @@
</div> </div>
</div> </div>
<div style="margin-top: -10px;margin-bottom: 50px"> <div style="margin-bottom: 50px">
<table style="width: 100%" class="rule-field"> <table style="width: 100%" class="rule-field">
<colgroup> <colgroup>
<col style="width:25%;"> <col style="width:25%;">
...@@ -360,6 +368,31 @@ ...@@ -360,6 +368,31 @@
</tr> </tr>
</tbody> </tbody>
</table> </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> </div>
...@@ -474,6 +507,10 @@ ...@@ -474,6 +507,10 @@
title: '赛包邮寄', title: '赛包邮寄',
statusIndex: 0, statusIndex: 0,
keyword: '', keyword: '',
page: 1,
pageSize: 10,
totalPage: 1,
total: 0,
statusOptions: [ statusOptions: [
{ {
name: "全部", name: "全部",
...@@ -514,8 +551,14 @@ ...@@ -514,8 +551,14 @@
} }
}, },
methods: { methods: {
// 页面刷新
refresh() {
this.page = 1;
this.fetchData()
},
changeStatus(index) { changeStatus(index) {
this.statusIndex = index; this.statusIndex = index;
this.page = 1;
this.fetchData() this.fetchData()
}, },
changePage(page) { changePage(page) {
...@@ -603,7 +646,14 @@ ...@@ -603,7 +646,14 @@
// 查询所有 // 查询所有
fetchData() { fetchData() {
if (!getCId()) return 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({ $.ajax({
type: 'GET', type: 'GET',
contentType: 'application/json', contentType: 'application/json',
...@@ -614,8 +664,14 @@ ...@@ -614,8 +664,14 @@
complete: () => { complete: () => {
layer.closeAll() layer.closeAll()
}, },
success: (data) => { success: (res) => {
this.list = data.content 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 @@ ...@@ -52,6 +52,12 @@
color: white; color: white;
} }
.right {
height: auto !important;
width: 80%;
margin: 0px 0px 0px 40px;
}
.action { .action {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
...@@ -222,6 +228,8 @@ ...@@ -222,6 +228,8 @@
width: 100% !important; width: 100% !important;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin-bottom: 10px !important;
margin-top: 0px !important;
} }
...@@ -256,7 +264,7 @@ ...@@ -256,7 +264,7 @@
<jsp:include page="../common/header.jsp"></jsp:include> <jsp:include page="../common/header.jsp"></jsp:include>
<div class="page-content d-flex align-items-stretch main-body"> <div class="page-content d-flex align-items-stretch main-body">
<jsp:include page="../common/menu.jsp"></jsp:include> <jsp:include page="../common/menu.jsp"></jsp:include>
<div class="rght" id="module"> <div class="right" id="module">
<div class="section"> <div class="section">
<div class="flex flex-row items-center justify-between"> <div class="flex flex-row items-center justify-between">
<h3 class="title">发票管理</h3> <h3 class="title">发票管理</h3>
...@@ -300,7 +308,7 @@ ...@@ -300,7 +308,7 @@
</div> </div>
</div> </div>
<div style="margin-top: -10px;margin-bottom: 50px"> <div style="margin-bottom: 50px">
<table style="width: 100%" class="rule-field"> <table style="width: 100%" class="rule-field">
<colgroup> <colgroup>
<col style="width:25%;"> <col style="width:25%;">
...@@ -397,6 +405,31 @@ ...@@ -397,6 +405,31 @@
</tr> </tr>
</tbody> </tbody>
</table> </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> </div>
...@@ -561,6 +594,10 @@ ...@@ -561,6 +594,10 @@
list: [], list: [],
dialog: false, dialog: false,
title: '发票管理', title: '发票管理',
page: 1,
pageSize: 10,
totalPage: 1,
total: 0,
// 发票方式 // 发票方式
invoiceTypeIndex: 0, invoiceTypeIndex: 0,
invoiceTypes: [ invoiceTypes: [
...@@ -646,17 +683,25 @@ ...@@ -646,17 +683,25 @@
}, },
methods: { methods: {
changeStatus(index) { changeStatus(index) {
this.page = 1
this.statusIndex = index; this.statusIndex = index;
this.fetchData() this.fetchData()
}, },
changeInvoice(index) { changeInvoice(index) {
this.page = 1
this.invoiceTypeIndex = index; this.invoiceTypeIndex = index;
this.fetchData() this.fetchData()
}, },
changePaper(index) { changePaper(index) {
this.page = 1
this.paperTypeIndex = index; this.paperTypeIndex = index;
this.fetchData() this.fetchData()
}, },
// 页面刷新
refresh() {
this.page = 1;
this.fetchData()
},
changePage(page) { changePage(page) {
this.page = page this.page = page
this.fetchData() this.fetchData()
...@@ -742,7 +787,15 @@ ...@@ -742,7 +787,15 @@
// 查询所有 // 查询所有
fetchData() { fetchData() {
if (!getCId()) return 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({ $.ajax({
type: 'GET', type: 'GET',
contentType: 'application/json', contentType: 'application/json',
...@@ -753,8 +806,14 @@ ...@@ -753,8 +806,14 @@
complete: () => { complete: () => {
layer.closeAll() layer.closeAll()
}, },
success: (data) => { success: (res) => {
this.list = data.content 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 @@ ...@@ -371,7 +371,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </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"> <ul class="pagination">
<li class="page-item" v-if="page!==1" @click="preview"><a class="page-link" <li class="page-item" v-if="page!==1" @click="preview"><a class="page-link"
href="#">Previous</a></li> href="#">Previous</a></li>
...@@ -624,10 +624,11 @@ ...@@ -624,10 +624,11 @@
fetchData() { fetchData() {
if (!getCId()) return if (!getCId()) return
const url = eccUrl + (this.isEnroll ? '/api-pick/v1/enroll-page' : '/api-pick/v1/mark-list') const url = eccUrl + (this.isEnroll ? '/api-pick/v1/enroll-page' : '/api-pick/v1/mark-list')
let isPickUp = this.statusOptions[this.statusIndex].value
let params = { let params = {
cmptId: gtCmptId, cmptId: gtCmptId,
keyword: this.keyword, keyword: this.keyword ?? undefined,
isPickUp: this.statusOptions[this.statusIndex].value, isPickUp: isPickUp === '' ? undefined : isPickUp,
current: this.page, current: this.page,
size: this.pageSize size: this.pageSize
} }
...@@ -671,7 +672,7 @@ ...@@ -671,7 +672,7 @@
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: JSON.stringify({
cmptId: 27262, cmptId: gtCmptId,
isPickUp: v, isPickUp: v,
current: this.page, current: this.page,
size: this.pageSize 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