Explorar o código

feat(web-admin): add OA instance comment API clients

Co-authored-by: Cursor <cursoragent@cursor.com>
zlwu hai 1 mes
pai
achega
a1b95b1f0b
Modificáronse 1 ficheiros con 48 adicións e 0 borrados
  1. 48 0
      web-admin/src/api/oaApproval.ts

+ 48 - 0
web-admin/src/api/oaApproval.ts

@@ -331,6 +331,54 @@ export function fetchOaInstanceDetail(id: string) {
   })
 }
 
+export type OaCommentAttachmentRef = {
+  fieldKey: string
+  fieldLabel?: string
+  url: string
+  fileName: 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
+}
+
+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[] }
+) {
+  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',
   params?: {