evidence.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * api/evidence.js — 证据包域接口(服务人员个人导出)
  3. * 契约见《健康服务人员助手_后端服务设计_v1.0》§7.5 证据包
  4. * 复用 utils/api.js 的统一 request 封装。
  5. *
  6. * scope=mine:仅导出本人记录(须登录);金额/学时单位不涉及本接口存储,
  7. * 导出文件由后端按既有口径生成(学时分钟、金额整分),前端仅展示下载。
  8. */
  9. import { request } from '@/utils/api.js'
  10. /**
  11. * 发起异步导出 ★返回 {taskNo, id, status:"pending"}(立即返回,不阻塞)
  12. * 入参(扁平,无 scope 嵌套):{type:"training"|"order", orgId?(admin必填), cohortId?, orderId?}
  13. * 服务人员本人导出:固定传 { type },明细由后端按「仅本人记录」聚合;
  14. * 后续如需按批次/单笔导出,追加 cohortId / orderId 即可(扁平)。
  15. * 出参:{taskNo:String, id:Long, status:"pending"}
  16. * ★轮询主键是 taskNo(status 接口按 taskNo 查、mustOwn),不是 id。
  17. * 错误:401 需登录 / 500「导出范围不能为空」
  18. * silent:业务错误由页面 toast,不弹全局
  19. */
  20. export function exportEvidence(type, opts) {
  21. var data = { type: type }
  22. if (opts) {
  23. if (opts.orgId) data.orgId = opts.orgId
  24. if (opts.cohortId) data.cohortId = opts.cohortId
  25. if (opts.orderId) data.orderId = opts.orderId
  26. }
  27. return request('/api/evidence/export', 'POST', data, { silent: true })
  28. }
  29. /**
  30. * 轮询任务状态 ★入参主键 taskNo
  31. * 入参:{taskNo}
  32. * 出参:{taskNo,id,type,status,progress,fileUrl?,error?,expireAt?,createdAt?}
  33. * status ∈ pending|processing|done|failed;fileUrl 出现即 done
  34. * mustOwn(任务属当前用户,他人 taskNo → 404)
  35. * silent:轮询是前台主动行为,失败由页面重试
  36. */
  37. export function getEvidenceStatus(taskNo) {
  38. return request('/api/evidence/status', 'POST', { taskNo: taskNo }, { silent: true })
  39. }