person.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* *********************************************************** */
  2. // 创建: Macheng 2025/09/10.
  3. // 修改: Macheng 2025/09/10
  4. // Description:
  5. // 该文件定义了 人员类 Person。用于保存人员数据。
  6. /* *********************************************************** */
  7. import BaseModel from './baseModel'
  8. class Person extends BaseModel {
  9. id = 0 // 人员ID
  10. name = '' // 人员名称
  11. job = '' // 职位
  12. phone = '' // 电话
  13. locId = 0 // 所属区域ID
  14. tagId = 0 // 绑定标签地址
  15. get tagAddr() {
  16. return this.tagId
  17. }
  18. set tagAddr(val) {
  19. this.tagId = val
  20. }
  21. constructor(opts) {
  22. if (!opts) opts = {}
  23. super(opts)
  24. this.init(opts)
  25. }
  26. init(opts) {
  27. if (!opts) opts = {}
  28. super.init(opts)
  29. this.id = Number(opts.id) || this.id
  30. this.name = opts.name || this.wifiLocalMaskname
  31. this.job = opts.job || this.job
  32. this.phone = opts.phone || this.phone
  33. this.locId = Number(opts.locId) || this.locId
  34. this.tagId = Number(opts.tagId) || Number(opts.tagAddr) || this.tagId
  35. this.isEnable = opts.enable || opts.isEnable || false
  36. }
  37. toJson() {
  38. const obj1 = super.toJson()
  39. const obj2 = {
  40. id: this.id,
  41. name: this.name,
  42. job: this.job,
  43. phone: this.phone,
  44. locId: this.locId,
  45. tagId: this.tagId,
  46. tagAddr: this.tagAddr
  47. }
  48. return Object.assign({}, obj1, obj2)
  49. }
  50. }
  51. export default Person