EventInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <entity-edit v-if="mounted"
  3. ref="eventEntityEdit"
  4. :key="eventEntityEditKey"
  5. v-model:value="inputs"
  6. title="مشخصات رویداد"
  7. :api="api"
  8. :show-close-button="false"
  9. :show-edit-button="false"
  10. :show-expand-button="false"
  11. :show-save-button="false"
  12. :show-reload-button="false"
  13. :after-load-input-data="afterLoadInputData">
  14. <template #after-form-builder>
  15. <div class="flex justify-end q-mt-md">
  16. <q-btn color="primary"
  17. label="بروزرسانی اطلاعات"
  18. @click="updateClassroom" />
  19. </div>
  20. </template>
  21. </entity-edit>
  22. <q-skeleton v-else
  23. type="rect"
  24. height="200px" />
  25. </template>
  26. <script>
  27. import { shallowRef } from 'vue'
  28. import { EntityEdit } from 'quasar-crud'
  29. import { Event } from 'src/models/Event.js'
  30. import Enums from 'src/assets/Enums/Enums.js'
  31. import { APIGateway } from 'src/api/APIGateway.js'
  32. import { Classroom } from 'src/models/Classroom.js'
  33. import { FormBuilderAssist } from 'quasar-form-builder'
  34. import ContentMedias from 'src/components/FormBuilderCustumComponents/ContentMedias/ContentMedias.vue'
  35. import FormBuilderInputEditor from 'src/components/FormBuilderCustumComponents/FormBuilderInputEditor.vue'
  36. const ContentMediasComp = shallowRef(ContentMedias)
  37. const FormBuilderInputEditorComp = shallowRef(FormBuilderInputEditor)
  38. export default {
  39. name: 'ClassroomInfo',
  40. components: {
  41. EntityEdit
  42. },
  43. props: {
  44. eventId: {
  45. type: Number,
  46. default: null
  47. },
  48. event: {
  49. type: Classroom,
  50. default: new Classroom()
  51. }
  52. },
  53. data () {
  54. const eventId = this.eventId
  55. return {
  56. inputs: [
  57. { type: 'separator', name: 'space', label: 'مشخصات رویدادها', className: 'custom-separator', col: 'col-12' },
  58. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان رویداد', placeholder: ' ', col: 'col-12' },
  59. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'آپلود عکس رویدادها', col: 'col-md-3 col-12' },
  60. { type: 'file', name: 'codes', responseKey: 'codes', label: 'آیین نامه رویدادها', col: 'col-md-3 col-12' },
  61. { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
  62. { type: 'select', name: 'category', responseKey: 'category', options: (new Event()).categoryEnums, value: null, placeholder: ' ', label: 'دسته بندی', col: 'col-md-3 col-12' },
  63. { type: 'select', name: 'holding_type', responseKey: 'holding_type', options: (new Event()).holding_typeEnums, value: null, placeholder: ' ', label: 'نوع برگزاری', col: 'col-md-3 col-12' },
  64. { type: 'input', name: 'price', responseKey: 'price', placeholder: ' ', label: 'هزینه برگزاری', col: 'col-md-3 col-12' },
  65. { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی رویدادها', col: 'col-12' },
  66. { type: FormBuilderInputEditorComp, name: 'event_address', responseKey: 'event_address', placeholder: ' ', label: 'آدرس مکان فیزیکی رویدادها', col: 'col-12' },
  67. { type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
  68. { type: 'select', name: 'audience_status_wwwww', responseKey: 'audience_status_wwwww', options: [], placeholder: ' ', label: 'وضعیت(؟)', col: 'col-md-3 col-12' },
  69. { type: 'select', name: 'category', responseKey: 'category', options: [], placeholder: ' ', label: 'مجموعه(؟)', col: 'col-md-3 col-12' },
  70. { type: 'select', name: 'audience_gender_type', responseKey: 'audience_gender_type', options: (new Event()).audience_gender_typeEnums, placeholder: ' ', label: 'جنسیت', col: 'col-md-3 col-12' },
  71. { type: 'select', name: 'audience_bashgah_wwwww', responseKey: 'audience_bashgah_wwwww', options: [], placeholder: ' ', label: 'باشگاه(؟)', col: 'col-md-3 col-12' },
  72. { type: ContentMediasComp, name: 'medias', responseKey: 'medias_info', sourceType: 'EVENT', col: 'col-md-12 col-12' },
  73. { type: 'separator', name: 'space', label: 'تنظیمات رویدادها', className: 'custom-separator', col: 'col-12' },
  74. { type: 'input', name: 'capacity', responseKey: 'capacity', placeholder: ' ', label: 'ظرفیت گروه درسی', col: 'col-md-3 col-12' },
  75. { type: 'separator', name: 'space', label: 'ثبت نام و حذف و اضافه', className: 'custom-separator', col: 'col-12' },
  76. { type: 'dateTime', name: 'beginning_enrollment_period', responseKey: 'beginning_enrollment_period', placeholder: ' ', label: 'تاریخ شروع پیش ثبت نام', col: 'col-md-6 col-12' },
  77. { type: 'dateTime', name: 'ending_enrollment_period', responseKey: 'ending_enrollment_period', placeholder: ' ', label: 'تاریخ پایان پیش ثبت نام', col: 'col-md-6 col-12' },
  78. { type: 'dateTime', name: 'beginning_registration_period', responseKey: 'beginning_registration_period', placeholder: ' ', label: 'تاریخ شروع ثبت نام', col: 'col-md-6 col-12' },
  79. { type: 'dateTime', name: 'ending_registration_period', responseKey: 'ending_registration_period', placeholder: ' ', label: 'تاریخ پایان ثبت نام', col: 'col-md-6 col-12' },
  80. { type: 'input', name: 'registration_period_refund_percent', responseKey: 'registration_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه ثبت نام', col: 'col-md-3 col-12' },
  81. { type: 'checkbox', name: 'allow_dropping_on_enrollment_period', responseKey: 'allow_dropping_on_enrollment_period', label: 'امکان حذف در بازه پیش ثبت نام', col: 'col-md-3 col-12' },
  82. { type: 'checkbox', name: 'allow_adding_on_registration_period', responseKey: 'allow_adding_on_registration_period', label: 'امکان اضافه کردن در بازه ثبت نام', col: 'col-md-3 col-12' },
  83. { type: 'checkbox', name: 'allow_dropping_on_registration_period', responseKey: 'allow_dropping_on_registration_period', label: 'امکان حذف ثبت نام در بازه ثبت نام', col: 'col-md-3 col-12' },
  84. { type: 'dateTime', name: 'beginning_drop_add_period', responseKey: 'beginning_drop_add_period', placeholder: ' ', label: 'تاریخ شروع حذف و اضافه', col: 'col-md-6 col-12' },
  85. { type: 'dateTime', name: 'ending_drop_add_period', responseKey: 'ending_drop_add_period', placeholder: ' ', label: 'تاریخ پایان حذف و اضافه', col: 'col-md-6 col-12' },
  86. { type: 'input', name: 'drop_add_period_refund_percent', responseKey: 'drop_add_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  87. { type: 'checkbox', name: 'allow_adding_on_drop_add_period', responseKey: 'allow_adding_on_drop_add_period', label: 'امکان اضافه شدن در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  88. { type: 'checkbox', name: 'allow_dropping_on_drop_add_period', responseKey: 'allow_dropping_on_drop_add_period', label: 'امکان حذف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  89. { type: 'dateTime', name: 'publish_time', responseKey: 'publish_time', placeholder: ' ', label: 'تاریخ انتشار', col: 'col-md-6 col-12' },
  90. { type: 'separator', name: 'space', label: 'قوانین', className: 'custom-separator', col: 'col-12' },
  91. { type: FormBuilderInputEditorComp, name: 'rules', responseKey: 'rules', label: 'قوانین رویداد', col: 'col-12' },
  92. { type: FormBuilderInputEditorComp, name: 'description', responseKey: 'description', label: 'توضیحات', col: 'col-12' },
  93. { type: FormBuilderInputEditorComp, name: 'specification', responseKey: 'specification', label: 'مشخصات', col: 'col-12' },
  94. { type: FormBuilderInputEditorComp, name: 'bulletin', responseKey: 'bulletin', label: 'تابلو اعلانات', col: 'col-12' },
  95. // -----------------------------------------------------------------------------------------------------------
  96. { type: 'separator', name: 'space', label: 'موارد زیر در طرح نبودند', className: 'custom-separator', col: 'col-12' },
  97. { type: 'select', name: 'audience_role', responseKey: 'audience_role', options: Enums.groups, placeholder: ' ', label: 'نقش', col: 'col-md-4 col-12' },
  98. { type: 'hidden', name: 'id', responseKey: 'id', label: 'id', col: 'col-md-3 col-12' }
  99. ],
  100. mounted: false,
  101. eventEntityEditKey: Date.now(),
  102. api: APIGateway.event.APIAdresses.byId(eventId)
  103. }
  104. },
  105. computed: {
  106. localClassroom: {
  107. get () {
  108. return this.event
  109. },
  110. set (newValue) {
  111. this.$emit('update:event', newValue)
  112. }
  113. }
  114. },
  115. mounted () {
  116. this.localClassroom.loading = true
  117. this.preLoadData()
  118. .then(() => {
  119. this.mounted = true
  120. })
  121. .catch(() => {
  122. this.mounted = true
  123. })
  124. },
  125. methods: {
  126. afterLoadInputData (data) {
  127. this.localClassroom = new Classroom(data)
  128. this.localClassroom.loading = false
  129. // const gg = data.beginning_enrollment_period.replace('T', ' ')
  130. // this.setInputAttr('beginning_enrollment_period', 'value', gg)
  131. },
  132. setInputAttr (name, attr, value) {
  133. FormBuilderAssist.setAttributeByName(this.inputs, name, attr, value)
  134. },
  135. preLoadData () {
  136. return new Promise((resolve, reject) => {
  137. APIGateway.event.get(this.eventId)
  138. .then((event) => {
  139. this.setInputAttr('category', 'value', event.category)
  140. this.beforeLoadInputData(event)
  141. .then((event) => {
  142. resolve(event)
  143. })
  144. .catch(() => {
  145. reject()
  146. })
  147. })
  148. .catch(() => {
  149. reject()
  150. })
  151. })
  152. },
  153. beforeLoadInputData (/* responseData */) {
  154. return new Promise((resolve, reject) => {
  155. const promise1 = this.getProfessors()
  156. this.$nextTick(() => {
  157. Promise.all([promise1])
  158. .then(() => {
  159. // this.setInputAttr('category', 'value', responseData.unit_info.category)
  160. this.eventEntityEditKey = Date.now()
  161. resolve()
  162. })
  163. .catch(() => {
  164. reject()
  165. })
  166. })
  167. })
  168. },
  169. getProfessors () {
  170. return APIGateway.user.index({ per_page: 9999, role: 'professor' })
  171. .then((users) => {
  172. this.setInputAttr('professor', 'options', users.list.list.map(item => {
  173. return {
  174. value: item.id,
  175. label: this.getUserFullname(item)
  176. }
  177. }))
  178. })
  179. .catch(() => {})
  180. },
  181. getUserFullname (user) {
  182. return user.firstname + ' ' + user.lastname
  183. },
  184. updateClassroom () {
  185. this.$refs.eventEntityEdit.editEntity()
  186. }
  187. }
  188. }
  189. </script>