feat(label): add label page

This commit is contained in:
2026-03-10 18:20:50 +08:00
parent 1ae8509cce
commit 014c34ab76
65 changed files with 23477 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
import httpFetch from "@/api/fetch"
import { BASE_LABEL_API } from "../const"
import { Organization, User } from "./typing"
// 获取用户列表
export const getUserList = (data: User.ListRequest) => {
return httpFetch<User.ListResponse>({
url: BASE_LABEL_API + "/api/v1/label_server/user/list",
method: "POST",
body: JSON.stringify({ ...data, tenant: "cowarobot" }),
})
}
// 新增用户
export const userAdd = (data: User.CreateProps) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/add",
method: "POST",
body: JSON.stringify(data),
})
}
// 批量导入用户
export const userImport = (data: { user_infos: any[] }) => {
return httpFetch<string[]>({
url: BASE_LABEL_API + "/api/v1/label_server/user/batch_add",
method: "POST",
body: JSON.stringify(data),
})
}
// 编辑用户
export const userEditById = (data: User.EditProps, id: number) => {
return httpFetch({
url: BASE_LABEL_API + `/api/v1/label_server/user/edit/${id}`,
method: "PUT",
body: JSON.stringify(data),
})
}
// 编辑用户组织
export const userUpdateGroup = (data: User.UpdateGroupProps) => {
return httpFetch({
url: BASE_LABEL_API + `/api/v1/label_server/user/update/group`,
method: "POST",
body: JSON.stringify(data),
})
}
// 获取用户组织树
export const getUserGroupTree = () => {
return httpFetch<Organization.Response[]>({
url: BASE_LABEL_API + "/api/v1/label_server/user/group/tree",
method: "GET",
})
}
// 新增用户组
export const userGroupAdd = (data: Organization.CreateProps) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/group/add",
method: "POST",
body: JSON.stringify(data),
})
}
// 修改用户密码
export const modifyUserPassword = (data: {
old_password: string
new_password: string
}) => {
return httpFetch({
url: BASE_LABEL_API + "/api/v1/label_server/user/modify_password",
method: "PUT",
body: JSON.stringify(data),
})
}
/* ****************************** Options ****************************** */
interface Option {
label: string
value: string
}
// 获取所有用户组
export const getUserGroupAll = () => {
return httpFetch<Array<Option>>({
url: BASE_LABEL_API + `/api/v1/label_server/user/group/all`,
method: "GET",
})
}
// 获取所有用户
export const getUserAll = () => {
return httpFetch<Array<Option>>({
url: BASE_LABEL_API + "/api/v1/label_server/user/all",
method: "GET",
})
}

View File

@@ -0,0 +1,76 @@
export namespace User {
export interface UserInfo {
uid: number
name: string
all_projects: { [x: number]: number[] }
collect_projects: number[]
group_name: string
group_uuid: string
work_status: number
base_city: string
}
export interface LoginInfo extends UserInfo {
token: string
refresh_token: string
}
export interface ListRequest {
name?: string
page_number?: number
page_size?: number
}
export interface ListResponse {
user_list: UserInfo[]
total_pages: number
total_items: number
}
export interface CreateProps {
user_name: string
group_uuid: string
base_city: string
}
export interface EditProps {
user_name?: string
password?: string
group_uuid?: string
base_city?: string
work_status?: number
}
export interface UpdateGroupProps {
user_id: number
group_uuid: string
}
}
export namespace Organization {
export interface CreateProps {
group_name: string
leader_uid: number
parent_group_uuid: string
}
interface Member {
base_city: string
id: number
name: string
work_status: number
}
export interface Response {
children?: Response[]
create_at?: string
create_user?: string
group_uuid: string
leader_uid?: number
leader_name?: string
members?: Member[]
name: string
parent_group_uuid: string
[key: string]: boolean | string | number | Response[] | Member[] | undefined
}
}