projectInfo.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <breadcrumbs style="margin-top: 29px; margin-bottom: 19px;" />
  3. <div class="flex justify-end">
  4. <q-btn flat
  5. color="grey"
  6. @click="$router.go(-1)">
  7. بازگشت
  8. >
  9. </q-btn>
  10. </div>
  11. <entity-show v-if="mounted"
  12. ref="projectEntityEdit"
  13. v-model:value="inputs"
  14. title="جزییات پروژه"
  15. :api="api"
  16. :show-index-button="false"
  17. :show-close-button="false"
  18. :show-edit-button="false"
  19. :show-expand-button="false"
  20. :show-save-button="false"
  21. :show-reload-button="false"
  22. :after-load-input-data="afterLoadProject">
  23. <template #after-form-builder>
  24. <q-separator class="q-my-lg" />
  25. <entity-create ref="entityCreate"
  26. v-model:value="attendanceSheetsInputs"
  27. :api="attendanceSheetsApi"
  28. :default-layout="false" />
  29. </template>
  30. </entity-show>
  31. </template>
  32. <script>
  33. import { shallowRef } from 'vue'
  34. import { Project } from 'src/models/Project.js'
  35. import { APIGateway } from 'src/api/APIGateway.js'
  36. import { Classroom } from 'src/models/Classroom.js'
  37. import { EntityShow, EntityCreate } from 'quasar-crud'
  38. import BtnControl from 'src/components/Control/btn.vue'
  39. import Breadcrumbs from 'src/components/Widgets/Breadcrumbs/Breadcrumbs.vue'
  40. import ContentsSelector from 'src/components/FormBuilderCustumComponents/ContentsSelector/ContentsSelector.vue'
  41. import { FormBuilderAssist } from 'quasar-form-builder'
  42. const BtnControlComp = shallowRef(BtnControl)
  43. const ContentsSelectorComp = shallowRef(ContentsSelector)
  44. export default {
  45. name: 'UserPanel.Profile.ClassroomInfo',
  46. components: {
  47. Breadcrumbs,
  48. EntityShow,
  49. EntityCreate
  50. },
  51. data () {
  52. const projectId = this.$route.params.project_id
  53. return {
  54. mounted: false,
  55. projectLoaded: false,
  56. classroomLoaded: false,
  57. project: new Project(),
  58. classroom: new Classroom(),
  59. api: APIGateway.project.APIAdresses.byId(projectId),
  60. inputs: [
  61. { type: 'input', name: 'title', responseKey: 'title', label: 'عنوان پروژه', placeholder: ' ', col: 'col-md-6 col-12' },
  62. {
  63. type: 'select',
  64. name: 'type',
  65. responseKey: 'type',
  66. label: 'نوع پروژه',
  67. options: (new Project()).typeEnums,
  68. placeholder: ' ',
  69. col: 'col-md-3 col-12'
  70. },
  71. { type: 'dateTime', name: 'beginning_doing_period', responseKey: 'beginning_doing_period', label: 'زمان شروع', placeholder: ' ', col: 'col-md-6 col-12' },
  72. { type: 'dateTime', name: 'ending_doing_period', responseKey: 'ending_doing_period', label: 'زمان پایان', placeholder: ' ', col: 'col-md-6 col-12' },
  73. { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
  74. { type: 'inputEditor', name: 'description', responseKey: 'description', label: 'توضیحات پروژه', placeholder: ' ', col: 'col-12' },
  75. { type: ContentsSelectorComp, name: 'contents', responseKey: 'contents_info', col: 'col-12' },
  76. { type: 'hidden', name: 'id', responseKey: 'id' },
  77. { type: 'hidden', name: 'classroom', responseKey: 'classroom' }
  78. ],
  79. attendanceSheetsApi: APIGateway.projectAttendanceSheets.APIAdresses.base,
  80. attendanceSheetsInputs: [
  81. { type: 'separator', name: 'space', label: 'انجام پروژه', className: 'custom-separator', col: 'col-12' },
  82. { type: 'inputEditor', name: 'answer_text', label: 'متن پاسخ', placeholder: ' ', col: 'col-12' },
  83. { type: 'file', name: 'answer_attachment', label: 'فای ضمیمه', placeholder: ' ', col: 'col-md-4 col-12' },
  84. { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'ارسال پروژه', placeholder: ' ', atClick: () => {}, col: 'col-12' },
  85. { type: 'hidden', name: 'project', value: projectId }
  86. ]
  87. }
  88. },
  89. computed: {
  90. projectAndClassroomLoaded () {
  91. return this.projectLoaded && this.classroomLoaded
  92. }
  93. },
  94. watch: {
  95. projectAndClassroomLoaded (newValue) {
  96. if (!newValue) {
  97. return
  98. }
  99. this.$store.commit('AppLayout/updateBreadcrumbs', {
  100. visible: true,
  101. loading: false,
  102. path: [
  103. {
  104. label: 'دوره های من',
  105. to: { name: 'UserPanel.Profile.AllClassrooms' }
  106. },
  107. {
  108. label: this.classroom.title,
  109. to: { name: 'UserPanel.Profile.ClassroomInfo', params: { id: this.classroom.id } }
  110. },
  111. {
  112. label: this.classroom.title,
  113. to: { name: 'UserPanel.Profile.ClassroomInfo', params: { classroom_id: this.classroom.id, project_id: this.project.id } }
  114. }
  115. ]
  116. })
  117. }
  118. },
  119. mounted () {
  120. this.mounted = true
  121. this.getClassroomInfo()
  122. FormBuilderAssist.setAttributeByName(this.attendanceSheetsInputs, 'btn', 'atClick', this.createAttendanceSheet)
  123. },
  124. methods: {
  125. createAttendanceSheet () {
  126. this.$refs.entityCreate.createEntity(false)
  127. .then(() => {
  128. this.reloadProject()
  129. })
  130. .catch(() => {
  131. this.reloadProject()
  132. })
  133. },
  134. getClassroomInfo () {
  135. const classroomId = this.$route.params.classroom_id
  136. this.classroom.loading = true
  137. APIGateway.classroom.get(classroomId)
  138. .then((classroom) => {
  139. this.classroom = new Classroom(classroom)
  140. this.classroom.loading = false
  141. this.classroomLoaded = true
  142. })
  143. .catch(() => {
  144. this.classroom.loading = false
  145. })
  146. },
  147. afterLoadProject (data) {
  148. this.project = new Project(data)
  149. this.projectLoaded = true
  150. },
  151. reloadProject () {
  152. this.$refs.projectEntityEdit.getData()
  153. }
  154. }
  155. }
  156. </script>