From 0165c5c6efad740c049b9582af2e4e461d95a80b Mon Sep 17 00:00:00 2001 From: jinchao <383321154@qq.com> Date: Mon, 12 May 2025 17:00:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E4=BA=8B=E9=A1=B9=E7=9A=84=E6=93=8D=E4=BD=9C=E7=9A=84=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Release/database/XNSim.db | Bin 192512 -> 192512 bytes XNSimHtml/components/todo-component.js | 89 ++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-) diff --git a/Release/database/XNSim.db b/Release/database/XNSim.db index 4d904410a4500706173f71baf06b6e2bb4c3e26a..1982a3239632dcfcf25c210e18a2f4c20da30be2 100644 GIT binary patch delta 52 zcmZp8z}@hGdxA9MwTUv$tk)Ry%DNj { + if (errorDiv.parentNode) { + errorDiv.parentNode.removeChild(errorDiv); + } + }, 3000); } // 显示编辑执行人对话框 showEditExecutorModal(todo) { + // 权限检查 + const currentUserLevel = this.currentUser.level || 0; + if (currentUserLevel <= 2 && todo.adduser !== this.currentUser.username) { + this.showError('您没有权限编辑他人创建的待办事项'); + return; + } + if (currentUserLevel === 3 && todo.adduser === 'admin') { + this.showError('您没有权限编辑管理员创建的待办事项'); + return; + } + this.editingTodo = todo; const { modal, style } = TodoModal.createModal('executor'); // 获取当前用户等级 - const currentUserLevel = this.currentUser.access_level || 0; + const currentUserAccessLevel = this.currentUser.access_level || 0; // 填充用户下拉列表 const executorSelect = modal.querySelector('#executor'); @@ -115,7 +154,7 @@ class TodoComponent extends HTMLElement { const availableUsers = this.users.filter(user => user && user.access_level > 0 && - user.access_level <= currentUserLevel + user.access_level <= currentUserAccessLevel ); // 添加用户选项 @@ -157,6 +196,17 @@ class TodoComponent extends HTMLElement { // 显示编辑计划时间对话框 showEditScheduleModal(todo) { + // 权限检查 + const currentUserLevel = this.currentUser.level || 0; + if (currentUserLevel <= 2 && todo.adduser !== this.currentUser.username) { + this.showError('您没有权限编辑他人创建的待办事项'); + return; + } + if (currentUserLevel === 3 && todo.adduser === 'admin') { + this.showError('您没有权限编辑管理员创建的待办事项'); + return; + } + this.editingTodo = todo; const { modal, style } = TodoModal.createModal('schedule'); @@ -856,6 +906,17 @@ class TodoComponent extends HTMLElement { onEditExecutor: (todo) => this.showEditExecutorModal(todo), onEditSchedule: (todo) => this.showEditScheduleModal(todo), onEditTitle: (todo) => { + // 权限检查 + const currentUserLevel = this.currentUser.level || 0; + if (currentUserLevel <= 2 && todo.adduser !== this.currentUser.username) { + this.showError('您没有权限编辑他人创建的待办事项'); + return; + } + if (currentUserLevel === 3 && todo.adduser === 'admin') { + this.showError('您没有权限编辑管理员创建的待办事项'); + return; + } + const { modal, style } = TodoModal.createModal('edit-title'); const titleInput = modal.querySelector('#title'); titleInput.value = todo.title; @@ -887,6 +948,17 @@ class TodoComponent extends HTMLElement { document.body.appendChild(modal); }, onEditDescription: (todo) => { + // 权限检查 + const currentUserLevel = this.currentUser.level || 0; + if (currentUserLevel <= 2 && todo.adduser !== this.currentUser.username) { + this.showError('您没有权限编辑他人创建的待办事项'); + return; + } + if (currentUserLevel === 3 && todo.adduser === 'admin') { + this.showError('您没有权限编辑管理员创建的待办事项'); + return; + } + const { modal, style } = TodoModal.createModal('edit-description'); const textInput = modal.querySelector('#text'); textInput.value = todo.text || ''; @@ -914,6 +986,17 @@ class TodoComponent extends HTMLElement { document.body.appendChild(modal); }, onDelete: async (todo) => { + // 权限检查 + const currentUserLevel = this.currentUser.level || 0; + if (currentUserLevel <= 2 && todo.adduser !== this.currentUser.username) { + this.showError('您没有权限删除他人创建的待办事项'); + return; + } + if (currentUserLevel === 3 && todo.adduser === 'admin') { + this.showError('您没有权限删除管理员创建的待办事项'); + return; + } + if (confirm('确定要删除这条待办事项吗?')) { try { await TodoService.deleteTodo(todo.id);