复诊到期跟进:预计复诊列支持正序/倒序排序,默认按最新在前
- 后端 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
@@ -163,6 +163,10 @@ export interface RevisitDueListsParams {
|
||||
slot?: string
|
||||
min_snooze?: number | ''
|
||||
keyword?: string
|
||||
/** 排序列(白名单:due_date = 预计复诊),缺省 due_date */
|
||||
sort_field?: 'due_date'
|
||||
/** 排序方向,缺省 desc(最新在前);无预计复诊日的行始终置后 */
|
||||
sort_order?: 'asc' | 'desc'
|
||||
page_no?: number
|
||||
page_size?: number
|
||||
/** 1 = 导出(export-data 组件追加) */
|
||||
|
||||
@@ -133,6 +133,8 @@
|
||||
stripe
|
||||
row-key="id"
|
||||
:row-class-name="rowClassName"
|
||||
:default-sort="{ prop: 'due_date', order: 'descending' }"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<el-table-column label="患者" min-width="120" fixed="left">
|
||||
<template #default="{ row }">
|
||||
@@ -181,7 +183,13 @@
|
||||
<span v-else class="text-missing">缺开药天数</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="预计复诊" width="110">
|
||||
<el-table-column
|
||||
label="预计复诊"
|
||||
prop="due_date"
|
||||
width="120"
|
||||
sortable="custom"
|
||||
:sort-orders="['descending', 'ascending']"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="cell-main">{{ row.due_date || '—' }}</div>
|
||||
<div v-if="row.anchor_date" class="cell-sub">
|
||||
@@ -411,7 +419,9 @@ const queryParams = reactive<RevisitDueListsParams>({
|
||||
days_bucket: '',
|
||||
slot: '',
|
||||
min_snooze: '',
|
||||
keyword: ''
|
||||
keyword: '',
|
||||
sort_field: 'due_date',
|
||||
sort_order: 'desc'
|
||||
})
|
||||
/** el-input-number 清空时为 null/undefined,单独持有后再写回 queryParams 的 '' */
|
||||
const minSnooze = ref<number | undefined>(undefined)
|
||||
@@ -423,6 +433,13 @@ const { pager, getLists, resetPage } = usePaging({
|
||||
|
||||
const doSearch = () => resetPage()
|
||||
|
||||
/** 表头排序:只在倒序 / 正序间切换(sort-orders 不含 null),切换后回到第 1 页 */
|
||||
const onSortChange = ({ order }: { prop: string | null; order: string | null }) => {
|
||||
queryParams.sort_field = 'due_date'
|
||||
queryParams.sort_order = order === 'ascending' ? 'asc' : 'desc'
|
||||
doSearch()
|
||||
}
|
||||
|
||||
const onMinSnoozeChange = (val: number | undefined | null) => {
|
||||
queryParams.min_snooze = val === null || val === undefined ? '' : Number(val)
|
||||
doSearch()
|
||||
|
||||
@@ -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