| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 |
- 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
- initiatorDeptId?: 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
- initiatorDeptId?: 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 }
- })
- }
- export type OaBankReceiptItem = {
- id?: string
- fileName: string
- fileUrl: string
- fileType?: string
- fileSize?: number | null
- createTime?: string
- }
- export function fetchOaBankReceipts(instanceId: string) {
- return request.get<{ items: OaBankReceiptItem[] }>({
- url: `${BASE}/instances/${instanceId}/bank-receipts`
- })
- }
- export function fetchReplaceOaBankReceipts(
- instanceId: string,
- items: Array<{
- fileUrl: string
- fileName?: string
- fileType?: string
- fileSize?: number | null
- }>
- ) {
- return request.put<{ items: OaBankReceiptItem[] }>({
- url: `${BASE}/instances/${instanceId}/bank-receipts`,
- data: { items }
- })
- }
|