Blame view

src/api/project/quest.ts 2.43 KB
1
2
3
4
5
6
7
import { defHttp } from '/@/utils/http/axios';

enum Api {
    QUEST_LIST = '/order/erp/quest/list_by_page',
    QUEST_CREATE = '/order/erp/quest/add',
    QUEST_DELETE = '/order/erp/quest/delete_by_id',
    QUEST_UPDATE = '/order/erp/quest/edit',
chenhang4442024 authored
8
9
10
11
    QUEST_SET_STATUS = '/order/erp/quest/setStatus',
    QUEST_RELEASE_LIST = '/order/erp/quest/realseList',
    QUEST_GET_ALL = '/order/erp/quest/get_all',
    QUEST_QUERY_TITLE = '/order/erp/quest/queryTitle',
12
13
14
15
16
}

export const questUpdate=async(data:any)=>{
  const res=await defHttp.post<any>({
    url: Api.QUEST_UPDATE,
chenhang4442024 authored
17
18
19
    data,
    successMsg: '操作成功'
  });
20
21
22
23
  return res;
}

export const questDelete = async (ids: number[]) => {
chenhang4442024 authored
24
25
26
27
28
  const res = await defHttp.post<any>({ 
    url: Api.QUEST_DELETE, 
    data: {ids},
    successMsg: '删除成功'
  });
29
30
31
32
  return res;
};

export const questCreate = async (data: any) => {
chenhang4442024 authored
33
34
35
36
37
  const res = await defHttp.post<any>({ 
    url: Api.QUEST_CREATE, 
    data,
    successMsg: '创建成功'
  });
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  return res;
};

export const getQuestList = async (params: any) => {
  const res=await defHttp.post<any>({
    url: Api.QUEST_LIST,
    params,
  });
  const result={
      items: res.records,
      total: res.total,
    };
    return result;
};
chenhang4442024 authored
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

export const setQuestStatus = async (data: { id: number; status: number; refuseRemark?: string }) => {
  const res = await defHttp.post<any>({ 
    url: Api.QUEST_SET_STATUS, 
    data,
    successMsg: data.status === 10 ? '审核通过成功' : '审核驳回成功'
  });
  return res;
};

export const getQuestReleaseData = async (id: number) => {
  const res = await defHttp.post<any>({ 
    url: Api.QUEST_RELEASE_LIST, 
    data: { id } 
  });

  // 如果返回的是带记录和总数的格式,处理为标准格式
  if (res && res.records && res.total !== undefined) {
    return {
      items: res.records,
      total: res.total
    };
  }

  return res;
};

/**
 * 获取所有扣款原因列表
 * @returns 扣款原因列表数组,包含id和title
 */
export const getAllQuests = async () => {
  const res = await defHttp.post<any>({
    url: Api.QUEST_GET_ALL
  });
  return res;
};

/**
 * 根据输入的关键词搜索匹配的扣款原因
 * @param title 搜索关键词
 * @returns 匹配的扣款原因列表数组,包含id和title
 */
export const queryQuestTitle = async (title: string) => {
  const res = await defHttp.post<any>({
    url: Api.QUEST_QUERY_TITLE,
    data: { title }
  });
  return res;
};