attend.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* *********************************************************** */
  2. // 创建: Macheng 2025/09/13.
  3. // 修改: Macheng 2025/09/13
  4. // Description:
  5. // 该文件定义了考勤记录类 Attend。用于保存单挑考勤数据。
  6. /* *********************************************************** */
  7. import BaseModel from './baseModel'
  8. import AttendItem from './attendItem'
  9. class Attend extends BaseModel {
  10. tm = 0 // 时间
  11. projId = 0 // 项目ID
  12. locId = 0 // 区域ID
  13. items = [] // 考勤项列表
  14. constructor(opts) {
  15. if (!opts) opts = {}
  16. super(opts)
  17. this.init(opts)
  18. }
  19. init(opts) {
  20. if (!opts) opts = {}
  21. super.init(opts)
  22. this.tm = Number(opts.tm) || this.tm
  23. this.projId = Number(opts.projId) || this.projId
  24. this.locId = Number(opts.locId) || this.locId
  25. this.items = (opts.items || []).map(item => {
  26. const t = new AttendItem(item)
  27. t.tm = this.tm
  28. t.projId = this.projId
  29. t.locId = this.locId
  30. t.parent = this
  31. return t
  32. })
  33. this.isEnable = opts.enable || opts.isEnable || false
  34. }
  35. toJson() {
  36. const obj1 = super.toJson()
  37. const obj2 = {
  38. tm: this.tm,
  39. projId: this.projId,
  40. locId: this.locId,
  41. items: this.items.map(item => item.toJson())
  42. }
  43. return Object.assign({}, obj1, obj2)
  44. }
  45. }
  46. export default Attend