Registration.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { User } from 'src/models/User.js'
  2. // import { Package } from 'src/models/Package.js'
  3. // import { Service } from 'src/models/Service.js'
  4. import { Collection, Model } from 'js-abstract-model'
  5. class Registration extends Model {
  6. constructor (data) {
  7. super(data, [
  8. { key: 'id' },
  9. { key: 'product_info' },
  10. { key: 'item' },
  11. { key: 'item_info' },
  12. { key: 'basket' },
  13. { key: 'count' },
  14. { key: 'user' },
  15. {
  16. key: 'user_info',
  17. relatedModel: User
  18. },
  19. { key: 'status' },
  20. { key: 'time_status' },
  21. { key: 'termination_datetime' },
  22. { key: 'creation_time' },
  23. { key: 'last_modification_time' }
  24. ], {
  25. status: {
  26. infoKey: 'status_info',
  27. enums: [
  28. {
  29. label: 'پیش ثبت نام',
  30. value: 'ENROLLED'
  31. },
  32. {
  33. label: 'ثبت نام',
  34. value: 'REGISTERED'
  35. },
  36. {
  37. label: 'حذف توسط شما',
  38. value: 'DROPPED_BY_ITSELF'
  39. },
  40. {
  41. label: 'حذف توسط ادمین',
  42. value: 'DROPPED_BY_ADMIN'
  43. }
  44. ]
  45. },
  46. time_status: {
  47. infoKey: 'time_status_info',
  48. enums: [
  49. {
  50. label: 'فعال',
  51. value: 'ONGOING',
  52. color: '#2FA84A'
  53. }
  54. ]
  55. }
  56. })
  57. // this.timeStatusEnums = [
  58. // {
  59. // label: 'فعال',
  60. // value: 'ONGOING',
  61. // color: '#2FA84A'
  62. // }
  63. // ]
  64. // this.loadTimeStatusInfo()
  65. }
  66. loadTimeStatusInfo () {
  67. const target = this.timeStatusEnums.find(type => type.value === this.time_status)
  68. if (!target) {
  69. this.time_status_info = {
  70. label: null,
  71. value: null,
  72. color: ''
  73. }
  74. } else {
  75. this.time_status_info = target
  76. }
  77. }
  78. loadProductData () {
  79. // if (this.product_info.product_type === 'package') {
  80. // this.product_data = new Package(this.product_info)
  81. // } else if (this.product_info.product_type === 'service') {
  82. // this.product_data = new Service(this.product_info)
  83. // }
  84. }
  85. }
  86. class RegistrationList extends Collection {
  87. model () {
  88. return Registration
  89. }
  90. }
  91. export { Registration, RegistrationList }