From 4264ef36b7516e8c5cf615b59b21e58294d6546f Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Wed, 9 Jul 2025 16:45:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(role):=20=E4=BF=AE=E5=A4=8D=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=E4=B8=AD=E9=9B=AA?= =?UTF-8?q?=E8=8A=B1ID=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复handleConfirmAssignMenu函数,保持字符串格式避免Number转换 - 修复handleRowSelectionChange函数,使用字符串比较避免精度丢失 - 移除菜单权限分配中的Number.parseInt转换,保持字符串格式 - 确保角色ID在整个权限分配流程中保持字符串格式 解决问题: - 部门管理等新菜单权限无法保存的问题 - 雪花ID在前端处理时精度丢失导致的数据不匹配 影响文件: - src/views/system/role/index.vue --- src/views/system/role/index.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index ffb975e..ea522a3 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -816,8 +816,9 @@ async function handleReset() { // 行选择变化 function handleRowSelectionChange(rowKeys: (string | number)[]) { - const numericKeys = rowKeys.map(key => typeof key === 'string' ? Number.parseInt(key) : key) - selectedRows.value = tableData.value.filter(row => numericKeys.includes(row.roleId)) + // 保持字符串格式避免精度丢失 + const stringKeys = rowKeys.map(key => String(key)) + selectedRows.value = tableData.value.filter(row => stringKeys.includes(String(row.roleId))) } // 批量修改(选中一个角色进行修改) @@ -1078,9 +1079,8 @@ async function handleConfirmAssignMenu() { // 确保选中子菜单时父菜单也被包含 const completeMenuIds = ensureParentMenusIncluded(checkedKeys.value, menuData.value) - // 将字符串格式的key转换为数字格式发送给后端 - const menuIds = completeMenuIds.map(key => Number.parseInt(String(key))) - const response = await saveRoleMenuPermission(currentAssignRole.value.roleId, menuIds) + // 保持字符串格式避免精度丢失 + const response = await saveRoleMenuPermission(String(currentAssignRole.value.roleId), completeMenuIds) if (response.isSuccess) { coiMsgSuccess('菜单权限分配成功')