diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue index d094cfd7..eb299abe 100644 --- a/src/views/system/role/index.vue +++ b/src/views/system/role/index.vue @@ -101,7 +101,7 @@ - + @@ -476,10 +476,15 @@ export default { }, // 多选框选中数据 handleSelectionChange(selection) { - this.ids = selection.map(item => item.roleId) - this.single = selection.length != 1 - this.multiple = !selection.length - }, + // 过滤掉不可选的行(虽然界面上不可选,但为了安全起见还是过滤一次) + const validSelection = selection.filter(row => this.checkSelectable(row)); + + // 更新选中的roleId数组 + this.ids = validSelection.map(item => item.roleId); + // 更新单选和多选状态 + this.single = validSelection.length !== 1; + this.multiple = !validSelection.length; + }, // 更多操作触发 handleCommand(command, row) { switch (command) { @@ -626,7 +631,33 @@ export default { this.download('system/role/export', { ...this.queryParams }, `role_${new Date().getTime()}.xlsx`) - } + }, + // 检查行是否可选 + checkSelectable(row) { + return !(row.roleId === 1 || row.isBuiltIn === '0'); + }, + + + getRowClassName(row) { + return !this.checkSelectable(row) ? 'disabled-row' : ''; + }, } } + + + \ No newline at end of file diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue index db82d217..1b8675dc 100644 --- a/src/views/system/user/index.vue +++ b/src/views/system/user/index.vue @@ -82,7 +82,7 @@ - + item.userId) - this.single = selection.length != 1 - this.multiple = !selection.length + // 过滤掉不可选的行(虽然界面上不可选,但为了安全起见还是过滤一次) + const validSelection = selection.filter(row => this.checkSelectable(row)); + + // 更新选中的roleId数组 + this.ids = validSelection.map(item => item.userId); + // 更新单选和多选状态 + this.single = validSelection.length !== 1; + this.multiple = !validSelection.length; }, // 更多操作触发 handleCommand(command, row) { @@ -782,7 +787,32 @@ export default { // 提交上传文件 submitFileForm() { this.$refs.upload.submit() - } + }, + // 检查行是否可选 + checkSelectable(row) { + return !(row.userId === 1 || row.isBuiltIn === '0'); + }, + + + getRowClassName(row) { + return !this.checkSelectable(row) ? 'disabled-row' : ''; + }, } } + + \ No newline at end of file