show.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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: 'file', name: 'codes', responseKey: 'codes', label: 'آیین نامه دوره', col: 'col-md-3 col-12' },
  221. { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
  222. { type: 'select', name: 'category', responseKey: 'unit_info.category_info.id', options: [], value: null, placeholder: ' ', label: 'دسته بندی', col: 'col-md-3 col-12' },
  223. { type: 'select', name: 'unit', responseKey: 'unit', options: [], value: null, placeholder: ' ', label: 'درس', col: 'col-md-3 col-12' },
  224. { type: 'select', name: 'holding_type', responseKey: 'holding_type', options: Enums.classroomHoldingTypes, value: null, placeholder: ' ', label: 'نوع برگزاری', col: 'col-md-3 col-12' },
  225. { type: 'input', name: 'price', responseKey: 'price', placeholder: ' ', label: 'هزینه برگزاری', col: 'col-md-3 col-12' },
  226. { type: 'input', name: 'live_streaming_url', responseKey: 'live_streaming_url', placeholder: ' ', label: 'لینک مکان مجازی دوره', col: 'col-12' },
  227. { type: 'inputEditor', name: 'classroom_address', responseKey: 'classroom_address', placeholder: ' ', label: 'آدرس مکان فیزیکی دوره', col: 'col-12' },
  228. {
  229. type: 'select',
  230. name: 'holding_year',
  231. responseKey: 'holding_year',
  232. options: [1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410],
  233. value: null,
  234. label: 'انتخاب سال دوره',
  235. placeholder: ' ',
  236. col: 'col-md-3'
  237. },
  238. {
  239. type: 'select',
  240. name: 'holding_month',
  241. responseKey: 'holding_month',
  242. options: [
  243. 'فروردین',
  244. 'اردیبهشت',
  245. 'خرداد',
  246. 'تیر',
  247. 'مرداد',
  248. 'شهریور',
  249. 'مهر',
  250. 'آبان',
  251. 'آذر',
  252. 'دی',
  253. 'بهمن',
  254. 'اسفند'
  255. ],
  256. value: null,
  257. label: 'انتخاب ماه دوره',
  258. placeholder: ' ',
  259. col: 'col-md-3'
  260. },
  261. { type: 'input', name: 'sessions_frequency', responseKey: 'sessions_frequency', placeholder: ' ', label: 'دوره تناوب', col: 'col-12' },
  262. { type: 'select', name: 'professor', responseKey: 'professor', options: [], value: null, placeholder: ' ', label: 'استاد دوره', col: 'col-md-3 col-12' },
  263. { type: 'separator', name: 'space', label: 'مشخصات اندیشه جو', className: 'custom-separator', col: 'col-12' },
  264. // { type: 'select', name: 'audience_status_wwwww', responseKey: 'audience_status_wwwww', options: [], placeholder: ' ', label: 'وضعیت(؟)', col: 'col-md-3 col-12' },
  265. // { type: 'select', name: 'category', responseKey: 'category', options: [], placeholder: ' ', label: 'مجموعه(؟)', col: 'col-md-3 col-12' },
  266. { type: 'select', name: 'audience_gender_type', responseKey: 'audience_gender_type', options: Enums.classroomGenders, placeholder: ' ', label: 'جنسیت', col: 'col-md-3 col-12' },
  267. // { type: 'select', name: 'audience_bashgah_wwwww', responseKey: 'audience_bashgah_wwwww', options: [], placeholder: ' ', label: 'باشگاه(؟)', col: 'col-md-3 col-12' },
  268. { type: 'separator', name: 'space', label: 'تنظیمات دوره', className: 'custom-separator', col: 'col-12' },
  269. { type: 'input', name: 'capacity', responseKey: 'capacity', placeholder: ' ', label: 'ظرفیت گروه درسی', col: 'col-md-3 col-12' },
  270. { type: 'input', name: 'allowed_absence_count', responseKey: 'allowed_absence_count', placeholder: ' ', label: 'تعداد مجاز غیبت', col: 'col-md-3 col-12' },
  271. { type: 'input', name: 'effective_absence_coefficient', responseKey: 'effective_absence_coefficient', placeholder: ' ', label: 'وزن نمره حضور و غیاب ', col: 'col-md-3 col-12' },
  272. { type: 'input', name: 'mandatory_assignment_count', responseKey: 'mandatory_assignment_count', placeholder: ' ', label: 'تعداد تکالیف اجباری', col: 'col-md-3 col-12' },
  273. { type: 'input', name: 'special_passing_mark', responseKey: 'special_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروطی ها', col: 'col-md-3 col-12' },
  274. { type: 'input', name: 'minimum_conditional_passing_mark', responseKey: 'minimum_conditional_passing_mark', placeholder: ' ', label: 'نمره قبولی مشروط', col: 'col-md-3 col-12' },
  275. { type: 'input', name: 'minimum_clean_passing_mark', responseKey: 'minimum_clean_passing_mark', placeholder: ' ', label: 'نمره قبولی', col: 'col-md-3 col-12' },
  276. { type: 'separator', name: 'space', label: 'ثبت نام و حذف و اضافه', className: 'custom-separator', col: 'col-12' },
  277. { type: 'dateTime', name: 'beginning_enrollment_period', responseKey: 'beginning_enrollment_period', outsideLabel: 'تاریخ شروع پیش ثبت نام', col: 'col-md-6 col-12' },
  278. { type: 'dateTime', name: 'ending_enrollment_period', responseKey: 'ending_enrollment_period', outsideLabel: 'تاریخ پایان پیش ثبت نام', col: 'col-md-6 col-12' },
  279. { type: 'dateTime', name: 'beginning_registration_period', responseKey: 'beginning_registration_period', outsideLabel: 'تاریخ شروع ثبت نام', col: 'col-md-6 col-12' },
  280. { type: 'dateTime', name: 'ending_registration_period', responseKey: 'ending_registration_period', outsideLabel: 'تاریخ پایان ثبت نام', col: 'col-md-6 col-12' },
  281. { type: 'input', name: 'registration_period_refund_percent', responseKey: 'registration_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه ثبت نام', col: 'col-md-3 col-12' },
  282. { type: 'checkbox', name: 'allow_dropping_on_enrollment_period', responseKey: 'allow_dropping_on_enrollment_period', label: 'امکان حذف در بازه پیش ثبت نام', col: 'col-md-3 col-12' },
  283. { type: 'checkbox', name: 'allow_adding_on_registration_period', responseKey: 'allow_adding_on_registration_period', label: 'امکان اضافه کردن در بازه ثبت نام', col: 'col-md-3 col-12' },
  284. { type: 'checkbox', name: 'allow_dropping_on_registration_period', responseKey: 'allow_dropping_on_registration_period', label: 'امکان حذف ثبت نام در بازه ثبت نام', col: 'col-md-3 col-12' },
  285. { type: 'dateTime', name: 'beginning_drop_add_period', responseKey: 'beginning_drop_add_period', outsideLabel: 'تاریخ شروع حذف و اضافه', col: 'col-md-6 col-12' },
  286. { type: 'dateTime', name: 'ending_drop_add_period', responseKey: 'ending_drop_add_period', outsideLabel: 'تاریخ پایان حذف و اضافه', col: 'col-md-6 col-12' },
  287. { type: 'input', name: 'drop_add_period_refund_percent', responseKey: 'drop_add_period_refund_percent', placeholder: ' ', label: 'درصد برگشت هزینه انصراف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  288. { type: 'checkbox', name: 'allow_adding_on_drop_add_period', responseKey: 'allow_adding_on_drop_add_period', label: 'امکان اضافه شدن در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  289. { type: 'checkbox', name: 'allow_dropping_on_drop_add_period', responseKey: 'allow_dropping_on_drop_add_period', label: 'امکان حذف در بازه حذف و اضافه', col: 'col-md-3 col-12' },
  290. { type: 'dateTime', name: 'publish_time', responseKey: 'publish_time', outsideLabel: 'تاریخ انتشار', col: 'col-md-6 col-12' },
  291. { type: 'separator', name: 'space', label: 'قوانین', className: 'custom-separator', col: 'col-12' },
  292. { type: 'inputEditor', name: 'rules', responseKey: 'rules', label: 'قوانین دوره آموزشی', col: 'col-12' },
  293. { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات', col: 'col-12' },
  294. { type: 'inputEditor', name: 'specification', responseKey: 'specification', label: 'مشخصات', col: 'col-12' },
  295. { type: 'inputEditor', name: 'bulletin', responseKey: 'bulletin', label: 'تابلو اعلانات', col: 'col-12' },
  296. // -----------------------------------------------------------------------------------------------------------
  297. // { type: 'separator', name: 'space', label: 'موارد زیر در طرح نبودند', className: 'custom-separator', col: 'col-12' },
  298. // { type: 'select', name: 'audience_role', responseKey: 'audience_role', options: Enums.groups, placeholder: ' ', label: 'نقش', col: 'col-md-4 col-12' },
  299. { type: 'hidden', name: 'id', responseKey: 'id', label: 'id', col: 'col-md-3 col-12' }
  300. ],
  301. classroom: new Classroom(),
  302. sessionListInputs: [
  303. { type: 'hidden', name: 'classroom', value: this.$route.params.id, label: 'نام دوره', col: 'col-12' }
  304. ],
  305. sessionListApi: APIGateway.session.APIAdresses.base,
  306. sessionListTable: {
  307. columns: [
  308. {
  309. name: 'id',
  310. required: true,
  311. label: 'شماره',
  312. align: 'left',
  313. field: row => row.id
  314. },
  315. {
  316. name: 'title',
  317. required: true,
  318. label: 'عنوان جلسه',
  319. align: 'left',
  320. field: row => row.title
  321. },
  322. {
  323. name: 'creation_time',
  324. required: true,
  325. label: 'زمان شروع جلسه',
  326. align: 'left',
  327. field: row => row.beginning_time ? ShamsiDate.getDateTime(row.beginning_time) : '-'
  328. },
  329. {
  330. name: 'last_modification_time',
  331. required: true,
  332. label: 'زمان پایان جلسه',
  333. align: 'left',
  334. field: row => row.ending_time ? ShamsiDate.getDateTime(row.ending_time) : '-'
  335. },
  336. {
  337. name: 'actions',
  338. required: true,
  339. label: 'عملیات',
  340. align: 'left',
  341. field: ''
  342. }
  343. ],
  344. data: []
  345. },
  346. sessionListTableKeys: {
  347. data: 'results',
  348. total: 'count',
  349. currentPage: 'current',
  350. perPage: 'per_page',
  351. pageKey: 'page'
  352. },
  353. dropClassroomByAdminLoading: false,
  354. exportReportLoading: false,
  355. membersListInputs: [
  356. { type: 'hidden', name: 'classroom', value: classroomId },
  357. { type: 'select', name: 'status', options: [{ label: 'پیش ثبت نام شده', value: 'ENROLLED' }, { label: 'ثبت نام شده', value: 'REGISTERED' }, { label: 'حذف توسط اندیشه جو', value: 'DROPPED_BY_ITSELF' }, { label: 'حذف توسط ادمین', value: 'DROPPED_BY_ADMIN' }, { label: 'حذف سیستمی (شرایط غیر مجاز)', value: 'DROPPED_FOR_CONDITION' }, { label: 'حذف به دلیل عدم نهایی سازی', value: 'DROPPED_FOR_NOT_FINALIZING' }], label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
  358. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  359. ],
  360. membersListApi: APIGateway.classroom.APIAdresses.members,
  361. membersListTable: {
  362. columns: [
  363. {
  364. name: 'number',
  365. required: true,
  366. label: 'شماره',
  367. align: 'left',
  368. field: () => ''
  369. },
  370. {
  371. name: 'id',
  372. required: true,
  373. label: 'شناسه',
  374. align: 'left',
  375. field: row => row.id
  376. },
  377. {
  378. name: 'owner_info.fullname',
  379. required: true,
  380. label: 'نام و نام خانوادگی',
  381. align: 'left',
  382. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  383. },
  384. {
  385. name: 'owner_info.national_code',
  386. required: true,
  387. label: 'کد ملی',
  388. align: 'left',
  389. field: row => row.owner_info.national_code
  390. },
  391. {
  392. name: 'owner_info.mobile_number',
  393. required: true,
  394. label: 'تلفن همراه',
  395. align: 'left',
  396. field: row => row.owner_info.mobile_number
  397. },
  398. {
  399. name: 'owner_info.email',
  400. required: true,
  401. label: 'ایمیل',
  402. align: 'left',
  403. field: row => row.owner_info.email
  404. },
  405. {
  406. name: 'owner_info.email',
  407. required: true,
  408. label: 'وضعیت',
  409. align: 'left',
  410. field: row => (new Classroom()).getUserRegisterInfoLabel(row.status)
  411. },
  412. {
  413. name: 'action',
  414. required: true,
  415. label: ' ',
  416. align: 'left',
  417. field: ''
  418. }
  419. ],
  420. data: []
  421. },
  422. membersListTableKeys: {
  423. data: 'results',
  424. total: 'count',
  425. currentPage: 'current',
  426. perPage: 'per_page',
  427. pageKey: 'page'
  428. },
  429. activitySheetListInputs: [
  430. { type: 'hidden', name: 'classroom', value: classroomId },
  431. { type: 'select', name: 'status', value: null, label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
  432. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  433. ],
  434. activitySheetListApi: APIGateway.classroom.APIAdresses.activitySheet,
  435. activitySheetListTable: {
  436. columns: [
  437. {
  438. name: 'id',
  439. required: true,
  440. label: 'شماره',
  441. align: 'left',
  442. field: row => row.id
  443. },
  444. {
  445. name: 'owner_info.fullname',
  446. required: true,
  447. label: 'نام و نام خانوادگی',
  448. align: 'left',
  449. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  450. },
  451. {
  452. name: 'owner_info.fullname',
  453. required: true,
  454. label: 'کد ملی',
  455. align: 'left',
  456. field: row => row.owner_info.national_code
  457. },
  458. {
  459. name: 'is_project_done',
  460. required: true,
  461. label: 'پروژه',
  462. align: 'left',
  463. field: row => row.is_project_done
  464. },
  465. {
  466. name: 'done_assignment_count',
  467. required: true,
  468. label: 'تکالیف انجام شده',
  469. align: 'left',
  470. field: row => row.done_assignment_count
  471. },
  472. {
  473. name: 'is_allowed_absence_count',
  474. required: true,
  475. label: 'حضور و غیاب',
  476. align: 'left',
  477. field: row => row.is_allowed_absence_count // bool
  478. },
  479. {
  480. name: 'attendance_score',
  481. required: true,
  482. label: 'نمره حضور و غیاب',
  483. align: 'left',
  484. field: row => row.attendance_score
  485. },
  486. {
  487. name: 'final_test',
  488. required: true,
  489. label: 'آزمون',
  490. align: 'left',
  491. field: row => row.final_test // number - null
  492. },
  493. {
  494. name: 'final_status',
  495. required: true,
  496. label: 'وضعیت نهایی',
  497. align: 'left',
  498. field: row => row.final_status
  499. },
  500. {
  501. name: 'actions',
  502. required: true,
  503. label: 'سابقه آموزشی',
  504. align: 'left',
  505. field: ''
  506. }
  507. ],
  508. data: []
  509. },
  510. activitySheetListTableKeys: {
  511. data: 'results',
  512. total: 'count',
  513. currentPage: 'current',
  514. perPage: 'per_page',
  515. pageKey: 'page'
  516. }
  517. }
  518. },
  519. computed: {
  520. selectedCategoryId () {
  521. return this.getInputValue('category')
  522. }
  523. },
  524. watch: {
  525. selectedCategoryId () {
  526. if (!this.mounted) {
  527. return
  528. }
  529. this.setInputValue('unit', null)
  530. this.getUnits(this.selectedCategoryId)
  531. }
  532. },
  533. mounted () {
  534. this.api = APIGateway.classroom.APIAdresses.byId(this.$route.params.id)
  535. this.setMembersListActionBtn()
  536. this.setActivitySheetListActionBtn()
  537. this.preLoadData()
  538. .then(() => {
  539. this.mounted = true
  540. })
  541. .catch(() => {
  542. this.mounted = true
  543. })
  544. },
  545. methods: {
  546. setMembersListActionBtn () {
  547. FormBuilderAssist.setAttributeByName(this.membersListInputs, 'btn', 'atClick', this.searchMembersList)
  548. },
  549. setActivitySheetListActionBtn () {
  550. FormBuilderAssist.setAttributeByName(this.activitySheetListInputs, 'btn', 'atClick', this.searchActivitySheetList)
  551. },
  552. searchMembersList () {
  553. this.$refs.membersList.search()
  554. },
  555. searchActivitySheetList () {
  556. this.$refs.activitySheet.search()
  557. },
  558. goToLiveStreamUrl () {
  559. window.open(this.classroom.live_streaming_url, '_blank')
  560. },
  561. afterLoadInputData (data) {
  562. this.classroom = new Classroom(data)
  563. // const gg = data.beginning_enrollment_period.replace('T', ' ')
  564. // this.setInputAttr('beginning_enrollment_period', 'value', gg)
  565. },
  566. setInputAttr (name, attr, value) {
  567. FormBuilderAssist.setAttributeByName(this.inputs, name, attr, value)
  568. // this.$refs.classroomEntityEdit.setInputAttributeByName(name, attr, value)
  569. },
  570. preLoadData () {
  571. return new Promise((resolve, reject) => {
  572. APIGateway.classroom.get(this.$route.params.id)
  573. .then((classroom) => {
  574. this.setInputAttr('category', 'value', classroom.unit_info.category_info.id)
  575. this.setInputAttr('unit', 'value', classroom.unit)
  576. this.beforeLoadInputData(classroom)
  577. .then((classroom) => {
  578. resolve()
  579. })
  580. .catch(() => {
  581. reject()
  582. })
  583. })
  584. .catch(() => {
  585. reject()
  586. })
  587. })
  588. },
  589. beforeLoadInputData (responseData) {
  590. return new Promise((resolve, reject) => {
  591. const promise1 = this.getProfessors()
  592. const promise2 = this.getCategories()
  593. const promise3 = this.getUnits(responseData.unit_info.category_info.id)
  594. this.$nextTick(() => {
  595. Promise.all([promise1, promise2, promise3])
  596. .then(() => {
  597. // this.setInputAttr('category', 'value', responseData.unit_info.category)
  598. // this.setInputAttr('unit', 'value', responseData.unit)
  599. this.classroomEntityEditKey = Date.now()
  600. resolve()
  601. })
  602. .catch(() => {
  603. reject()
  604. })
  605. })
  606. })
  607. },
  608. getProfessors () {
  609. return APIGateway.user.index({ per_page: 9999, role: 'professor' })
  610. .then((users) => {
  611. this.setInputAttr('professor', 'options', users.list.list.map(item => {
  612. return {
  613. value: item.id,
  614. label: this.getUserFullname(item)
  615. }
  616. }))
  617. })
  618. .catch(() => {})
  619. },
  620. getCategories () {
  621. return APIGateway.unitCategory.index({ per_page: 9999, type: 'DISCUSSION_CIRCLE' })
  622. .then((categories) => {
  623. this.setInputAttr('category', 'options', categories.list.list.map(item => {
  624. return {
  625. value: item.id,
  626. label: item.title
  627. }
  628. }))
  629. })
  630. .catch(() => {})
  631. },
  632. getUnits (selectedcategoryId) {
  633. if (!selectedcategoryId) {
  634. this.setInputAttr('unit', 'options', [])
  635. return
  636. }
  637. this.unitsLoading = true
  638. return APIGateway.unit.index({ per_page: 9999, category: selectedcategoryId })
  639. .then((units) => {
  640. this.setInputAttr('unit', 'options', units.list.list.map(item => {
  641. return {
  642. value: item.id,
  643. label: item.title
  644. }
  645. }))
  646. this.unitsLoading = false
  647. })
  648. .catch(() => {
  649. this.unitsLoading = false
  650. })
  651. },
  652. getUserFullname (user) {
  653. return user.firstname + ' ' + user.lastname
  654. },
  655. getSelectOptions (result, value, label) {
  656. return result.map(item => {
  657. return {
  658. value: item[value],
  659. label: item[label]
  660. }
  661. })
  662. },
  663. getInputValue (name) {
  664. const inputIndex = this.inputs.findIndex(input => input.name === name)
  665. return this.inputs[inputIndex].value
  666. },
  667. setInputValue (name, value) {
  668. const inputIndex = this.inputs.findIndex(input => input.name === name)
  669. this.inputs[inputIndex].value = value
  670. },
  671. loadSelectOptions (name, value, setNewInputData) {
  672. const inputIndex = this.inputs.findIndex(input => input.name === name)
  673. this.inputs[inputIndex].options = value
  674. if (typeof setNewInputData === 'function') {
  675. setNewInputData(this.inputs)
  676. }
  677. },
  678. updateClassroom () {
  679. this.$refs.classroomEntityEdit.editEntity()
  680. },
  681. getMembersExcel () {
  682. this.exportReportLoading = true
  683. const status = FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value ? FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value : null
  684. APIGateway.registration.exportReport({
  685. classroom: this.$route.params.id,
  686. type: 'users',
  687. status
  688. })
  689. .then((xlsxData) => {
  690. Assist.saveXlsx(xlsxData, this.classroom.title)
  691. this.exportReportLoading = false
  692. })
  693. .catch(() => {
  694. this.exportReportLoading = false
  695. })
  696. },
  697. getRemoveMessage (row) {
  698. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  699. },
  700. dropClassroomByAdmin (row) {
  701. const classroomId = row.classroom
  702. const userId = row.owner
  703. const message = 'آیا از انصراف (' + row.owner_info.firstname + ' ' + row.owner_info.lastname + ') اطمینان دارید؟'
  704. this.$q.dialog({
  705. title: 'توجه',
  706. message,
  707. html: true,
  708. cancel: true,
  709. persistent: true
  710. }).onOk(() => {
  711. this.dropClassroomByAdminLoading = true
  712. APIGateway.classroom.dropByAdmin(classroomId, userId)
  713. .then(() => {
  714. this.dropClassroomByAdminLoading = false
  715. this.searchMembersList()
  716. })
  717. .catch(() => {
  718. this.dropClassroomByAdminLoading = false
  719. })
  720. })
  721. }
  722. }
  723. }
  724. </script>
  725. <style lang="scss" scoped>
  726. .AdminClassroomShow {
  727. .action-column-entity-index {
  728. display: flex;
  729. align-items: center;
  730. justify-content: flex-start;
  731. }
  732. }
  733. </style>