credit.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * api/credit.js — 学时账户域接口
  3. * 契约见《健康服务人员助手_后端服务设计_v1.0》§7.1 培训线
  4. * ⚠ 单位红线:total/theory/practice/gap/hours 一律为【分钟整数】,
  5. * 展示层统一走 utils/format.js 的 creditHours() 做 /60 换算,后端不做小时转换。
  6. * 复用 utils/api.js 的统一 request 封装。
  7. */
  8. import { request } from '@/utils/api.js'
  9. /**
  10. * 我的学时账户
  11. * 入参:{year?: int = 当前年}(历史年走后端台账聚合,明细 status='settled')
  12. * 出参(后端实际实现):{year, totalHours, theoryHours, practiceHours, effectiveHours, pendingHours,
  13. * detail:[{id,sourceType,sourceId,hours,theory,practice,status,effectiveAt}]}
  14. * 兼容键(设计文档 §7.1 旧表述):total / theory / practice / gap / list
  15. * status: pending | effective | objected | rejected | settled
  16. * ⚠ 所有学时数值字段一律为【分钟整数】(含字段名带 Hours 的),展示层统一 creditHours() /60。
  17. * 错误:401
  18. */
  19. export function getCreditMine(year) {
  20. var data = {}
  21. if (year) data.year = year
  22. return request('/api/credit/mine', 'POST', data, { silent: true })
  23. }
  24. /**
  25. * 待生效明细(T+3 待入账)
  26. * 入参:{page, size}
  27. * 出参:{list:[pending 明细], total}
  28. * 错误:401
  29. */
  30. export function getCreditPending(page, size) {
  31. return request('/api/credit/pending', 'POST', {
  32. page: page || 1,
  33. size: size || 20
  34. }, { silent: true })
  35. }
  36. /**
  37. * 学时异议 ★幂等
  38. * 入参:{creditId: Long 必填, reason: String 必填}
  39. * 出参:Boolean
  40. * 错误:404「学时记录不存在或不属于您」/ 500「该学时状态不允许异议」
  41. */
  42. export function creditObject(creditId, reason) {
  43. return request('/api/credit/object', 'POST', {
  44. creditId: creditId,
  45. reason: reason
  46. }, { silent: true })
  47. }