Make dynamic column-facet values respect other active filters (Excel-style), with backend facet context helpers, list-page wiring, slip print/sidebar fixes, and refreshed graphify graphs. Co-authored-by: Cursor <cursoragent@cursor.com>
755 lines
18 KiB
TypeScript
755 lines
18 KiB
TypeScript
import request from '@/utils/http'
|
||
import type { AppRouteRecord } from '@/types/router'
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 后端菜单 / 角色(与 router 后端模式、用户弹窗对齐)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
/** 后端菜单模式:拉取动态路由 */
|
||
export async function fetchGetMenuList() {
|
||
const res = await request.get<AppRouteRecord[] | { menuList?: AppRouteRecord[] }>({
|
||
url: '/web/menu/list'
|
||
})
|
||
if (Array.isArray(res)) return res
|
||
return res?.menuList || []
|
||
}
|
||
|
||
/** 用户表单等:角色下拉 */
|
||
export function fetchGetRoleList() {
|
||
return request.get<Array<{ label: string; value: string }>>({
|
||
url: '/web/admin/roles'
|
||
})
|
||
}
|
||
|
||
/** 用户下拉选项(label=昵称,value=用户ID,nickName/userNo 供审批人等场景展示账号) */
|
||
export function fetchUserOptions() {
|
||
return request.get<Array<{ label: string; value: string; nickName?: string; userNo?: string }>>({
|
||
url: '/web/admin/users/options'
|
||
})
|
||
}
|
||
|
||
/** 流程设计器:角色下拉选项(label=角色名,value=角色ID UUID) */
|
||
export function fetchRoleOptions() {
|
||
return request.get<Array<{ label: string; value: string }>>({
|
||
url: '/web/admin/roles/options'
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 租户(系统管理)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchTenantList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||
return request.get<{
|
||
list: Api.Tenant.TenantItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({
|
||
url: '/web/admin/tenants',
|
||
params
|
||
})
|
||
}
|
||
|
||
|
||
export function fetchExportTenants(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/tenants/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
export function fetchCreateTenant(data: {
|
||
tenantNo: string
|
||
tenantName: string
|
||
contactName?: string
|
||
contactPhone?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post<Api.Tenant.TenantItem>({
|
||
url: '/web/admin/tenants',
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchUpdateTenant(
|
||
id: string,
|
||
data: Partial<{
|
||
tenantNo: string
|
||
tenantName: string
|
||
contactName: string
|
||
contactPhone: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put<Api.Tenant.TenantItem>({
|
||
url: `/web/admin/tenants/${id}`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchDeleteTenant(id: string) {
|
||
return request.del({
|
||
url: `/web/admin/tenants/${id}`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 用户管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchUserList(params?: {
|
||
page?: number
|
||
pageSize?: number
|
||
keyword?: string
|
||
deptId?: string
|
||
status?: string
|
||
userNo?: string
|
||
nickName?: string
|
||
phoneNo?: string
|
||
statusIn?: string
|
||
[key: string]: unknown
|
||
}) {
|
||
return request.get<{
|
||
list: Api.User.UserItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({
|
||
url: '/web/admin/users',
|
||
params
|
||
})
|
||
}
|
||
|
||
/** 用户列表列头可选值(账号/用户名/手机号去重) */
|
||
export function fetchUserColumnFacetValues(
|
||
data: {
|
||
field: 'userNo' | 'nickName' | 'phoneNo'
|
||
keyword?: string
|
||
limit?: number
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/admin/users/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
/** Excel 导出用户 */
|
||
export function fetchExportUsers(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/users/export',
|
||
data,
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
/** 租户列表列头可选值(编号/名称/联系人去重) */
|
||
export function fetchTenantColumnFacetValues(
|
||
data: {
|
||
field: 'tenantNo' | 'tenantName' | 'contactName' | 'contactPhone'
|
||
keyword?: string
|
||
limit?: number
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/admin/tenants/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
/** 字典类型列表列头可选值(名称/编码去重) */
|
||
export function fetchDictTypeColumnFacetValues(
|
||
data: {
|
||
field: 'dictName' | 'dictType'
|
||
keyword?: string
|
||
limit?: number
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/admin/dict-types/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
/** 职位列表列头可选值(名称/编码去重) */
|
||
export function fetchPostColumnFacetValues(
|
||
data: {
|
||
field: 'postName' | 'postCode'
|
||
keyword?: string
|
||
limit?: number
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/admin/posts/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
/** 角色列表列头可选值(名称去重) */
|
||
export function fetchRoleColumnFacetValues(
|
||
data: {
|
||
field: 'roleName'
|
||
keyword?: string
|
||
limit?: number
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/admin/role-management/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
export function fetchUserDetail(id: string) {
|
||
return request.get<Api.User.UserItem>({
|
||
url: `/web/admin/users/${id}`
|
||
})
|
||
}
|
||
|
||
export function fetchCreateUser(data: {
|
||
userNo: string
|
||
nickName: string
|
||
password: string
|
||
deptId?: string
|
||
email?: string
|
||
phoneNo?: string
|
||
sex?: string
|
||
avatar?: string
|
||
status?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
roleIds?: string[]
|
||
postIds?: string[]
|
||
}) {
|
||
return request.post({
|
||
url: '/web/admin/users',
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchUpdateUser(
|
||
id: string,
|
||
data: Partial<{
|
||
nickName: string
|
||
deptId: string
|
||
email: string
|
||
phoneNo: string
|
||
sex: string
|
||
avatar: string
|
||
status: string
|
||
orderNum: number
|
||
remark: string
|
||
roleIds: string[]
|
||
postIds: string[]
|
||
}>
|
||
) {
|
||
return request.put({
|
||
url: `/web/admin/users/${id}`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchDeleteUser(id: string) {
|
||
return request.del({
|
||
url: `/web/admin/users/${id}`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchResetPassword(id: string) {
|
||
return request.post({
|
||
url: `/web/admin/users/${id}/reset-password`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
/** 上传用户头像,返回存储后的 URL,供写入 avatarUrl */
|
||
export function fetchUploadUserAvatar(data: FormData) {
|
||
return request.post<{ url: string }>({
|
||
url: '/web/admin/users/upload-avatar',
|
||
data
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 字典类型
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchDictTypeList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||
return request.get<{
|
||
list: Api.Dict.DictTypeItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({
|
||
url: '/web/admin/dict-types',
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchExportDictTypes(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/dict-types/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
export function fetchCreateDictType(data: {
|
||
dictName: string
|
||
dictType: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/dict-types', params: data })
|
||
}
|
||
|
||
export function fetchUpdateDictType(
|
||
id: string,
|
||
data: Partial<{
|
||
dictName: string
|
||
dictType: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/dict-types/${id}`, params: data })
|
||
}
|
||
|
||
export function fetchDeleteDictType(id: string) {
|
||
return request.del({ url: `/web/admin/dict-types/${id}` })
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 字典数据
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchDictDataList(params?: {
|
||
page?: number
|
||
pageSize?: number
|
||
dictType?: string
|
||
keyword?: string
|
||
}) {
|
||
return request.get<{
|
||
list: Api.Dict.DictDataItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({
|
||
url: '/web/admin/dict-data',
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchCreateDictData(data: {
|
||
dictLabel: string
|
||
dictValue: string
|
||
dictType: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/dict-data', params: data })
|
||
}
|
||
|
||
export function fetchUpdateDictData(
|
||
id: string,
|
||
data: Partial<{
|
||
dictLabel: string
|
||
dictValue: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/dict-data/${id}`, params: data })
|
||
}
|
||
|
||
export function fetchDeleteDictData(id: string) {
|
||
return request.del({ url: `/web/admin/dict-data/${id}` })
|
||
}
|
||
|
||
export function fetchDictDataOptions(dictType: string) {
|
||
return request.get<Api.Dict.DictDataOption[]>({
|
||
url: '/web/admin/dict-data/options',
|
||
params: { dictType }
|
||
})
|
||
}
|
||
|
||
export function fetchAllDictData() {
|
||
return request.get<Api.Dict.DictAllResponse>({
|
||
url: '/web/admin/dict-data/all'
|
||
})
|
||
}
|
||
|
||
export function fetchEnsureDictData(data: {
|
||
dictType: string
|
||
label: string
|
||
preferredValue?: string
|
||
}) {
|
||
return request.post<{ label: string; value: string; created: boolean }>({
|
||
url: '/web/admin/dict-data/ensure',
|
||
data
|
||
})
|
||
}
|
||
|
||
export function fetchEnsureRemoveDictData(data: { dictType: string; value: string }) {
|
||
return request.post({
|
||
url: '/web/admin/dict-data/ensure-remove',
|
||
data
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 组织管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchDeptTree(params?: { keyword?: string }) {
|
||
return request.get<Api.Dept.DeptItem[]>({
|
||
url: '/web/admin/depts',
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchExportDepts(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/depts/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
export function fetchCreateDept(data: {
|
||
parentId?: string
|
||
deptName: string
|
||
deptCategoryCode?: string
|
||
status?: string
|
||
leader?: string
|
||
leaderPhone?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/depts', params: data })
|
||
}
|
||
|
||
export function fetchUpdateDept(
|
||
id: string,
|
||
data: Partial<{
|
||
deptName: string
|
||
deptCategoryCode: string
|
||
status: string
|
||
leader: string
|
||
leaderPhone: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/depts/${id}`, params: data })
|
||
}
|
||
|
||
export function fetchDeleteDept(id: string) {
|
||
return request.del({ url: `/web/admin/depts/${id}` })
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 站点管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchSiteList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||
return request.get<{
|
||
list: Api.Site.SiteItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({ url: '/web/admin/sites', params })
|
||
}
|
||
|
||
|
||
export function fetchExportSites(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/sites/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
export function fetchCreateSite(data: {
|
||
siteName: string
|
||
siteCode: string
|
||
siteType?: string
|
||
status?: string
|
||
address?: string
|
||
contactName?: string
|
||
contactPhone?: string
|
||
businessScope?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/sites', params: data })
|
||
}
|
||
export function fetchUpdateSite(
|
||
id: string,
|
||
data: Partial<{
|
||
siteName: string
|
||
siteCode: string
|
||
siteType: string
|
||
status: string
|
||
address: string
|
||
contactName: string
|
||
contactPhone: string
|
||
businessScope: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/sites/${id}`, params: data })
|
||
}
|
||
export function fetchDeleteSite(id: string) {
|
||
return request.del({ url: `/web/admin/sites/${id}` })
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 职位管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchPostList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||
return request.get<{
|
||
list: Api.Post.PostItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({ url: '/web/admin/posts', params })
|
||
}
|
||
|
||
|
||
export function fetchExportPosts(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/posts/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
export function fetchCreatePost(data: {
|
||
postName: string
|
||
postCode: string
|
||
status?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/posts', params: data })
|
||
}
|
||
export function fetchUpdatePost(
|
||
id: string,
|
||
data: Partial<{
|
||
postName: string
|
||
postCode: string
|
||
status: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/posts/${id}`, params: data })
|
||
}
|
||
export function fetchDeletePost(id: string) {
|
||
return request.del({ url: `/web/admin/posts/${id}` })
|
||
}
|
||
|
||
export function fetchPostBoundUserIds(postId: string) {
|
||
return request.get<{ userIds: string[] }>({ url: `/web/admin/posts/${postId}/users` })
|
||
}
|
||
|
||
export function fetchUpdatePostBoundUsers(postId: string, userIds: string[]) {
|
||
return request.put({
|
||
url: `/web/admin/posts/${postId}/users`,
|
||
params: { userIds },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 菜单管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchMenuTree(params?: { keyword?: string }) {
|
||
return request.get<Api.Menu.MenuItem[]>({
|
||
url: '/web/admin/menus',
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchExportMenus(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/menus/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
|
||
export function fetchCreateMenu(data: {
|
||
menuName: string
|
||
parentId?: string
|
||
menuType?: string
|
||
path?: string
|
||
component?: string
|
||
perms?: string
|
||
isFrame?: number
|
||
visible?: string
|
||
status?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/menus', params: data })
|
||
}
|
||
|
||
export function fetchUpdateMenu(
|
||
id: string,
|
||
data: Partial<{
|
||
menuName: string
|
||
parentId: string
|
||
menuType: string
|
||
path: string
|
||
component: string
|
||
perms: string
|
||
isFrame: number
|
||
visible: string
|
||
status: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({ url: `/web/admin/menus/${id}`, params: data })
|
||
}
|
||
|
||
export function fetchDeleteMenu(id: string) {
|
||
return request.del({ url: `/web/admin/menus/${id}` })
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 角色管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchRoleList(params?: { page?: number; pageSize?: number; keyword?: string }) {
|
||
return request.get<{
|
||
list: Api.Role.RoleItem[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
totalPages: number
|
||
}>({ url: '/web/admin/role-management', params })
|
||
}
|
||
|
||
|
||
export function fetchExportRoles(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/admin/role-management/export',
|
||
data,
|
||
responseType: 'blob'
|
||
})
|
||
}
|
||
export function fetchRoleDetail(id: string) {
|
||
return request.get<Api.Role.RoleItem>({ url: `/web/admin/role-management/${id}` })
|
||
}
|
||
export function fetchCreateRole(data: {
|
||
roleName: string
|
||
dataScope?: string
|
||
status?: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({ url: '/web/admin/role-management', params: data, showSuccessMessage: true })
|
||
}
|
||
export function fetchUpdateRole(
|
||
id: string,
|
||
data: Partial<{
|
||
roleName: string
|
||
dataScope: string
|
||
status: string
|
||
orderNum: number
|
||
remark: string
|
||
}>
|
||
) {
|
||
return request.put({
|
||
url: `/web/admin/role-management/${id}`,
|
||
params: data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
export function fetchDeleteRole(id: string) {
|
||
return request.del({ url: `/web/admin/role-management/${id}`, showSuccessMessage: true })
|
||
}
|
||
export function fetchRoleMenuIds(roleId: string) {
|
||
return request.get<{ menuIds: string[] }>({ url: `/web/admin/role-management/${roleId}/menus` })
|
||
}
|
||
export function fetchUpdateRoleMenus(roleId: string, menuIds: string[]) {
|
||
return request.put({
|
||
url: `/web/admin/role-management/${roleId}/menus`,
|
||
params: { menuIds },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
export function fetchRoleDataScope(roleId: string) {
|
||
return request.get<{
|
||
dataScope: string
|
||
scopeDetails: Array<{ scopeType: string; scopeValue: string }>
|
||
}>({ url: `/web/admin/role-management/${roleId}/data-scope` })
|
||
}
|
||
export function fetchUpdateRoleDataScope(
|
||
roleId: string,
|
||
data: { dataScope: string; scopeDetails?: Array<{ scopeType: string; scopeValue: string }> }
|
||
) {
|
||
return request.put({
|
||
url: `/web/admin/role-management/${roleId}/data-scope`,
|
||
params: data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 附件管理
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchUploadAttachment(data: FormData) {
|
||
return request.post<{
|
||
id: string
|
||
fileName: string
|
||
fileUrl: string
|
||
fileSize: number
|
||
fileSizeDisplay?: string
|
||
fileType?: string
|
||
bizType?: string
|
||
}>({
|
||
url: '/web/admin/attachment/upload',
|
||
data
|
||
})
|
||
}
|
||
|
||
export function fetchAttachmentDownloadUrl(data: { fileUrl: string; fileName?: string }) {
|
||
return request.post<{ downloadUrl: string }>({
|
||
url: '/web/admin/attachment/download-url',
|
||
data
|
||
})
|
||
}
|
||
|
||
export function fetchAttachmentPreviewUrl(data: { fileUrl: string; fileName?: string }) {
|
||
return request.post<{ previewUrl: string }>({
|
||
url: '/web/admin/attachment/preview-url',
|
||
data
|
||
})
|
||
}
|