From 1d787d91e9ef23794a6ec648123bb8bfeaa00d44 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期二, 21 十二月 2021 10:43:48 +0800
Subject: [PATCH] refactor: appointment model, role enum

---
 /dev/null                                        |   18 ------
 PAMapp/components/BackActionBar.vue              |    2 
 PAMapp/components/Consultant/ConsultantCard.vue  |   87 +++++++++++++++--------------
 PAMapp/pages/consultantLogin/index.vue           |    2 
 PAMapp/pages/login/index.vue                     |    4 
 PAMapp/components/NavBar.vue                     |    2 
 PAMapp/pages/agentInfo/_agentNo.vue              |    2 
 PAMapp/assets/ts/models/appointment.model.ts     |   19 ++++++
 PAMapp/assets/ts/api/consultant.ts               |   21 ++-----
 PAMapp/components/Consultant/ConsultantList.vue  |    3 
 PAMapp/assets/ts/services/appointment.service.ts |   11 +++
 11 files changed, 88 insertions(+), 83 deletions(-)

diff --git a/PAMapp/assets/ts/api/consultant.ts b/PAMapp/assets/ts/api/consultant.ts
index 0853916..120188d 100644
--- a/PAMapp/assets/ts/api/consultant.ts
+++ b/PAMapp/assets/ts/api/consultant.ts
@@ -1,5 +1,4 @@
 import { AxiosResponse } from 'axios';
-import { AppointmentDetail } from '../models/AppointmentDetail';
 import { ConsultantLoginInfo } from '../models/ConsultantLoginInfo';
 import _ from 'lodash';
 import { UserSetting } from '../models/account.model';
@@ -53,14 +52,6 @@
     return http.delete('/consultant/favorite/'+agentId, {headers})
 }
 
-// �����蝝啁�
-export function getAppointmentDetail(apointmentId: number):Promise<AxiosResponse<AppointmentDetail>> {
-    const headers = {
-        Authorization: 'Bearer ' + localStorage.getItem('id_token')
-    }
-    return http.get('/appointment/getDetail/'+apointmentId, {headers})
-}
-
 //���蝙��董�����
 export function getUserAccountSetting() : Promise<UserSetting> {
     const headers = {
@@ -87,12 +78,12 @@
 }
 
 // ������
-export function cancelAppointment(appointment: number) {
-    const headers = {
-        Authorization: 'Bearer ' + localStorage.getItem('id_token')
-    }
-    return http.delete('/appointment/'+appointment ,{headers});
-}
+// export function cancelAppointment(appointment: number) {
+//     const headers = {
+//         Authorization: 'Bearer ' + localStorage.getItem('id_token')
+//     }
+//     return http.delete('/appointment/'+appointment ,{headers});
+// }
 
 // 蝺刻摩����
 export function editAppointment(editAppointmentParams: editAppointmentParams) {
diff --git a/PAMapp/assets/ts/models/AppointmentDetail.ts b/PAMapp/assets/ts/models/AppointmentDetail.ts
deleted file mode 100644
index c13f9a8..0000000
--- a/PAMapp/assets/ts/models/AppointmentDetail.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-
-export interface AppointmentDetail {
-    id: number;
-    phone: string;
-    email: string;
-    contactType: string;
-    gender: string;
-    age: string;
-    job: string;
-    requirement: string;
-    communicateStatus: string;
-    hopeContactTime: string;
-    otherRequirement: string;
-    appointmentDate: Date;
-    agentNo: string;
-    customerId: number;
-    name: string;
-}
diff --git a/PAMapp/assets/ts/models/appointment.model.ts b/PAMapp/assets/ts/models/appointment.model.ts
index 36b9c77..f411b7a 100644
--- a/PAMapp/assets/ts/models/appointment.model.ts
+++ b/PAMapp/assets/ts/models/appointment.model.ts
@@ -37,3 +37,22 @@
   updateTime          : Date | string;
   contactStatus       : string;
 }
+
+export interface AppointmentDetail {
+  id               : number;
+  phone            : string;
+  email            : string;
+  contactType      : string;
+  gender           : string;
+  age              : string;
+  job              : string;
+  requirement      : string;
+  communicateStatus: string;
+  hopeContactTime  : string;
+  otherRequirement : string;
+  appointmentDate  : string;
+  agentNo          : string;
+  customerId       : number;
+  name             : string;
+}
+
diff --git a/PAMapp/assets/ts/services/appointment.service.ts b/PAMapp/assets/ts/services/appointment.service.ts
index b544948..33f33b2 100644
--- a/PAMapp/assets/ts/services/appointment.service.ts
+++ b/PAMapp/assets/ts/services/appointment.service.ts
@@ -1,6 +1,7 @@
 import { http } from "./httpClient";
 
 import { ClientInfo } from "../models/client.model";
+import { AppointmentDetail } from "../models/appointment.model";
 
 class AppointmentService {
 
@@ -32,6 +33,16 @@
     return http.post(`/appointment/recordRead/${appointmentId}`);
   }
 
+  // �����蝝啁�
+  async getAppointmentDetail(appointmentId: number):Promise<AppointmentDetail> {
+    return http.get(`/appointment/getDetail/${appointmentId}`).then((res) => res.data);
+  }
+
+  // ������
+  cancelAppointment(appointmentId: number): Promise<void> {
+    return http.delete(`/appointment/${appointmentId}`);
+  }
+
 }
 
 export default new AppointmentService();
