AdminClassroomAnswerBookList.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div class="AdminClassroomAnswerBookList">
  3. <entity-index v-if="mounted"
  4. ref="entityIndex"
  5. v-model:value="inputs"
  6. :title="'لیست ' + classroomTypeTitle"
  7. :api="api"
  8. :table="table"
  9. :table-keys="tableKeys"
  10. :show-expand-button="false"
  11. :show-reload-button="false"
  12. :show-search-button="false">
  13. <template v-slot:entity-index-table-cell="{inputData}">
  14. <template v-if="inputData.col.name === 'number'">
  15. {{ inputData.rowNumber }}
  16. </template>
  17. <template v-else-if="inputData.col.name === 'actions'">
  18. <div class="action-column-entity-index">
  19. <q-btn size="md"
  20. color="primary"
  21. label="جزییات"
  22. :to="{name: 'Admin.Classroom.Test.AnswerBooks.ShowGrade', params: {classroom_id: $route.params.classroom_id, test_id: $route.params.test_id, answer_book_id: inputData.props.row.id}}"
  23. class="q-mr-md" />
  24. </div>
  25. </template>
  26. <template v-else>
  27. {{ inputData.col.value }}
  28. </template>
  29. </template>
  30. </entity-index>
  31. </div>
  32. </template>
  33. <script>
  34. import { shallowRef } from 'vue'
  35. import { EntityIndex } from 'quasar-crud'
  36. import { Test } from 'src/models/Test.js'
  37. import Enums from 'src/assets/Enums/Enums.js'
  38. import { mixinWidget, mixinAuth } from 'src/mixin/Mixins.js'
  39. import { APIGateway } from 'src/api/APIGateway.js'
  40. // import ShamsiDate from 'src/assets/ShamsiDate.js'
  41. import { FormBuilderAssist } from 'quasar-form-builder'
  42. import BtnControl from 'src/components/Control/btn.vue'
  43. import { UnitCategory } from 'src/models/UnitCategory.js'
  44. const BtnControlComp = shallowRef(BtnControl)
  45. export default {
  46. name: 'AdminClassroomAnswerBookList',
  47. components: {
  48. EntityIndex
  49. },
  50. mixins: [mixinWidget, mixinAuth],
  51. data () {
  52. return {
  53. mounted: false,
  54. defaultOptions: {
  55. classroomType: 'TRAINING'
  56. },
  57. api: APIGateway.answerBook.APIAdresses.base,
  58. inputs: [
  59. {
  60. type: 'select',
  61. name: 'status',
  62. options: [
  63. { label: 'جاری', value: 'CREATED,FETCHED,SUBMITTED' },
  64. { label: 'در حال تصحیح', value: 'GRADING' },
  65. { label: 'تصحیح شده', value: 'GRADED' }
  66. ],
  67. label: 'وضعیت',
  68. placeholder: ' ',
  69. value: null,
  70. col: 'col-md-4 col-12'
  71. },
  72. { type: 'hidden', name: 'test', value: this.$route.params.test_id },
  73. { type: 'hidden', name: 'test__classroom', value: this.$route.params.classroom_id },
  74. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  75. ],
  76. table: {
  77. columns: [
  78. {
  79. name: 'number',
  80. required: true,
  81. label: 'شماره',
  82. align: 'left',
  83. field: () => ''
  84. },
  85. {
  86. name: 'id',
  87. required: true,
  88. label: 'شناسه',
  89. align: 'left',
  90. field: row => row.id
  91. },
  92. {
  93. name: 'owner_info.fullname',
  94. required: true,
  95. label: 'نام و نام خانوادگی',
  96. align: 'left',
  97. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  98. },
  99. {
  100. name: 'owner_info.mobile_number',
  101. required: true,
  102. label: 'موبایل',
  103. align: 'left',
  104. field: row => row.owner_info.mobile_number
  105. },
  106. {
  107. name: 'title',
  108. required: true,
  109. label: 'عنوان آزمون',
  110. align: 'left',
  111. field: row => row.test_info.title
  112. },
  113. {
  114. name: 'test_set_questions_length',
  115. required: true,
  116. label: 'تعداد سوالات',
  117. align: 'left',
  118. field: row => row.test_info.test_set_questions_length
  119. },
  120. // {
  121. // name: 'level',
  122. // required: true,
  123. // label: 'درچه سختی',
  124. // align: 'left',
  125. // field: row => (new Test(row.test_set_info)).level_info.label
  126. // },
  127. {
  128. name: 'test_info_status_info',
  129. required: true,
  130. label: 'وضعیت آزمون',
  131. align: 'left',
  132. field: row => (new Test(row.test_info)).status_info.label
  133. },
  134. {
  135. name: 'actions',
  136. required: true,
  137. label: 'عملیات',
  138. align: 'left',
  139. field: ''
  140. }
  141. ]
  142. },
  143. tableKeys: {
  144. data: 'results',
  145. total: 'count',
  146. currentPage: 'current',
  147. perPage: 'per_page',
  148. pageKey: 'page'
  149. }
  150. }
  151. },
  152. computed: {
  153. classroomTypeTitle () {
  154. const unitCategory = new UnitCategory({ type: this.localOptions.classroomType })
  155. return unitCategory.type_info.label
  156. },
  157. createPageRouteName () {
  158. if (this.localOptions.classroomType === 'TRAINING') {
  159. return 'Admin.Classroom.Create'
  160. }
  161. if (this.localOptions.classroomType === 'EVENT') {
  162. return 'Admin.Event.Create'
  163. }
  164. return 'Admin.Classroom.Create'
  165. },
  166. showPageRouteName () {
  167. if (this.localOptions.classroomType === 'TRAINING') {
  168. return 'Admin.Classroom.Show'
  169. }
  170. if (this.localOptions.classroomType === 'EVENT') {
  171. return 'Admin.Event.Show'
  172. }
  173. return 'Admin.Classroom.Show'
  174. }
  175. },
  176. mounted () {
  177. this.setActionBtn()
  178. this.setClassroomTypeOfInputs()
  179. this.mounted = true
  180. },
  181. methods: {
  182. setActionBtn () {
  183. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  184. },
  185. setClassroomTypeOfInputs () {
  186. this.table.columns.forEach(col => {
  187. if (col.name === 'title') {
  188. col.label = 'نام ' + this.classroomTypeTitle
  189. }
  190. if (col.name === 'professor_info') {
  191. col.label = (this.localOptions.classroomType === 'TRAINING') ? 'استاد مربوطه' : 'برگزار کننده'
  192. }
  193. })
  194. },
  195. search () {
  196. this.$refs.entityIndex.search()
  197. },
  198. getSelectOptions (result, value, label) {
  199. return result.map(item => {
  200. return {
  201. value: item[value],
  202. label: item[label]
  203. }
  204. })
  205. },
  206. getRemoveMessage (row) {
  207. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  208. },
  209. getClassroomHoldingTypeTitle (type) {
  210. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  211. if (!target) {
  212. return '-'
  213. }
  214. return target.label
  215. },
  216. getClassroomStatusesTitle (type) {
  217. const target = Enums.classroomStatuses.find(item => item.value === type)
  218. if (!target) {
  219. return '-'
  220. }
  221. return target.label
  222. }
  223. }
  224. }
  225. </script>
  226. <style lang="scss" scoped>
  227. .AdminClassroomAnswerBookList {
  228. .add-new-action-row {
  229. display: flex;
  230. flex-flow: row;
  231. align-items: center;
  232. justify-content: flex-end;
  233. margin-bottom: 22px;
  234. }
  235. .action-column-entity-index {
  236. display: flex;
  237. align-items: center;
  238. justify-content: flex-start;
  239. }
  240. }
  241. </style>