feat(frontend): 更新前端审批服务
- 添加submitApproval提交审批方法 - 添加cancelApproval取消审批方法 - 更新getPendingApprovals/getApprovedList/getMyApplications方法传递userId - 更新approve方法支持operatorId参数
This commit is contained in:
@@ -161,8 +161,8 @@ class ApprovalService {
|
|||||||
/**
|
/**
|
||||||
* 获取待审批列表
|
* 获取待审批列表
|
||||||
*/
|
*/
|
||||||
async getPendingApprovals(): Promise<ApprovalRecord[]> {
|
async getPendingApprovals(userId: number): Promise<ApprovalRecord[]> {
|
||||||
const response = await fetch(`${this.baseUrl}/approval/pending`, {
|
const response = await fetch(`${this.baseUrl}/approval/pending?userId=${userId}`, {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
})
|
})
|
||||||
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
||||||
@@ -175,8 +175,8 @@ class ApprovalService {
|
|||||||
/**
|
/**
|
||||||
* 获取已审批列表
|
* 获取已审批列表
|
||||||
*/
|
*/
|
||||||
async getApprovedList(): Promise<ApprovalRecord[]> {
|
async getApprovedList(userId: number): Promise<ApprovalRecord[]> {
|
||||||
const response = await fetch(`${this.baseUrl}/approval/approved`, {
|
const response = await fetch(`${this.baseUrl}/approval/processed?userId=${userId}`, {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
})
|
})
|
||||||
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
||||||
@@ -189,8 +189,8 @@ class ApprovalService {
|
|||||||
/**
|
/**
|
||||||
* 获取我发起的审批
|
* 获取我发起的审批
|
||||||
*/
|
*/
|
||||||
async getMyApplications(): Promise<ApprovalRecord[]> {
|
async getMyApplications(userId: number): Promise<ApprovalRecord[]> {
|
||||||
const response = await fetch(`${this.baseUrl}/approval/my`, {
|
const response = await fetch(`${this.baseUrl}/approval/my?userId=${userId}`, {
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
})
|
})
|
||||||
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
const result = await response.json() as ApiResponse<ApprovalRecord[]>
|
||||||
@@ -205,7 +205,8 @@ class ApprovalService {
|
|||||||
*/
|
*/
|
||||||
async approve(data: {
|
async approve(data: {
|
||||||
recordId: number
|
recordId: number
|
||||||
action: 'approve' | 'reject' | 'transfer'
|
action: 'APPROVE' | 'REJECT' | 'TRANSFER'
|
||||||
|
operatorId: number
|
||||||
comment?: string
|
comment?: string
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
const response = await fetch(`${this.baseUrl}/approval/handle`, {
|
const response = await fetch(`${this.baseUrl}/approval/handle`, {
|
||||||
@@ -220,6 +221,46 @@ class ApprovalService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提交审批申请
|
||||||
|
*/
|
||||||
|
async submitApproval(data: {
|
||||||
|
flowId: number
|
||||||
|
bizType: string
|
||||||
|
bizId: number
|
||||||
|
title: string
|
||||||
|
applicantId: number
|
||||||
|
applyReason: string
|
||||||
|
}): Promise<number> {
|
||||||
|
const response = await fetch(`${this.baseUrl}/approval/submit`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
})
|
||||||
|
const result = await response.json() as ApiResponse<{ recordId: number }>
|
||||||
|
if (result.code !== 200) {
|
||||||
|
throw new Error(result.message || '提交审批失败')
|
||||||
|
}
|
||||||
|
return result.data.recordId
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消审批
|
||||||
|
*/
|
||||||
|
async cancelApproval(recordId: number, operatorId: number): Promise<void> {
|
||||||
|
const response = await fetch(`${this.baseUrl}/approval/cancel`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
credentials: 'include',
|
||||||
|
body: JSON.stringify({ recordId, operatorId })
|
||||||
|
})
|
||||||
|
const result = await response.json() as ApiResponse<void>
|
||||||
|
if (result.code !== 200) {
|
||||||
|
throw new Error(result.message || '取消审批失败')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取审批记录详情
|
* 获取审批记录详情
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user