feat(oa): extend mobile OA APIs for drafts, tasks, and detail actions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
730cc99ae7
commit
2dac9d6fbd
2 files changed
+150
-1
No files matched your search
+107
-1
@@ -1,4 +1,4 @@
|
||||
import { get } from './request.js'
|
||||
import { get, post, request } from './request.js'
|
||||
import { getToken } from './auth.js'
|
||||
|
||||
function authHeader() {
|
||||
@@ -6,6 +6,22 @@ function authHeader() {
|
||||
return token ? { Authorization: 'Bearer ' + token } : {}
|
||||
}
|
||||
|
||||
/** 小程序侧无 URLSearchParams 时用手写 query */
|
||||
function buildQuery(params) {
|
||||
const parts = []
|
||||
Object.keys(params || {}).forEach((k) => {
|
||||
const v = params[k]
|
||||
if (v == null || v === '') return
|
||||
parts.push(encodeURIComponent(k) + '=' + encodeURIComponent(String(v)))
|
||||
})
|
||||
return parts.join('&')
|
||||
}
|
||||
|
||||
function withQuery(path, params) {
|
||||
const qs = buildQuery(params)
|
||||
return qs ? path + '?' + qs : path
|
||||
}
|
||||
|
||||
export function fetchOaGroupList() {
|
||||
return get('/web/admin/oa-approval/groups', authHeader())
|
||||
}
|
||||
@@ -20,3 +36,93 @@ export function fetchOaTemplateDetail(appId) {
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
// —— drafts ——
|
||||
|
||||
export function fetchOaInstanceDraftList(params) {
|
||||
const p = params || {}
|
||||
return get(
|
||||
withQuery('/web/admin/oa-approval/drafts', {
|
||||
keyword: p.keyword,
|
||||
groupId: p.groupId,
|
||||
updateTimeFrom: p.updateTimeFrom,
|
||||
updateTimeTo: p.updateTimeTo,
|
||||
page: p.page != null ? p.page : 1,
|
||||
pageSize: p.pageSize != null ? p.pageSize : 20
|
||||
}),
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchOaInstanceDraftCount() {
|
||||
return get('/web/admin/oa-approval/drafts/count', authHeader())
|
||||
}
|
||||
|
||||
export function fetchDeleteOaInstanceDraft(id) {
|
||||
return request({
|
||||
url: '/web/admin/oa-approval/drafts/' + encodeURIComponent(id),
|
||||
method: 'DELETE',
|
||||
header: authHeader()
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchBatchDeleteOaInstanceDrafts(ids) {
|
||||
return post(
|
||||
'/web/admin/oa-approval/drafts/batch-delete',
|
||||
{ ids: ids || [] },
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchSubmitOaInstanceDraft(id, data) {
|
||||
return post(
|
||||
'/web/admin/oa-approval/drafts/' + encodeURIComponent(id) + '/submit',
|
||||
data || {},
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
// —— tasks ——
|
||||
|
||||
export function fetchOaTasks(kind, params) {
|
||||
const p = params || {}
|
||||
const appName = (p.appName || '').trim()
|
||||
const initiatorName = (p.initiatorName || '').trim()
|
||||
const query = {
|
||||
page: p.page != null ? p.page : 1,
|
||||
pageSize: p.pageSize != null ? p.pageSize : 20
|
||||
}
|
||||
if (kind === 'cc') {
|
||||
query.readStatus = p.readStatus != null && p.readStatus !== '' ? p.readStatus : 'unread'
|
||||
}
|
||||
if (appName) query.appName = appName
|
||||
if (initiatorName) query.initiatorName = initiatorName
|
||||
return get(
|
||||
withQuery('/web/admin/oa-approval/tasks/' + encodeURIComponent(kind), query),
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchOaPendingTaskCount() {
|
||||
return get('/web/admin/oa-approval/tasks/pending/count', authHeader())
|
||||
}
|
||||
|
||||
export function fetchOaCcUnreadCount() {
|
||||
return get('/web/admin/oa-approval/tasks/cc/unread-count', authHeader())
|
||||
}
|
||||
|
||||
export function fetchMarkOaCcTaskRead(taskId) {
|
||||
return post(
|
||||
'/web/admin/oa-approval/tasks/' + encodeURIComponent(taskId) + '/read',
|
||||
{},
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchBatchMarkOaCcTasksRead(ids) {
|
||||
return post(
|
||||
'/web/admin/oa-approval/tasks/cc/read-batch',
|
||||
{ ids: ids || [] },
|
||||
authHeader()
|
||||
)
|
||||
}
|
||||
@@ -87,4 +87,47 @@ export function fetchCnHolidayRange(start, end) {
|
||||
return get('/cn-holiday/range', { start, end })
|
||||
}
|
||||
|
||||
// —— 详情 / 办理动作(对齐 web-admin oaApproval.ts)——
|
||||
|
||||
export function fetchOaInstanceDetail(id) {
|
||||
return get(`/web/admin/oa-approval/instances/${encodeURIComponent(id)}`)
|
||||
}
|
||||
|
||||
export function fetchApproveOaTask(taskId, comment) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/approve`, {
|
||||
comment
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchRejectOaTask(taskId, comment) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/reject`, {
|
||||
comment
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchReturnOaTask(taskId, comment) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/return`, {
|
||||
comment
|
||||
})
|
||||
}
|
||||
|
||||
export function fetchAddSignOaTask(taskId, data) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/add-sign`, data)
|
||||
}
|
||||
|
||||
export function fetchTransferOaTask(taskId, data) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/transfer`, data)
|
||||
}
|
||||
|
||||
export function fetchWithdrawOaInstance(instanceId) {
|
||||
return post(
|
||||
`/web/admin/oa-approval/instances/${encodeURIComponent(instanceId)}/withdraw`,
|
||||
{}
|
||||
)
|
||||
}
|
||||
|
||||
export function fetchMarkOaCcTaskRead(taskId) {
|
||||
return post(`/web/admin/oa-approval/tasks/${encodeURIComponent(taskId)}/read`, {})
|
||||
}
|
||||
|
||||
export { post, put }
|
||||
Reference in new issue
Block a user