WIP : SAV produit cassé dans interface V2
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import TicketApi from "@/services/TicketApi.js";
|
import TicketApi from "@/services/TicketApi.js";
|
||||||
import {onMounted, ref, nextTick} from 'vue';
|
import {onMounted, ref, nextTick, computed} from 'vue';
|
||||||
import {storeToRefs} from "pinia";
|
import {storeToRefs} from "pinia";
|
||||||
import {format, formatDistance} from "date-fns";
|
import {format, formatDistance} from "date-fns";
|
||||||
import {fr} from 'date-fns/locale';
|
import {fr} from 'date-fns/locale';
|
||||||
@@ -15,19 +15,81 @@ const {
|
|||||||
currentTicket,
|
currentTicket,
|
||||||
} = storeToRefs(storeTicket)
|
} = storeToRefs(storeTicket)
|
||||||
|
|
||||||
|
const brokenAmount = ref(0)
|
||||||
|
|
||||||
|
const actionClaim = computed(()=> {
|
||||||
|
|
||||||
|
if (brokenAmount.value > 10) {
|
||||||
|
return {
|
||||||
|
label : "Demander le retour du colis au client",
|
||||||
|
method : 'askParcelReturn'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(messages.value[0].claim.refund_mode === 'Réexpédition souhaitée'){
|
||||||
|
return {
|
||||||
|
label : "Valider la demande de réexpedition",
|
||||||
|
method : 'validateResend'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return {
|
||||||
|
label : "Valider la demande de remboursement",
|
||||||
|
method : 'validateRefund'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
messages.value = await TicketApi.getMessages(storeTicket.currentTicket.code, storeTicket.idTicket)
|
messages.value = await TicketApi.getMessages(storeTicket.currentTicket.code, storeTicket.idTicket)
|
||||||
|
|
||||||
|
if(currentTicket.value.filter2 === 'Produit cassé / défaillant'){
|
||||||
|
brokenAmount.value = await TicketApi.getBrokenAmount(storeTicket.currentTicket.code, storeTicket.idTicket)
|
||||||
|
//brokenAmount.value = 8
|
||||||
|
}
|
||||||
|
|
||||||
await moveToBottom("body-modal-to-scroll")
|
await moveToBottom("body-modal-to-scroll")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const closeClaim = async ()=>{
|
||||||
|
const deliveryData = await TicketApi.validateBrokenIssue(currentTicket.value.code, currentTicket.value.idTicket, actionClaim.value.method)
|
||||||
|
|
||||||
|
let trackingNumber = null
|
||||||
|
let labelUrl = null
|
||||||
|
|
||||||
|
if(actionClaim.value.method === 'askParcelReturn'){
|
||||||
|
trackingNumber = deliveryData.parcel_list.filter(parcel=>parcel.delivery_slip_code === 'R1')[0].tracking_number
|
||||||
|
labelUrl = deliveryData.projectHost + deliveryData.parcel_list.filter(parcel=>parcel.delivery_slip_code === 'R1')[0].parcel_label_file
|
||||||
|
}
|
||||||
|
const closeClaim = await TicketApi.closeBrokenIssue(currentTicket.value.code, currentTicket.value.idTicket, messages.value[0].claim.refund_mode, trackingNumber, labelUrl)
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
/*
|
||||||
|
let url = '/App/api.php?prj=pharmamp&controller=TicketingController&method=closeBrokenProductIssue&id_business='+idBusiness+'&code_business='+codeBusiness+'&clientChoice='+clientChoice
|
||||||
|
|
||||||
|
if(ticketAction === 'askParcelReturn'){
|
||||||
|
const trackingNumber = data.parcel_list.filter(parcel=>parcel.delivery_slip_code === 'R1')[0].tracking_number
|
||||||
|
const labelUrl = data.projectHost + data.parcel_list.filter(parcel=>parcel.delivery_slip_code === 'R1')[0].parcel_label_file
|
||||||
|
|
||||||
|
url += '&trackingNumber='+trackingNumber+'&labelUrl='+encodeURI(labelUrl)
|
||||||
|
}
|
||||||
|
|
||||||
|
fetch(url).then(response => Affaire('11','0','{$this->Cbusiness->getCodeBusiness()}','{$this->Cbusiness->getIdBusiness()}','4'))
|
||||||
|
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
||||||
<div v-if="messages.length >0" class="container-fluid">
|
<div v-if="messages.length >0" class="container-fluid">
|
||||||
|
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="chat-app" id="test">
|
<div class="chat-app" id="test">
|
||||||
<div class="chat">
|
<div class="chat">
|
||||||
@@ -75,7 +137,13 @@ onMounted(async () => {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="brokenAmount >0 && i===0">
|
||||||
|
<button class="btn btn-primary" @click="closeClaim">{{actionClaim.label}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li class="clearfix" v-if="suspens">
|
<li class="clearfix" v-if="suspens">
|
||||||
<div class="message-data text-end">Envoi en cours</div>
|
<div class="message-data text-end">Envoi en cours</div>
|
||||||
|
|||||||
@@ -60,6 +60,54 @@ export default {
|
|||||||
|
|
||||||
return response.json();
|
return response.json();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getBrokenAmount(code, id) {
|
||||||
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=ProxyController&method=getBrokenProductAmount&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 validateBrokenIssue(code, id, method) {
|
||||||
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=ProxyController&method='+method+'&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 closeBrokenIssue(code, id, clientChoice, trackingNumber, trackingUrl) {
|
||||||
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=closeBrokenProductIssue&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) {
|
async saveMessage(code, id, quill, attachedDoc, replyOption) {
|
||||||
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=saveMessage'
|
const apiUrl = '/App/api.php?prj=pharmamp&controller=TicketingController&method=saveMessage'
|
||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
|
|||||||
Reference in New Issue
Block a user