624 lines
15 KiB
TypeScript
624 lines
15 KiB
TypeScript
import request from '@/utils/http'
|
||
|
||
const BASE = '/web/admin/oa-approval'
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 收款账户
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchOaReceiveAccountList(params?: {
|
||
keyword?: string
|
||
accountType?: string
|
||
page?: number
|
||
pageSize?: number
|
||
}) {
|
||
return request.get<{ list: any[]; total: number }>({
|
||
url: `${BASE}/receive-accounts`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchOaReceiveAccountOptions() {
|
||
return request.get<{ list: any[] }>({ url: `${BASE}/receive-accounts/options` })
|
||
}
|
||
|
||
export function fetchOaReceiveAccountDetail(id: string) {
|
||
return request.get<any>({ url: `${BASE}/receive-accounts/${id}` })
|
||
}
|
||
|
||
export function fetchCreateOaReceiveAccount(data: Record<string, unknown>) {
|
||
return request.post({ url: `${BASE}/receive-accounts`, data, showSuccessMessage: true })
|
||
}
|
||
|
||
export function fetchUpdateOaReceiveAccount(id: string, data: Record<string, unknown>) {
|
||
return request.put({ url: `${BASE}/receive-accounts/${id}`, data, showSuccessMessage: true })
|
||
}
|
||
|
||
export function fetchDeleteOaReceiveAccount(id: string) {
|
||
return request.del({ url: `${BASE}/receive-accounts/${id}`, showSuccessMessage: true })
|
||
}
|
||
|
||
export function fetchBatchDeleteOaReceiveAccounts(ids: string[]) {
|
||
return request.post({
|
||
url: `${BASE}/receive-accounts/batch-delete`,
|
||
data: { ids },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 分组 / 应用 / 草稿 / 发布
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchOaGroupList() {
|
||
return request.get<{ list: any[] }>({ url: `${BASE}/groups` })
|
||
}
|
||
|
||
export function fetchCreateOaGroup(data: {
|
||
groupName: string
|
||
orderNum?: number
|
||
remark?: string
|
||
}) {
|
||
return request.post({
|
||
url: `${BASE}/groups`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchUpdateOaGroup(
|
||
id: string,
|
||
data: Partial<{ groupName: string; orderNum: number; remark: string }>
|
||
) {
|
||
return request.put({
|
||
url: `${BASE}/groups/${id}`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchDeleteOaGroup(id: string) {
|
||
return request.del({
|
||
url: `${BASE}/groups/${id}`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchOaAppList(params?: {
|
||
groupId?: string
|
||
keyword?: string
|
||
status?: string
|
||
}) {
|
||
return request.get<{ list: any[] }>({
|
||
url: `${BASE}/apps`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchCreateOaApp(data: Record<string, any>) {
|
||
return request.post({
|
||
url: `${BASE}/apps`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchUpdateOaApp(id: string, data: Record<string, any>) {
|
||
return request.put({
|
||
url: `${BASE}/apps/${id}`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchDeleteOaApp(id: string) {
|
||
return request.del({
|
||
url: `${BASE}/apps/${id}`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchCopyOaApp(id: string) {
|
||
return request.post({
|
||
url: `${BASE}/apps/${id}/copy`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchOaAppDraft(appId: string) {
|
||
return request.get<any>({ url: `${BASE}/apps/${appId}/draft` })
|
||
}
|
||
|
||
export function fetchSaveOaAppDraft(
|
||
appId: string,
|
||
data: {
|
||
basic?: Record<string, any>
|
||
formSchemaJson?: any
|
||
flowTreeJson?: any
|
||
advancedSettingsJson?: any
|
||
}
|
||
) {
|
||
return request.put({
|
||
url: `${BASE}/apps/${appId}/draft`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchPublishOaApp(appId: string) {
|
||
return request.post({
|
||
url: `${BASE}/apps/${appId}/publish`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 运行时
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchOaTemplates() {
|
||
return request.get<{ list: any[] }>({ url: `${BASE}/templates` })
|
||
}
|
||
|
||
export function fetchOaTemplateDetail(appId: string) {
|
||
return request.get<any>({ url: `${BASE}/templates/${appId}` })
|
||
}
|
||
|
||
/** 发起前审批流预览(条件齐后返回最终路径) */
|
||
export function fetchOaFlowPreview(
|
||
appId: string,
|
||
opts?: { formData?: Record<string, any>; initiatorSelectByNode?: Record<string, string[]> }
|
||
) {
|
||
return request.post<{
|
||
resolved: boolean
|
||
message?: string
|
||
steps: OaFlowPreviewStep[]
|
||
}>({
|
||
url: `${BASE}/templates/${appId}/flow-preview`,
|
||
data: {
|
||
formData: opts?.formData || {},
|
||
initiatorSelectByNode: opts?.initiatorSelectByNode || undefined
|
||
},
|
||
showSuccessMessage: false
|
||
})
|
||
}
|
||
|
||
export type OaFlowPreviewStep = {
|
||
id: string
|
||
type: 'start' | 'approval' | 'cc' | 'branch' | 'end' | string
|
||
name: string
|
||
signMode?: string
|
||
assigneeType?: string
|
||
assigneeTypes?: string[]
|
||
meta?: string
|
||
people?: Array<{ id: string; nickName: string }>
|
||
resolveError?: string
|
||
}
|
||
|
||
export function fetchStartOaInstance(data: {
|
||
appId: string
|
||
formData?: Record<string, any>
|
||
title?: string
|
||
initiatorDeptId?: string
|
||
initiatorSelectByNode?: Record<string, string[]>
|
||
relatedInstanceIds?: string[]
|
||
}) {
|
||
return request.post({
|
||
url: `${BASE}/instances`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 发起审批草稿箱
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export function fetchOaInstanceDraftList(params?: {
|
||
keyword?: string
|
||
groupId?: string
|
||
updateTimeFrom?: string
|
||
updateTimeTo?: string
|
||
page?: number
|
||
pageSize?: number
|
||
}) {
|
||
return request.get<{ list: any[]; total: number }>({
|
||
url: `${BASE}/drafts`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchOaInstanceDraftCount() {
|
||
return request.get<{ count: number }>({ url: `${BASE}/drafts/count` })
|
||
}
|
||
|
||
export function fetchOaInstanceDraftDetail(id: string) {
|
||
return request.get<any>({ url: `${BASE}/drafts/${id}` })
|
||
}
|
||
|
||
export function fetchCreateOaInstanceDraft(data: {
|
||
appId: string
|
||
formData?: Record<string, any>
|
||
title?: string
|
||
initiatorDeptId?: string
|
||
initiatorSelectByNode?: Record<string, string[]>
|
||
}) {
|
||
return request.post({
|
||
url: `${BASE}/drafts`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchUpdateOaInstanceDraft(
|
||
id: string,
|
||
data: {
|
||
formData?: Record<string, any>
|
||
title?: string
|
||
initiatorDeptId?: string
|
||
initiatorSelectByNode?: Record<string, string[]>
|
||
}
|
||
) {
|
||
return request.put({
|
||
url: `${BASE}/drafts/${id}`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchDeleteOaInstanceDraft(id: string) {
|
||
return request.del({
|
||
url: `${BASE}/drafts/${id}`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchBatchDeleteOaInstanceDrafts(ids: string[]) {
|
||
return request.post({
|
||
url: `${BASE}/drafts/batch-delete`,
|
||
data: { ids },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchSubmitOaInstanceDraft(
|
||
id: string,
|
||
data?: {
|
||
formData?: Record<string, any>
|
||
title?: string
|
||
initiatorDeptId?: string
|
||
initiatorSelectByNode?: Record<string, string[]>
|
||
}
|
||
) {
|
||
return request.post({
|
||
url: `${BASE}/drafts/${id}/submit`,
|
||
data: data || {},
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
/** 详情审批进度投影项(后端 build_progress_items) */
|
||
export interface OaProgressPerson {
|
||
id?: string
|
||
nickName?: string
|
||
status?: string
|
||
timestamp?: string
|
||
commentText?: string
|
||
taskId?: string
|
||
transferToUserId?: string
|
||
transferToUserName?: string
|
||
}
|
||
|
||
export interface OaProgressItem {
|
||
kind: 'submit' | 'task' | 'pending_node' | 'terminal' | string
|
||
roundNo?: number
|
||
title?: string
|
||
status?: string
|
||
assigneeUserId?: string
|
||
assigneeUserName?: string
|
||
timestamp?: string
|
||
commentText?: string
|
||
nodeKey?: string
|
||
taskType?: string
|
||
resolveSource?: string
|
||
taskId?: string
|
||
people?: OaProgressPerson[]
|
||
}
|
||
|
||
export function fetchOaInstanceDetail(id: string) {
|
||
return request.get<{ progress?: OaProgressItem[]; tasks?: any[] } & Record<string, any>>({
|
||
url: `${BASE}/instances/${id}`
|
||
})
|
||
}
|
||
|
||
export type OaCommentAttachmentRef = {
|
||
source?: 'form' | 'upload' | string
|
||
fieldKey?: string
|
||
fieldLabel?: string
|
||
url: string
|
||
fileName: string
|
||
}
|
||
|
||
export type OaCommentMention = {
|
||
userId: string
|
||
userName: string
|
||
}
|
||
|
||
export type OaInstanceComment = {
|
||
id: string
|
||
instanceId?: string
|
||
content: string
|
||
attachmentRefs: OaCommentAttachmentRef[]
|
||
status: 'normal' | 'revoked' | string
|
||
revokedTime?: string
|
||
createBy: string
|
||
createByName?: string
|
||
createTime: string
|
||
canRevoke?: boolean
|
||
mentions?: OaCommentMention[]
|
||
}
|
||
|
||
export function fetchOaFormAttachments(instanceId: string) {
|
||
return request.get<{ items: Array<{ fieldKey: string; fieldLabel: string; files: OaCommentAttachmentRef[] }> }>({
|
||
url: `${BASE}/instances/${instanceId}/form-attachments`
|
||
})
|
||
}
|
||
|
||
export function fetchOaInstanceComments(instanceId: string) {
|
||
return request.get<{ list: OaInstanceComment[] }>({
|
||
url: `${BASE}/instances/${instanceId}/comments`
|
||
})
|
||
}
|
||
|
||
export function fetchCreateOaComment(
|
||
instanceId: string,
|
||
data: {
|
||
content?: string
|
||
attachmentRefs?: OaCommentAttachmentRef[]
|
||
mentionUserIds?: string[]
|
||
}
|
||
) {
|
||
return request.post<OaInstanceComment>({
|
||
url: `${BASE}/instances/${instanceId}/comments`,
|
||
data
|
||
})
|
||
}
|
||
|
||
export function fetchRevokeOaComment(instanceId: string, commentId: string) {
|
||
return request.post<OaInstanceComment>({
|
||
url: `${BASE}/instances/${instanceId}/comments/${commentId}/revoke`
|
||
})
|
||
}
|
||
|
||
export function fetchOaTasks(
|
||
kind: 'pending' | 'done' | 'mine' | 'cc' | 'mention',
|
||
params?: {
|
||
readStatus?: 'unread' | 'read' | 'all'
|
||
appName?: string
|
||
initiatorName?: string
|
||
applyTimeFrom?: string
|
||
applyTimeTo?: string
|
||
instanceStatus?: string
|
||
page?: number
|
||
pageSize?: number
|
||
}
|
||
) {
|
||
const appName = (params?.appName || '').trim()
|
||
const initiatorName = (params?.initiatorName || '').trim()
|
||
const applyTimeFrom = (params?.applyTimeFrom || '').trim()
|
||
const applyTimeTo = (params?.applyTimeTo || '').trim()
|
||
const instanceStatus = (params?.instanceStatus || '').trim()
|
||
return request.get<{ list: any[]; total: number }>({
|
||
url: `${BASE}/tasks/${kind}`,
|
||
params: {
|
||
page: params?.page ?? 1,
|
||
pageSize: params?.pageSize ?? 20,
|
||
...(kind === 'cc' ? { readStatus: params?.readStatus ?? 'unread' } : {}),
|
||
...(appName ? { appName } : {}),
|
||
...(initiatorName ? { initiatorName } : {}),
|
||
...(applyTimeFrom ? { applyTimeFrom } : {}),
|
||
...(applyTimeTo ? { applyTimeTo } : {}),
|
||
...(instanceStatus ? { instanceStatus } : {})
|
||
}
|
||
})
|
||
}
|
||
|
||
export function fetchOaInstanceHistory(params: {
|
||
appId: string
|
||
instanceId?: string
|
||
instanceStatus?: string
|
||
initiatorName?: string
|
||
applyTimeFrom?: string
|
||
applyTimeTo?: string
|
||
finishTimeFrom?: string
|
||
finishTimeTo?: string
|
||
page?: number
|
||
pageSize?: number
|
||
}) {
|
||
return request.get<{
|
||
list: any[]
|
||
total: number
|
||
canViewAll?: boolean
|
||
}>({
|
||
url: `${BASE}/instances/history`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchOaInstanceHistoryExport(params: {
|
||
appId: string
|
||
instanceId?: string
|
||
instanceIds?: string
|
||
instanceStatus?: string
|
||
initiatorName?: string
|
||
applyTimeFrom?: string
|
||
applyTimeTo?: string
|
||
finishTimeFrom?: string
|
||
finishTimeTo?: string
|
||
}) {
|
||
return request.get<{
|
||
appName?: string
|
||
businessColumns?: Array<{
|
||
key: string
|
||
label: string
|
||
kind?: string
|
||
subLabel?: string
|
||
}>
|
||
fixedColumns?: Array<{ key: string; label: string }>
|
||
rows?: Array<{
|
||
index?: number
|
||
id?: string
|
||
business?: Record<string, string>
|
||
fixed?: Record<string, string>
|
||
}>
|
||
total?: number
|
||
}>({
|
||
url: `${BASE}/instances/history/export`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchOaPendingTaskCount() {
|
||
return request.get<{ count: number }>({ url: `${BASE}/tasks/pending/count` })
|
||
}
|
||
|
||
export function fetchOaCcUnreadCount() {
|
||
return request.get<{ count: number }>({ url: `${BASE}/tasks/cc/unread-count` })
|
||
}
|
||
|
||
export function fetchMarkOaCcTaskRead(taskId: string) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/read`,
|
||
showSuccessMessage: false
|
||
})
|
||
}
|
||
|
||
export function fetchBatchMarkOaCcTasksRead(ids: string[]) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/cc/read-batch`,
|
||
data: { ids },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function formatOaCcUnreadBadgeCount(count: number): string {
|
||
return count > 99 ? '99+' : String(count)
|
||
}
|
||
|
||
export function fetchApproveOaTask(taskId: string, comment?: string) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/approve`,
|
||
data: { comment },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchRejectOaTask(taskId: string, comment?: string) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/reject`,
|
||
data: { comment },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchReturnOaTask(taskId: string, comment: string) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/return`,
|
||
data: { comment },
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchAddSignOaTask(
|
||
taskId: string,
|
||
data: { userIds: string[]; comment?: string }
|
||
) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/add-sign`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchTransferOaTask(
|
||
taskId: string,
|
||
data: { targetUserId: string; comment?: string }
|
||
) {
|
||
return request.post({
|
||
url: `${BASE}/tasks/${taskId}/transfer`,
|
||
data,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
export function fetchWithdrawOaInstance(instanceId: string) {
|
||
return request.post({
|
||
url: `${BASE}/instances/${instanceId}/withdraw`,
|
||
showSuccessMessage: true
|
||
})
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 关联审批单
|
||
// ---------------------------------------------------------------------------
|
||
|
||
export type OaRelatedSummaryField = {
|
||
label: string
|
||
value: string
|
||
fullWidth?: boolean
|
||
/** 嵌套关联审批单的 instanceId 列表(可跳转 / 打印递归) */
|
||
relatedIds?: string[]
|
||
}
|
||
|
||
export type OaRelatedSummary = {
|
||
id: string
|
||
unavailable?: boolean
|
||
appName: string
|
||
applyTime: string
|
||
status: string
|
||
fields: OaRelatedSummaryField[]
|
||
}
|
||
|
||
export type OaRelatedCandidatePreviewField = {
|
||
label: string
|
||
value: string
|
||
}
|
||
|
||
export type OaRelatedCandidate = {
|
||
id: string
|
||
appName: string
|
||
title: string
|
||
displayTitle: string
|
||
initiatorUserName: string
|
||
initiatorDeptName: string
|
||
applyTime: string
|
||
status: string
|
||
statusText: string
|
||
currentApproverNames: string
|
||
previewFields: OaRelatedCandidatePreviewField[]
|
||
}
|
||
|
||
export function fetchOaRelatedCandidates(params?: {
|
||
tab?: 'mine' | 'done' | 'cc'
|
||
keyword?: string
|
||
page?: number
|
||
pageSize?: number
|
||
}) {
|
||
return request.get<{
|
||
list: OaRelatedCandidate[]
|
||
total: number
|
||
page: number
|
||
pageSize: number
|
||
}>({
|
||
url: `${BASE}/related-candidates`,
|
||
params
|
||
})
|
||
}
|
||
|
||
export function fetchOaRelatedSummaries(ids: string[], mode: 'picker' | 'view' = 'view') {
|
||
return request.get<{ list: OaRelatedSummary[] }>({
|
||
url: `${BASE}/related-summaries`,
|
||
params: { ids: ids.filter(Boolean).join(','), mode }
|
||
})
|
||
}
|