AdminClassroomAnswerBookList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <div class="AdminClassroomAnswerBookList">
  3. <q-skeleton v-if="!classroom.id"
  4. type="text"
  5. width="200px" />
  6. <breadcrumbs v-else
  7. style="margin-top: 29px; margin-bottom: 19px;" />
  8. <div class="flex justify-end">
  9. <q-btn flat
  10. color="grey"
  11. @click="$router.go(-1)">
  12. بازگشت
  13. >
  14. </q-btn>
  15. </div>
  16. <entity-index v-if="mounted"
  17. ref="entityIndex"
  18. v-model:value="inputs"
  19. :title="'لیست ' + classroomTypeTitle"
  20. :api="api"
  21. :table="table"
  22. :table-keys="tableKeys"
  23. :show-expand-button="false"
  24. :show-reload-button="false"
  25. :show-search-button="false"
  26. @onPageChanged="onPageChanged">
  27. <template v-slot:entity-index-table-cell="{inputData}">
  28. <template v-if="inputData.col.name === 'number'">
  29. {{ inputData.rowNumber }}
  30. </template>
  31. <template v-else-if="inputData.col.name === 'actions'">
  32. <div class="action-column-entity-index">
  33. <q-btn size="md"
  34. color="primary"
  35. :label="inputData.props.row.grader ? 'ویرایش تصحیح' : 'تصحیح آزمون'"
  36. :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}}"
  37. class="q-mr-md" />
  38. </div>
  39. </template>
  40. <template v-else>
  41. {{ inputData.col.value }}
  42. </template>
  43. </template>
  44. </entity-index>
  45. </div>
  46. </template>
  47. <script>
  48. import { shallowRef } from 'vue'
  49. import { EntityIndex } from 'quasar-crud'
  50. import { Test } from 'src/models/Test.js'
  51. import Enums from 'src/assets/Enums/Enums.js'
  52. import { APIGateway } from 'src/api/APIGateway.js'
  53. import { Classroom } from 'src/models/Classroom.js'
  54. import { AnswerBook } from 'src/models/AnswerBook.js'
  55. // import ShamsiDate from 'src/assets/ShamsiDate.js'
  56. import { FormBuilderAssist } from 'quasar-form-builder'
  57. import BtnControl from 'src/components/Control/btn.vue'
  58. import { UnitCategory } from 'src/models/UnitCategory.js'
  59. import { mixinWidget, mixinAuth } from 'src/mixin/Mixins.js'
  60. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  61. import Assist from 'assets/js/Assist'
  62. const BtnControlComp = shallowRef(BtnControl)
  63. export default {
  64. name: 'AdminClassroomAnswerBookList',
  65. components: {
  66. EntityIndex,
  67. Breadcrumbs
  68. },
  69. mixins: [mixinWidget, mixinAuth],
  70. data () {
  71. return {
  72. mounted: false,
  73. entityLoading: true,
  74. test: new Test(),
  75. classroom: new Classroom(),
  76. defaultOptions: {
  77. classroomType: 'TRAINING'
  78. },
  79. api: APIGateway.answerBook.APIAdresses.base,
  80. inputs: [
  81. {
  82. type: 'select',
  83. name: 'status',
  84. options: [
  85. { label: 'جاری', value: 'CREATED,FETCHED,SUBMITTED' },
  86. { label: 'در حال تصحیح', value: 'GRADING' },
  87. { label: 'تصحیح شده', value: 'GRADED' },
  88. {
  89. label: 'حذف شده',
  90. value: 'DELETED'
  91. },
  92. {
  93. label: 'نیاز به رفع مشکل',
  94. value: 'UNGRADABLE'
  95. },
  96. {
  97. label: 'تصحیح شده',
  98. value: 'GRADED'
  99. },
  100. {
  101. label: 'اعتراض شده',
  102. value: 'OBJECTED'
  103. }
  104. ],
  105. label: 'وضعیت',
  106. placeholder: ' ',
  107. value: null,
  108. col: 'col-md-4 col-12'
  109. },
  110. { type: 'hidden', name: 'test', value: this.$route.params.test_id },
  111. { type: 'hidden', name: 'test__classroom', value: this.$route.params.classroom_id },
  112. { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
  113. ],
  114. table: {
  115. columns: [
  116. {
  117. name: 'number',
  118. required: true,
  119. label: 'شماره',
  120. align: 'left',
  121. field: () => ''
  122. },
  123. {
  124. name: 'id',
  125. required: true,
  126. label: 'شناسه',
  127. align: 'left',
  128. field: row => row.id
  129. },
  130. {
  131. name: 'owner_info.fullname',
  132. required: true,
  133. label: 'نام و نام خانوادگی',
  134. align: 'left',
  135. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  136. },
  137. {
  138. name: 'owner_info.national_code',
  139. required: true,
  140. label: 'کد ملی',
  141. align: 'left',
  142. field: row => row.owner_info.national_code
  143. },
  144. {
  145. name: 'attending_start_time',
  146. required: true,
  147. label: 'زمان شروع',
  148. align: 'left',
  149. field: row => row.attending_start_time ? this.toShamsi(row.attending_start_time) : '-'
  150. },
  151. {
  152. name: 'attending_start_time',
  153. required: true,
  154. label: 'زمان پایان',
  155. align: 'left',
  156. field: row => row.attending_end_time ? this.toShamsi(row.attending_end_time) : '-'
  157. },
  158. {
  159. name: 'grader_info',
  160. required: true,
  161. label: 'مصحح',
  162. align: 'left',
  163. field: row => row.grader_info ? row.grader_info.firstname + ' ' + row.grader_info.lastname : '-'
  164. },
  165. {
  166. name: 'last_modification_time',
  167. required: true,
  168. label: 'زمان آخرین ویرایش تصحیح',
  169. align: 'left',
  170. field: row => row.last_modification_time ? this.toShamsi(row.last_modification_time) : '-'
  171. },
  172. // {
  173. // name: 'title',
  174. // required: true,
  175. // label: 'عنوان آزمون',
  176. // align: 'left',
  177. // field: row => row.test_info.title
  178. // },
  179. // {
  180. // name: 'test_questions_length',
  181. // required: true,
  182. // label: 'تعداد سوالات',
  183. // align: 'left',
  184. // field: row => row.test_info.test_questions_length
  185. // },
  186. {
  187. name: 'status_info',
  188. required: true,
  189. label: 'وضعیت تصحیح',
  190. align: 'left',
  191. field: row => (new AnswerBook(row)).status_info.label
  192. },
  193. {
  194. name: 'test_info_status_info',
  195. required: true,
  196. label: 'وضعیت آزمون',
  197. align: 'left',
  198. field: row => (new Test(row.test_info)).status_info.label
  199. },
  200. {
  201. name: 'actions',
  202. required: true,
  203. label: 'عملیات',
  204. align: 'left',
  205. field: ''
  206. }
  207. ]
  208. },
  209. tableKeys: {
  210. data: 'results',
  211. total: 'count',
  212. currentPage: 'current',
  213. perPage: 'per_page',
  214. pageKey: 'page'
  215. }
  216. }
  217. },
  218. computed: {
  219. classroomTypeTitle () {
  220. const unitCategory = new UnitCategory({ type: this.localOptions.classroomType })
  221. return unitCategory.type_info.label
  222. },
  223. createPageRouteName () {
  224. if (this.localOptions.classroomType === 'TRAINING') {
  225. return 'Admin.Classroom.Create'
  226. }
  227. if (this.localOptions.classroomType === 'EVENT') {
  228. return 'Admin.Event.Create'
  229. }
  230. return 'Admin.Classroom.Create'
  231. },
  232. showPageRouteName () {
  233. if (this.localOptions.classroomType === 'TRAINING') {
  234. return 'Admin.Classroom.Show'
  235. }
  236. if (this.localOptions.classroomType === 'EVENT') {
  237. return 'Admin.Event.Show'
  238. }
  239. return 'Admin.Classroom.Show'
  240. }
  241. },
  242. mounted () {
  243. this.setActionBtn()
  244. this.setClassroomTypeOfInputs()
  245. this.mounted = true
  246. },
  247. methods: {
  248. toShamsi (miladi) {
  249. return Assist.miladiToShamsi(miladi)
  250. },
  251. onPageChanged () {
  252. if (!this.classroom.id) {
  253. this.getClassroom()
  254. }
  255. },
  256. getClassroom () {
  257. this.classroom.loading = true
  258. APIGateway.classroom.get(this.$route.params.classroom_id)
  259. .then((classroom) => {
  260. this.classroom = new Classroom(classroom)
  261. this.classroom.loading = false
  262. this.updateBreadcrumbs()
  263. })
  264. .catch(() => {
  265. this.classroom.loading = false
  266. })
  267. },
  268. updateBreadcrumbs () {
  269. this.$store.commit('AppLayout/updateBreadcrumbs', {
  270. visible: true,
  271. loading: false,
  272. path: [
  273. {
  274. label: 'لیست ' + this.classroomTypeTitle,
  275. to: { name: this.indexPageRouteName }
  276. },
  277. {
  278. label: this.classroom.title,
  279. to: { name: this.showPageRouteName, params: { id: this.$route.params.classroom_id } }
  280. },
  281. {
  282. label: 'تصحیح آزمون'
  283. },
  284. {
  285. label: 'لیست شرکت کنندگان'
  286. }
  287. ]
  288. })
  289. },
  290. setActionBtn () {
  291. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  292. },
  293. setClassroomTypeOfInputs () {
  294. this.table.columns.forEach(col => {
  295. if (col.name === 'title') {
  296. col.label = 'نام ' + this.classroomTypeTitle
  297. }
  298. if (col.name === 'professor_info') {
  299. col.label = (this.localOptions.classroomType === 'TRAINING') ? 'استاد مربوطه' : 'برگزار کننده'
  300. }
  301. })
  302. },
  303. search () {
  304. this.$refs.entityIndex.search()
  305. },
  306. getSelectOptions (result, value, label) {
  307. return result.map(item => {
  308. return {
  309. value: item[value],
  310. label: item[label]
  311. }
  312. })
  313. },
  314. getRemoveMessage (row) {
  315. return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
  316. },
  317. getClassroomHoldingTypeTitle (type) {
  318. const target = Enums.classroomHoldingTypes.find(item => item.value === type)
  319. if (!target) {
  320. return '-'
  321. }
  322. return target.label
  323. },
  324. getClassroomStatusesTitle (type) {
  325. const target = Enums.classroomStatuses.find(item => item.value === type)
  326. if (!target) {
  327. return '-'
  328. }
  329. return target.label
  330. }
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. .AdminClassroomAnswerBookList {
  336. .add-new-action-row {
  337. display: flex;
  338. flex-flow: row;
  339. align-items: center;
  340. justify-content: flex-end;
  341. margin-bottom: 22px;
  342. }
  343. .action-column-entity-index {
  344. display: flex;
  345. align-items: center;
  346. justify-content: flex-start;
  347. }
  348. }
  349. </style>