ali 3 éve
szülő
commit
8de482dc1e

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

@@ -10,7 +10,9 @@ export default class ClassroomAPI extends APIRepository {
       base: '/lma/classrooms',
       byId: (id) => '/lma/classrooms/' + id,
       enroll: (id) => '/lma/classrooms/' + id + '/enroll',
+      drop: (id) => '/lma/classrooms/' + id + '/drop',
       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',
       createInvoiceByAdmin: (classroomId, userId) => '/lma/classrooms/' + classroomId + '/create_invoice?user_id=' + userId
     }
@@ -80,11 +82,25 @@ export default class ClassroomAPI extends APIRepository {
     })
   }
 
-  enrollByAdmin (classroomId, userId) {
+  dropByUser (id) {
     return this.sendRequest({
       apiMethod: 'put',
       api: this.api,
-      request: this.APIAdresses.enrollByAdmin(classroomId, userId),
+      request: this.APIAdresses.drop(id),
+      resolveCallback: (response) => {
+        return new Classroom(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  dropByAdmin (classroomId, userId) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.dropByAdmin(classroomId, userId),
       resolveCallback: (response) => {
         return new Classroom(response.data)
       },

+ 24 - 20
src/components/Widgets/Other/Shop/ShopCompleteInfo/ShopCompleteInfo.vue

@@ -144,64 +144,68 @@ export default {
     showRouteName: 'UserPanel.ShopPaymentFromWallet',
     inputs: [
       { type: 'separator', name: 'space', label: 'اطلاعات ضروری', col: 'col-md-12' },
-      { type: 'input', name: 'email', label: 'ایمیل', responseKey: 'email', col: 'col-md-3' },
-      { type: 'input', name: 'on_call_mobile_number', label: 'تلفن همراه', responseKey: 'on_call_mobile_number', col: 'col-md-3' },
-      { type: 'input', name: 'national_code', label: 'کدملی/کد اتباع غیر ایرانی', responseKey: 'national_code', col: 'col-md-3' },
+      { type: 'input', name: 'email', label: 'ایمیل', responseKey: 'email', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'on_call_mobile_number', label: 'تلفن همراه', responseKey: 'on_call_mobile_number', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'national_code', label: 'کدملی/کد اتباع غیر ایرانی', responseKey: 'national_code', placeholder: ' ', col: 'col-md-3' },
       { type: 'separator', name: 'space', label: 'اطلاعات پروفایل', col: 'col-md-12' },
-      { type: 'file', name: 'picture', label: 'عکس پروفایل', responseKey: 'picture', col: 'col-md-3' },
+      { type: 'file', name: 'picture', label: 'عکس پروفایل', responseKey: 'picture', placeholder: ' ', col: 'col-md-3' },
       { type: 'separator', name: 'space', size: '0', col: 'col-md-12' },
-      { type: 'input', name: 'firstname', label: 'نام', responseKey: 'firstname', col: 'col-md-3' },
-      { type: 'input', name: 'lastname', label: 'نام خانوادگی', responseKey: 'lastname', col: 'col-md-3' },
+      { type: 'input', name: 'firstname', label: 'نام', responseKey: 'firstname', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'lastname', label: 'نام خانوادگی', responseKey: 'lastname', placeholder: ' ', col: 'col-md-3' },
       {
         type: 'select',
         name: 'gender',
         responseKey: 'gender',
+        placeholder: ' ',
         options: Enums.genders,
         value: null,
         label: 'جنسیت',
         col: 'col-md-3'
       },
-      { type: 'date', name: 'birthdate', label: 'تولد', responseKey: 'birthdate', col: 'col-md-3' },
+      { type: 'date', name: 'birthdate', label: 'تولد', responseKey: 'birthdate', placeholder: ' ', col: 'col-md-3' },
       {
         type: 'select',
         name: 'marital_status',
         responseKey: 'marital_status',
+        placeholder: ' ',
         options: Enums.maritalStatuses,
         value: null,
         label: 'وضعیت تاهل',
         col: 'col-md-3'
       },
-      { type: 'input', name: 'on_call_mobile_number', label: 'تلفن همراه جهت تماس', responseKey: 'on_call_mobile_number', col: 'col-md-3' },
-      { type: 'input', name: 'on_social_network_mobile_number', label: 'تلفن همراه جهت شبکه های اجتماعی', responseKey: 'on_social_network_mobile_number', col: 'col-md-3' },
-      { type: 'input', name: 'phone_number', label: 'تلفن منزل', responseKey: 'phone_number', col: 'col-md-3' },
+      { type: 'input', name: 'on_call_mobile_number', label: 'تلفن همراه جهت تماس', responseKey: 'on_call_mobile_number', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'on_social_network_mobile_number', label: 'تلفن همراه جهت شبکه های اجتماعی', responseKey: 'on_social_network_mobile_number', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'phone_number', label: 'تلفن منزل', responseKey: 'phone_number', placeholder: ' ', col: 'col-md-3' },
       {
         type: 'select',
         name: 'last_academic_degree',
         responseKey: 'last_academic_degree',
+        placeholder: ' ',
         options: Enums.academicDegree,
         value: null,
         label: 'آخرین مقطع تحصیلی',
         col: 'col-md-3'
       },
-      { type: 'input', name: 'last_academic_degree_field', label: 'رشته تحصیلی', responseKey: 'last_academic_degree_field', col: 'col-md-3' },
-      { type: 'input', name: 'last_academy_name', label: 'نام دانشگاه یا حوزه تحصیلی', responseKey: 'last_academy_name', col: 'col-md-3' },
+      { type: 'input', name: 'last_academic_degree_field', label: 'رشته تحصیلی', responseKey: 'last_academic_degree_field', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'last_academy_name', label: 'نام دانشگاه یا حوزه تحصیلی', responseKey: 'last_academy_name', placeholder: ' ', col: 'col-md-3' },
       {
         type: 'select',
         name: 'educational_status',
         responseKey: 'educational_status',
+        placeholder: ' ',
         options: Enums.educationalStatus,
         value: null,
         label: 'وضعیت تحصیلی',
         col: 'col-md-3'
       },
-      { type: 'input', name: 'birth_country', label: 'کشور محل تولد', responseKey: 'birth_country', col: 'col-md-4' },
-      { type: 'input', name: 'birth_province', label: 'استان محل تولد', responseKey: 'birth_province', col: 'col-md-4' },
-      { type: 'input', name: 'birth_city', label: 'شهر محل تولد', responseKey: 'birth_city', col: 'col-md-4' },
-      { type: 'input', name: 'living_country', label: 'کشور محل زندگی فعلی', responseKey: 'living_country', col: 'col-md-4' },
-      { type: 'input', name: 'living_abroad_province', label: 'استان محل زندگی فعلی', responseKey: 'living_province', col: 'col-md-4' },
-      { type: 'input', name: 'living_abroad_city', label: 'شهر محل زندگی فعلی', responseKey: 'living_city', col: 'col-md-4' },
-      { type: 'input', name: 'living_postal_code', label: 'کد پستی محل زندگی', responseKey: 'living_postal_code', col: 'col-md-3' },
-      { type: 'input', name: 'living_address', label: 'آدرس پستی محل زندگی', responseKey: 'living_address', col: 'col-md-9' },
+      { type: 'input', name: 'birth_country', label: 'کشور محل تولد', responseKey: 'birth_country', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'birth_province', label: 'استان محل تولد', responseKey: 'birth_province', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'birth_city', label: 'شهر محل تولد', responseKey: 'birth_city', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'living_country', label: 'کشور محل زندگی فعلی', responseKey: 'living_country', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'living_abroad_province', label: 'استان محل زندگی فعلی', responseKey: 'living_province', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'living_abroad_city', label: 'شهر محل زندگی فعلی', responseKey: 'living_city', placeholder: ' ', col: 'col-md-4' },
+      { type: 'input', name: 'living_postal_code', label: 'کد پستی محل زندگی', responseKey: 'living_postal_code', placeholder: ' ', col: 'col-md-3' },
+      { type: 'input', name: 'living_address', label: 'آدرس پستی محل زندگی', responseKey: 'living_address', placeholder: ' ', col: 'col-md-9' },
       { type: 'hidden', name: 'id', responseKey: 'id' }
     ]
   }),

+ 65 - 4
src/components/Widgets/Other/ShowClassroomInfo/ShowClassroomInfo.vue

@@ -24,7 +24,7 @@
             </div>
           </div>
           <div class="col-md-4 col-12 classroom-action-col">
-            <q-btn v-if="!defaultOptions.profileMode && !classroom.is_current_user_registered"
+            <q-btn v-if="!defaultOptions.profileMode && !classroom.is_current_user_registered && classroom.is_enabled_adding"
                    color="primary"
                    class="btn-register"
                    @click="openRulesDialog">
@@ -42,6 +42,25 @@
               </svg>
               ثبت نام
             </q-btn>
+            <q-btn v-if="!defaultOptions.profileMode && !classroom.is_current_user_registered && classroom.is_enabled_enrolment"
+                   color="primary"
+                   class="btn-register"
+                   :loading="enrolmentLoading"
+                   @click="onEnrolment">
+              <svg data-name="Add User"
+                   xmlns="http://www.w3.org/2000/svg"
+                   width="20"
+                   height="19.795"
+                   viewBox="0 0 20 19.795"
+                   class="q-mr-md">
+                <path id="Combined_Shape"
+                      data-name="Combined Shape"
+                      d="M0,16.115c0-3.281,4.5-3.659,7.877-3.659,1.949,0,7.877,0,7.877,3.681,0,3.279-4.5,3.658-7.877,3.658C5.928,19.795,0,19.795,0,16.115Zm1.5,0c0,1.446,2.146,2.18,6.377,2.18s6.377-.726,6.377-2.158c0-1.447-2.146-2.181-6.377-2.181S1.5,14.683,1.5,16.115Zm14.954-5.436V9.424H15.16a.75.75,0,0,1,0-1.5h1.294V6.669a.75.75,0,1,1,1.5,0V7.924h1.3a.75.75,0,0,1,0,1.5h-1.3v1.255a.75.75,0,1,1-1.5,0Zm-8.609-.043a5.334,5.334,0,1,1,.031,0ZM4.06,5.318A3.8,3.8,0,0,0,7.849,9.136l.028.75v-.75A3.818,3.818,0,1,0,4.06,5.318Z"
+                      transform="translate(0)"
+                      fill="#fff" />
+              </svg>
+              پیش ثبت نام
+            </q-btn>
             <q-btn v-if="!defaultOptions.profileMode && classroom.is_current_user_registered"
                    color="primary"
                    class="btn-register"
@@ -71,7 +90,8 @@
                    outline
                    color="red"
                    class="btn-register q-ml-md"
-                   @click="openRulesDialog">
+                   :loading="dropLoading"
+                   @click="onDropping">
               انصراف
             </q-btn>
           </div>
@@ -336,13 +356,15 @@ export default {
     defaultOptions: {
       profileMode: false
     },
+    enrolmentLoading: false,
+    dropLoading: false,
     rulesAccept: false,
     rulesDialog: false,
     loading: true,
     classroom: new Classroom()
   }),
   mounted () {
-    this.getClassrooms()
+    this.getClassroom()
   },
   methods: {
     getTitledDateTime (dateTime) {
@@ -352,6 +374,45 @@ export default {
       this.$store.commit('Shop/updateOnRegisterClassroom', this.classroom)
       this.$router.push({ name: 'UserPanel.ShopCompleteInfo' })
     },
+    onEnrolment () {
+      this.$q.dialog({
+        title: 'توجه',
+        message: 'آیا از پیش ثبت نام این دوره اطمینان دارید؟' + '\n' + this.classroom.unit_info.codes,
+        html: true,
+        cancel: true,
+        persistent: true
+      }).onOk(() => {
+        this.enrolmentLoading = true
+        const classroomId = this.$route.params.id
+        APIGateway.classroom.enrollByUser(classroomId)
+          .then(() => {
+            this.enrolmentLoading = false
+            this.getClassroom()
+          })
+          .catch(() => {
+            this.enrolmentLoading = false
+          })
+      })
+    },
+    onDropping () {
+      this.$q.dialog({
+        title: 'توجه',
+        message: 'آیا از حذف نام این دوره اطمینان دارید؟',
+        cancel: true,
+        persistent: true
+      }).onOk(() => {
+        this.dropLoading = true
+        const classroomId = this.$route.params.id
+        APIGateway.classroom.dropByUser(classroomId)
+          .then(() => {
+            this.dropLoading = false
+            this.getClassroom()
+          })
+          .catch(() => {
+            this.dropLoading = false
+          })
+      })
+    },
     openRulesDialog () {
       this.rulesDialog = true
     },
@@ -378,7 +439,7 @@ export default {
       }
       return ShamsiDate.getTerm(classroom.beginning_registration_period)
     },
-    getClassrooms () {
+    getClassroom () {
       this.loading = true
       APIGateway.classroom.get(this.$route.params.id)
         .then(classroom => {