|
@@ -22,6 +22,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@d8d/shared-ui-componen
|
|
|
import { Calendar } from '@d8d/shared-ui-components/components/ui/calendar';
|
|
import { Calendar } from '@d8d/shared-ui-components/components/ui/calendar';
|
|
|
import { cn } from '@d8d/shared-ui-components/utils/cn';
|
|
import { cn } from '@d8d/shared-ui-components/utils/cn';
|
|
|
import { DisabledStatus } from '@d8d/shared-types';
|
|
import { DisabledStatus } from '@d8d/shared-types';
|
|
|
|
|
+import { CompanySelectorWrapper } from './CompanySelectorWrapper';
|
|
|
|
|
|
|
|
// 使用RPC方式提取类型
|
|
// 使用RPC方式提取类型
|
|
|
type CreateUserRequest = InferRequestType<typeof userClient.index.$post>['json'];
|
|
type CreateUserRequest = InferRequestType<typeof userClient.index.$post>['json'];
|
|
@@ -63,6 +64,7 @@ export const UserManagement = () => {
|
|
|
phone: null,
|
|
phone: null,
|
|
|
name: null,
|
|
name: null,
|
|
|
password: '',
|
|
password: '',
|
|
|
|
|
+ companyId: null,
|
|
|
isDisabled: DisabledStatus.ENABLED,
|
|
isDisabled: DisabledStatus.ENABLED,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
@@ -76,6 +78,7 @@ export const UserManagement = () => {
|
|
|
phone: null,
|
|
phone: null,
|
|
|
name: null,
|
|
name: null,
|
|
|
password: '',
|
|
password: '',
|
|
|
|
|
+ companyId: null,
|
|
|
isDisabled: 0,
|
|
isDisabled: 0,
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
@@ -116,7 +119,7 @@ export const UserManagement = () => {
|
|
|
const totalCount = usersData?.pagination?.total || 0;
|
|
const totalCount = usersData?.pagination?.total || 0;
|
|
|
|
|
|
|
|
// 防抖搜索函数
|
|
// 防抖搜索函数
|
|
|
- const debounce = <T extends (...args: unknown[]) => void>(func: T, delay: number) => {
|
|
|
|
|
|
|
+ const debounce = <T extends (...args: any[]) => void>(func: T, delay: number) => {
|
|
|
let timeoutId: NodeJS.Timeout;
|
|
let timeoutId: NodeJS.Timeout;
|
|
|
return (...args: Parameters<T>) => {
|
|
return (...args: Parameters<T>) => {
|
|
|
clearTimeout(timeoutId);
|
|
clearTimeout(timeoutId);
|
|
@@ -184,6 +187,7 @@ export const UserManagement = () => {
|
|
|
phone: null,
|
|
phone: null,
|
|
|
name: null,
|
|
name: null,
|
|
|
password: '',
|
|
password: '',
|
|
|
|
|
+ companyId: null,
|
|
|
isDisabled: DisabledStatus.ENABLED,
|
|
isDisabled: DisabledStatus.ENABLED,
|
|
|
});
|
|
});
|
|
|
setIsModalOpen(true);
|
|
setIsModalOpen(true);
|
|
@@ -200,6 +204,7 @@ export const UserManagement = () => {
|
|
|
phone: user.phone,
|
|
phone: user.phone,
|
|
|
name: user.name,
|
|
name: user.name,
|
|
|
avatarFileId: user.avatarFileId,
|
|
avatarFileId: user.avatarFileId,
|
|
|
|
|
+ companyId: user.companyId,
|
|
|
isDisabled: user.isDisabled,
|
|
isDisabled: user.isDisabled,
|
|
|
});
|
|
});
|
|
|
setIsModalOpen(true);
|
|
setIsModalOpen(true);
|
|
@@ -502,6 +507,7 @@ export const UserManagement = () => {
|
|
|
<TableHead>昵称</TableHead>
|
|
<TableHead>昵称</TableHead>
|
|
|
<TableHead>邮箱</TableHead>
|
|
<TableHead>邮箱</TableHead>
|
|
|
<TableHead>真实姓名</TableHead>
|
|
<TableHead>真实姓名</TableHead>
|
|
|
|
|
+ <TableHead>关联企业</TableHead>
|
|
|
<TableHead>角色</TableHead>
|
|
<TableHead>角色</TableHead>
|
|
|
<TableHead>状态</TableHead>
|
|
<TableHead>状态</TableHead>
|
|
|
<TableHead>创建时间</TableHead>
|
|
<TableHead>创建时间</TableHead>
|
|
@@ -512,7 +518,7 @@ export const UserManagement = () => {
|
|
|
{isLoading ? (
|
|
{isLoading ? (
|
|
|
// 显示表格骨架屏
|
|
// 显示表格骨架屏
|
|
|
<TableRow>
|
|
<TableRow>
|
|
|
- <TableCell colSpan={8} className="p-4">
|
|
|
|
|
|
|
+ <TableCell colSpan={10} className="p-4">
|
|
|
{renderTableSkeleton()}
|
|
{renderTableSkeleton()}
|
|
|
</TableCell>
|
|
</TableCell>
|
|
|
</TableRow>
|
|
</TableRow>
|
|
@@ -541,6 +547,7 @@ export const UserManagement = () => {
|
|
|
<TableCell>{user.nickname || '-'}</TableCell>
|
|
<TableCell>{user.nickname || '-'}</TableCell>
|
|
|
<TableCell>{user.email || '-'}</TableCell>
|
|
<TableCell>{user.email || '-'}</TableCell>
|
|
|
<TableCell>{user.name || '-'}</TableCell>
|
|
<TableCell>{user.name || '-'}</TableCell>
|
|
|
|
|
+ <TableCell>{user.company?.companyName || '无'}</TableCell>
|
|
|
<TableCell>
|
|
<TableCell>
|
|
|
<Badge
|
|
<Badge
|
|
|
variant={user.roles?.some((role) => role.name === 'admin') ? 'destructive' : 'default'}
|
|
variant={user.roles?.some((role) => role.name === 'admin') ? 'destructive' : 'default'}
|
|
@@ -718,6 +725,28 @@ export const UserManagement = () => {
|
|
|
)}
|
|
)}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
|
|
+ <FormField
|
|
|
|
|
+ control={createForm.control}
|
|
|
|
|
+ name="companyId"
|
|
|
|
|
+ render={({ field }) => (
|
|
|
|
|
+ <FormItem>
|
|
|
|
|
+ <FormLabel>关联企业</FormLabel>
|
|
|
|
|
+ <FormControl>
|
|
|
|
|
+ <CompanySelectorWrapper
|
|
|
|
|
+ value={field.value}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ placeholder="请选择关联企业(可选)"
|
|
|
|
|
+ data-testid="company-selector"
|
|
|
|
|
+ />
|
|
|
|
|
+ </FormControl>
|
|
|
|
|
+ <FormDescription>
|
|
|
|
|
+ 为用户分配关联的企业,留空表示不关联任何企业
|
|
|
|
|
+ </FormDescription>
|
|
|
|
|
+ <FormMessage />
|
|
|
|
|
+ </FormItem>
|
|
|
|
|
+ )}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
<FormField
|
|
<FormField
|
|
|
control={createForm.control}
|
|
control={createForm.control}
|
|
|
name="isDisabled"
|
|
name="isDisabled"
|
|
@@ -839,6 +868,28 @@ export const UserManagement = () => {
|
|
|
)}
|
|
)}
|
|
|
/>
|
|
/>
|
|
|
|
|
|
|
|
|
|
+ <FormField
|
|
|
|
|
+ control={updateForm.control}
|
|
|
|
|
+ name="companyId"
|
|
|
|
|
+ render={({ field }) => (
|
|
|
|
|
+ <FormItem>
|
|
|
|
|
+ <FormLabel>关联企业</FormLabel>
|
|
|
|
|
+ <FormControl>
|
|
|
|
|
+ <CompanySelectorWrapper
|
|
|
|
|
+ value={field.value}
|
|
|
|
|
+ onChange={field.onChange}
|
|
|
|
|
+ placeholder="请选择关联企业(可选)"
|
|
|
|
|
+ data-testid="company-selector-edit"
|
|
|
|
|
+ />
|
|
|
|
|
+ </FormControl>
|
|
|
|
|
+ <FormDescription>
|
|
|
|
|
+ 为用户分配关联的企业,留空表示不关联任何企业
|
|
|
|
|
+ </FormDescription>
|
|
|
|
|
+ <FormMessage />
|
|
|
|
|
+ </FormItem>
|
|
|
|
|
+ )}
|
|
|
|
|
+ />
|
|
|
|
|
+
|
|
|
<FormField
|
|
<FormField
|
|
|
control={updateForm.control}
|
|
control={updateForm.control}
|
|
|
name="isDisabled"
|
|
name="isDisabled"
|