ClassroomList.vue 12 KB

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