保誠-保戶業務員媒合平台
Tomas
2022-01-13 46da7429ca192bf6a947d79437e8076b94676a05
PAMapp/shared/services/appointment.service.ts
@@ -1,14 +1,13 @@
import { http } from "./httpClient";
import { ClientInfo } from "~/shared/models/client.model";
import { AppointmentDetail, EditAppointmentParams } from "~/shared/models/appointment.model";
import { Appointment, AppointmentDetail, AppointmentMemoInfo, createdMemoInfo, EditAppointmentParams, updatedMemoInfo } from "~/shared/models/appointment.model";
class AppointmentService {
  // 取得所有預約清單
  async getMyAppointmentList(): Promise<ClientInfo[]> {
  // 顧問取得所有自己的預約單API
  async getMyAppointmentList(): Promise<Appointment[]> {
    return http.get('/consultant/getMyAppointment').then((res) => {
      const hasNewAppointment = res.data.find((appointment: ClientInfo) => !appointment.consultantViewTime);
      const hasNewAppointment = res.data.find((appointment: Appointment) => !appointment.consultantViewTime);
      if (hasNewAppointment) {
        this.viewAllAppointment();
      }
@@ -16,16 +15,9 @@
    });
  }
  // 顧問瀏覽自己所有的預約單紀錄觸發API
  private viewAllAppointment(): void {
    http.post('/consultant/record/allAppointmentsView').then();
  }
  // 標記為已聯絡
  markAsContact(appointmentId: number): Promise<void> {
      // TODO: 跟後端確認,這裡的 API 不應該傳回 void, 而是應該是更新後的資料 - Ben 2021/11/16
      // return http.post('/appointment/markAsContacted/'+appointmentId, undefined, {headers})
      //         .then(res => res.data)
      return http.post(`/appointment/markAsContacted/${appointmentId}`);
  }
  // 讀取預約單時觸發,紀錄讀取預約單時間
@@ -48,6 +40,20 @@
    return http.put('/appointment', editAppointmentParams);
  }
  // 新增註記
  createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> {
    return http.post('/appointment/memo/create', memoInfo).then(res => res.data);
  }
  // 編輯註記
  updateMemo(memoInfo: updatedMemoInfo): Promise<AppointmentMemoInfo> {
    return http.post('/appointment/memo/update', memoInfo).then(res => res.data);
  }
  // 刪除註記
  deleteMemo(appointmentMemoId: number) {
    return http.delete(`/appointment/memo/${appointmentMemoId}`)
  }
}
export default new AppointmentService();