ClassroomList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <breadcrumbs style="margin-top: 29px; margin-bottom: 19px;" />
  3. <template v-if="mounted">
  4. <q-card class="barcode-section">
  5. <q-card-section>
  6. شناسه ورود به جلسه
  7. </q-card-section>
  8. <q-separator />
  9. <form-builder-bar-code lable=""
  10. :value="this.national_code" />
  11. </q-card>
  12. </template>
  13. <entity-index v-if="mounted"
  14. ref="entityIndex"
  15. v-model:value="inputs"
  16. :title="listTitle"
  17. :api="api"
  18. :table="table"
  19. :table-keys="tableKeys"
  20. :table-grid-size="$q.screen.lt.sm"
  21. :show-expand-button="false"
  22. :show-reload-button="false"
  23. :show-search-button="false">
  24. <template #entity-index-table-cell="{inputData}">
  25. <template v-if="inputData.col.name === 'number'">
  26. {{ inputData.rowNumber }}
  27. </template>
  28. <template v-if="inputData.col.name === 'status'">
  29. <div :class="this.getRegistrationStatusTitleClass(inputData.props.row)">
  30. {{ this.getRegistrationStatusTitle(inputData.props.row) }}
  31. </div>
  32. </template>
  33. <template v-else-if="inputData.col.name === 'action'">
  34. <q-btn size="md"
  35. color="primary"
  36. label="جزییات"
  37. :to="{name: showPageRouteName, params: {id: inputData.props.row.classroom_info.id}}" />
  38. </template>
  39. <template v-else>
  40. {{ inputData.col.value }}
  41. </template>
  42. </template>
  43. <template #entity-index-table-item-cell="{inputData}">
  44. <user-classroom-card :registration="inputData.props.row" />
  45. </template>
  46. </entity-index>
  47. </template>
  48. <script>
  49. import { shallowRef } from 'vue'
  50. import { EntityIndex } from 'quasar-crud'
  51. import Enums from 'src/assets/Enums/Enums.js'
  52. import { Invoice } from 'src/models/Invoice.js'
  53. import ShamsiDate from 'src/assets/ShamsiDate.js'
  54. import { APIGateway } from 'src/api/APIGateway.js'
  55. import { FormBuilderAssist } from 'quasar-form-builder'
  56. import BtnControl from 'src/components/Control/btn.vue'
  57. import { Registration } from 'src/models/Registration.js'
  58. import { mixinAuth, mixinWidget } from 'src/mixin/Mixins.js'
  59. import UserClassroomCard from 'src/components/Widgets/Classroom/UserClassroomCard/UserClassroomCard.vue'
  60. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  61. import { TranscriptSheet } from 'src/models/TranscriptSheet'
  62. import FormBuilderBarCode from 'src/components/FormBuilderCustumComponents/FormBuilderBarCode.vue'
  63. const BtnControlComp = shallowRef(BtnControl)
  64. export default {
  65. name: 'UserPanel.Profile.AllClassrooms',
  66. components: {
  67. FormBuilderBarCode,
  68. EntityIndex,
  69. Breadcrumbs,
  70. UserClassroomCard
  71. },
  72. mixins: [mixinAuth, mixinWidget],
  73. data () {
  74. return {
  75. mounted: false,
  76. national_code: null,
  77. inputs: [
  78. {
  79. type: 'select',
  80. name: 'category',
  81. options: [],
  82. value: null,
  83. label: 'گروه آموزشی',
  84. placeholder: ' ',
  85. col: 'col-md-2 col-12'
  86. },
  87. {
  88. type: 'select',
  89. name: 'unit',
  90. responseKey: 'unit',
  91. options: [],
  92. value: null,
  93. label: 'درس',
  94. placeholder: ' ',
  95. col: 'col-md-2 col-12'
  96. },
  97. { type: 'hidden', name: 'classroom__unit__category__type', value: 'TRAINING' },
  98. { type: 'hidden', name: 'owner', value: null },
  99. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  100. ],
  101. api: APIGateway.registration.APIAdresses.base,
  102. table: {
  103. columns: [
  104. {
  105. name: 'number',
  106. required: true,
  107. label: 'شماره',
  108. align: 'left',
  109. field: () => ''
  110. },
  111. {
  112. name: 'classroom_info.title',
  113. required: true,
  114. label: 'عنوان',
  115. align: 'left',
  116. field: row => row.classroom_info?.title
  117. },
  118. {
  119. name: 'title',
  120. required: true,
  121. label: 'نوع برگزاری',
  122. align: 'left',
  123. field: row => this.getClassroomHoldingTypeTitle(row.classroom_info.holding_type)
  124. },
  125. {
  126. name: 'professor_info',
  127. required: true,
  128. label: 'استاد',
  129. align: 'left',
  130. field: row => row.classroom_info?.professor_info?.firstname + ' ' + row.classroom_info?.professor_info?.lastname
  131. },
  132. {
  133. name: 'sessions_info',
  134. required: true,
  135. label: 'تعداد جلسات',
  136. align: 'left',
  137. field: row => row.classroom_info?.sessions_count
  138. },
  139. {
  140. name: 'status',
  141. required: true,
  142. label: 'وضعیت',
  143. align: 'left',
  144. // field: row => (new Registration(row)).status_info.label
  145. field: row => this.getRegistrationStatusTitle(row)
  146. },
  147. {
  148. name: 'title',
  149. required: true,
  150. label: 'زمان ثبت نام',
  151. align: 'left',
  152. field: row => ShamsiDate.getDateTime(row.creation_time)
  153. },
  154. {
  155. name: 'invoice_status',
  156. required: true,
  157. label: 'وضعیت مالی',
  158. align: 'left',
  159. field: row => (new Invoice(row.invoice_info)).status_info.label ? (new Invoice(row.invoice_info)).status_info.label : '-'
  160. },
  161. {
  162. name: 'action',
  163. required: true,
  164. label: 'جزییات',
  165. align: 'left',
  166. field: ''
  167. }
  168. ]
  169. },
  170. defaultOptions: {
  171. classroomType: 'TRAINING'
  172. },
  173. tableKeys: {
  174. data: 'results',
  175. total: 'count',
  176. currentPage: 'current',
  177. perPage: 'per_page',
  178. pageKey: 'page'
  179. }
  180. }
  181. },
  182. computed: {
  183. listTitle () {
  184. if (this.localOptions.classroomType === 'TRAINING') {
  185. return 'لیست دوره های آموزشی'
  186. }
  187. if (this.localOptions.classroomType === 'EVENT') {
  188. return 'لیست رویدادها'
  189. }
  190. return 'لیست دوره های آموزشی'
  191. },
  192. showPageRouteName () {
  193. if (this.localOptions.classroomType === 'TRAINING') {
  194. return 'UserPanel.Profile.ClassroomInfo'
  195. }
  196. if (this.localOptions.classroomType === 'EVENT') {
  197. return 'UserPanel.Profile.EventInfo'
  198. }
  199. return 'UserPanel.Profile.ClassroomInfo'
  200. },
  201. selectedCategoryId () {
  202. return this.getInputValue('category')
  203. }
  204. },
  205. watch: {
  206. selectedCategoryId () {
  207. this.setInputValue('unit', null)
  208. this.getUnits(this.selectedCategoryId)
  209. }
  210. },
  211. mounted () {
  212. this.setClassroomTypeOfInputs()
  213. this.setOwner()
  214. this.setActionBtn()
  215. this.loadInputDataOptions()
  216. this.mounted = true
  217. },
  218. methods: {
  219. setClassroomTypeOfInputs () {
  220. FormBuilderAssist.setAttributeByName(this.inputs, 'classroom__unit__category__type', 'value', this.localOptions.classroomType)
  221. // if (this.localOptions.classroomType === 'TRAINING') {
  222. // }
  223. if (this.localOptions.classroomType === 'EVENT') {
  224. FormBuilderAssist.setAttributeByName(this.inputs, 'classroom__unit__category__type', 'type', 'hidden')
  225. FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'type', 'hidden')
  226. FormBuilderAssist.setAttributeByName(this.inputs, 'unit', 'label', 'دسته')
  227. FormBuilderAssist.setAttributeByName(this.inputs, 'status', 'label', 'مرحله رویداد')
  228. this.table.columns.forEach(col => {
  229. if (col.name === 'professor_info') {
  230. col.label = 'برگزار کننده'
  231. }
  232. if (col.name === 'sessions_info') {
  233. col.label = 'تعداد برنامه ها'
  234. }
  235. })
  236. }
  237. },
  238. setOwner () {
  239. const user = this.$store.getters['Auth/user']
  240. this.national_code = user.national_code
  241. FormBuilderAssist.setAttributeByName(this.inputs, 'owner', 'value', user.id)
  242. },
  243. setActionBtn () {
  244. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  245. },
  246. search () {
  247. this.$refs.entityIndex.search()
  248. },
  249. getClassroomHoldingTypeTitle (type) {
  250. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  251. if (!target) {
  252. return '-'
  253. }
  254. return target.label
  255. },
  256. getRegistrationStatusTitle (registration) {
  257. if (registration.status === 'REGISTERED' && registration.transcript_sheet_info) {
  258. return (new TranscriptSheet(registration.transcript_sheet_info)).status_info.label
  259. } else {
  260. return (new Registration(registration)).status_info.label
  261. }
  262. },
  263. getRegistrationStatusTitleClass (registration) {
  264. if (registration.status === 'REGISTERED' && registration.transcript_sheet_info) {
  265. return (new TranscriptSheet(registration.transcript_sheet_info)).status_info.value
  266. }
  267. return null
  268. },
  269. getClassroomStatusTitle (type) {
  270. const target = Enums.classroomStatuses.find(item => item.value === type)
  271. if (!target) {
  272. return '-'
  273. }
  274. return target.label
  275. },
  276. getInvoiceStatusTitle (type) {
  277. const target = Enums.invoiceStatus.find(item => item.value === type)
  278. if (!target) {
  279. return '-'
  280. }
  281. return target.label
  282. },
  283. loadInputDataOptions () {
  284. this.getCategories()
  285. this.getUnits()
  286. },
  287. getCategories () {
  288. APIGateway.unitCategory.index({ per_page: 9999, type: this.localOptions.classroomType })
  289. .then((categories) => {
  290. FormBuilderAssist.setAttributeByName(this.inputs, 'category', 'options', categories.list.list.map(item => {
  291. return {
  292. value: item.id,
  293. label: item.title
  294. }
  295. }))
  296. })
  297. .catch(() => {})
  298. },
  299. getUnits (selectedcategoryId) {
  300. APIGateway.unit.index({
  301. category: selectedcategoryId,
  302. category__type: this.localOptions.classroomType
  303. })
  304. .then(unitList => {
  305. this.loadSelectOptions('unit', this.getSelectOptions(unitList.list.list, 'id', 'title'))
  306. })
  307. .catch(() => {
  308. })
  309. },
  310. getInputValue (name) {
  311. const inputIndex = this.inputs.findIndex(input => input.name === name)
  312. return this.inputs[inputIndex].value
  313. },
  314. setInputValue (name, value) {
  315. const inputIndex = this.inputs.findIndex(input => input.name === name)
  316. this.inputs[inputIndex].value = value
  317. },
  318. getSelectOptions (result, value, label) {
  319. return result.map(item => {
  320. return {
  321. value: item[value],
  322. label: item[label]
  323. }
  324. })
  325. },
  326. loadSelectOptions (name, value) {
  327. const inputIndex = this.inputs.findIndex(input => input.name === name)
  328. this.inputs[inputIndex].options = value
  329. }
  330. }
  331. }
  332. </script>
  333. <style scoped lang="scss">
  334. .barcode-section{
  335. margin-bottom: 8px;
  336. padding-bottom: 8px;
  337. }
  338. .CLEAN_PASSED {
  339. //font-size: 1.1em;
  340. color: green;
  341. }
  342. .CONDITIONAL_PASSED{
  343. color: yellow;
  344. }
  345. .FAILED{
  346. color: darkred;
  347. }
  348. .FAILED_DUE_TO_PRE_CONDITIONAL{
  349. color: red;
  350. }
  351. </style>