ClassroomList.vue 11 KB

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