From 3ecee0fa557b7bb9e83b67e289b316f04efa9ce5 Mon Sep 17 00:00:00 2001 From: jack <jack.su@pollex.com.tw> Date: 星期二, 05 九月 2023 11:59:07 +0800 Subject: [PATCH] Merge branch '滲透' of ssh://dev.pollex.com.tw:29418/pcalife/PAM into 滲透 --- PAMapp/shared/services/appointment.service.ts | 163 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 147 insertions(+), 16 deletions(-) diff --git a/PAMapp/shared/services/appointment.service.ts b/PAMapp/shared/services/appointment.service.ts index ef4cea0..b36fb3f 100644 --- a/PAMapp/shared/services/appointment.service.ts +++ b/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, AppointmentMemoInfo, createdMemoInfo, EditAppointmentParams, InterviewRecordInfo, ToCloseAppointment, ToDoneAppointment, ToInformAppointment, updatedMemoInfo, UpdateInterviewRecordInfo } 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,18 @@ }); } - 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}`); + // 憿批��汗�撌望������蝝���孛�API + private async viewAllAppointment(): Promise<void> { + try { + const response = await http.post('/consultant/record/allAppointmentsView'); + if (response !== null) { + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + console.error('An error occurred while viewing all appointments:', error); + throw error; + } } // 霈�������孛�嚗������������ @@ -34,7 +35,7 @@ } // �����蝝啁� - async getAppointmentDetail(appointmentId: number):Promise<AppointmentDetail> { + async getAppointmentDetail(appointmentId: number):Promise<Appointment> { return http.get(`/appointment/getDetail/${appointmentId}`).then((res) => res.data); } @@ -48,6 +49,136 @@ return http.put('/appointment', editAppointmentParams); } + /** + * �憓酉閮� + * @param memoInfo ���憓酉閮�����隞� + * @returns ���憓�酉閮��� + */ + async createMemo(memoInfo: createdMemoInfo): Promise<AppointmentMemoInfo> { + try { + const response = await http.post('/appointment/memo/create', memoInfo); + // 撘望�� test2: ���� !response + if (!response) { + throw new Error('http.post returned null-like value.'); + } else { + return response.data; + } + } catch (error) { + // �隞亙甇方���隤斗����身�� + console.error('An error occurred while creating memo:', error); + throw error; + } + } + + + /** + * 蝺刻摩閮餉�� + * @param memoInfo ��蝺刻摩閮餉������隞� + * @returns ����敺�酉閮��� + */ + async updateMemo(memoInfo: updatedMemoInfo): Promise<AppointmentMemoInfo> { + try { + const response = await http.post('/appointment/memo/update', memoInfo); + if (response !== null) { + return response.data; + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + // �隞亙甇方���隤斗����身�� + console.error('An error occurred while updating memo:', error); + throw error; + } + } + + + // ��閮餉�� + deleteMemo(appointmentMemoId: number) { + return http.delete(`/appointment/memo/${appointmentMemoId}`) + } + + /** + * ���蝯��, ��蝯��敦 + * @param appointmentInfo ��蝯������隞� + * @returns ��蝯���� + */ + async closeAppointment(appointmentInfo: ToDoneAppointment | ToCloseAppointment) { + // 撘望�est5: ����� promise + try { + const response = await http.post(`/appointment/close`, appointmentInfo); + const responsePromise = new Promise((resolve, reject) => { + if (response !== null) { + resolve(response.data); + } else { + reject('http.post returned null-like value.'); + } + }); + if (!response) { + throw new Error('http.post returned null-like value.'); + } else { + return responsePromise.then(res => res); + } + } catch (error) { + // �隞亙甇方���隤斗����身�� + console.error('An error occurred while closing appointment:', error); + throw error; + } + } + + + // 蝝赤� API + async informAppointment(appointmentInformation: ToInformAppointment) { + try { + const response = await http.post(`/notice/send`, appointmentInformation); + if (response !== null) { + return response.data; + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + console.error('An error occurred while informing appointment:', error); + // �隞亙甇方���隤斗����身�� + throw error; + } + } + + + // �憓�赤閮�� + async createInterviewRecord(interviewRecordInfo: InterviewRecordInfo) { + try { + const response = await http.post('/interview_record/create', interviewRecordInfo); + if (response !== null) { + return response.data; + } else { + throw new Error('http.post returned null-like value.'); + } + } catch (error) { + console.error('An error occurred while creating interview record:', error); + // �隞亙甇方���隤斗����身�� + throw error; + } + } + + // 靽格蝝赤閮�� + async updateInterviewRecord(updateInterviewRecordInfo: UpdateInterviewRecordInfo) { + return http.post('/interview_record/update', updateInterviewRecordInfo) + } + + // ��蝝赤閮�� + async deleteInterviewRecord(interviewRecordId) { + return http.delete(`/interview_record/${interviewRecordId}`); + } + + // 摰X�������������� + async getNotContactAppointment(): Promise<Appointment> { + return http.get(`/appointment/customer/expiring/newest`).then((res) => res.data); + } + + // 憿批������������ + async getPendingAppointmentSum(): Promise<number> { + return http.get(`/appointment/consultant/pending/sum`).then((res) => res.data) + } + } export default new AppointmentService(); -- Gitblit v1.8.0