AdminSessionAttendanceSheetList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="AdminSessionAttendanceSheetList"
  3. :style="localOptions.style">
  4. <breadcrumbs class="q-mb-xl"
  5. style="margin-top: 29px; margin-bottom: 19px;" />
  6. <div class="flex justify-end">
  7. <q-btn flat
  8. color="grey"
  9. @click="$router.go(-1)">
  10. بازگشت
  11. >
  12. </q-btn>
  13. </div>
  14. <entity-index v-if="mounted"
  15. ref="entityIndex"
  16. v-model:value="inputs"
  17. title="لیست حضور و غیاب"
  18. :api="api"
  19. :table="table"
  20. :table-keys="tableKeys"
  21. :create-route-name="createRouteName"
  22. :show-search-button="false"
  23. :show-expand-button="false"
  24. :show-reload-button="false">
  25. <template #toolbar>
  26. <q-btn color="primary"
  27. :loading="exportReportLoading"
  28. @click="getReportExcel">
  29. خروجی اکسل
  30. </q-btn>
  31. </template>
  32. <template #after-index-table>
  33. <q-separator class="q-my-lg" />
  34. <entity-edit ref="uploadExcelEntity"
  35. v-model:value="uploadInputs"
  36. title="ارسال لیست حضور و غیاب"
  37. :loaded-data="{}"
  38. :api="uploadAPI"
  39. :show-reload-button="false"
  40. :show-expand-button="false"
  41. :show-save-button="false"
  42. :show-close-button="false" />
  43. </template>
  44. <template #entity-index-table-cell="{inputData}">
  45. <template v-if="inputData.col.name === 'number'">
  46. {{ inputData.rowNumber }}
  47. </template>
  48. <template v-else-if="inputData.col.name === 'action'">
  49. <q-btn color="primary"
  50. outline
  51. class="q-mr-md"
  52. :to="{name: 'Admin.Classroom.Session.AttendanceSheet.Attendance', params: {classroom_id: $route.params.classroom_id, session_id: $route.params.session_id, session_attendance_sheet_id: inputData.props.row.id}}">
  53. حضور و غیاب
  54. </q-btn>
  55. <q-btn v-if="localOptions.classroomType === 'TRAINING'"
  56. color="primary"
  57. :outline="inputData.props.row.assignment_status !== 'NOT_SENT'"
  58. :to="{name: 'Admin.Classroom.Session.AttendanceSheet.Assignment', params: {classroom_id: $route.params.classroom_id, session_id: $route.params.session_id, session_attendance_sheet_id: inputData.props.row.id}}">
  59. <template v-if="inputData.props.row.assignment_status !== 'NOT_SENT'">
  60. ویرایش تصحیح
  61. </template>
  62. <template v-else>
  63. بررسی تکلیف
  64. </template>
  65. </q-btn>
  66. </template>
  67. <template v-else>
  68. {{ inputData.col.value }}
  69. </template>
  70. </template>
  71. </entity-index>
  72. </div>
  73. </template>
  74. <script>
  75. import { shallowRef } from 'vue'
  76. import Assist from 'assets/js/Assist.js'
  77. import { mixinWidget } from 'src/mixin/Mixins.js'
  78. import { APIGateway } from 'src/api/APIGateway.js'
  79. import { Classroom } from 'src/models/Classroom.js'
  80. import { EntityIndex, EntityEdit } from 'quasar-crud'
  81. import { FormBuilderAssist } from 'quasar-form-builder'
  82. import BtnControl from 'src/components/Control/btn.vue'
  83. import { Registration } from 'src/models/Registration.js'
  84. import { UnitCategory } from 'src/models/UnitCategory.js'
  85. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  86. import { SessionAttendanceSheets } from 'src/models/SessionAttendanceSheets.js'
  87. const BtnControlComp = shallowRef(BtnControl)
  88. export default {
  89. name: 'AdminSessionAttendanceSheetList',
  90. components: {
  91. EntityIndex,
  92. EntityEdit,
  93. Breadcrumbs
  94. },
  95. mixins: [mixinWidget],
  96. data () {
  97. const sessionId = this.$route.params.session_id
  98. return {
  99. classroom: new Classroom(),
  100. api: APIGateway.sessionAttendanceSheets.APIAdresses.sessionSheets,
  101. tableKeys: {
  102. data: 'results',
  103. total: 'count',
  104. currentPage: 'current',
  105. perPage: 'per_page',
  106. pageKey: 'page'
  107. },
  108. inputs: [
  109. { type: 'hidden', name: 'session', value: sessionId },
  110. { type: 'input', name: 'owner__national_code', label: 'کد ملی', placeholder: ' ', value: null, col: 'col-md-3 col-12' },
  111. { type: 'select', name: 'registration__status', label: 'وضعیت ثبت نام', placeholder: ' ', value: null, options: (new Registration()).statusEnums, col: 'col-md-3 col-12' },
  112. { type: 'select', name: 'assignment_status', label: 'وضعیت انجام تکلیف', placeholder: ' ', value: null, options: (new SessionAttendanceSheets()).assignment_statusEnums, col: 'col-md-3 col-12' },
  113. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-3 col-12' }
  114. ],
  115. uploadInputs: [
  116. { type: 'hidden', name: 'type', value: 'excel' },
  117. { type: 'file', name: 'file', label: 'انتخاب فایل', placeholder: ' ', value: null, col: 'col-md-8 col-12' },
  118. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ارسال', placeholder: ' ', atClick: () => {}, col: 'col-md-4 col-12' }
  119. ],
  120. uploadAPI: APIGateway.sessionAttendanceSheets.APIAdresses.importList,
  121. tableForClassroom: {
  122. columns: [
  123. {
  124. name: 'number',
  125. required: true,
  126. label: 'شماره',
  127. align: 'left',
  128. field: () => ''
  129. },
  130. {
  131. name: 'id',
  132. required: true,
  133. label: 'شناسه',
  134. align: 'left',
  135. field: row => row.id
  136. },
  137. {
  138. name: 'sender',
  139. required: true,
  140. label: 'نام و نام خانوادگی',
  141. align: 'left',
  142. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  143. },
  144. {
  145. name: 'sender',
  146. required: true,
  147. label: 'کد ملی',
  148. align: 'left',
  149. field: row => row.owner_info.national_code
  150. },
  151. {
  152. name: 'assignment_status',
  153. required: true,
  154. label: 'وضعیت تکلیف',
  155. align: 'left',
  156. field: row => (new SessionAttendanceSheets(row)).assignment_status_info.label
  157. },
  158. {
  159. name: 'attendance_status',
  160. required: true,
  161. label: 'وضعیت حضور و غیاب',
  162. align: 'left',
  163. field: row => (new SessionAttendanceSheets(row)).attendance_status_info.label
  164. },
  165. {
  166. name: 'action',
  167. required: true,
  168. label: 'عملیات',
  169. align: 'left',
  170. field: row => ''
  171. }
  172. ]
  173. },
  174. tableForEvent: {
  175. columns: [
  176. {
  177. name: 'number',
  178. required: true,
  179. label: 'شماره',
  180. align: 'left',
  181. field: () => ''
  182. },
  183. {
  184. name: 'id',
  185. required: true,
  186. label: 'شناسه',
  187. align: 'left',
  188. field: row => row.id
  189. },
  190. {
  191. name: 'sender',
  192. required: true,
  193. label: 'نام و نام خانوادگی',
  194. align: 'left',
  195. field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
  196. },
  197. {
  198. name: 'sender',
  199. required: true,
  200. label: 'کد ملی',
  201. align: 'left',
  202. field: row => row.owner_info.national_code
  203. },
  204. {
  205. name: 'attendance_status',
  206. required: true,
  207. label: 'وضعیت حضور و غیاب',
  208. align: 'left',
  209. field: row => (new SessionAttendanceSheets(row)).attendance_status_info.label
  210. },
  211. {
  212. name: 'action',
  213. required: true,
  214. label: 'عملیات',
  215. align: 'left',
  216. field: row => ''
  217. }
  218. ]
  219. },
  220. table: {
  221. columns: []
  222. },
  223. mounted: false,
  224. exportReportLoading: false,
  225. createRouteName: ''
  226. }
  227. },
  228. computed: {
  229. classroomTypeTitle () {
  230. const unitCategory = new UnitCategory({ type: this.localOptions.classroomType })
  231. return unitCategory.type_info.label
  232. }
  233. },
  234. mounted() {
  235. this.setClassroomTypeOfInputs()
  236. this.mounted = true
  237. this.setActionBtn()
  238. this.getClassroom()
  239. .then(classroom => {
  240. this.updateBreadcrumbs(classroom)
  241. })
  242. },
  243. methods: {
  244. setClassroomTypeOfInputs () {
  245. if (this.localOptions.classroomType === 'TRAINING') {
  246. this.table = this.tableForClassroom
  247. }
  248. if (this.localOptions.classroomType === 'EVENT') {
  249. this.table = this.tableForEvent
  250. }
  251. },
  252. updateBreadcrumbs (classroom) {
  253. this.classroom = new Classroom(classroom)
  254. this.$store.commit('AppLayout/updateBreadcrumbs', {
  255. visible: true,
  256. loading: false,
  257. path: [
  258. {
  259. label: 'لیست ' + this.classroomTypeTitle,
  260. to: { name: 'Admin.Classroom.Index' }
  261. },
  262. {
  263. label: this.classroom.title,
  264. to: { name: 'Admin.Classroom.Show', params: { id: this.$route.params.classroom_id } }
  265. },
  266. {
  267. label: 'لیست حضور و غیاب',
  268. to: { name: 'Admin.Classroom.Session.AttendanceSheetList', params: { classroom_id: this.$route.params.classroom_id, session_id: this.$route.params.session_id } }
  269. }
  270. ]
  271. })
  272. },
  273. search () {
  274. this.$refs.entityIndex.search()
  275. },
  276. getReportExcel () {
  277. this.exportReportLoading = true
  278. const status = FormBuilderAssist.getInputsByName(this.inputs, 'registration__status').value ? FormBuilderAssist.getInputsByName(this.inputs, 'registration__status').value : null
  279. APIGateway.sessionAttendanceSheets.exportReport({
  280. session: this.$route.params.session_id,
  281. type: 'list',
  282. registration__status: status
  283. })
  284. .then((xlsxData) => {
  285. const title = `جلسه ${this.$route.query.session_number} - ${this.classroom.title}`
  286. Assist.saveXlsx(xlsxData, title)
  287. this.exportReportLoading = false
  288. })
  289. .catch((e) => {
  290. this.exportReportLoading = false
  291. })
  292. },
  293. setActionBtn () {
  294. FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
  295. FormBuilderAssist.setAttributeByName(this.uploadInputs, 'btn', 'atClick', this.uploadExcelEntity)
  296. },
  297. getClassroom () {
  298. return APIGateway.classroom.get(this.$route.params.classroom_id)
  299. },
  300. uploadExcelEntity () {
  301. this.$refs.uploadExcelEntity.editEntity(false)
  302. .then(() => {
  303. this.search()
  304. })
  305. .catch(() => {
  306. this.search()
  307. })
  308. }
  309. }
  310. }
  311. </script>
  312. <style scoped lang="scss">
  313. .AdminSessionAttendanceSheetList {
  314. :deep(.entity-edit) {
  315. .q-item {
  316. display: none;
  317. }
  318. }
  319. }
  320. </style>