保誠-保戶業務員媒合平台
Tomas
2022-01-17 4e2d4a859ec0516de067622412cfa1933163a2bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { http } from "./httpClient";
 
import { Appointment, AppointmentDetail, AppointmentMemoInfo, createdMemoInfo, EditAppointmentParams, ToCloseAppointment, ToDoneAppointment, ToInformAppointment, updatedMemoInfo } from "~/shared/models/appointment.model";
 
class AppointmentService {
 
  // 顧問取得所有自己的預約單API
  async getMyAppointmentList(): Promise<Appointment[]> {
    return http.get('/consultant/getMyAppointment').then((res) => {
      const hasNewAppointment = res.data.find((appointment: Appointment) => !appointment.consultantViewTime);
      if (hasNewAppointment) {
        this.viewAllAppointment();
      }
      return res.data;
    });
  }
 
  // 顧問瀏覽自己所有的預約單紀錄觸發API
  private viewAllAppointment(): void {
    http.post('/consultant/record/allAppointmentsView').then();
  }
 
  // 讀取預約單時觸發,紀錄讀取預約單時間
  recordRead(appointmentId: number): Promise<void> {
    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}`);
  }
 
  // 編輯預約
  editAppointment(editAppointmentParams: EditAppointmentParams) {
    return http.put('/appointment', editAppointmentParams);
  }
 
  // 新增註記
  async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> {
    return http.post('/appointment/memo/create', memoInfo).then(res => res.data);
  }
 
  // 編輯註記
  async 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}`)
  }
 
  // 預約單結案
  async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) {
    return http.post(`/appointment/close`, appointmentInfo).then((res) => res.data);
  }
 
  // 約訪通知 API
  async informAppointment(appointmentInformation: ToInformAppointment) {
    return http.post(`/notice/send`, appointmentInformation).then((res) => res.data);
  }
}
 
export default new AppointmentService();