ali преди 3 години
родител
ревизия
2bde4b25cf
променени са 4 файла, в които са добавени 190 реда и са изтрити 31 реда
  1. 2 1
      src/api/models/Classroom.js
  2. 20 0
      src/api/models/Registration.js
  3. 18 26
      src/models/Classroom.js
  4. 150 4
      src/pages/Admin/Classroom/show.vue

+ 2 - 1
src/api/models/Classroom.js

@@ -11,7 +11,8 @@ export default class ClassroomAPI extends APIRepository {
       byId: (id) => '/lma/classrooms/' + id,
       enroll: (id) => '/lma/classrooms/' + id + '/enroll',
       drop: (id) => '/lma/classrooms/' + id + '/drop',
-      members: (classroomId) => '/lma/registrations/activity_sheet?classroom=' + classroomId,
+      members: '/lma/registrations',
+      activitySheet: '/lma/registrations/activity_sheet',
       enrollByAdmin: (classroomId, userId) => '/lma/classrooms/' + classroomId + '/enrolll?user_id=' + userId,
       dropByAdmin: (classroomId, userId) => '/lma/classrooms/' + classroomId + '/drop?user_id=' + userId,
       createInvoice: (id) => '/lma/classrooms/' + id + '/create_invoice',

+ 20 - 0
src/api/models/Registration.js

@@ -7,6 +7,7 @@ export default class RegistrationAPI extends APIRepository {
     super('registrations', appApi, '/lma/registrations', Registration)
     this.APIAdresses = {
       base: '/lma/registrations',
+      exportReport: '/lma/registrations/export_report',
       byId: (id) => '/lma/registrations/' + id
     }
     this.CacheList = {
@@ -46,4 +47,23 @@ export default class RegistrationAPI extends APIRepository {
       }
     })
   }
+
+  exportReport(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.exportReport,
+      data: this.getNormalizedSendData({
+        classroom: null, // Number
+        type: null, // String
+        status: null // String
+      }, data),
+      resolveCallback: (response) => {
+        return response.data
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 18 - 26
src/models/Classroom.js

@@ -72,27 +72,29 @@ class Classroom extends Model {
       { key: 'is_deleted' },
       { key: 'status' }
 
-    ])
-
-    this.statusEnums = [
-      {
-        label: 'قبل از دوره حذف و اضافه',
-        value: 'BEFORE_DROP_ADD_PERIOD'
-      },
-      {
-        label: 'در دوره حذف و اضافه',
-        value: 'IN_REGISTRATION_PERIOD'
+    ], {
+      status: {
+        infoKey: 'status_info',
+        enumListKey: 'statusEnums',
+        enums: [
+          {
+            label: 'قبل از دوره حذف و اضافه',
+            value: 'BEFORE_DROP_ADD_PERIOD'
+          },
+          {
+            label: 'در دوره حذف و اضافه',
+            value: 'IN_REGISTRATION_PERIOD'
+          }
+        ]
       }
-    ]
-
-    this.loadStatusInfo()
+    })
 
     if (!this.thumbnail) {
       this.thumbnail = '/assets/images/web/sample-class-thumbnail.jpg'
     }
   }
 
