feat: 完善员工门店管理交互
This commit is contained in:
+47
-1
@@ -11,6 +11,13 @@ const API_PREFIX = "/api";
|
||||
/** 后端员工与门店共用的启停状态枚举。 */
|
||||
export type EmployeeStatus = "ACTIVE" | "INACTIVE";
|
||||
export type StoreStatus = "ACTIVE" | "INACTIVE";
|
||||
export type EmployeeStatusTagVariant = "success" | "warning" | "default";
|
||||
|
||||
export interface EmployeeStatusTag {
|
||||
code: "EMPLOYEE_ACTIVE" | "EMPLOYEE_INACTIVE" | "STORE_INACTIVE";
|
||||
label: string;
|
||||
variant: EmployeeStatusTagVariant;
|
||||
}
|
||||
|
||||
/** 员工列表中展示的角色摘要。 */
|
||||
export interface RoleSummary {
|
||||
@@ -23,9 +30,11 @@ export interface Employee {
|
||||
id: number;
|
||||
storeId: number;
|
||||
storeName: string;
|
||||
storeStatus: StoreStatus;
|
||||
name: string;
|
||||
phone: string;
|
||||
status: EmployeeStatus;
|
||||
statusTags: EmployeeStatusTag[];
|
||||
remark: string | null;
|
||||
roles: RoleSummary[];
|
||||
createdAt: string;
|
||||
@@ -53,6 +62,10 @@ export interface Store extends StoreOption {
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface StoreDetail extends Store {
|
||||
employees: Employee[];
|
||||
}
|
||||
|
||||
export interface Role extends RoleOption {
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -150,6 +163,11 @@ export interface EmployeePayload {
|
||||
roleIds: number[];
|
||||
}
|
||||
|
||||
export interface EmployeePasswordPayload {
|
||||
oldPassword: string;
|
||||
newPassword: string;
|
||||
}
|
||||
|
||||
/** access-manage 后端普通响应包裹结构。 */
|
||||
export interface ApiResult<T> {
|
||||
success: boolean;
|
||||
@@ -205,7 +223,10 @@ export const listRolePage = (params: RoleListParams) => {
|
||||
};
|
||||
|
||||
export const getStore = (id: number) => {
|
||||
return http.request<ApiResult<Store>>("get", `${API_PREFIX}/stores/${id}`);
|
||||
return http.request<ApiResult<StoreDetail>>(
|
||||
"get",
|
||||
`${API_PREFIX}/stores/${id}`
|
||||
);
|
||||
};
|
||||
|
||||
export const createStore = (data: StorePayload) => {
|
||||
@@ -224,6 +245,13 @@ export const deleteStore = (id: number) => {
|
||||
return http.request<void>("delete", `${API_PREFIX}/stores/${id}`);
|
||||
};
|
||||
|
||||
export const removeStoreEmployee = (storeId: number, employeeId: number) => {
|
||||
return http.request<void>(
|
||||
"delete",
|
||||
`${API_PREFIX}/stores/${storeId}/employees/${employeeId}`
|
||||
);
|
||||
};
|
||||
|
||||
/** 角色接口:维护员工可绑定的权限角色。 */
|
||||
export const getRole = (id: number) => {
|
||||
return http.request<ApiResult<Role>>("get", `${API_PREFIX}/roles/${id}`);
|
||||
@@ -283,6 +311,24 @@ export const updateEmployeeStatus = (id: number, status: EmployeeStatus) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const updateEmployeePassword = (
|
||||
id: number,
|
||||
data: EmployeePasswordPayload
|
||||
) => {
|
||||
return http.request<ApiResult<Employee>>(
|
||||
"patch",
|
||||
`${API_PREFIX}/employees/${id}/password`,
|
||||
{ data }
|
||||
);
|
||||
};
|
||||
|
||||
export const resetEmployeePassword = (id: number) => {
|
||||
return http.request<ApiResult<Employee>>(
|
||||
"patch",
|
||||
`${API_PREFIX}/employees/${id}/password/reset`
|
||||
);
|
||||
};
|
||||
|
||||
export const deleteEmployee = (id: number) => {
|
||||
return http.request<void>("delete", `${API_PREFIX}/employees/${id}`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user