复诊到期跟进:预计复诊列支持正序/倒序排序,默认按最新在前
- 后端 RevisitDueLists 新增 sort_field / sort_order 参数(白名单 due_date),默认 due_date 倒序,无预计复诊日的行始终置后,同日按 id 同向排序保证分页稳定 - 前端表头「预计复诊」改为可排序,仅在倒序/正序间切换,切换后回到第 1 页;导出沿用当前排序 Co-Authored-By: Claude Opus 5 <[EMAIL]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
d199d66f8c
commit
19159668fb
@@ -25,7 +25,7 @@ use think\facade\Db;
|
||||
* 筛选:assistant_id / dept_id(经 admin_dept 子查询,含下级部门)/ state / days_bucket / slot(诊次,N 或 N+)/ min_snooze / keyword(患者姓名);默认排除失效行(closed_state<>5)。
|
||||
* state 的 SQL 条件与 DiagnosisLists::applyRevisitDueFilters 完全一致,另加 closed = closed_state=4(人工关闭,主管视图标记)。
|
||||
* 数据范围:HasDataScopeFilter::applyDataScopeByOwner('rd.assistant_id'),主管按角色 data_scope 看下属。
|
||||
* 排序:escalation_level desc(越点越上心优先),due_date asc(NULL 置后),id asc。
|
||||
* 排序:sort_field=due_date + sort_order=asc|desc,默认 due_date desc(最新预计复诊在前),NULL 始终置后,见 orderSql()。
|
||||
* 导出:export=1/2,字段见 setExcelFields。
|
||||
*/
|
||||
class RevisitDueLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||
@@ -51,7 +51,7 @@ class RevisitDueLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
public function lists(): array
|
||||
{
|
||||
$rows = $this->buildQuery()
|
||||
->orderRaw('rd.escalation_level DESC, rd.due_date IS NULL ASC, rd.due_date ASC, rd.id ASC')
|
||||
->orderRaw($this->orderSql())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
@@ -113,6 +113,20 @@ class RevisitDueLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
|
||||
// ---------------------------------------------------------------- 内部
|
||||
|
||||
/**
|
||||
* 排序:sort_field 仅白名单列(目前 due_date = 预计复诊),sort_order asc|desc,默认 desc(最新的预计复诊日在前)。
|
||||
* 无论正序倒序,缺预计复诊日(NULL)的行始终置后;同日按 id 同向排序保证分页稳定。
|
||||
*/
|
||||
private function orderSql(): string
|
||||
{
|
||||
$fieldMap = ['due_date' => 'rd.due_date'];
|
||||
$field = (string) ($this->params['sort_field'] ?? '');
|
||||
$col = $fieldMap[$field] ?? $fieldMap['due_date'];
|
||||
$dir = strtolower((string) ($this->params['sort_order'] ?? '')) === 'asc' ? 'ASC' : 'DESC';
|
||||
|
||||
return "{$col} IS NULL ASC, {$col} {$dir}, rd.id {$dir}";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \think\db\Query
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user