From e2e439ba3042760387927b6858d46783abfdb141 Mon Sep 17 00:00:00 2001 From: weiweiw <14335254+weiweiw22@user.noreply.gitee.com> Date: Fri, 15 Nov 2024 11:24:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=92=8C=E8=A7=92=E8=89=B2li?= =?UTF-8?q?st=20=E5=AF=B9id=20=E4=B8=BA1=20=E6=88=96=E5=86=85=E7=BD=AE?= =?UTF-8?q?=E7=9A=84=20=E4=B8=8D=E8=83=BD=E5=88=A0=E9=99=A4=E6=88=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/role/index.vue | 43 ++++++++++++++++++++++++++++----- src/views/system/user/index.vue | 40 ++++++++++++++++++++++++++---- 2 files changed, 72 insertions(+), 11 deletions(-) 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