show.vue 31 KB

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