From d530b09cd5a4c14be721310af34718829d511b0f Mon Sep 17 00:00:00 2001 From: leiyun Date: Sat, 21 Mar 2026 18:10:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9BBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/admin/patient.js | 2 +- src/model/patient.js | 20 ++++++++++---------- view/admin/patient_index.html | 13 ++++++++++--- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/controller/admin/patient.js b/src/controller/admin/patient.js index 17090d3..0d96aca 100644 --- a/src/controller/admin/patient.js +++ b/src/controller/admin/patient.js @@ -54,7 +54,7 @@ module.exports = class extends Base { item.region_name = [pName, cName, dName].filter(Boolean).join(' '); }); - const counts = await model.getStatusCounts(); + const counts = await model.getStatusCounts({ keyword, tag, startDate, endDate, province_code, city_code, district_code }); return this.success({ ...list, counts }); } diff --git a/src/model/patient.js b/src/model/patient.js index 1e2f06c..c8853d7 100644 --- a/src/model/patient.js +++ b/src/model/patient.js @@ -147,17 +147,17 @@ module.exports = class extends think.Model { } /** - * 获取各状态数量(单次查询) + * 获取各状态数量(支持筛选条件,排除 status) */ - async getStatusCounts() { - const sql = `SELECT - COUNT(*) AS \`all\`, - SUM(status = -1) AS draft, - SUM(status = 0) AS pending, - SUM(status = 1) AS approved, - SUM(status = 2) AS rejected - FROM patient WHERE is_deleted = 0`; - const rows = await this.query(sql); + async getStatusCounts(filters = {}) { + // 复用 _buildWhere,但排除 status + const { status, ...rest } = filters; + const where = this._buildWhere(rest); + // 删掉 status 条件(_buildWhere 不会加,但保险起见) + delete where.status; + const rows = await this.where(where) + .field('COUNT(*) AS `all`, SUM(status = -1) AS draft, SUM(status = 0) AS pending, SUM(status = 1) AS approved, SUM(status = 2) AS rejected') + .select(); const row = rows[0] || {}; return { all: parseInt(row.all, 10) || 0, diff --git a/view/admin/patient_index.html b/view/admin/patient_index.html index 7b9e6cf..8c10272 100644 --- a/view/admin/patient_index.html +++ b/view/admin/patient_index.html @@ -98,10 +98,12 @@
@@ -322,6 +324,11 @@ const app = createApp({ loadList(); } + function onSizeChange() { + pagination.page = 1; + loadList(); + } + function viewDetail(row) { if (!perms.canView) { ElementPlus.ElMessageBox.alert('暂无查看详情权限,请先联系管理员授权', '温馨提示', { @@ -480,7 +487,7 @@ const app = createApp({ keyword, dateRange, tagFilter, regionFilter, activeTab, loading, tableData, pagination, counts, uploadHeaders, addVisible, addSaving, addForm, exporting, editingId, perms, regionTree, tagOptions, Plus, Download, - loadList, resetFilter, onTabChange, viewDetail, showAddDialog, showEditDialog, handleExport, + loadList, resetFilter, onTabChange, onSizeChange, viewDetail, showAddDialog, showEditDialog, handleExport, onIdCardInput, onDocUpload, onSignUpload, submitAdd }; }