Blame view

src/api/project/account.ts 1.8 KB
sanmu authored
1
2
3
4
5
import { defHttp } from '/@/utils/http/axios';

enum Api {
  ROLE_LIST = '/order/erp/roles/all',
  USER_LIST = '/order/erp/users/list_by_page',
sanmu authored
6
7
8
  USER_ADD = '/order/erp/users/add',
  USER_EDIT = '/order/erp/users/edit',
  USER_DELETE = '/order/erp/users/delete',
sanmu authored
9
10
  USER_OPT = '/order/erp/users/opt',
  USER_RESET_PASSWORD = '/order/erp/users/reset', // 管理员重置密码
sanmu authored
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
}

export const getRoleList = async (params: any) => {
  return defHttp.post<any>({
    url: Api.ROLE_LIST,
    params,
  });
};

export const getUserList = async (params: any) => {
  const res = await defHttp.post<any>({
    url: Api.USER_LIST,
    params,
  });
  return new Promise((resolve) => {
sanmu authored
26
27
28
29
    resolve({
      items: res.records,
      total: res.total,
    });
sanmu authored
30
31
32
33
34
35
36
37
38
39
40
  });
};

// export const getAccountList = async (params: AccountParams) => {
//   const res = await defHttp.post<AccountListGetResultModel>({ url: Api.AccountList, params });
//   return new Promise((resolve) => {
//     resolve(res.records);
//   });
// };

export const userAdd = async (params: any) => {
sanmu authored
41
42
43
44
45
46
47
  return defHttp.post<any>(
    {
      url: Api.USER_ADD,
      params,
    },
    { message: '保存成功' },
  );
sanmu authored
48
49
50
};

export const userEdit = async (params: any) => {
sanmu authored
51
52
53
54
55
56
57
  return defHttp.post<any>(
    {
      url: Api.USER_EDIT,
      params,
    },
    { message: '保存成功' },
  );
sanmu authored
58
59
60
61
62
63
64
65
};

export const userDelete = async (params: any) => {
  return defHttp.post<any>({
    url: Api.USER_DELETE,
    params,
  });
};
sanmu authored
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85

export const userOpt = async (params: any) => {
  return defHttp.post<any>(
    {
      url: Api.USER_OPT,
      params,
    },
    { message: '操作成功' },
  );
};

export const userResetPassword = async (params: any) => {
  return defHttp.post<any>(
    {
      url: Api.USER_RESET_PASSWORD,
      params,
    },
    { message: '重置密码成功' },
  );
};