Commit 5f87eaa0 by liuyingkang

feat: 添加分页设置并优化查询逻辑

在LawyerCovenantIncomeController中添加分页设置,默认每页显示50条,并提供可选分页大小。优化Covenant仓库中的查询逻辑,确保分页参数从请求中获取,并调整默认每页显示数量为50。同时,修复查询条件,确保已删除的记录不被计入统计。
parent e9c74026
......@@ -90,6 +90,10 @@ protected function grid()
$actions->append('<a href="/view-covenant-invoiced?cid=' . $cid . '" alt="查看开票" >查看开票</a>');
}
});
// 添加分页设置
$grid->paginate(50); // 默认每页50条
$grid->perPages([10, 20, 50, 100]); // 可选分页大小
});
}
......
......@@ -9,6 +9,7 @@
use Dcat\Admin\Repositories\EloquentRepository;
use Dcat\Admin\Grid;
use Illuminate\Support\Facades\DB;
use App\Command\Log;
class Covenant extends EloquentRepository
{
......@@ -46,8 +47,8 @@ public function get(Grid\Model $model)
{
// 获取当前页数
$currentPage = $model->getCurrentPage();
// 获取每页显示行数
$perPage = $model->getPerPage();
// 获取每页显示行数,从请求参数中获取,默认50
$perPage = $model->filter()->input('per_page', 50);
$start = ($currentPage - 1) * $perPage;
......@@ -68,6 +69,7 @@ public function get(Grid\Model $model)
$param = [
'sort' => $sort,
'start' => $start,
'per_page' => $perPage, // 添加这行
'search' => ['lawyer_id' => $lawyerID, 'number' => $number, 'cname' => $cname, 'principal' => $principal, 'invoiced_at' => $invoiced_at, 'received_at' => $received_at,]
];
......@@ -82,7 +84,7 @@ public function get(Grid\Model $model)
// 获取列表数据
public function getList(array $param)
{
$prePage = $param['per_page'] ?? 20;
$prePage = $param['per_page'] ?? 50;
$stepstart = $param['start'] ?? 0;
$lawyer_id = $param['search']['lawyer_id'] ?? 0;
$number = $param['search']['number'] ?? '';
......@@ -180,10 +182,13 @@ public function getList(array $param)
$tmp['ctype'] = $item->ctype;
$tmp['principal'] = $item->principal;
$cid = $item->cid;
$lawyer_id = $item->lawyer_id;
//开票金额
$invoiced_money = ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 2])->sum('invoiced_money');
$invoiced_money = ModelsCovenantReceivePayment::where(['cid' => $cid,'lawyer_id' => $lawyer_id, 'rtype' => 2])->whereNull('deleted_at')->sum('invoiced_money');
//Log::add("debug: ",'invoiced_money:'.$invoiced_money.';lawyer_id:'.$lawyer_id.';cid:'.$item->cid);
//已收款
$receipt_money = ModelsCovenantReceivePayment::where(['cid' => $cid, 'rtype' => 1])->sum('received_amount');
$receipt_money = ModelsCovenantReceivePayment::where(['cid' => $cid,'lawyer_id' => $lawyer_id, 'rtype' => 1])->whereNull('deleted_at')->sum('received_amount');
$tmp['invoice_amount'] = number_format($invoiced_money, 2);
$tmp['receipt_money'] = number_format($receipt_money, 2);
......
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