show.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. <template>
  2. <q-card class="AdminClassroomShow">
  3. <q-tabs v-model="tab"
  4. dense
  5. class="text-grey"
  6. active-color="primary"
  7. indicator-color="primary"
  8. align="justify"
  9. narrow-indicator>
  10. <q-tab name="classroomInfo"
  11. label="مشخصات" />
  12. <q-tab name="educations"
  13. label="لیست جلسات" />
  14. <q-tab name="movies1"
  15. label="پروژه‌ها" />
  16. <q-tab name="movies2"
  17. label="آزمون" />
  18. <q-tab name="members"
  19. label="اندیشه جویان" />
  20. <q-tab name="activity_sheet"
  21. label="فعالیت کلاسی" />
  22. <q-tab name="live_streaming_url"
  23. label="بخش آنلاین" />
  24. </q-tabs>
  25. <q-separator />
  26. <q-tab-panels v-model="tab"
  27. animated>
  28. <q-tab-panel name="classroomInfo"
  29. class="q-pa-none">
  30. <entity-edit v-if="mounted"
  31. ref="classroomEntityEdit"
  32. :key="classroomEntityEditKey"
  33. v-model:value="inputs"
  34. title="مشخصات دوره آموزشی"
  35. :api="api"
  36. :entity-id-key="entityIdKey"
  37. :entity-param-key="entityParamKey"
  38. :show-route-name="showRouteName"
  39. :show-close-button="false"
  40. :show-edit-button="false"
  41. :show-expand-button="false"
  42. :show-save-button="false"
  43. :show-reload-button="false"
  44. :after-load-input-data="afterLoadInputData">
  45. <template #after-form-builder>
  46. <div class="flex justify-end q-mt-md">
  47. <q-btn color="primary"
  48. label="بروزرسانی اطلاعات"
  49. @click="updateClassroom" />
  50. </div>
  51. </template>
  52. </entity-edit>
  53. <q-skeleton v-else
  54. type="rect"
  55. height="200px" />
  56. </q-tab-panel>
  57. <q-tab-panel name="educations"
  58. class="q-pa-none">
  59. <entity-index v-if="mounted"
  60. v-model:value="sessionListInputs"
  61. title="لیست جلسات"
  62. :api="sessionListApi"
  63. :table="sessionListTable"
  64. :table-keys="sessionListTableKeys"
  65. :show-search-button="false"
  66. :show-reload-button="false"
  67. :show-expand-button="false">
  68. <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
  69. <template v-if="inputData.col.name === 'actions'">
  70. <div class="action-column-entity-index">
  71. <q-btn size="md"
  72. color="primary"
  73. label="جزییات"
  74. :to="{name: 'Admin.Session.Show', params: {id: inputData.props.row.id}}"
  75. class="q-mr-md" />
  76. <delete-btn @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))" />
  77. </div>
  78. </template>
  79. <template v-else>
  80. {{ inputData.col.value }}
  81. </template>
  82. </template>
  83. </entity-index>
  84. <q-skeleton v-else
  85. type="rect"
  86. height="200px" />
  87. </q-tab-panel>
  88. <q-tab-panel name="movies1">
  89. پروژه‌ها
  90. </q-tab-panel>
  91. <q-tab-panel name="movies2">
  92. آزمون
  93. </q-tab-panel>
  94. <q-tab-panel name="members"
  95. class="q-pa-none">
  96. <entity-index v-if="mounted"
  97. ref="membersList"
  98. v-model:value="membersListInputs"
  99. title="لیست کاربران"
  100. :api="membersListApi"
  101. :table="membersListTable"
  102. :table-keys="membersListTableKeys"
  103. :show-search-button="false"
  104. :show-reload-button="false"
  105. :show-expand-button="false">
  106. <template #toolbar>
  107. <q-btn color="primary"
  108. :loading="exportReportLoading"
  109. @click="getMembersExcel">
  110. خروجی اکسل
  111. </q-btn>
  112. </template>
  113. <template v-slot:entity-index-table-cell="{inputData}">
  114. <template v-if="inputData.col.name === 'number'">
  115. {{ inputData.rowNumber }}
  116. </template>
  117. <template v-else-if="inputData.col.name === 'action'">
  118. <div class="action-column-entity-index">
  119. <q-btn v-if="inputData.props.row.status !== 'DROPPED_BY_ADMIN'"
  120. size="md"
  121. color="red"
  122. outline
  123. label="انصراف"
  124. :loading="dropClassroomByAdminLoading"
  125. class="q-mr-md"
  126. @click="dropClassroomByAdmin(inputData.props.row)" />
  127. </div>
  128. </template>
  129. <template v-else>
  130. {{ inputData.col.value }}
  131. </template>
  132. </template>
  133. </entity-index>
  134. <q-skeleton v-else
  135. type="rect"
  136. height="200px" />
  137. </q-tab-panel>
  138. <q-tab-panel name="activity_sheet"
  139. class="q-pa-none">
  140. <entity-index v-if="mounted"
  141. ref="activitySheetList"
  142. v-model:value="activitySheetListInputs"
  143. title="فعالیت کلاسی"
  144. :api="activitySheetListApi"
  145. :table="activitySheetListTable"
  146. :table-keys="activitySheetListTableKeys"
  147. :show-search-button="false"
  148. :show-reload-button="false"
  149. :show-expand-button="false">
  150. <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
  151. <template v-if="inputData.col.name === 'actions'">
  152. <div class="action-column-entity-index">
  153. <q-btn size="md"
  154. color="primary"
  155. outline
  156. label="سابقه آموزشی"
  157. class="q-mr-md" />
  158. <!-- :to="{name: 'Admin.Session.Show', params: {id: inputData.props.row.id}}"-->
  159. <delete-btn @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveMessage(inputData.props.row))" />
  160. </div>
  161. </template>
  162. <template v-else>
  163. {{ inputData.col.value }}
  164. </template>
  165. </template>
  166. </entity-index>
  167. <q-skeleton v-else
  168. type="rect"
  169. height="200px" />
  170. </q-tab-panel>
  171. <q-tab-panel name="live_streaming_url">
  172. <q-btn class="full-width q-mb-lg"
  173. color="primary"
  174. @click="goToLiveStreamUrl">
  175. رفتن به کلاس
  176. </q-btn>
  177. <iframe :src="classroom.live_streaming_url"
  178. title="W3Schools Free Online Web Tutorials"
  179. style="height: 80vh"
  180. class="full-width" />
  181. </q-tab-panel>
  182. </q-tab-panels>
  183. </q-card>
  184. </template>
  185. <script>
  186. import { shallowRef } from 'vue'
  187. import Assist from 'src/assets/js/Assist.js'
  188. import Enums from 'src/assets/Enums/Enums.js'
  189. import ShamsiDate from 'src/assets/ShamsiDate.js'
  190. import { APIGateway } from 'src/api/APIGateway.js'
  191. import { Classroom } from 'src/models/Classroom.js'
  192. import { EntityEdit, EntityIndex } from 'quasar-crud'
  193. import { FormBuilderAssist } from 'quasar-form-builder'
  194. import BtnControl from 'src/components/Control/btn.vue'
  195. import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
  196. const BtnControlComp = shallowRef(BtnControl)
  197. export default {
  198. name: 'Admin.Classroom.Show',
  199. components: {
  200. EntityEdit,
  201. EntityIndex,
  202. DeleteBtn
  203. },
  204. data () {
  205. const classroomId = this.$route.params.id
  206. return {
  207. mounted: false,
  208. classroomEntityEditKey: Date.now(),
  209. tab: 'classroomInfo',
  210. api: null,
  211. entityIdKey: 'id',
  212. entityParamKey: 'id',
  213. showRouteName: 'Admin.Classroom.Show',
  214. inputs: [
  215. { type: 'separator', name: 'space', label: 'مشخصات دوره', className: 'custom-separator', col: 'col-12' },
  216. { type: 'file', name: 'thumbnail', responseKey: 'thumbnail', label: 'آپلود عکس دوره', col: 'col-md-3 col-12' },
  217. { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
  218. { type: 'select', name: 'category', responseKey: 'unit_info.category_info.id', options: [], value: null, placeholder: ' ', label: 'دسته بندی', col: 'col-md-3 col-12' },
  219. { type: 'select', name: 'unit', responseKey: 'unit', options: [], value: null, placeholder: ' ', label: 'درس', col: 'col-md-3 col-12' },
  220. { type: 'select', name: 'holding_type', responseKey: 'holding_type', options: Enums.classroomHoldingTypes, value: null, placeholder: ' ', label: 'نوع برگزاری', col: 'col-md-3 col-12' },
  221. { type: 'input', name: 'price', responseKey: 'price', placeholder: ' ', label: 'هزینه برگزاری', col: 'col-md-3 col-12' },
  222. { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی دوره', col: 'col-12' },
  223. { type: 'inputEditor', name: 'classroom_address', responseKey: 'classroom_address', placeholder: ' ', label: 'آدرس مکان فیزیکی دوره', col: 'col-12' },
  224. {
  225. type: 'select',
  226. name: 'holding_year',
  227. responseKey: 'holding_year',
  228. options: [1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410],
  229. value: null,
  230. label: 'انتخاب سال دوره',
  231. placeholder: ' ',
  232. col: 'col-md-3'
  233. },
  234. {
  235. type: 'select',
  236. name: 'holding_month',
  237. responseKey: 'holding_month',
  238. options: [
  239. 'فروردین',
  240. 'اردیبهشت',
  241. 'خرداد',
  242. 'تیر',
  243. 'مرداد',
  244. 'شهریور',
  245. 'مهر',
  246. 'آبان',
  247. 'آذر',
  248. 'دی',
  249. 'بهمن',
  250. 'اسفند'
  251. ],
  252. value: null,
  253. label: 'انتخاب ماه دوره',
  254. placeholder: ' ',
  255. col: 'col-md-3'
  256. },
  257. { type: 'input', name: 'sessions_frequency', responseKey: 'sessions_frequency', placeholder: ' ', label: 'دوره تناوب', col: 'col-12' },
  258. { type: 'select', name: 'professor', responseKey: 'professor', options: [], value: null, placeholder: ' ', label: 'استاد دوره', col: 'col-md-3 col-12' },
  259. { type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
  260. { type: 'select', name: 'audience_status_wwwww', responseKey: 'audience_status_wwwww', options: [], placeholder: ' ', label: 'وضعیت(؟)', col: 'col-md-3 col-12' },
  261. { type: 'select', name: 'category', responseKey: 'category', options: [], placeholder: ' ', label: 'مجموعه(؟)', col: 'col-md-3 col-12' },
  262. { type: 'select', name: 'audience_gender_type', responseKey: 'audience_gender_type', options: Enums.classroomGenders, placeholder: ' ', label: 'جنسیت', col: 'col-md-3 col-12' },
  263. { type: 'select', name: 'audience_bashgah_wwwww', responseKey: 'audience_bashgah_wwwww', options: [], placeholder: ' ', label: 'باشگاه(؟)', col: 'col-md-3 col-12' },
  264. { type: 'separator', name: 'space', label: 'تنظیمات دوره', className: 'custom-separator', col: 'col-12' },
  265. { type: 'input', name: 'capacity', responseKey: 'capacity', placeholder: ' ', label: 'ظرفیت گروه درسی', col: 'col-md-3 col-12' },
  266. { type: 'input', name: 'allowed_absence_count', responseKey: 'allowed_absence_count', placeholder: ' ', label: 'تعداد مجاز غیبت', col: 'col-md-3 col-12' },
  267. { type: 'input', name: 'effective_absence_coefficient', responseKey: 'effective_absence_coefficient', placeholder: ' ', label: 'ضریب نمره حضور و غیاب', col: 'col-md-3 col-12' },
  268. { type: 'input', name: 'mandatory_assignment_count', responseKey: 'mandatory_assignment_count', placeholder: ' ', label: 'تعداد تکالیف اجباری', col: 'col-md-3 col-12' },
  269. { type: 'input', name: 'special_passing_mark', responseKey: 'special_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروطی ها', col: 'col-md-3 col-12' },
  270. { type: 'input', name: 'minimum_conditional_passing_mark', responseKey: 'minimum_conditional_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروط', col: 'col-md-3 col-12' },
  271. { type: 'input', name: 'minimum_clean_passing_mark', responseKey: 'minimum_clean_passing_mark', placeholder: ' ', label: 'نمره قبولی', col: 'col-md-3 col-12' },
  272. { type: 'separator', name: 'space', label: 'ثبت نام و حذف و اضافه', className: 'custom-separator', col: 'col-12' },
  273. { type: 'dateTime', name: 'beginning_enrollment_period', responseKey: 'beginning_enrollment_period', placeholder: ' ', label: 'تاریخ شروع پیش ثبت نام', col: 'col-md-6 col-12' },
  274. { type: 'dateTime', name: 'ending_enrollment_period', responseKey: 'ending_enrollment_period', placeholder: ' ', label: 'تاریخ پایان پیش ثبت نام', col: 'col-md-6 col-12' },
  275. { type: 'dateTime', name: 'beginning_registration_period', responseKey: 'beginning_registration_period', placeholder: ' ', label: 'تاریخ شروع ثبت نام', col: 'col-md-6 col-12' },
  276. { type: 'dateTime', name: 'ending_registration_period', responseKey: 'ending_registration_period', placeholder: ' ', label: 'تاریخ پایان ثبت نام', col: 'col-md-6 col-12' },
  277. { type: 'input', name: 'registration_period_refund_percent', responseKey: 'registration_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه ثبت نام', col: 'col-md-3 col-12' },
  278. { type: 'checkbox', name: 'allow_adding_on_registration_period', responseKey: 'allow_adding_on_registration_period', label: 'امکان اضافه کردن در بازه ثبت نام', col: 'col-md-3 col-12' },
  279. { type: 'checkbox', name: 'allow_dropping_on_registration_period', responseKey: 'allow_dropping_on_registration_period', label: 'امکان حذف ثبت نام در بازه ثبت نام', col: 'col-md-3 col-12' },
  280. { type: 'dateTime', name: 'beginning_drop_add_period', responseKey: 'beginning_drop_add_period', placeholder: ' ', label: 'تاریخ شروع حذف و اضافه', col: 'col-md-6 col-12' },
  281. { type: 'dateTime', name: 'ending_drop_add_period', responseKey: 'ending_drop_add_period', placeholder: ' ', label: 'تاریخ پایان حذف و اضافه', col: 'col-md-6 col-12' },
  282. { type: 'input', name: 'drop_add_period_refund_percent', responseKey: 'drop_add_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  283. { type: 'checkbox', name: 'allow_adding_on_drop_add_period', responseKey: 'allow_adding_on_drop_add_period', label: 'امکان اضافه شدن در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  284. { type: 'checkbox', name: 'allow_dropping_on_drop_add_period', responseKey: 'allow_dropping_on_drop_add_period', label: 'امکان حذف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  285. { type: 'dateTime', name: 'publish_time', responseKey: 'publish_time', placeholder: ' ', label: 'تاریخ انتشار', col: 'col-md-6 col-12' },
  286. { type: 'separator', name: 'space', label: 'قوانین', className: 'custom-separator', col: 'col-12' },
  287. { type: 'inputEditor', name: 'rules', responseKey: 'rules', label: 'قوانین دوره آموزشی', col: 'col-12' },
  288. // -----------------------------------------------------------------------------------------------------------
  289. { type: 'separator', name: 'space', label: 'موارد زیر در طرح نبودند', className: 'custom-separator', col: 'col-12' },
  290. { type: 'select', name: 'audience_role', responseKey: 'audience_role', options: Enums.groups, placeholder: ' ', label: 'نقش', col: 'col-md-4 col-12' },
  291. { type: 'inputEditor', name: 'description', responseKey: 'description', label: '??توضیحات', col: 'col-12' },
  292. { type: 'hidden', name: 'id', responseKey: 'id', label: 'id', col: 'col-md-3 col-12' }
  293. ],
  294. classroom: new Classroom(),
  295. sessionListInputs: [
  296. { type: 'hidden', name: 'classroom', value: this.$route.params.id, label: 'نام دوره', col: 'col-12' }
  297. ],
  298. sessionListApi: APIGateway.session.APIAdresses.base,
  299. sessionListTable: {
  300. columns: [
  301. {
  302. name: 'id',
  303. required: true,
  304. label: 'شماره',
  305. align: 'left',
  306. field: row => row.id
  307. },
  308. {
  309. name: 'title',
  310. required: true,
  311. label: 'عنوان جلسه',
  312. align: 'left',
  313. field: row => row.title
  314. },
  315. {
  316. name: 'creation_time',
  317. required: true,
  318. label: 'زمان شروع جلسه',
  319. align: 'left',
  320. field: row => row.starting_time ? ShamsiDate.getDateTime(row.starting_time) : '-'
  321. },
  322. {
  323. name: 'last_modification_time',
  324. required: true,
  325. label: 'زمان پایان جلسه',
  326. align: 'left',
  327. field: row => row.ending_time ? ShamsiDate.getDateTime(row.ending_time) : '-'
  328. },
  329. {
  330. name: 'actions',
  331. required: true,
  332. label: 'عملیات',
  333. align: 'left',
  334. field: ''
  335. }
  336. ],
  337. data: []
  338. },
  339. sessionListTableKeys: {
  340. data: 'results',
  341. total: 'count',
  342. currentPage: 'current',
  343. perPage: 'per_page',
  344. pageKey: 'page'
  345. },
  346. dropClassroomByAdminLoading: false,
  347. exportReportLoading: false,
  348. membersListInputs: [
  349. { type: 'hidden', name: 'classroom', value: classroomId },
  350. { type: 'select', name: 'status', options: [{ label: 'ثبت نام شده', value: 'REGISTERED' }, { label: 'پیش ثبت نام شده', value: 'ENROLLED' }, { label: 'حذف توسط اندیشه جو', value: 'DROPPED_BY_ITSELF' }, { label: 'حذف توسط ادمین', value: 'DROPPED_BY_ADMIN' }], label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
  351. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  352. ],
  353. membersListApi: APIGateway.classroom.APIAdresses.members,
  354. membersListTable: {
  355. columns: [
  356. {
  357. name: 'number',
  358. required: true,
  359. label: 'شماره',
  360. align: 'left',
  361. field: () => ''
  362. },
  363. {
  364. name: 'id',
  365. required: true,
  366. label: 'شناسه',
  367. align: 'left',
  368. field: row => row.id
  369. },
  370. {
  371. name: 'owner_info.fullname',
  372. required: true,
  373. label: 'نام و نام خانوادگی',
  374. align: 'left',
  375. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  376. },
  377. {
  378. name: 'owner_info.national_code',
  379. required: true,
  380. label: 'کد ملی',
  381. align: 'left',
  382. field: row => row.owner_info.national_code
  383. },
  384. {
  385. name: 'owner_info.mobile_number',
  386. required: true,
  387. label: 'تلفن همراه',
  388. align: 'left',
  389. field: row => row.owner_info.mobile_number
  390. },
  391. {
  392. name: 'owner_info.email',
  393. required: true,
  394. label: 'ایمیل',
  395. align: 'left',
  396. field: row => row.owner_info.email
  397. },
  398. {
  399. name: 'owner_info.email',
  400. required: true,
  401. label: 'وضعیت',
  402. align: 'left',
  403. field: row => (new Classroom()).getUserRegisterInfoLabel(row.status)
  404. },
  405. {
  406. name: 'action',
  407. required: true,
  408. label: ' ',
  409. align: 'left',
  410. field: ''
  411. }
  412. ],
  413. data: []
  414. },
  415. membersListTableKeys: {
  416. data: 'results',
  417. total: 'count',
  418. currentPage: 'current',
  419. perPage: 'per_page',
  420. pageKey: 'page'
  421. },
  422. activitySheetListInputs: [
  423. { type: 'hidden', name: 'classroom', value: classroomId },
  424. { type: 'select', name: 'status', value: null, label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
  425. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  426. ],
  427. activitySheetListApi: APIGateway.classroom.APIAdresses.activitySheet,
  428. activitySheetListTable: {
  429. columns: [
  430. {
  431. name: 'id',
  432. required: true,
  433. label: 'شماره',
  434. align: 'left',
  435. field: row => row.id
  436. },
  437. {
  438. name: 'owner_info.fullname',
  439. required: true,
  440. label: 'نام و نام خانوادگی',
  441. align: 'left',
  442. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  443. },
  444. {
  445. name: 'owner_info.fullname',
  446. required: true,
  447. label: 'کد ملی',
  448. align: 'left',
  449. field: row => row.owner_info.national_code
  450. },
  451. {
  452. name: 'is_project_done',
  453. required: true,
  454. label: 'پروژه',
  455. align: 'left',
  456. field: row => row.is_project_done
  457. },
  458. {
  459. name: 'done_assignment_count',
  460. required: true,
  461. label: 'تکالیف انجام شده',
  462. align: 'left',
  463. field: row => row.done_assignment_count
  464. },
  465. {
  466. name: 'is_allowed_absence_count',
  467. required: true,
  468. label: 'حضور و غیاب',
  469. align: 'left',
  470. field: row => row.is_allowed_absence_count // bool
  471. },
  472. {
  473. name: 'attendance_score',
  474. required: true,
  475. label: 'نمره حضور و غیاب',
  476. align: 'left',
  477. field: row => row.attendance_score
  478. },
  479. {
  480. name: 'final_test',
  481. required: true,
  482. label: 'آزمون',
  483. align: 'left',
  484. field: row => row.final_test // number - null
  485. },
  486. {
  487. name: 'final_status',
  488. required: true,
  489. label: 'وضعیت نهایی',
  490. align: 'left',
  491. field: row => row.final_status
  492. },
  493. {
  494. name: 'actions',
  495. required: true,
  496. label: 'سابقه آموزشی',
  497. align: 'left',
  498. field: ''
  499. }
  500. ],
  501. data: []
  502. },
  503. activitySheetListTableKeys: {
  504. data: 'results',
  505. total: 'count',
  506. currentPage: 'current',
  507. perPage: 'per_page',
  508. pageKey: 'page'
  509. }
  510. }
  511. },
  512. computed: {
  513. selectedCategoryId () {
  514. return this.getInputValue('category')
  515. }
  516. },
  517. watch: {
  518. selectedCategoryId () {
  519. if (!this.mounted) {
  520. return
  521. }
  522. this.setInputValue('unit', null)
  523. this.getUnits(this.selectedCategoryId)
  524. }
  525. },
  526. mounted () {
  527. this.api = APIGateway.classroom.APIAdresses.byId(this.$route.params.id)
  528. this.setMembersListActionBtn()
  529. this.setActivitySheetListActionBtn()
  530. this.preLoadData()
  531. .then(() => {
  532. this.mounted = true
  533. })
  534. .catch(() => {
  535. this.mounted = true
  536. })
  537. },
  538. methods: {
  539. setMembersListActionBtn () {
  540. FormBuilderAssist.setAttributeByName(this.membersListInputs, 'btn', 'atClick', this.searchMembersList)
  541. },
  542. setActivitySheetListActionBtn () {
  543. FormBuilderAssist.setAttributeByName(this.activitySheetListInputs, 'btn', 'atClick', this.searchActivitySheetList)
  544. },
  545. searchMembersList () {
  546. this.$refs.membersList.search()
  547. },
  548. searchActivitySheetList () {
  549. this.$refs.activitySheet.search()
  550. },
  551. goToLiveStreamUrl () {
  552. window.open(this.classroom.live_streaming_url, '_blank')
  553. },
  554. afterLoadInputData (data) {
  555. this.classroom = new Classroom(data)
  556. // const gg = data.beginning_enrollment_period.replace('T', ' ')
  557. // this.setInputAttr('beginning_enrollment_period', 'value', gg)
  558. },
  559. setInputAttr (name, attr, value) {
  560. FormBuilderAssist.setAttributeByName(this.inputs, name, attr, value)
  561. // this.$refs.classroomEntityEdit.setInputAttributeByName(name, attr, value)
  562. },
  563. preLoadData () {
  564. return new Promise((resolve, reject) => {
  565. APIGateway.classroom.get(this.$route.params.id)
  566. .then((classroom) => {
  567. this.setInputAttr('category', 'value', classroom.unit_info.category_info.id)
  568. this.setInputAttr('unit', 'value', classroom.unit)
  569. this.beforeLoadInputData(classroom)
  570. .then((classroom) => {
  571. resolve()
  572. })
  573. .catch(() => {
  574. reject()
  575. })
  576. })
  577. .catch(() => {
  578. reject()
  579. })
  580. })
  581. },
  582. beforeLoadInputData (responseData) {
  583. return new Promise((resolve, reject) => {
  584. const promise1 = this.getProfessors()
  585. const promise2 = this.getCategories()
  586. const promise3 = this.getUnits(responseData.unit_info.category)
  587. this.$nextTick(() => {
  588. Promise.all([promise1, promise2, promise3])
  589. .then(() => {
  590. // this.setInputAttr('category', 'value', responseData.unit_info.category)
  591. // this.setInputAttr('unit', 'value', responseData.unit)
  592. this.classroomEntityEditKey = Date.now()
  593. resolve()
  594. })
  595. .catch(() => {
  596. reject()
  597. })
  598. })
  599. })
  600. },
  601. getProfessors () {
  602. return APIGateway.user.index({ per_page: 9999, role: 'professor' })
  603. .then((users) => {
  604. this.setInputAttr('professor', 'options', users.list.list.map(item => {
  605. return {
  606. value: item.id,
  607. label: this.getUserFullname(item)
  608. }
  609. }))
  610. })
  611. .catch(() => {})
  612. },
  613. getCategories () {
  614. return APIGateway.unitCategory.index({ per_page: 9999 })
  615. .then((categories) => {
  616. this.setInputAttr('category', 'options', categories.list.list.map(item => {
  617. return {
  618. value: item.id,
  619. label: item.title
  620. }
  621. }))
  622. })
  623. .catch(() => {})
  624. },
  625. getUnits (selectedcategoryId) {
  626. return APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
  627. .then((units) => {
  628. this.setInputAttr('unit', 'options', units.list.list.map(item => {
  629. return {
  630. value: item.id,
  631. label: item.title
  632. }
  633. }))
  634. })
  635. .catch(() => {})
  636. },
  637. getUserFullname (user) {
  638. return user.firstname + ' ' + user.lastname
  639. },
  640. getSelectOptions (result, value, label) {
  641. return result.map(item => {
  642. return {
  643. value: item[value],
  644. label: item[label]
  645. }
  646. })
  647. },
  648. getInputValue (name) {
  649. const inputIndex = this.inputs.findIndex(input => input.name === name)
  650. return this.inputs[inputIndex].value
  651. },
  652. setInputValue (name, value) {
  653. const inputIndex = this.inputs.findIndex(input => input.name === name)
  654. this.inputs[inputIndex].value = value
  655. },
  656. loadSelectOptions (name, value, setNewInputData) {
  657. const inputIndex = this.inputs.findIndex(input => input.name === name)
  658. this.inputs[inputIndex].options = value
  659. if (typeof setNewInputData === 'function') {
  660. setNewInputData(this.inputs)
  661. }
  662. },
  663. updateClassroom () {
  664. this.$refs.classroomEntityEdit.editEntity()
  665. },
  666. getMembersExcel () {
  667. this.exportReportLoading = true
  668. const status = FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value ? FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value : null
  669. APIGateway.registration.exportReport({
  670. classroom: this.$route.params.id,
  671. type: 'users',
  672. status
  673. })
  674. .then((csvData) => {
  675. Assist.saveCSV(csvData, this.classroom.title)
  676. this.exportReportLoading = false
  677. })
  678. .catch(() => {
  679. this.exportReportLoading = false
  680. })
  681. },
  682. getRemoveMessage (row) {
  683. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  684. },
  685. dropClassroomByAdmin (row) {
  686. const classroomId = row.classroom
  687. const userId = row.owner
  688. const message = 'آیا از انصراف (' + row.owner_info.firstname + ' ' + row.owner_info.lastname + ') اطمینان دارید؟'
  689. this.$q.dialog({
  690. title: 'توجه',
  691. message,
  692. html: true,
  693. cancel: true,
  694. persistent: true
  695. }).onOk(() => {
  696. this.dropClassroomByAdminLoading = true
  697. APIGateway.classroom.dropByAdmin(classroomId, userId)
  698. .then(() => {
  699. this.dropClassroomByAdminLoading = false
  700. this.searchMembersList()
  701. })
  702. .catch(() => {
  703. this.dropClassroomByAdminLoading = false
  704. })
  705. })
  706. }
  707. }
  708. }
  709. </script>
  710. <style lang="scss" scoped>
  711. .AdminClassroomShow {
  712. .action-column-entity-index {
  713. display: flex;
  714. align-items: center;
  715. justify-content: flex-start;
  716. }
  717. }
  718. </style>