// Função para carregar o TOM SELECT com estilo/dados da empresa
function loadSelectEmpresa(elemento = '#selectEmpresaChamado') {
new TomSelect(`${elemento}`, {
maxItems: 1,
create: false,
allowEmptyOption: true,
placeholder: 'SELECIONE A EMPRESA',
persist: false,
searchField: ['cnpj', 'nome', 'fantasia'],
render: {
option(data, escape) {
if (data.value == 0) {
return `
TODAS EMPRESAS
`;
} else if (data.value == -1) {
return `SELECIONE A EMPRESA
`
}
const cnpj = escape(data.cnpj);
const nome = escape(data.nome);
const nomeFantasia = escape(data.fantasia);
const inativo = escape(data.inativo);
return `
${cnpj}
${nome}
${nomeFantasia}
`;
},
item(data, escape) {
if (data.value == 0) {
return ` TODAS EMPRESAS
`;
} else if (data.value == -1) {
return `SELECIONE A EMPRESA
`
}
const cnpj = escape(data.cnpj);
const nome = escape(data.nome);
const inativo = escape(data.inativo);
return `
${nome}
(${cnpj})
`;
}
}
});
}
function loadSelectUsuario(elemento = '#selectAtendenteFiltroChamados', allText = 'ATENDENTES', selectText = 'ATENDENTE') {
new TomSelect(`${elemento}`, {
maxItems: 1,
create: false,
allowEmptyOption: true,
placeholder: `SELECIONE O ${selectText}`,
persist: false,
searchField: ['cnpj', 'nome', 'fantasia'],
render: {
option(data, escape) {
if (data.value == 0) {
return ` TODOS ${allText}
`;
} else if (data.value == -1) {
return `SELECIONE O ${selectText}
`
}
const nome = escape(data.nome);
const email = escape(data.email);
const foto = escape(data.foto);
const srcFoto = foto ? URL_ARQUIVOS + '/' + foto : DEFAULT_PICTURE;
return `
${nome}
${email}
`;
},
item(data, escape) {
if (data.value == 0) {
return ` TODOS ${allText}
`;
} else if (data.value == -1) {
return `SELECIONE O ${selectText}
`
}
const nome = escape(data.nome);
const foto = escape(data.foto);
const email = escape(data.email);
const srcFoto = foto ? URL_ARQUIVOS + '/' + foto : DEFAULT_PICTURE;
return `
${nome}
(${email})
`;
}
}
});
}