Browse Source

Adicionando pesquisa por protocolo/nome/numero

Felipe
guilherme guia 12 months ago
parent
commit
25c9da610d
  1. 2
      app/view/content.php
  2. 4
      public/js/main.js
  3. 12
      public/js/requests.js
  4. 53
      public/js/util.js

2
app/view/content.php

@ -31,7 +31,7 @@
</div>
<div class="search">
<i class="fas fa-search search-icon"></i>
<input type="text" class="search-form" placeholder="Pesquisar contato" id="search-form">
<input type="text" class="search-form" placeholder="Pesquisar atendimento" id="search-form">
</div>
<div class="chats" id="chats">
</div>

4
public/js/main.js

@ -4,6 +4,7 @@
$(function () {
connect(localStorage.getItem('obj_ws'));
notifications();
startSearch();
changeColors(darkMode, html);
localStorage.removeItem('session_status');
localStorage.setItem('session_status', 0);
@ -192,7 +193,7 @@ const selectNotification = (id, status, datetime) => {
localStorage.getItem("my_uniqueid")
);
const allNotifications = JSON.parse(
localStorage.getItem("obj_notification")
localStorage.getItem("obj_search")
);
const atendimentos = await buscarAtendimento(id);
@ -464,7 +465,6 @@ const viewMessage = (ev) => {
$(".chat-window").append(`<div class="events"><span class="events-message">${ev.event.mensagem.content}</span></div>`);
break;
case "alert":
console.log("eae eae peixe");
break;
case "recover":
$(".chat-window").append(`<div class="events"><span class="events-message">${ev.event.mensagem.content}</span></div>`);

12
public/js/requests.js

@ -108,6 +108,18 @@ const listarAtendimentoAgente = (matricula) => new Promise((resolve) => {
});
})
const listarTodosAtendimentoAgente = (matricula) => new Promise((resolve) => {
$.ajax({
url: `${server_api}${version_api}atendimentos/listar/${matricula}`,
type: "GET",
success: function (res) {
resolve(res)
},
error: function (res) {
}
});
})
const listarPausasAgente = (id_empresa) => new Promise((resolve) => {
$.ajax({
url: `${server_api}${version_api}pausas`,

53
public/js/util.js

@ -4,12 +4,10 @@ const scrollDown = () => {
};
const responsivoButtonsHeader = () => {
let chat_windown = document.querySelector(".chat-window-header-right");
chat_windown.classList.toggle("ativo");
};
function formatedNumber(telefone) {
const numeros = telefone.replace(/\D/g, '');
if (numeros.length < 10) {
return telefone;
}
@ -19,18 +17,35 @@ function formatedNumber(telefone) {
const search = (input) => {
let inputValue = input.value.trim();
$("#chats").empty();
let pesquisa = chatsArray.filter((item) =>
item.nome.toLowerCase().includes(inputValue.toLowerCase())
);
const atendimentos = JSON.parse(localStorage.getItem('obj_search')).data;
let pesquisa;
let chatList = "";
pesquisa.sort((a, b) => b.status - a.status);
pesquisa.forEach((e) => {
if (!inputValue) {
notifications();
return;
}
pesquisa = atendimentos.filter((atendimento) => {
return (
atendimento.nome.toLowerCase().includes(inputValue.toLowerCase()) ||
atendimento.protocolo.toString().includes(inputValue.toLowerCase()) ||
atendimento.cliente_id.toString().includes(inputValue.toLowerCase())
)
});
let chat = pesquisa.filter(function (a) {
return (
!this[JSON.stringify(a.uniqueid)] && (this[JSON.stringify(a.uniqueid)] = true)
);
}, Object.create(null));
chat.sort((a, b) => b.status - a.status);
chat.forEach((e) => {
chatList += buildNotification({
uniqueid: e.uniqueid,
number: e.cliente_id,
media: e.context,
name: e.nome,
name: e.profile_name,
datetime: e.data_reg,
status: e.status,
protocolo: e.protocolo,
@ -431,9 +446,6 @@ const monitoraStatusRecuperacaoAtendimento = (date) => {
const start = new Date(formatedTransferDate);
const end = new Date(formatedDate);
const diffInTime = Math.abs(end - start) / 1000 / 60 / 60
console.log(start);
console.log(end);
console.log(diffInTime);
if (diffInTime > RecuperacaoAtendimentoLimite) {
return;
}
@ -967,6 +979,20 @@ const notifyMe = (title, content) => {
});
}
};
const startSearch = () => {
let matricula = localStorage.getItem("token")
if (typeof matricula == "undefined") {
return;
}
listarTodosAtendimentoAgente(
localStorage.getItem("my_uniqueid")
).then(res => {
localStorage.removeItem('obj_search');
localStorage.setItem('obj_search', JSON.stringify(res));
})
}
/**
* CRIA AS NOTIFICACOES DE TODOS OS ATENDIMENTOS NA INICIALIZACAO DO SISTEMA OU ATUALIZACAO
*/
@ -1029,7 +1055,6 @@ const notifications = (obj = {}) => {
});
};
/**
* CRIA AS NOTIFICACOES DE TODOS OS ATENDIMENTOS QUE ESTÃO NA FILA
*/
@ -1131,6 +1156,7 @@ const supervisorAgente = () => {
if (agente.status == "error" && agente.message == "Agente não encontrado") {
window.close();
}
startSearch();
});
}, 30000);
};
@ -1211,7 +1237,6 @@ const connect = (wsserver) => {
}
/** RECEBE AS NOTIFICAÇÕES E RENDERIZA NA TELA)*/
// console.log(data);
if (data.event?.mensagem.type === 'alert') {
renderNotification(data);
}

Loading…
Cancel
Save