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