| | |
| | | const displayedActionNodes = computed(() => |
| | | selectedPermissionSections.value.flatMap(section => section.actions)) |
| | | |
| | | function areMatchedActionsAllChecked(matchers: RegExp[]) { |
| | | const matchedActions = displayedActionNodes.value.filter(action => |
| | | matchers.some(pattern => pattern.test(action.menuName))) |
| | | |
| | | if (!matchedActions.length) |
| | | return false |
| | | |
| | | const checkedKeySet = new Set(checkedPermissionKeys.value) |
| | | return matchedActions.every(action => checkedKeySet.has(action.key)) |
| | | } |
| | | |
| | | function getBatchActionLabel(matchers: RegExp[], actionText: string) { |
| | | return `${areMatchedActionsAllChecked(matchers) ? '批量不选中' : '批量选中'}${actionText}` |
| | | } |
| | | |
| | | function handleBatchToggleActions(matchers: RegExp[], successText: string, cancelText: string) { |
| | | if (!displayedActionNodes.value.length) |
| | | return |
| | |
| | | <div class="permission-config-wrap"> |
| | | <div class="permission-toolbar"> |
| | | <NButton :disabled="batchActionDisabled" @click="handleBatchView"> |
| | | 批量选中/不选中查看 |
| | | {{ getBatchActionLabel([/查看/, /详情/], '查看') }} |
| | | </NButton> |
| | | <NButton :disabled="batchActionDisabled" @click="handleBatchEdit"> |
| | | 批量选中/不选中编辑 |
| | | {{ getBatchActionLabel([/编辑/, /修改/], '编辑') }} |
| | | </NButton> |
| | | <NButton :disabled="batchActionDisabled" @click="handleBatchDelete"> |
| | | 批量选中/不选中删除 |
| | | {{ getBatchActionLabel([/删除/], '删除') }} |
| | | </NButton> |
| | | <NButton :disabled="batchActionDisabled" @click="handleBatchExport"> |
| | | 批量选中/不选中导出 |
| | | {{ getBatchActionLabel([/导出/], '导出') }} |
| | | </NButton> |
| | | <NButton class="w-84px" :disabled="isReadOnlyMode" @click="handleResetPermissions"> |
| | | 重置 |