94 lines
2.6 KiB
JavaScript
94 lines
2.6 KiB
JavaScript
export default {
|
|
async getTickets() {
|
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=getTickets'
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(apiUrl)
|
|
}
|
|
|
|
const response = await fetch(apiUrl)
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(response.clone().text())
|
|
}
|
|
|
|
return response.json();
|
|
},
|
|
|
|
async getStandardMessageList(id) {
|
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=getStandardMessageList&id_business=' + id
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(apiUrl)
|
|
}
|
|
|
|
const response = await fetch(apiUrl)
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(response.clone().text())
|
|
}
|
|
|
|
return response.json();
|
|
},
|
|
async getMessages(code, id) {
|
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=getMessages&code_business=' + code + '&id_business=' + id
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(apiUrl)
|
|
}
|
|
|
|
const response = await fetch(apiUrl)
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(response.clone().text())
|
|
}
|
|
|
|
return response.json();
|
|
},
|
|
async setAssignment(code, id) {
|
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=setTicketAssignment&code_business=' + code + '&id_business=' + id
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(apiUrl)
|
|
}
|
|
|
|
const response = await fetch(apiUrl)
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(response.clone().text())
|
|
}
|
|
|
|
return response.json();
|
|
},
|
|
async saveMessage(code, id, quill, attachedDoc, replyOption) {
|
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=saveMessage'
|
|
if (import.meta.env.DEV) {
|
|
console.log(apiUrl)
|
|
}
|
|
|
|
const postData = new FormData();
|
|
postData.append("id_business", id);
|
|
postData.append("code_business", code);
|
|
postData.append("quill", quill);
|
|
|
|
if (attachedDoc !== null) {
|
|
for (const file of attachedDoc.files) {
|
|
postData.append('attached_doc', file, file.name)
|
|
}
|
|
}
|
|
|
|
postData.append("data", JSON.stringify(replyOption));
|
|
|
|
const response = await fetch(apiUrl, {
|
|
method: 'POST',
|
|
body: postData
|
|
});
|
|
|
|
if (import.meta.env.DEV) {
|
|
console.log(response.clone().text())
|
|
}
|
|
|
|
return response.json();
|
|
},
|
|
}
|