diff --git a/PAMapp/components/BackActionBar.vue b/PAMapp/components/BackActionBar.vue
index ef98239..1ef0c3f 100644
--- a/PAMapp/components/BackActionBar.vue
+++ b/PAMapp/components/BackActionBar.vue
@@ -10,8 +10,8 @@
 <script lang="ts">
 import { namespace } from 'nuxt-property-decorator';
 import { Vue, Component,} from 'vue-property-decorator';
-import { Role } from '~/assets/ts/models/enum/Role';
 import * as _ from 'lodash';
+import { Role } from '~/assets/ts/models/enum/role';
 
 const roleStorage = namespace('localStorage');
 @Component
diff --git a/PAMapp/components/Consultant/ConsultantCard.vue b/PAMapp/components/Consultant/ConsultantCard.vue
index e930d83..8531755 100644
--- a/PAMapp/components/Consultant/ConsultantCard.vue
+++ b/PAMapp/components/Consultant/ConsultantCard.vue
@@ -127,15 +127,17 @@
 </template>
 
 <script lang="ts">
-import { Vue, Component, Prop, Action, namespace } from 'nuxt-property-decorator';
-import { getAppointmentDetail, UserReviewsConsultantsParams, userReviewsConsultants, cancelAppointment } from '~/assets/ts/api/consultant';
+import { Vue, Component, Prop, Action, namespace, State } from 'nuxt-property-decorator';
+
+import appointmentService from '~/assets/ts/services/appointment.service';
+import { isMobileDevice } from '~/assets/ts/device';
+import { hideReviews } from '~/assets/ts/const/hide-reviews';
+import { UserReviewsConsultantsParams, userReviewsConsultants } from '~/assets/ts/api/consultant';
 import { Consultant, ConsultantWithAppointmentId } from '~/assets/ts/models/consultant.model';
 import { Appointment } from '~/assets/ts/models/appointment.model';
-import { isMobileDevice } from '~/assets/ts/device';
-import { Role } from '~/assets/ts/models/enum/Role';
-import { hideReviews } from '~/assets/ts/const/hide-reviews';
+import { Role } from '~/assets/ts/models/enum/role';
 
