ali 3 anni fa
parent
commit
9f58379113

+ 34 - 0
src/api/models/ProjectAttendanceSheets.js

@@ -7,6 +7,7 @@ export default class ProjectAttendanceSheetsAPI extends APIRepository {
     super('project', appApi, '/lma/projects', ProjectAttendanceSheets)
     this.APIAdresses = {
       base: '/lma/project_attendance_sheets',
+      project_sheets: '/lma/project_attendance_sheets/project_sheets',
       byId: (id) => '/lma/project_attendance_sheets/' + id
     }
     this.CacheList = {
@@ -47,4 +48,37 @@ export default class ProjectAttendanceSheetsAPI extends APIRepository {
       }
     })
   }
+
+  projectSheets(data) {
+    return this.sendRequest({
+      apiMethod: 'get',
+      api: this.api,
+      request: this.APIAdresses.base,
+      data: this.getNormalizedSendData({
+        project: null, // Number
+        per_page: 10, // Number
+        page: 1 // Number
+      }, data),
+      resolveCallback: (response) => {
+        const paginate = response.data
+        const results = response.data.results
+        delete paginate.results
+        return {
+          list: new ProjectAttendanceSheetsList(results),
+          paginate
+          // {
+          //   "count": 1,
+          //   "num_pages": 1,
+          //   "per_page": 10,
+          //   "current": 1,
+          //   "next": null,
+          //   "previous": null,
+          // }
+        }
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 31 - 2
src/models/ProjectAttendanceSheets.js

@@ -1,3 +1,4 @@
+import { User } from 'src/models/User.js'
 import { Model, Collection } from 'js-abstract-model'
 
 class ProjectAttendanceSheets extends Model {
@@ -5,9 +6,37 @@ class ProjectAttendanceSheets extends Model {
     super(data, [
       { key: 'id' },
       { key: 'project' },
+      { key: 'is_answer_verified' },
       { key: 'answer_text' },
-      { key: 'answer_attachment' }
-    ])
+      { key: 'answer_status' },
+      { key: 'answer_attachment' },
+      { key: 'creation_time' },
+      { key: 'last_modification_time' },
+      { key: 'owner' },
+      {
+        key: 'owner_info',
+        relatedModel: User
+      }
+    ], {
+      answer_status: {
+        infoKey: 'answer_status_info',
+        enumListKey: 'answer_statusEnums',
+        enums: [
+          {
+            label: 'ارسال نشده',
+            value: 'NOT_SENT'
+          },
+          {
+            label: 'ارسال شده',
+            value: 'SENT'
+          },
+          {
+            label: 'بررسی شده',
+            value: 'REVIEWED'
+          }
+        ]
+      }
+    })
   }
 }
 

+ 23 - 59
src/pages/Admin/Classroom/project/members.vue

@@ -18,13 +18,6 @@
                   :show-expand-button="false"
                   :show-reload-button="false"
                   :show-search-button="false">
-      <template #toolbar>
-        <q-btn color="primary"
-               :loading="exportReportLoading"
-               @click="exportExcel">
-          خروجی اکسل
-        </q-btn>
-      </template>
       <template v-slot:entity-index-table-cell="{inputData, showConfirmRemoveDialog}">
         <template v-if="inputData.col.name === 'number'">
           {{ inputData.rowNumber }}
@@ -59,14 +52,15 @@
 </template>
 
 <script>
-import { shallowRef } from 'vue'
+// import { shallowRef } from 'vue'
 import { EntityIndex } from 'quasar-crud'
-import Assist from 'src/assets/js/Assist.js'
 import { APIGateway } from 'src/api/APIGateway.js'
-import BtnControl from 'src/components/Control/btn.vue'
+import { FormBuilderAssist } from 'quasar-form-builder'
+// import BtnControl from 'src/components/Control/btn.vue'
 import DeleteBtn from 'src/components/Control/DeleteBtn.vue'
+import { ProjectAttendanceSheets } from 'src/models/ProjectAttendanceSheets'
 
-const BtnControlComp = shallowRef(BtnControl)
+// const BtnControlComp = shallowRef(BtnControl)
 
 export default {
   name: 'Admin.User.Index',
@@ -75,19 +69,21 @@ export default {
     EntityIndex
   },
   data () {
+    const projectId = this.$route.params.project_id
     return {
       mounted: false,
       exportReportLoading: false,
       inputs: [
-        { type: 'input', name: 'id', value: null, label: 'شناسه', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: 'input', name: 'national_code', value: null, label: 'کد ملی', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: 'input', name: 'mobile_number', value: null, label: 'شماره همراه', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: 'input', name: 'email', value: null, label: 'ایمیل', placeholder: ' ', col: 'col-md-3 col-12' },
-        { type: 'input', name: 'firstname', value: null, label: 'نام', placeholder: ' ', col: 'col-md-3 col-12' },
-        { type: 'input', name: 'lastname', value: null, label: 'نام خانوادگی', placeholder: ' ', col: 'col-md-3 col-12' },
-        { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-3 col-12' }
+        // { type: 'input', name: 'id', value: null, label: 'شناسه', placeholder: ' ', col: 'col-md-4 col-12' },
+        // { type: 'input', name: 'national_code', value: null, label: 'کد ملی', placeholder: ' ', col: 'col-md-4 col-12' },
+        // { type: 'input', name: 'mobile_number', value: null, label: 'شماره همراه', placeholder: ' ', col: 'col-md-4 col-12' },
+        // { type: 'input', name: 'email', value: null, label: 'ایمیل', placeholder: ' ', col: 'col-md-3 col-12' },
+        // { type: 'input', name: 'firstname', value: null, label: 'نام', placeholder: ' ', col: 'col-md-3 col-12' },
+        // { type: 'input', name: 'lastname', value: null, label: 'نام خانوادگی', placeholder: ' ', col: 'col-md-3 col-12' },
+        // { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-3 col-12' },
+        { type: 'hidden', name: 'project', value: projectId }
       ],
-      api: APIGateway.user.APIAdresses.base,
+      api: APIGateway.projectAttendanceSheets.APIAdresses.project_sheets,
       table: {
         columns: [
           {
@@ -109,42 +105,28 @@ export default {
             required: true,
             label: 'نام و نام خانوادگی',
             align: 'left',
-            field: row => row.firstname + ' ' + row.lastname
+            field: row => row.owner_info?.firstname + ' ' + row.owner_info?.lastname
           },
           {
             name: 'national_code',
             required: true,
             label: 'کد ملی',
             align: 'left',
-            field: row => row.national_code
+            field: row => row.owner_info?.national_code
           },
           {
             name: 'mobile_number',
             required: true,
-            label: 'شماره همراه',
-            align: 'left',
-            field: row => row.mobile_number
-          },
-          {
-            name: 'email',
-            required: true,
-            label: 'ایمیل',
-            align: 'left',
-            field: row => row.email
-          },
-          {
-            name: 'roles',
-            required: true,
-            label: 'نقش',
+            label: 'وضعیت',
             align: 'left',
-            field: row => row.roles.join(', ')
+            field: row => new ProjectAttendanceSheets(row).answer_status_info.label
           },
           {
-            name: 'is_active',
+            name: 'mobile_number',
             required: true,
-            label: 'وضعیت',
+            label: 'نتیجه',
             align: 'left',
-            field: row => row.is_active ? 'فعال' : 'غیر فعال'
+            field: row => (row.is_answer_verified === null) ? '-' : ((row.is_answer_verified ? 'انجام شده' : 'انجام نشده'))
           },
           {
             name: 'action',
@@ -170,26 +152,8 @@ export default {
     this.mounted = true
   },
   methods: {
-    exportExcel () {
-      const params = this.$refs.entityIndex.createParams()
-      this.exportReportLoading = true
-      delete params.btn
-      params.type = 'users'
-      APIGateway.user.exportReport(params)
-        .then((xlsxData) => {
-          Assist.saveXlsx(xlsxData, 'لیست کاربران')
-          this.exportReportLoading = false
-        })
-        .catch(() => {
-          this.exportReportLoading = false
-        })
-    },
     setActionBtn () {
-      this.inputs.forEach((item, index) => {
-        if (item.name === 'btn') {
-          this.inputs[index].atClick = this.search
-        }
-      })
+      FormBuilderAssist.setAttributeByName(this.inputs, 'btn', 'atClick', this.search)
     },
     search () {
       this.$refs.entityIndex.search()

+ 1 - 1
src/pages/Admin/Classroom/show.vue

@@ -456,7 +456,7 @@ export default {
       },
 
       projectListInputs: [
-        { type: 'hidden', name: 'classroom', value: this.$route.params.id, label: 'نام دوره', col: 'col-12' }
+        { type: 'hidden', name: 'classroom', value: this.$route.params.id }
       ],
       projectListApi: APIGateway.project.APIAdresses.base,
       projectListTable: {