-  getUserRegisterInfoLabel () {
+  getUserRegisterInfoLabel (status) {
     const enums = {
       REGISTERED: 'ثبت نام شده',
       ENROLLED: 'پیش ثبت نام شده',
@@ -100,19 +102,9 @@ class Classroom extends Model {
       DROPPED_BY_ADMIN: 'حذف شده توسط ادمین'
     }
 
-    return enums[this.current_user_register_info?.status] || null
-  }
+    const target = status || this.current_user_register_info?.status
 
-  loadStatusInfo () {
-    const target = this.statusEnums.find(type => type.value === this.status)
-    if (!target) {
-      this.status_info = {
-        label: null,
-        value: null
-      }
-    } else {
-      this.status_info = target
-    }
+    return enums[target] || null
   }
 }
 

+ 150 - 4
src/pages/Admin/Classroom/show.vue

@@ -17,6 +17,8 @@
              label="آزمون" />
       <q-tab name="members"
              label="اندیشه جویان" />
+      <q-tab name="activity_sheet"
+             label="فعالیت کلاسی" />
       <q-tab name="live_streaming_url"
              label="بخش آنلاین" />
     </q-tabs>
@@ -104,6 +106,48 @@
                       :show-search-button="false"
                       :show-reload-button="false"
                       :show-expand-button="false">
+          <template #toolbar>
+            <q-btn color="primary"
+                   :loading="exportReportLoading"
+                   @click="getMembersExcel">
+              خروجی اکسل
+            </q-btn>
+          </template>
+          <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
+            <template v-if="inputData.col.name === 'number'">
+              {{ inputData.rowNumber }}
+            </template>
+            <template v-else-if="inputData.col.name === 'action'">
+              <div class="action-column-entity-index">
+                <q-btn size="md"
+                       color="red"
+                       outline
+                       label="انصراف"
+                       class="q-mr-md"
+                       @click="showConfirmRemoveDialog(inputData.props.row, 'id', getRemoveRegistrationMessage(inputData.props.row))" />
+              </div>
+            </template>
+            <template v-else>
+              {{ inputData.col.value }}
+            </template>
+          </template>
+        </entity-index>
+        <q-skeleton v-else
+                    type="rect"
+                    height="200px" />
+      </q-tab-panel>
+      <q-tab-panel name="activity_sheet"
+                   class="q-pa-none">
+        <entity-index v-if="mounted"
+                      ref="activitySheetList"
+                      v-model:value="activitySheetListInputs"
+                      title="فعالیت کلاسی"
+                      :api="activitySheetListApi"
+                      :table="activitySheetListTable"
+                      :table-keys="activitySheetListTableKeys"
+                      :show-search-button="false"
+                      :show-reload-button="false"
+                      :show-expand-button="false">
           <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
             <template v-if="inputData.col.name === 'actions'">
               <div class="action-column-entity-index">
@@ -161,6 +205,7 @@ export default {
     DeleteBtn
   },
   data () {
+    const classroomId = this.$route.params.id
     return {
       mounted: false,
       classroomEntityEditKey: Date.now(),
@@ -314,12 +359,89 @@ export default {
         pageKey: 'page'
       },
 
+      exportReportLoading: false,
       membersListInputs: [
-        { type: 'select', name: 'classroom', value: null, label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'hidden', name: 'classroom', value: classroomId },
+        { type: 'select', name: 'status', options: [{ label: 'ثبت نام شده', value: 'REGISTERED' }, { label: 'پیش ثبت نام شده', value: 'ENROLLED' }, { label: 'حذف توسط اندیشه جو', value: 'DROPPED_BY_ITSELF' }, { label: 'حذف توسط ادمین', value: 'DROPPED_BY_ADMIN' }], label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
         { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
       ],
-      membersListApi: null,
+      membersListApi: APIGateway.classroom.APIAdresses.members,
       membersListTable: {
+        columns: [
+          {
+            name: 'number',
+            required: true,
+            label: 'شماره',
+            align: 'left',
+            field: () => ''
+          },
+          {
+            name: 'id',
+            required: true,
+            label: 'شناسه',
+            align: 'left',
+            field: row => row.id
+          },
+          {
+            name: 'owner_info.fullname',
+            required: true,
+            label: 'نام و نام خانوادگی',
+            align: 'left',
+            field: row => row.owner_info.firstname + ' ' + row.owner_info.lastname
+          },
+          {
+            name: 'owner_info.national_code',
+            required: true,
+            label: 'کد ملی',
+            align: 'left',
+            field: row => row.owner_info.national_code
+          },
+          {
+            name: 'owner_info.mobile_number',
+            required: true,
+            label: 'تلفن همراه',
+            align: 'left',
+            field: row => row.owner_info.mobile_number
+          },
+          {
+            name: 'owner_info.email',
+            required: true,
+            label: 'ایمیل',
+            align: 'left',
+            field: row => row.owner_info.email
+          },
+          {
+            name: 'owner_info.email',
+            required: true,
+            label: 'وضعیت',
+            align: 'left',
+            field: row => (new Classroom()).getUserRegisterInfoLabel(row.status)
+          },
+          {
+            name: 'action',
+            required: true,
+            label: ' ',
+            align: 'left',
+            field: ''
+          }
+        ],
+        data: []
+      },
+      membersListTableKeys: {
+        data: 'results',
+        total: 'count',
+        currentPage: 'current',
+        perPage: 'per_page',
+        pageKey: 'page'
+      },
+
+      activitySheetListInputs: [
+        { type: 'hidden', name: 'classroom', value: classroomId },
+        { type: 'select', name: 'status', value: null, label: 'وضعیت', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: BtnControlComp, name: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
+      ],
+      activitySheetListApi: APIGateway.classroom.APIAdresses.activitySheet,
+      activitySheetListTable: {
         columns: [
           {
             name: 'id',
@@ -394,7 +516,7 @@ export default {
         ],
         data: []
       },
-      membersListTableKeys: {
+      activitySheetListTableKeys: {
         data: 'results',
         total: 'count',
         currentPage: 'current',
@@ -419,7 +541,7 @@ export default {
   },
   mounted () {
     this.api = APIGateway.classroom.APIAdresses.byId(this.$route.params.id)
-    this.membersListApi = APIGateway.classroom.APIAdresses.members(this.$route.params.id)
+    this.setMembersListActionBtn()
     this.setMembersListActionBtn()
     this.preLoadData()
       .then(() => {
@@ -433,9 +555,15 @@ export default {
     setMembersListActionBtn () {
       FormBuilderAssist.setAttributeByName(this.membersListInputs, 'btn', 'atClick', this.searchMembersList)
     },
+    setActivitySheetListActionBtn () {
+      FormBuilderAssist.setAttributeByName(this.activitySheetListInputs, 'btn', 'atClick', this.searchMembersList)
+    },
     searchMembersList () {
       this.$refs.membersList.search()
     },
+    searchActivitySheetList () {
+      this.$refs.activitySheet.search()
+    },
     goToLiveStreamUrl () {
       window.open(this.classroom.live_streaming_url, '_blank')
     },
@@ -551,8 +679,26 @@ export default {
     updateClassroom () {
       this.$refs.classroomEntityEdit.editEntity()
     },
+    getMembersExcel () {
+      this.exportReportLoading = true
+      const status = FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value ? FormBuilderAssist.getInputsByName(this.membersListInputs, 'status').value : null
+      APIGateway.registration.exportReport({
+        classroom: this.$route.params.id,
+        type: 'user',
+        status
+      })
+        .then(() => {
+          this.exportReportLoading = false
+        })
+        .catch(() => {
+          this.exportReportLoading = false
+        })
+    },
     getRemoveMessage (row) {
       return 'آیا از حذف ' + row.title + ' اطمینان دارید؟'
+    },
+    getRemoveRegistrationMessage (row) {
+      return 'آیا از انصراف (' + row.owner_info.firstname + ' ' + row.owner_info.lastname + ') اطمینان دارید؟'
     }
   }
 }