-const roleStorage = namespace('localStorage');
+const localStorage = namespace('localStorage');
 @Component({
     filters: {
         formatNumber(index: number) {
@@ -157,16 +159,11 @@
 })
 export default class ConsultantCard extends Vue {
 
-    @Action
-    removeFromMyConsultantList!: (agentNo: string) => Promise<boolean>;
-
-    @Action
-    storeConsultantList!: any;
-
     @Prop()
     agentInfo!: Consultant | ConsultantWithAppointmentId;
 
-    @roleStorage.Getter currentRole!:string;
+    @localStorage.State('current_role')
+    currentRole!: string;
 
     isVisibleDialog = false;
     reviewsBtn = false;
@@ -176,6 +173,30 @@
     isCancelPopup = false;
     hideReviews = hideReviews;
     isConfirmPopup = false;
+
+
+    appointmentDetail: any = {
+        age               : '',
+        agentNo           : '',
+        appointmentDate   : '',
+        communicateStatus : '',
+        consultantReadTime: null,
+        consultantViewTime: null,
+        contactTime       : '',
+        contactType       : '',
+        customerId        : 0,
+        email             : '',
+        gender            : '',
+        hopeContactTime   : "",
+        id                : 0,
+        job               : "",
+        lastModifiedDate  : '',
+        name              : '',
+        otherRequirement  : null,
+        phone             : "",
+        requirement       : '',
+        satisfactionScore : 0,
+    };
 
     get notScoreAppointmentYet(): boolean {
       const isAppointment = !!this.agentInfo['appointmentStatus'];
@@ -229,29 +250,6 @@
         return time as string;
     }
 
-    appointmentDetail: any = {
-        age               : '',
-        agentNo           : '',
-        appointmentDate   : '',
-        communicateStatus : '',
-        consultantReadTime: null,
-        consultantViewTime: null,
-        contactTime       : '',
-        contactType       : '',
-        customerId        : 0,
-        email             : '',
-        gender            : '',
-        hopeContactTime   : "",
-        id                : 0,
-        job               : "",
-        lastModifiedDate  : '',
-        name              : '',
-        otherRequirement  : null,
-        phone             : "",
-        requirement       : '',
-        satisfactionScore : 0,
-    };
-
     get avatarFileName() {
         return this.agentInfo.img;
     }
@@ -303,11 +301,17 @@
 
     get hopeContactTime() {
         const contactList = this.appointmentDetail.hopeContactTime
-            .split("'").map(item => item.slice(0, item.length));
-        return contactList.filter(item => !!item && item !== ",")
+            .split("'").map((item: any) => item.slice(0, item.length));
+        return contactList.filter((item: any) => !!item && item !== ",")
     }
 
     //////////////////////////////////////////////////////////////////////
+
+    @Action
+    removeFromMyConsultantList!: (agentNo: string) => Promise<boolean>;
+
+    @Action
+    storeConsultantList!: () => void;
 
     reserveCommunication() {
       const isAppointment = !!this.agentInfo['appointmentStatus'];
@@ -327,10 +331,9 @@
                           ? this.agentInfo['appointmentId']
                           : this.latestReservedAppointment.id;
 
-        getAppointmentDetail(appointmentId!).then(res => {
+        appointmentService.getAppointmentDetail(appointmentId!).then(res => {
             this.appointmentDetail = {
-                ...this.appointmentDetail,
-                ...res.data,
+                ...res,
                 satisfactionScore:  this.agentInfo['appointmentScore'],
             };
             this.width = isMobileDevice() ? '80%' : '';
@@ -361,7 +364,7 @@
     }
 
     cancel() {
-        cancelAppointment(this.latestReservedAppointment.id).then(res => {
+        appointmentService.cancelAppointment(this.latestReservedAppointment.id).then(res => {
             this.storeConsultantList();
             this.isVisibleDialog = false;
             this.isCancelPopup = false;
diff --git a/PAMapp/components/Consultant/ConsultantList.vue b/PAMapp/components/Consultant/ConsultantList.vue
index 1e7bd7c..33b9929 100644
--- a/PAMapp/components/Consultant/ConsultantList.vue
+++ b/PAMapp/components/Consultant/ConsultantList.vue
@@ -25,14 +25,13 @@
 <script lang="ts">
 import { Vue, Component, Prop, namespace } from 'nuxt-property-decorator';
 import { Consultant } from '~/assets/ts/models/consultant.model';
-import { Role } from '~/assets/ts/models/enum/Role';
 
 const roleStorage = namespace('localStorage');
 
 @Component
 export default class ConsultantList extends Vue {
     @Prop() agents!: Consultant[];
-    @Prop() title! : string; 
+    @Prop() title! : string;
     @roleStorage.Getter isUserLogin!:boolean;
 
     get agentList(){
diff --git a/PAMapp/components/NavBar.vue b/PAMapp/components/NavBar.vue
index 6e3d2ab..0aa05ff 100644
--- a/PAMapp/components/NavBar.vue
+++ b/PAMapp/components/NavBar.vue
@@ -34,7 +34,7 @@
 <script lang="ts">
   import { Vue, Component } from 'vue-property-decorator';
   import { namespace } from 'nuxt-property-decorator';
-  import { Role } from '~/assets/ts/models/enum/Role';
+  import { Role } from '~/assets/ts/models/enum/role';
   import * as _ from 'lodash';
 
   const roleStorage = namespace('localStorage');
diff --git a/PAMapp/pages/agentInfo/_agentNo.vue b/PAMapp/pages/agentInfo/_agentNo.vue
index 0267976..fb434b4 100644
--- a/PAMapp/pages/agentInfo/_agentNo.vue
+++ b/PAMapp/pages/agentInfo/_agentNo.vue
@@ -193,7 +193,7 @@
 import myConsultantService from '~/assets/ts/services/my-consultant.service';
 import { AgentInfo } from '~/assets/ts/models/agent-info.model';
 import { hideReviews } from '~/assets/ts/const/hide-reviews';
-import { Role } from '~/assets/ts//models/enum/Role';
+import { Role } from '~/assets/ts/models/enum/role';
 
 const roleStorage = namespace('localStorage');
 
diff --git a/PAMapp/pages/consultantLogin/index.vue b/PAMapp/pages/consultantLogin/index.vue
index 14fe5ed..8ad62c8 100644
--- a/PAMapp/pages/consultantLogin/index.vue
+++ b/PAMapp/pages/consultantLogin/index.vue
@@ -58,7 +58,7 @@
 <script lang="ts">
   import { Vue, Component , namespace } from 'nuxt-property-decorator';
   import { AxiosError } from 'axios';
-  import { Role } from '~/assets/ts/models/enum/Role';
+  import { Role } from '~/assets/ts/models/enum/role';
   import ErrorMessageBox from '~/assets/ts/errorService';
   import loginService from '~/assets/ts/services/login.service'
 
diff --git a/PAMapp/pages/login/index.vue b/PAMapp/pages/login/index.vue
index cfeb5a3..1167d6f 100644
--- a/PAMapp/pages/login/index.vue
+++ b/PAMapp/pages/login/index.vue
@@ -337,7 +337,7 @@
 import { Vue, Component, Ref } from 'vue-property-decorator';
 import ErrorMessageBox from '~/assets/ts/errorService';
 import { OtpErrorCode } from '~/assets/ts/models/enum/otpErrorCode';
-import { Role } from '~/assets/ts/models/enum/Role';
+import { Role } from '~/assets/ts/models/enum/role';
 import { LoginRequest } from '~/assets/ts/models/loginRequest.model';
 import { LoginVerify } from '~/assets/ts/models/loginVerify.model';
 import { OtpInfo } from '~/assets/ts/models/otpInfo.model';
@@ -415,8 +415,8 @@
     clearInterval(this.autoRedirectInterval);
   }
 
-
   //////////////////////////////////////////////////////////
+
   detectContractReadStatus(event: any): void {
     const scrollTop = Math.round(event.target.scrollTop);
     const height = event.target.scrollHeight - event.target.clientHeight;

--
Gitblit v1.8.0