mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
fix: workspaceFormItem rules
This commit is contained in:
parent
6cfb2a248b
commit
15574bd38d
|
|
@ -40,7 +40,7 @@ import type { WorkspaceItem } from '@/api/type/workspace'
|
|||
|
||||
const props = defineProps({
|
||||
data: {
|
||||
type: Array,
|
||||
type: Array<any>,
|
||||
default: () => [],
|
||||
},
|
||||
currentWorkspace: {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const {
|
|||
} = route as any
|
||||
|
||||
const isShared = computed(() => {
|
||||
return folderId === 'shared' || route.name.includes('ResourceManagement')
|
||||
return folderId === 'shared' || route.name?.includes('ResourceManagement')
|
||||
})
|
||||
const { theme } = useStore()
|
||||
const isDefaultTheme = computed(() => {
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ const filter_menu_nodes = computed(() => {
|
|||
if (!search_text.value) return menuNodes;
|
||||
const searchTerm = search_text.value.toLowerCase();
|
||||
|
||||
return menuNodes.reduce((result, item) => {
|
||||
return menuNodes.reduce((result: any[], item) => {
|
||||
const filteredList = item.list.filter(listItem =>
|
||||
listItem.label.toLowerCase().includes(searchTerm)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ async function refresh(group?: ListItem) {
|
|||
if (group) {
|
||||
current.value = group
|
||||
} else {
|
||||
current.value = list.value.find(item => item.id === current.value.id)
|
||||
current.value = list.value.find(item => item.id === current.value?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
<div v-for="(element, index) in form" :key="index" class="flex w-full">
|
||||
<el-form-item v-for="model of props.models" :key="model.path" :prop="`[${index}].${model.path}`"
|
||||
:rules="model.rules" :label="index === 0 && model.label ? model.label : ''" class="mr-8" style="flex: 1">
|
||||
<el-select v-show="!model?.hidden?.(element)" v-model="element[model.path]"
|
||||
<el-select v-if="!model?.hidden?.(element)" v-model="element[model.path]"
|
||||
:placeholder="model.selectProps?.placeholder ?? $t('common.selectPlaceholder')" clearable filterable
|
||||
multiple style="width: 100%" collapse-tags collapse-tags-tooltip v-bind="model.selectProps">
|
||||
<el-option v-for="opt in model.selectProps?.options" :key="opt.value" :label="opt.label"
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ async function refresh(role?: RoleItem) {
|
|||
if (role) {
|
||||
currentRole.value = role
|
||||
} else {
|
||||
currentRole.value = customRoleList.value.find(item => item.id === currentRole.value.id)
|
||||
currentRole.value = customRoleList.value.find(item => item.id === currentRole.value?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,6 +137,20 @@ async function getWorkspaceFormItem() {
|
|||
path: 'workspace_ids',
|
||||
label: t('views.role.member.workspace'),
|
||||
hidden: (e) => adminRoleList.value.find(item => item.id === e.role_id),
|
||||
rules: [
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
const match = rule.field?.match(/\[(\d+)\]/);
|
||||
const isAdmin = adminRoleList.value.some(role => role.id === list.value[parseInt(match?.[1] ?? '', 10)].role_id);
|
||||
if (!isAdmin && (!value || value.length === 0)) {
|
||||
callback(new Error(`${t('common.selectPlaceholder')}${t('views.role.member.workspace')}`));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: 'change',
|
||||
},
|
||||
],
|
||||
selectProps: {
|
||||
options:
|
||||
res.data?.map((item) => ({
|
||||
|
|
@ -275,7 +289,6 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||
...userForm.value,
|
||||
role_setting: list.value
|
||||
}
|
||||
console.log(list.value)
|
||||
if (isEdit.value) {
|
||||
userManageApi.putUserManage(userForm.value.id, params, loading).then((res) => {
|
||||
emit('refresh')
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
<template #default="{ row }">
|
||||
<span @click.stop>
|
||||
<el-switch
|
||||
:disabled="row.role === 'ADMIN'"
|
||||
:disabled="row.role === 'ADMIN' || row.id === user.userInfo?.id"
|
||||
size="small"
|
||||
v-model="row.is_active"
|
||||
:before-change="() => changeState(row)"
|
||||
|
|
@ -153,7 +153,7 @@
|
|||
</span>
|
||||
<span>
|
||||
<el-button
|
||||
:disabled="row.role === 'ADMIN'"
|
||||
:disabled="row.role === 'ADMIN' || row.id === user.userInfo?.id"
|
||||
type="primary"
|
||||
text
|
||||
@click.stop="deleteUserManage(row)"
|
||||
|
|
|
|||
|
|
@ -96,11 +96,7 @@
|
|||
<div class="flex align-center mb-16">
|
||||
<h4 class="medium">{{ currentWorkspace?.name }}</h4>
|
||||
<el-divider direction="vertical" class="mr-8 ml-8" />
|
||||
<AppIcon
|
||||
iconName="app-workspace"
|
||||
style="font-size: 16px"
|
||||
class="color-input-placeholder"
|
||||
></AppIcon>
|
||||
<el-icon class="color-input-placeholder"><UserFilled /></el-icon>
|
||||
<span class="color-input-placeholder ml-4">
|
||||
{{ currentWorkspace?.user_count }}
|
||||
</span>
|
||||
|
|
@ -152,7 +148,7 @@ async function refresh(workspace?: WorkspaceItem) {
|
|||
if (workspace) {
|
||||
currentWorkspace.value = workspace
|
||||
} else {
|
||||
currentWorkspace.value = list.value.find(item => item.id === currentWorkspace.value.id)
|
||||
currentWorkspace.value = list.value.find(item => item.id === currentWorkspace.value?.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue