From 8570c7e610c5b9504fb3947cd2435087e01e671d Mon Sep 17 00:00:00 2001 From: leiyun Date: Mon, 23 Mar 2026 11:25:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=88=A0=E9=99=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/admin/patient.js | 20 ++++++++ src/controller/admin/system/role.js | 3 +- view/admin/patient_index.html | 72 +++++++++++++++++++++++++---- 3 files changed, 86 insertions(+), 9 deletions(-) diff --git a/src/controller/admin/patient.js b/src/controller/admin/patient.js index 5b15aa5..dcd69c3 100644 --- a/src/controller/admin/patient.js +++ b/src/controller/admin/patient.js @@ -13,6 +13,7 @@ module.exports = class extends Base { this.assign('canExport', this.isSuperAdmin || (this.userPermissions || []).includes('patient:export')); this.assign('canAudit', this.isSuperAdmin || (this.userPermissions || []).includes('patient:audit')); this.assign('canView', this.isSuperAdmin || (this.userPermissions || []).includes('patient:view')); + this.assign('canDelete', this.isSuperAdmin || (this.userPermissions || []).includes('patient:delete')); return this.display(); } @@ -275,6 +276,25 @@ module.exports = class extends Base { return this.success(); } + // 删除患者(软删除,支持批量) + async deleteAction() { + const { ids } = this.post(); + if (!ids || !ids.length) return this.fail('参数错误'); + + const model = this.model('patient'); + const patients = await model.where({ id: ['in', ids], is_deleted: 0 }).select(); + if (!patients.length) return this.fail('患者不存在'); + + await model.where({ id: ['in', ids] }).update({ + is_deleted: 1, + update_by: this.adminUser?.id || 0 + }); + + const names = patients.map(p => p.name).join('、'); + await this.log('delete', '患者管理', `删除患者「${names}」共${patients.length}条`); + return this.success(); + } + // 编辑患者 async editAction() { const data = this.post(); diff --git a/src/controller/admin/system/role.js b/src/controller/admin/system/role.js index ddeed75..8d5dde5 100644 --- a/src/controller/admin/system/role.js +++ b/src/controller/admin/system/role.js @@ -255,7 +255,8 @@ module.exports = class extends Base { { name: '新增', key: 'patient:add' }, { name: '编辑', key: 'patient:edit' }, { name: '导出', key: 'patient:export' }, - { name: '审核', key: 'patient:audit' } + { name: '审核', key: 'patient:audit' }, + { name: '删除', key: 'patient:delete' } ] }, { diff --git a/view/admin/patient_index.html b/view/admin/patient_index.html index 467c42e..8fe09cd 100644 --- a/view/admin/patient_index.html +++ b/view/admin/patient_index.html @@ -34,6 +34,7 @@
新增患者 导出 + 批量删除 (${ selectedIds.length })
@@ -57,7 +58,8 @@ - + + @@ -86,11 +88,12 @@ 已驳回 - + @@ -254,14 +257,15 @@ {% block js %}