ClassroomAnswerBookList.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="ClassroomAnswerBookList">
  3. <entity-index v-if="mounted"
  4. ref="entityIndex"
  5. v-model:value="inputs"
  6. title="لیست نتایج"
  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: 'UserPanel.Classroom.MyAsGraderClassroom.AnswerBooks.ShowGrade', params: {classroom_id: $route.params.classroom_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. import { AnswerBook } from 'src/models/AnswerBook'
  45. const BtnControlComp = shallowRef(BtnControl)
  46. export default {
  47. name: 'ClassroomAnswerBookList',
  48. components: {
  49. EntityIndex
  50. },
  51. mixins: [mixinWidget, mixinAuth],
  52. data () {
  53. return {
  54. mounted: false,
  55. defaultOptions: {
  56. classroomType: 'TRAINING'
  57. },
  58. api: APIGateway.answerBook.APIAdresses.base,
  59. inputs: [
  60. {
  61. type: 'select',
  62. name: 'status',
  63. clearable: false,
  64. options: [
  65. { label: 'در انتظار تصحیح', value: 'WAITING_FOR_GRADING' },
  66. { label: 'در حال تصحیح', value: 'GRADING' },
  67. { label: 'تصحیح شده', value: 'GRADED' },
  68. {
  69. label: 'حذف شده',
  70. value: 'DELETED'
  71. },
  72. {
  73. label: 'نیاز به رفع مشکل',
  74. value: 'UNGRADABLE'
  75. },
  76. {
  77. label: 'اعتراض شده',
  78. value: 'OBJECTED'
  79. },
  80. {
  81. label: 'پاسخ اعتراض',
  82. value: 'OBJECTION_RESPONDED'
  83. }
  84. ],
  85. label: 'وضعیت',
  86. placeholder: ' ',
  87. value: 'WAITING_FOR_GRADING',
  88. col: 'col-md-4 col-12'
  89. },
  90. { type: 'hidden', name: 'test__classroom', value: this.$route.params.classroom_id },
  91. { type: 'hidden', name: 'grader', value: null },
  92. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  93. ],
  94. table: {
  95. columns: [
  96. {
  97. name: 'number',
  98. required: true,
  99. label: 'شماره',
  100. align: 'left',
  101. field: () => ''
  102. },
  103. {
  104. name: 'id',
  105. required: true,
  106. label: 'شناسه',
  107. align: 'left',
  108. field: row => row.id
  109. },
  110. {
  111. name: 'owner_info.fullname',
  112. required: true,
  113. label: 'نام و نام خانوادگی',
  114. align: 'left',
  115. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  116. },
  117. {
  118. name: 'owner_info.mobile_number',
  119. required: true,
  120. label: 'موبایل',
  121. align: 'left',
  122. field: row => row.owner_info.mobile_number
  123. },
  124. {
  125. name: 'title',
  126. required: true,
  127. label: 'عنوان آزمون',
  128. align: 'left',
  129. field: row => row.test_info.title
  130. },
  131. {
  132. name: 'test_questions_length',
  133. required: true,
  134. label: 'تعداد سوالات',
  135. align: 'left',
  136. field: row => row.test_info.test_questions_length
  137. },
  138. // {
  139. // name: 'level',
  140. // required: true,
  141. // label: 'درچه سختی',
  142. // align: 'left',
  143. // field: row => (new Test(row.test_set_info)).level_info.label
  144. // },
  145. {
  146. name: 'test_info_status_info',
  147. required: true,
  148. label: 'وضعیت آزمون',
  149. align: 'left',
  150. field: row => (new Test(row.test_info)).status_info.label
  151. },
  152. {
  153. name: 'status_info',
  154. required: true,
  155. label: 'وضعیت تصحیح',
  156. align: 'left',
  157. field: row => (new AnswerBook(row)).status_info.label
  158. },
  159. {
  160. name: 'actions',
  161. required: true,
  162. label: 'عملیات',
  163. align: 'left',
  164. field: ''
  165. }
  166. ]
  167. },
  168. tableKeys: {
  169. data: 'results',
  170. total: 'count',
  171. currentPage: 'current',
  172. perPage: 'per_page',
  173. pageKey: 'page'
  174. }
  175. }
  176. },
  177. computed: {
  178. selectedStatus () {
  179. const target = FormBuilderAssist.getInputsByName(this.inputs, 'status')
  180. return target?.value
  181. },
  182. classroomTypeTitle () {
  183. const unitCategory = new UnitCategory({ type: this.localOptions.classroomType })
  184. return unitCategory.type_info.label
  185. },
  186. createPageRouteName () {
  187. if (this.localOptions.classroomType === 'TRAINING') {
  188. return 'Admin.Classroom.Create'
  189. }
  190. if (this.localOptions.classroomType === 'EVENT') {
  191. return 'Admin.Event.Create'
  192. }
  193. return 'Admin.Classroom.Create'
  194. },
  195. showPageRouteName () {
  196. if (this.localOptions.classroomType === 'TRAINING') {
  197. return 'Admin.Classroom.Show'
  198. }
  199. if (this.localOptions.classroomType === 'EVENT') {
  200. return 'Admin.Event.Show'
  201. }
  202. return 'Admin.Classroom.Show'
  203. }
  204. },
  205. watch: {
  206. selectedStatus (newValue) {
  207. let grader = this.user.id
  208. if (newValue === 'WAITING_FOR_GRADING') {
  209. grader = null
  210. }
  211. FormBuilderAssist.setAttributeByName(this.inputs, 'grader', 'value', grader)
  212. }
  213. },
  214. mounted () {
  215. this.setActionBtn()
  216. // this.setClassroomTypeOfInputs() // for what?
  217. this.mounted = true
  218. },
  219. methods: {
  220. setActionBtn () {
  221. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  222. },
  223. setClassroomTypeOfInputs () {
  224. this.table.columns.forEach(col => {
  225. if (col.name === 'title') {
  226. col.label = 'نام ' + this.classroomTypeTitle
  227. }
  228. if (col.name === 'professor_info') {
  229. col.label = (this.localOptions.classroomType === 'TRAINING') ? 'استاد مربوطه' : 'برگزار کننده'
  230. }
  231. })
  232. },
  233. search () {
  234. this.$refs.entityIndex.search()
  235. },
  236. getSelectOptions (result, value, label) {
  237. return result.map(item => {
  238. return {
  239. value: item[value],
  240. label: item[label]
  241. }
  242. })
  243. },
  244. getRemoveMessage (row) {
  245. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  246. },
  247. getClassroomHoldingTypeTitle (type) {
  248. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  249. if (!target) {
  250. return '-'
  251. }
  252. return target.label
  253. },
  254. getClassroomStatusesTitle (type) {
  255. const target = Enums.classroomStatuses.find(item => item.value === type)
  256. if (!target) {
  257. return '-'
  258. }
  259. return target.label
  260. }
  261. }
  262. }
  263. </script>
  264. <style lang="scss" scoped>
  265. .ClassroomAnswerBookList {
  266. .add-new-action-row {
  267. display: flex;
  268. flex-flow: row;
  269. align-items: center;
  270. justify-content: flex-end;
  271. margin-bottom: 22px;
  272. }
  273. .action-column-entity-index {
  274. display: flex;
  275. align-items: center;
  276. justify-content: flex-start;
  277. }
  278. }
  279. </style>