create.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="AdminClassroomCreate">
  3. <q-linear-progress v-if="unitsLoading"
  4. indeterminate />
  5. <entity-create v-if="mounted"
  6. ref="classroomEntityCreate"
  7. :key="classroomEntityCreateKey"
  8. v-model:value="inputs"
  9. title="مشخصات حلقه آموزشی"
  10. :api="api"
  11. :entity-id-key="entityIdKey"
  12. :entity-param-key="entityParamKey"
  13. :show-route-name="showRouteName"
  14. :show-close-button="false"
  15. :show-edit-button="false"
  16. :show-expand-button="false"
  17. :show-save-button="false"
  18. :show-reload-button="false">
  19. <template #after-form-builder>
  20. <div class="flex justify-end">
  21. <q-btn color="primary"
  22. label="ایجاد حلقه آموزشی جدید"
  23. @click="createClassroom" />
  24. </div>
  25. </template>
  26. </entity-create>
  27. </div>
  28. </template>
  29. <script>
  30. import { EntityCreate } from 'quasar-crud'
  31. import Enums from 'src/assets/Enums/Enums.js'
  32. import { APIGateway } from 'src/api/APIGateway.js'
  33. import { FormBuilderAssist } from 'quasar-form-builder'
  34. export default {
  35. name: 'Admin.Classroom.DiscussionCircles.Create',
  36. components: {
  37. EntityCreate
  38. },
  39. data () {
  40. return {
  41. mounted: false,
  42. unitsLoading: false,
  43. classroomEntityCreateKey: Date.now(),
  44. newUnitLoading: false,
  45. newUnitName: null,
  46. newUnitSessionCount: null,
  47. api: APIGateway.classroom.APIAdresses.base,
  48. entityIdKey: 'id',
  49. entityParamKey: 'id',
  50. showRouteName: 'Admin.Classroom.DiscussionCircles.Show',
  51. inputs: [
  52. { type: 'separator', name: 'space', label: 'مشخصات حلقه', className: 'custom-separator', col: 'col-12' },
  53. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'آپلود عکس حلقه', col: 'col-md-3 col-12' },
  54. { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
  55. { type: 'select', name: 'category', responseKey: 'unit_info.category', options: [], value: null, placeholder: ' ', label: 'دسته بندی', col: 'col-md-3 col-12' },
  56. { type: 'select', name: 'unit', responseKey: 'unit', options: [], value: null, placeholder: ' ', label: 'درس', col: 'col-md-3 col-12' },
  57. { type: 'select', name: 'holding_type', responseKey: 'holding_type', options: Enums.classroomHoldingTypes, value: null, placeholder: ' ', label: 'نوع برگزاری', col: 'col-md-3 col-12' },
  58. { type: 'input', name: 'price', responseKey: 'price', placeholder: ' ', label: 'هزینه برگزاری', col: 'col-md-3 col-12' },
  59. { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی حلقه', col: 'col-12' },
  60. { type: 'inputEditor', name: 'classroom_address', responseKey: 'classroom_address', placeholder: ' ', label: 'آدرس مکان فیزیکی حلقه', col: 'col-12' },
  61. {
  62. type: 'select',
  63. name: 'holding_year',
  64. responseKey: 'holding_year',
  65. options: [1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410],
  66. value: null,
  67. label: 'انتخاب سال حلقه',
  68. placeholder: ' ',
  69. col: 'col-md-3'
  70. },
  71. {
  72. type: 'select',
  73. name: 'holding_month',
  74. responseKey: 'holding_month',
  75. options: [
  76. 'فروردین',
  77. 'اردیبهشت',
  78. 'خرداد',
  79. 'تیر',
  80. 'مرداد',
  81. 'شهریور',
  82. 'مهر',
  83. 'آبان',
  84. 'آذر',
  85. 'دی',
  86. 'بهمن',
  87. 'اسفند'
  88. ],
  89. value: null,
  90. label: 'انتخاب ماه حلقه',
  91. placeholder: ' ',
  92. col: 'col-md-3'
  93. },
  94. { type: 'input', name: 'sessions_frequency', responseKey: 'sessions_frequency', placeholder: ' ', label: 'دوره تناوب', col: 'col-12' },
  95. { type: 'select', name: 'professor', responseKey: 'professor', options: [], value: null, placeholder: ' ', label: 'استاد حلقه', col: 'col-md-3 col-12' },
  96. { type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
  97. { type: 'select', name: 'audience_status_wwwww', responseKey: 'audience_status_wwwww', options: [], placeholder: ' ', label: 'وضعیت(؟)', col: 'col-md-3 col-12' },
  98. { type: 'select', name: 'category', responseKey: 'category', options: [], placeholder: ' ', label: 'مجموعه(؟)', col: 'col-md-3 col-12' },
  99. { type: 'select', name: 'audience_gender_type', responseKey: 'audience_gender_type', options: Enums.genders, placeholder: ' ', label: 'جنسیت', col: 'col-md-3 col-12' },
  100. { type: 'select', name: 'audience_bashgah_wwwww', responseKey: 'audience_bashgah_wwwww', options: [], placeholder: ' ', label: 'باشگاه(؟)', col: 'col-md-3 col-12' },
  101. { type: 'separator', name: 'space', label: 'تنظیمات حلقه', className: 'custom-separator', col: 'col-12' },
  102. { type: 'input', name: 'capacity', responseKey: 'capacity', placeholder: ' ', label: 'ظرفیت گروه درسی', col: 'col-md-3 col-12' },
  103. { type: 'input', name: 'allowed_absence_count', responseKey: 'allowed_absence_count', placeholder: ' ', label: 'تعداد مجاز غیبت', col: 'col-md-3 col-12' },
  104. { type: 'input', name: 'effective_absence_coefficient', responseKey: 'effective_absence_coefficient', placeholder: ' ', label: 'ضریب نمره حضور و غیاب', col: 'col-md-3 col-12' },
  105. { type: 'input', name: 'mandatory_assignment_count', responseKey: 'mandatory_assignment_count', placeholder: ' ', label: 'تعداد تکالیف اجباری', col: 'col-md-3 col-12' },
  106. { type: 'input', name: 'special_passing_mark', responseKey: 'special_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروطی ها', col: 'col-md-3 col-12' },
  107. { type: 'input', name: 'minimum_conditional_passing_mark', responseKey: 'minimum_conditional_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروط', col: 'col-md-3 col-12' },
  108. { type: 'input', name: 'minimum_clean_passing_mark', responseKey: 'minimum_clean_passing_mark', placeholder: ' ', label: 'نمره قبولی', col: 'col-md-3 col-12' },
  109. { type: 'separator', name: 'space', label: 'ثبت نام و حذف و اضافه', className: 'custom-separator', col: 'col-12' },
  110. { type: 'dateTime', name: 'beginning_enrollment_period', responseKey: 'beginning_enrollment_period', placeholder: ' ', label: 'تاریخ شروع پیش ثبت نام', col: 'col-md-6 col-12' },
  111. { type: 'dateTime', name: 'ending_enrollment_period', responseKey: 'ending_enrollment_period', placeholder: ' ', label: 'تاریخ پایان پیش ثبت نام', col: 'col-md-6 col-12' },
  112. { type: 'dateTime', name: 'beginning_registration_period', responseKey: 'beginning_registration_period', placeholder: ' ', label: 'تاریخ شروع ثبت نام', col: 'col-md-6 col-12' },
  113. { type: 'dateTime', name: 'ending_registration_period', responseKey: 'ending_registration_period', placeholder: ' ', label: 'تاریخ پایان ثبت نام', col: 'col-md-6 col-12' },
  114. { type: 'input', name: 'registration_period_refund_percent', responseKey: 'registration_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه ثبت نام', col: 'col-md-3 col-12' },
  115. { type: 'checkbox', name: 'allow_adding_on_registration_period', responseKey: 'allow_adding_on_registration_period', label: 'امکان اضافه کردن در بازه ثبت نام', value: false, col: 'col-md-3 col-12' },
  116. { type: 'checkbox', name: 'allow_dropping_on_registration_period', responseKey: 'allow_dropping_on_registration_period', label: 'امکان حذف ثبت نام در بازه ثبت نام', value: false, col: 'col-md-3 col-12' },
  117. { type: 'dateTime', name: 'beginning_drop_add_period', responseKey: 'beginning_drop_add_period', placeholder: ' ', label: 'تاریخ شروع حذف و اضافه', col: 'col-md-6 col-12' },
  118. { type: 'dateTime', name: 'ending_drop_add_period', responseKey: 'ending_drop_add_period', placeholder: ' ', label: 'تاریخ پایان حذف و اضافه', col: 'col-md-6 col-12' },
  119. { type: 'input', name: 'drop_add_period_refund_percent', responseKey: 'drop_add_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  120. { type: 'checkbox', name: 'allow_adding_on_drop_add_period', responseKey: 'allow_adding_on_drop_add_period', label: 'امکان اضافه شدن در بازه حذف و اضافه', value: false, col: 'col-md-3 col-12' },
  121. { type: 'checkbox', name: 'allow_dropping_on_drop_add_period', responseKey: 'allow_dropping_on_drop_add_period', label: 'امکان حذف در بازه حذف و اضافه', value: false, col: 'col-md-3 col-12' },
  122. { type: 'dateTime', name: 'publish_time', responseKey: 'publish_time', placeholder: ' ', label: 'تاریخ انتشار', col: 'col-md-6 col-12' },
  123. { type: 'separator', name: 'space', label: 'قوانین', className: 'custom-separator', col: 'col-12' },
  124. { type: 'inputEditor', name: 'rules', responseKey: 'rules', label: 'قوانین حلقه آموزشی', col: 'col-12' },
  125. // -----------------------------------------------------------------------------------------------------------
  126. { type: 'separator', name: 'space', label: 'موارد زیر در طرح نبودند', className: 'custom-separator', col: 'col-12' },
  127. { type: 'select', name: 'audience_role', responseKey: 'audience_role', options: Enums.groups, placeholder: ' ', label: 'نقش', col: 'col-md-4 col-12' },
  128. { type: 'inputEditor', name: 'description', responseKey: 'description', label: '??توضیحات', col: 'col-12' },
  129. { type: 'hidden', name: 'id', responseKey: 'id', label: 'id', col: 'col-md-3 col-12' }
  130. ]
  131. }
  132. },
  133. computed: {
  134. selectedCategoryId () {
  135. return FormBuilderAssist.getInputsByName(this.inputs, 'category')?.value
  136. }
  137. },
  138. watch: {
  139. selectedCategoryId () {
  140. FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'value', null)
  141. FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', [])
  142. this.getUnits(this.selectedCategoryId)
  143. }
  144. },
  145. mounted () {
  146. this.preLoadData()
  147. .then(() => {
  148. this.mounted = true
  149. })
  150. .catch(() => {
  151. })
  152. },
  153. methods: {
  154. setInputAttr (name, attr, value) {
  155. this.$refs.classroomEntityCreate.setInputAttributeByName(name, attr, value)
  156. },
  157. preLoadData () {
  158. return new Promise((resolve, reject) => {
  159. const promise1 = this.getProfessors()
  160. const promise2 = this.getCategories()
  161. this.$nextTick(() => {
  162. Promise.all([promise1, promise2])
  163. .then(() => {
  164. resolve()
  165. })
  166. .catch(() => {
  167. reject()
  168. })
  169. })
  170. })
  171. },
  172. getProfessors () {
  173. return APIGateway.user.index({ per_page: 9999, role: 'professor' })
  174. .then((users) => {
  175. FormBuilderAssist.setAttributeByName(this.inputs, 'professor', 'options', users.list.list.map(item => {
  176. return {
  177. value: item.id,
  178. label: this.getUserFullname(item)
  179. }
  180. }))
  181. })
  182. .catch(() => {})
  183. },
  184. getCategories () {
  185. return APIGateway.unitCategory.index({ per_page: 9999, type: 'DISCUSSION_CIRCLE' })
  186. .then((categories) => {
  187. FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'options', categories.list.list.map(item => {
  188. return {
  189. value: item.id,
  190. label: item.title
  191. }
  192. }))
  193. })
  194. .catch(() => {})
  195. },
  196. getUnits (selectedcategoryId = null) {
  197. if (!selectedcategoryId) {
  198. FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', [])
  199. return
  200. }
  201. this.unitsLoading = true
  202. APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
  203. .then((units) => {
  204. FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'options', units.list.list.map(item => {
  205. return {
  206. value: item.id,
  207. label: item.title
  208. }
  209. }))
  210. this.unitsLoading = false
  211. })
  212. .catch(() => {
  213. this.unitsLoading = false
  214. })
  215. },
  216. getUserFullname (user) {
  217. return user.firstname + ' ' + user.lastname
  218. },
  219. createClassroom () {
  220. this.$refs.classroomEntityCreate.createEntity()
  221. }
  222. }
  223. }
  224. </script>