Browse Source

Habilitando a pesquisa de atendimentos na fila de espera e em conversasao

Felipe
guilherme guia 12 months ago
parent
commit
b93ff58453
  1. 19
      public/js/main.js
  2. 1
      public/js/requests.js
  3. 67
      public/js/util.js

19
public/js/main.js

@ -47,9 +47,12 @@ $(function () {
});
$("#btnFila").on("click", () => {
filaNotifications();
isAtend = false;
});
$("#btnAtendimento").on("click", () => {
notifications();
isAtend = true;
click_btn(document.querySelector("#btnAtendimento"));
});
$("#exitChat").on("click", () => {
abrirMensagem = false;
@ -82,6 +85,10 @@ $(function () {
recuperarAtendimento();
}
});
$("input[name=contato]").on("keyup", (event) => {
let input = event.target
input.value = phoneMask(input.value)
});
/**
* HABILITA O ENVIO DE MIDIAS CTRL+V
*/
@ -179,7 +186,7 @@ $(function () {
* EVENTOS DE CLICK PARA SELECIONAR A SESSAO DE MENSAGEM/CONVERSA E RECUPERAR AS MENSAGENS JA TROCADAS NO ATENDIMENTO
* @param {*} id
*/
const selectNotification = (id, status, datetime) => {
const selectNotification = (id, status, datetime, chatType) => {
marcarMensagemVista(id);
toggleEnvioTemplates(0);
listaMensagem(id).then(async () => {
@ -192,13 +199,11 @@ const selectNotification = (id, status, datetime) => {
listarAtendimentoAgente(
localStorage.getItem("my_uniqueid")
);
const allNotifications = JSON.parse(
localStorage.getItem("obj_search")
);
const allNotifications = typeChat(chatType);
const atendimentos = await buscarAtendimento(id);
hideButtons(false);
allNotifications.data.forEach((e) => {
allNotifications.forEach((e) => {
$("#" + e.uniqueid.replace(".", `\\.`)).removeClass(
"select-notification"
);
@ -214,7 +219,7 @@ const selectNotification = (id, status, datetime) => {
});
$("#" + id.replace(".", `\\.`)).addClass("select-notification");
allNotifications.data.forEach((e) => {
allNotifications.forEach((e) => {
if (e.uniqueid == id && e.status == 0) {
hideButtons(true);
monitoraStatusRecuperacaoAtendimento(datetime);
@ -229,7 +234,7 @@ const selectNotification = (id, status, datetime) => {
});
}
allNotifications.data.forEach((e) => {
allNotifications.forEach((e) => {
if (id === e.uniqueid) {
uniqueid = e.uniqueid;
name = e.nome;

1
public/js/requests.js

@ -390,7 +390,6 @@ const cadastrarContato = (dataSend) => new Promise((resolve) =>{
resolve(res)
},
error: function (res) {
console.log(res);
alert(res.responseText);
}
});

67
public/js/util.js

@ -1,3 +1,12 @@
const phoneMask = (value) => {
if (!value) return ""
value = value.replace(/\D/g,'')
value = value.replace(/(\d{2})(\d)/,"+$1 $2")
value = value.replace(/(\d{2})(\d)/,"($1) $2")
value = value.replace(/(\d)(\d{4})$/,"$1-$2")
return value
}
/** ROLAGEM DO SCROLL AT<EFBFBD> NO FINAL DO CHAT */
const scrollDown = () => {
$(".chat-window").animate({ scrollTop: 99999 * $(this).height() }, 1);
@ -16,21 +25,20 @@ function formatedNumber(telefone) {
}
const search = (input) => {
let inputValue = input.value.trim();
$("#chats").empty();
const atendimentos = JSON.parse(localStorage.getItem('obj_search')).data;
let pesquisa;
let chatList = "";
if (!inputValue) {
notifications();
return;
return isAtend ? notifications() : filaNotifications();;
}
$("#chats").empty();
const key = isAtend ? 'obj_search' : 'obj_queueNotification';
const atendimentos = JSON.parse(localStorage.getItem(key));
let pesquisa;
let chatList = "";
pesquisa = atendimentos.filter((atendimento) => {
return (
atendimento.nome.toLowerCase().includes(inputValue.toLowerCase()) ||
atendimento.protocolo.toString().includes(inputValue.toLowerCase()) ||
atendimento.cliente_id.toString().includes(inputValue.toLowerCase())
atendimento?.nome.toLowerCase().includes(inputValue.toLowerCase()) ||
atendimento?.protocolo.toString().includes(inputValue.toLowerCase()) ||
atendimento?.cliente_id.toString().includes(inputValue.toLowerCase())
)
});
@ -50,7 +58,8 @@ const search = (input) => {
status: e.status,
protocolo: e.protocolo,
media: e.media,
evento: e.evento
evento: e.evento,
type: chatTypes.search
});
});
@ -377,11 +386,10 @@ const enviaHsm = async (btn) => {
toggleEnvioTemplates(false);
abrirTelaContato();
const atendimento = response.data.data;
startSearch();
notifications();
loadingBtn(btn, "Enviar Mensagem", false)
setTimeout(() => {
selectNotification(atendimento.uniqueid, true, atendimento.data_reg);
selectNotification(atendimento.uniqueid, true, atendimento.data_reg, chatTypes.notification);
}, 1000);
}
}
@ -397,13 +405,29 @@ const cadastroContato = async (form) => {
descricao: formData.get("descricao"),
status: formData.get("ativo")
};
const response = await cadastrarContato(dataSend);
if (response) {
alert('Cadastrado com sucesso');
voltarTelaCadastro();
}
}
/**
* Gerencia a renderização do chat
*/
const typeChat = (type) => {
let data;
switch (type) {
case 1:
data = JSON.parse(localStorage.getItem("obj_search"))
break;
case 2:
data = JSON.parse(localStorage.getItem("obj_notification")).data
break;
default:
break;
}
return data;
}
/**
* GERENCIA A RESPONSIVIDADE DO LAYOUT
*/
@ -889,7 +913,7 @@ const buildNotification = (data = {}) => {
const badge = data.evento === sendTemplate ? "<i class='fas fa-share'></i>" : "<i class='fas fa-reply'></i>"
const datesend = converdata(data.datetime);
const status = (data.status == 0) ? "opacity-8" : "";
return `<div class="chat ${status}" id="${data.uniqueid}" onclick="selectNotification(this.id, ${data.status}, '${data.datetime}')">
return `<div class="chat ${status}" id="${data.uniqueid}" onclick="selectNotification(this.id, ${data.status}, '${data.datetime}', ${data.type})">
<div class="chat-left">
<img src="${path}/images/${data.media}.png"/>
</div>
@ -991,7 +1015,7 @@ const startSearch = () => {
localStorage.getItem("my_uniqueid")
).then(res => {
localStorage.removeItem('obj_search');
localStorage.setItem('obj_search', JSON.stringify(res));
localStorage.setItem('obj_search', JSON.stringify(res.data));
})
}
/**
@ -1046,12 +1070,11 @@ const notifications = (obj = {}) => {
status: e.status,
protocolo: e.protocolo,
media: e.media,
evento: e.evento
evento: e.evento,
type: chatTypes.notification
});
});
chatsArray = chat;
click_btn(document.querySelector("#btnAtendimento"));
$("#chats").append(chatList);
});
};
@ -1092,9 +1115,7 @@ const filaNotifications = (obj = {}) => {
media: e.media,
});
});
chatsArray = chat;
localStorage.setItem('obj_queueNotification', JSON.stringify(chat));
$("#chats").append(chatList);
}
);
@ -1158,12 +1179,10 @@ const supervisorAgente = () => {
window.close();
}
startSearch();
notifications();
});
}, 30000);
};
/** CONNECT TO WS */
const connect = (wsserver) => {
const ws = new WebSocket(wsserver);

Loading…
Cancel
Save