Ver código fonte

Merge branch 'master' of http://git.hghweb.ir/ali.s/palizvani-front-vite

ali 2 anos atrás
pai
commit
64a54ac727

+ 21 - 0
src/api/models/Classroom.js

@@ -21,6 +21,7 @@ export default class ClassroomAPI extends APIRepository {
       getClassroomAndCorrespondingRegistration: (classroomId, ownerId) => '/lma/classrooms/' + classroomId + '/get_classroom_and_corresponding_registration/' + ownerId,
       members: '/lma/registrations',
       activitySheet: '/lma/registrations/activity_sheet',
+      exportActivitySheetReport: '/lma/registrations/export_report',
       enrollByAdmin: (classroomId, userId) => '/lma/classrooms/' + classroomId + '/enrolll?user_id=' + userId,
       dropByAdmin: (classroomId) => '/lma/classrooms/' + classroomId + '/drop',
       createInvoice: (id) => '/lma/classrooms/' + id + '/create_invoice'
@@ -64,6 +65,26 @@ export default class ClassroomAPI extends APIRepository {
     })
   }
 
+  exportActivitySheetReport(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.exportActivitySheetReport,
+      data: this.getNormalizedSendData({
+        classroom: null, // Number
+        type: null, // String
+        status: null // String
+      }, data),
+      responseType: 'blob',
+      resolveCallback: (response) => {
+        return response.data // xlsxData
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
   get (id) {
     return this.sendRequest({
       apiMethod: 'get',

+ 5 - 4
src/components/EventItem.vue

@@ -87,15 +87,16 @@
 
 <script>
 import { defineComponent } from 'vue'
-import { Event } from 'src/models/Event.js'
+// import { Event } from 'src/models/Event.js'
+import { Classroom } from 'src/models/Classroom' //  using Classroom instead of Event to prevent props warning
 import Assist from 'src/assets/js/Assist.js'
 
 export default defineComponent({
   name: 'OptionPanel',
   props: {
     event: {
-      type: Event,
-      default: new Event()
+      type: Classroom,
+      default: new Classroom()
     }
   },
   data() {
@@ -151,7 +152,7 @@ export default defineComponent({
   },
   methods: {
     getHoldingType (event) {
-      return new Event(event).holding_type_info.label
+      return new Classroom(event).holding_type_info.label
     },
     miladiToShamsi () {
       if (!this.event.publish_time) {

+ 25 - 0
src/components/Widgets/Classroom/AdminClassroomShow/components/ActivitySheetList.vue

@@ -9,6 +9,13 @@
                 :show-search-button="false"
                 :show-reload-button="false"
                 :show-expand-button="false">
+    <template #toolbar>
+      <q-btn color="primary"
+             :loading="exportReportLoading"
+             @click="getActivitySheetExcel">
+        خروجی اکسل
+      </q-btn>
+    </template>
     <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
       <template v-if="inputData.col.name === 'is_project_done'">
         <q-badge rounded
@@ -60,6 +67,7 @@ import { EntityIndex } from 'quasar-crud'
 import { APIGateway } from 'src/api/APIGateway.js'
 import BtnControl from 'src/components/Control/btn.vue'
 import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
+import Assist from 'assets/js/Assist'
 
 const BtnControlComp = shallowRef(BtnControl)
 
@@ -81,6 +89,7 @@ export default {
       mounted: false,
       createInvoiceLoading: false,
 
+      exportReportLoading: false,
       activitySheetListInputs: [
         { type: 'hidden', name: 'classroom', value: classroomId },
         { type: 'input', name: 'owner__national_code', value: null, label: 'کد ملی', placeholder: ' ', col: 'col-md-3 col-12' },
@@ -187,6 +196,22 @@ export default {
     },
     getRemoveMessage (row) {
       return 'آیا از حذف ' + row.owner_info.firstname + ' ' + row.owner_info.lastname + ' اطمینان دارید؟'
+    },
+    getActivitySheetExcel () {
+      this.exportReportLoading = true
+      const status = null
+      APIGateway.classroom.exportActivitySheetReport({
+        classroom: this.$route.params.id,
+        type: 'activity_sheet_export',
+        status
+      })
+        .then((xlsxData) => {
+          Assist.saveXlsx(xlsxData, this.classroomId)
+          this.exportReportLoading = false
+        })
+        .catch((e) => {
+          this.exportReportLoading = false
+        })
     }
   }
 }

+ 5 - 4
src/components/Widgets/Event/LastEvents/LastEvents.vue

@@ -55,7 +55,8 @@ import { User } from 'src/models/User.js'
 import ShamsiDate from 'src/assets/ShamsiDate.js'
 import { APIGateway } from 'src/api/APIGateway.js'
 import EventItem from 'src/components/EventItem.vue'
-import { Event, EventList } from 'src/models/Event.js'
+// import { Event, EventList } from 'src/models/Event.js'
+import { Classroom, ClassroomList } from 'src/models/Classroom' //  using Classroom instead of Event to prevent props warning
 import { mixinPrefetchServerData } from 'src/mixin/Mixins.js'
 import { EventRegistrationList } from 'src/models/EventRegistration.js'
 import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel/dist/carousel'
@@ -76,7 +77,7 @@ export default {
     eventsKey: Date.now(),
     userRegistrations: new EventRegistrationList(),
     slide: 0,
-    events: new EventList(),
+    events: new ClassroomList(),
     breakpoints: {
       // 1024 and up
       1024: {
@@ -105,13 +106,13 @@ export default {
   },
   methods: {
     getHoldingType (event) {
-      return new Event(event).holding_type_info.label
+      return new Classroom(event).holding_type_info.label
     },
     prefetchServerDataPromise () {
       return this.getEvents()
     },
     prefetchServerDataPromiseThen (eventList) {
-      this.events = new EventList(eventList.list)
+      this.events = new ClassroomList(eventList.list)
       this.events.loading = false
     },
     prefetchServerDataPromiseCatch () {

+ 17 - 2
src/pages/Public/Events.vue

@@ -6,9 +6,24 @@
 </template>
 
 <script>
-import { mixinSEO, mixinPageOptions, mixinPrefetchServerData } from 'src/mixin/Mixins.js'
+// import { mixinSEO, mixinPageOptions, mixinPrefetchServerData } from 'src/mixin/Mixins.js'
+import { mixinAuth } from 'src/mixin/Mixins.js'
 export default {
   name: 'Public.AllEvents',
-  mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO]
+  mixins: [mixinAuth],
+  // mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO]
+  data () {
+    return {
+      pageConfig: {},
+      pageBuilderEditable: false,
+      pageBuilderLoading: false,
+      currenSections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllClassrooms', options: { style: {}, classroomType: 'EVENT' } }], options: {} }], options: { boxed: true } }] } }]
+    }
+  },
+  mounted() {
+    if (this.user && this.user.id !== null) {
+      this.currenSections = [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllClassrooms', options: { style: {}, classroomType: 'EVENT' } }, { name: 'RegistrationList', options: { style: { marginBottom: '32px' }, classroomType: 'EVENT' } }], options: {} }], options: { boxed: true } }] } }]
+    }
+  }
 }
 </script>

+ 9 - 4
src/pages/Public/classrooms.vue

@@ -7,19 +7,24 @@
 
 <script>
 // import { mixinSEO, mixinPageOptions, mixinPrefetchServerData } from 'src/mixin/Mixins.js'
+import { mixinAuth } from 'src/mixin/Mixins.js'
+
 export default {
   name: 'Public.AllClassrooms',
   // mixins: [mixinPrefetchServerData, mixinPageOptions, mixinSEO],
+  mixins: [mixinAuth],
   data () {
     return {
       pageConfig: {},
       pageBuilderEditable: false,
       pageBuilderLoading: false,
-      currenSections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllClassrooms', options: { imageSource: null, ratio: null, hasAction: false, useAEEEvent: false, AEEEventBody: { id: '-', name: '-', creative: null, position: null }, action: { name: null, route: null, scrollTo: null, eventName: null, eventArgs: null }, xs: { height: null, width: null, src: null }, sm: { height: null, width: null, src: null }, md: { height: null, width: null, src: null }, lg: { height: null, width: null, src: null }, xl: { height: null, width: null, src: null }, style: { marginBottom: '32px' } } }, { name: 'RegistrationList', options: { style: { marginBottom: '32px' } } }] }], options: { boxed: true } }] } }]
+      currenSections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllClassrooms', options: { imageSource: null, ratio: null, hasAction: false, useAEEEvent: false, AEEEventBody: { id: '-', name: '-', creative: null, position: null }, action: { name: null, route: null, scrollTo: null, eventName: null, eventArgs: null }, xs: { height: null, width: null, src: null }, sm: { height: null, width: null, src: null }, md: { height: null, width: null, src: null }, lg: { height: null, width: null, src: null }, xl: { height: null, width: null, src: null }, style: { marginBottom: '32px' } } }] }], options: { boxed: true } }] } }]
+    }
+  },
+  mounted() {
+    if (this.user && this.user.id !== null) {
+      this.currenSections = [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AllClassrooms', options: { imageSource: null, ratio: null, hasAction: false, useAEEEvent: false, AEEEventBody: { id: '-', name: '-', creative: null, position: null }, action: { name: null, route: null, scrollTo: null, eventName: null, eventArgs: null }, xs: { height: null, width: null, src: null }, sm: { height: null, width: null, src: null }, md: { height: null, width: null, src: null }, lg: { height: null, width: null, src: null }, xl: { height: null, width: null, src: null }, style: { marginBottom: '32px' } } }, { name: 'RegistrationList', options: { style: { marginBottom: '32px' } } }] }], options: { boxed: true } }] } }]
     }
   }
-  // mounted() {
-  //   this.currenSections = this.sections
-  // }
 }
 </script>