1import{n as i,h as s}from"./index-ytIs-52l.js";const l={data(){return{profissionalDpo:!1,route:"pessoas",passwordValid:!1,form:{nome:"",gestor:!1,comiteEtica:!1,gestorDenuncias:!1,setor:null,email:"",telefone:"",password:"",funcao:null,receberEmail:!0,podeLogar:!1,isDpo:!1,perfil:null,novoPerfilNome:"",modulos:null,ativo:!0,turno:null,timePrivacidade:!1,foto:null,atualizarSenhaPadrao:!1,dataAtualizacaoSenha:null},dropzoneOptions:this.$http.getDropzoneConfig("v1/upload","post",{maxFiles:1,addRemoveLinks:!0,capture:!0,dictDefaultMessage:"Clique ou arraste aqui",dictRemoveFile:"Remover"}),setores:[],funcoes:[],perfis:[],perfilSelecao:"novo",organizacoes:[],formNovoItem:{nome:""},tipo:""}},computed:{operadora(){return!!this.form.perfil||Array.isArray(this.form.modulos)},sectionStyle(){return this.isDarkMode?{backgroundColor:"#1c1e21",borderColor:"#2c2f33"}:{backgroundColor:"#fafafa",borderColor:"#e5e7eb"}}},watch:{"form.comiteEtica"(t){t||(this.form.gestorDenuncias=!1)},"form.podeLogar"(t){t||(this.form.perfil=null,this.perfilSelecao="novo")},perfilSelecao(t){if(t==="novo"){this.form.perfil=null;return}this.form.perfil=t,this.form.novoPerfilNome="";const e=this.perfis.find(o=>o._id===t);e&&(this.form.modulos=Array.isArray(e.modulos)?JSON.parse(JSON.stringify(e.modulos)):null)},operadora(t){t||(this.form.isDpo=!1)}},methods:{editarMatriz(t){this.form.modulos=t,this.perfilSelecao!=="novo"&&(this.perfilSelecao="novo")},async getMe(){const t=await this.$http.post("/v1/profissionais/me");this.profissionalDpo=t&&t.data&&t.data.pessoa?t.data.pessoa.isDpo:!1},async cadastrarNovoItem(){if(!this.formNovoItem.nome.trim())return this.$toast.warning("Insira um nome.");const t=await this.$http.post(`/v1/${this.tipo}`,this.formNovoItem);if(t.data.success){this.$toast.success("Cadastrado!");const e=t.data.data;if(this.tipo==="organizacoes"&&(this.organizacoes=await this.getOrganizacoes(),await this.$nextTick(),e&&e._id&&(this.form.organizacao=e._id)),this.tipo==="funcoes"&&(this.funcoes=await this.getFuncoes(),await this.$nextTick(),e&&e._id&&(this.form.funcao=e._id)),this.tipo==="setores"){this.setores=await this.get
1Setores();const o=e&&this.setores.find(a=>String(a._id)===String(e._id));if(o){const a=Array.isArray(this.form.setor)?this.form.setor:[];a.some(r=>String(r._id)===String(o._id))||(this.form.setor=[...a,o])}}this.formNovoItem.nome="",this.$modal.hide("modalNovoItem")}else this.$toast.error(t.data.err)},novoItem(t){this.tipo=t,this.formNovoItem.nome="",this.$modal.show("modalNovoItem")},async reenviarSenhaTemporaria(){this.$confirm({title:"Reenviar senha temporária",message:`Uma nova senha temporária será gerada e enviada para ${this.form.email}. A senha anterior deixará de funcionar. Confirma?`,button:{no:"Cancelar",yes:"Reenviar"},callback:async t=>{if(!t)return;const e=await this.$http.post(`/v1/pessoas/reenviar-senha/${this.form._id}`);e.data.success?this.$toast.success("Senha temporária enviada por email"):this.$toast.error(e.data.err)}})},async save(){if(!this.form.ativo&&!this.form.dataDesligamento)return this.$toast.warning("Informe data de desligamento!");if(this.form.podeLogar&&(!this.form.email||!this.form.email.trim()))return this.$toast.warning("E-mail é obrigatório quando a pessoa pode logar no sistema");if(this.$store.state.user.cliente){if(this.precisaTrocarSenha()&&!this.form.password)return this.$toast.warning("Senha é obrigatória!");if(this.form.password&&!this.passwordValid)return this.$toast.warning("Senha não atende aos requisitos mÃnimos!")}const e=this.form._id?"put":"post",o=await this.$http[e](`/v1/${this.route}`,this.form);if(o.data.success){if(this.$toast.success("Salvo!"),o.data.clienteLogin&&o.data.clienteLogin._id&&this.$store.state.user.cliente){await localStorage.setItem("user",JSON.stringify(o.data.clienteLogin)),this.$store.commit("login",o.data.clienteLogin),this.$router.push({path:"/projetos"});return}this.$router.back()}else this.$toast.error(o.data.err)},updateFoto(t,e){this.form.foto=e.file},async getOrganizacoes(){return(await this.$http.post("/v1/organizacoes/list",{all:!0})).data.data},async getFuncoes(){return(await this.$http.post("/v1/funcoes/list",{all:!0})).data.data},async getPerfis(){return(await this.$http.post("/v1/perfis/list",{all:!0})).data.data||[]},async getSetores(){return(await this.$http.post("/v1/setores/list",{all:!0})).data.data},formatarData(t){return s(t).format("DD/MM/YYYY HH:mm")},precisaTrocarSenha(){if(this.$store.state.user.cliente){const t=this.form.dataAtualizacaoSenha?s(this.form.dataAtualizacaoSenha).add(2,"months"):null;if(this.form.atualizarSenhaPadrao||t&&s().isAfter(t)||!this.form.dataAtualizacaoSenha)return!0}return!1}},async beforeMount(){const t=this.$route.params.id;
1if(this.setores=await this.getSetores(),this.funcoes=await this.getFuncoes(),this.organizacoes=await this.getOrganizacoes(),this.perfis=await this.getPerfis(),this.$store.state.user.consultor?this.profissionalDpo=!0:this.$store.state.user.profissional&&await this.getMe(),t){const e=await this.$http.get(`/v1/${this.route}/${t}`);if(Array.isArray(e.data.setor)&&(e.data.setor=e.data.setor.filter(o=>o&&o.nome)),this.form=e.data,"modulos"in this.form||this.$set(this.form,"modulos",null),"isDpo"in this.form||this.$set(this.form,"isDpo",!1),"perfil"in this.form||this.$set(this.form,"perfil",null),this.form.perfil&&this.form.perfil._id&&(this.form.perfil=this.form.perfil._id),this.$set(this.form,"novoPerfilNome",""),this.perfilSelecao=this.form.perfil||"novo",this.precisaTrocarSenha())return this.$toast.warning("Por favor, atualize a senha!")}}};var n=function(){var e=this,o=e._self._c;return o("div",{staticClass:"min-h-app",style:{backgroundColor:e.isDarkMode?"#151618":"#ffffff",color:e.isDarkMode?"#e8eaed":"#111827"}},[e.$store.state.user.cliente?o("Navbar",{attrs:{page:"Seu perfil"}}):o("Navbar",{attrs:{page:`${e.form._id?"Editar":"Novo"} Convidado`,link:"/cadastros",nameLink:"Cadastros",link_2:"/cadastros/pessoas",nameLink_2:"Convidados"}}),o("div",{staticClass:"mx-auto px-4 py-6 md:px-8 md:py-8"},[e.$store.state.user.cliente?o("header",{staticClass:"mb-6"},[o("h1",{staticClass:"text-2xl font-semibold"},[e._v("Seu perfil")])]):e._e(),o("form",{staticClass:"text-sm space-y-2",attrs:{action:"#",method:"POST"}},[e.$store.state.user.cliente?e._e():o("section",{staticClass:"rounded-md border p-4 md:p-5",style:e.sectionStyle},[o("h2",{staticClass:"text-base font-semibold mb-1"},[e._v("Permissões de acesso")]),o("p",{staticClass:"text-[11px] opacity-60 mb-4"},[e._v("Defina como este convidado poderá acessar e usar o sistema.")]),o("div",{staticClass:"flex flex-col gap-2"},[o("div",{staticClass:"flex gap-1 items-center"},[o("Checkbox",{attrs:{id:"podeLogar",label:"Pode logar no sistema",size:"sm",observacao:"Quando ativado, o convidado recebe um email com uma senha temporária e poderá </br>acessar o sistema usando seu e-mail e essa senha.</br></br> No primeiro login, será solicitada a troca da senha. </br>Quando desativado, o convidado fica apenas cadastrado (sem acesso ao sistema)."},model:{value:e.form.podeLogar,callback:function(a){e.$set(e.form,"podeLogar",a)},expression:"form.podeLogar"}}),e.form._id&&e.form.podeLogar&&e.form.email?o("button",{staticClass:"inline-flex items-center px-3 py-1.5 text-sm font-medium rounded-md bg-blue-100 hover:bg-blue-200 text-blue-700",staticStyle:{"margin-left":"3.75rem"},attrs:{type:"button"},on:{click:e.reenviarSenhaTemporaria}},[e._v(" Reenviar senha temporária por email ")]):e._e()],1),e.form.gestor?o("Checkbox",{attrs:{label:"Definir como gestor",size:"sm",observacao:"Quando ativado, o convidado poderá visualizar informações adicionais nos módulos"},model:{value:e.form.gestor,callback:function(a){e.$set(e.form,"gestor",a)},expression:"form.gestor"}}):e._e(),e.form.podeLogar&&e.$store.state.user.consultor?[o("Select",{attrs:{name:"perfil",id:"perfil",label:"Perfil de acesso",options:e.perfis,"option-label":"nome","option-value":"_id",placeholder:"Personalizado","placeholder-value":"novo",tooltip:{content:"Perfil é um modelo: escolher um copia as permissões dele, e você pode ajustar à vontade.<br/>Enquanto a matriz ficar igual ao perfil, ela acompanha as mudanças do perfil. Ajustou à mão, vira Personalizado.<br/>Em Personalizado, dê um nome para salvar a matriz como um perfil novo.",html:!0,placement:"bottom"},"custom-style":e.inputStyle},model:{value:e.perfilSelecao,callback:function(a){e.perfilSelecao=a},expression:"perfilSelecao"}}),e.perfilSelecao==="novo"?o("TextInput",{attrs:{name:"novoPerfilNome",id:"novoPerfilNome",label:"Salvar como perfil novo (opcional)",placeholder:"Ex.: RH, JurÃdico, Sócio. Vazio = não cria perfil","custom-style":e.inputStyle},model:{value:e.form.novoPerfilNome,callback:function(a){e.$set(e.form,"
1novoPerfilNome",a)},expression:"form.novoPerfilNome"}}):e._e(),o("p",{staticClass:"text-xs",style:{color:e.isDarkMode?"#9aa0a6":"#535862"}},[e._v(" Convidado com perfil de acesso terá seu acesso liberado na plataforma para operar os módulos marcados. Sem perfil, entra apenas para responder questionários. ")]),e.operadora?o("div",{staticClass:"ml-6 pl-4 border-l-2 border-gray-200"},[o("Checkbox",{attrs:{label:"DPO",size:"sm",observacao:"Libera o módulo de Denúncias LGPD e a exclusão de convidados"},model:{value:e.form.isDpo,callback:function(a){e.$set(e.form,"isDpo",a)},expression:"form.isDpo"}})],1):e._e()]:e._e(),e.moduloDenunciasNr1?[o("Checkbox",{attrs:{label:"Comitê de ética",size:"sm",observacao:"Quando ativado, o convidado poderá visualizar o módulo de denúncias, apenas denúncias que ele for designado como apurador serão listados"},model:{value:e.form.comiteEtica,callback:function(a){e.$set(e.form,"comiteEtica",a)},expression:"form.comiteEtica"}}),e.form.comiteEtica?o("div",{staticClass:"ml-6 pl-4 border-l-2 border-gray-200"},[o("Checkbox",{attrs:{label:"Pode registrar denúncias e visualizar o link e QRCode das denúncias",size:"sm",observacao:"Quando ativado, o convidado poderá registrar denúncias manualmente e visualizar o link e o QRCode do canal de denúncias"},model:{value:e.form.gestorDenuncias,callback:function(a){e.$set(e.form,"gestorDenuncias",a)},expression:"form.gestorDenuncias"}})],1):e._e()]:e._e(),e.form.podeLogar&&e.$store.state.user.consultor?o("div",{staticClass:"mt-4"},[o("MatrizPermissoes",{attrs:{value:e.form.modulos},on:{input:e.editarMatriz}})],1):e._e()],2)]),o("section",{staticClass:"rounded-md border p-4 md:p-5",style:e.sectionStyle},[o("h2",{staticClass:"text-base font-semibold mb-4"},[e._v("Dados pessoais")]),o("div",{staticClass:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"},[o("TextInput",{attrs:{name:"nome",label:"Nome Completo",required:"","custom-style":e.inputStyle}
1,model:{value:e.form.nome,callback:function(a){e.$set(e.form,"nome",a)},expression:"form.nome"}}),o("TextInput",{attrs:{name:"email",label:"Email",type:"email",required:e.form.podeLogar,"custom-style":e.inputStyle},model:{value:e.form.email,callback:function(a){e.$set(e.form,"email",a)},expression:"form.email"}}),e.$store.state.user.cliente?e._e():o("Select",{attrs:{required:"",name:"receberEmail",id:"receberEmail",label:"Receber e-mail de atualização",tooltip:{content:"Quando ativado, a pessoa poderá receber </br>e-mails de atualizações no sistema.",html:!0,placement:"bottom"},placeholder:"",options:[{label:"Sim",value:!0},{label:"Não",value:!1}],"custom-style":e.inputStyle},model:{value:e.form.receberEmail,callback:function(a){e.$set(e.form,"receberEmail",a)},expression:"form.receberEmail"}}),e.$store.state.user.cliente?o("div",[o("label",{staticClass:"block mb-1",attrs:{for:"password"}},[e._v("Nova senha")]),o("PasswordInput",{attrs:{name:"password",id:"password",autocomplete:"new-password",placeholder:"Digite uma nova senha","input-class":"focus:ring-azul-facil-400 focus:border-azul-facil-400 block w-full text-sm p-2 rounded-md"},on:{valid:function(a){e.passwordValid=a}},model:{value:e.form.password,callback:function(a){e.$set(e.form,"password",a)},expression:"form.password"}})],1):e._e(),e.form.dataAtualizacaoSenha&&e.$store.state.user.cliente?o("div",[o("label",{staticClass:"block mb-1"},[e._v("Atualização da senha")]),o("input",{staticClass:"block w-full text-sm p-2 rounded-md border border-gray-300 bg-gray-50 text-gray-600 cursor-not-allowed",attrs:{type:"text",disabled:""},domProps:{value:e.formatarData(e.form.dataAtualizacaoSenha)}})]):e._e()],1)]),e.$store.state.user.cliente?e._e():o("section",{staticClass:"rounded-md border p-4 md:p-5",style:e.sectionStyle},[o("h2",{staticClass:"text-base font-semibold mb-4"},[e._v("Alocação")]),o("div",{staticClass:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-2 gap-4"},[o("div",[o("div",{staticClass:"flex items-center gap-1 mb-1"},[o("label",{attrs:{for:"setor"}},[e._v("Setor / Departamento")]),o("button",{directives:[{name:"tooltip",rawName:"v-tooltip",value:"Cadastrar novo setor",expression:"'Cadastrar novo setor'"}],staticClass:"text-green-600 hover:text-green-700",attrs:{type:"button"},on:{click:function(a){return e.novoItem("setores")}}},[o("svg",{staticClass:"h-5 w-5",attrs:{fill:"currentColor",viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg"}},[o("path",{attrs:{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm44-92a4,4,0,0,1-4,4H132v36a4,4,0,0,1-8,0V132H88a4,4,0,0,1,0-8h36V88a4,4,0,0,1,8,0v36h36A4,4,0,0,1,172,128Z"}})])])]),o("multiselect",{attrs:{options:e.setores,multiple:!0,"close-on-select":!1,label:"nome",trackBy:"_id",placeholder:"Selecione os setores",selectedLabel:"selecionado",deselectLabel:"",selectLabel:"",id:"setor"},model:{value:e.form.setor,callback:function(a){e.$set(e.form,"setor",a)},expression:"form.setor"}})],1),o("div",[o("div",{staticClass:"flex items-center gap-1 mb-1"},[o("label",{attrs:{for:"funcao"}},[e._v("Cargo / Função")]),o("button",{directives:[{name:"tooltip",rawName:"v-tooltip",value:"Cadastrar novo cargo",expression:"'Cadastrar novo cargo'"}],staticClass:"text-green-600 hover:text-green-700",attrs:{type:"button"},on:{click:function(a){return e.novoItem("funcoes")}}},[o("svg",{staticClass:"h-5 w-5",attrs:{fill:"currentColor",viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg"}},[o("path",{attrs:{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm44-92a4,4,0,0,1-4,4H132v36a4,4,0,0,1-8,0V132H88a4,4,0,0,1,0-8h36V88a4,4,0,0,1,8,0v36h36A4,4,0,0,1,172,128Z"}})])])]),o("Select",{attrs:{required:"",name:"funcao",id:"funcao",options:e.funcoes,"option-label":"nome","option-value":"_id",placeholder:"Selecione um cargo/função","custom-style":e.inputStyle},model:{value:e.form.funcao,callback:function(a){e.$set(e.form,"funcao",a)},expression:"form.funcao"}})],1),o("div",[o("div",{staticClass:"flex items-center gap-1 mb-1"},[o("label",{attrs:{for:"organizacao"}},[e._v("Unidades de negócio")]),o("button",{directives:[{name:"tooltip",rawName:"v-tooltip",value:"Cadastrar nova unidade",expression:"'Cadastrar nova unidade'"}],staticClass:"text-green-600 hover:text-green-700",attrs:{type:"button"},on:{click:function(a){return e.novoItem("organizacoes")}}}
1,[o("svg",{staticClass:"h-5 w-5",attrs:{fill:"currentColor",viewBox:"0 0 256 256",xmlns:"http://www.w3.org/2000/svg"}},[o("path",{attrs:{d:"M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm44-92a4,4,0,0,1-4,4H132v36a4,4,0,0,1-8,0V132H88a4,4,0,0,1,0-8h36V88a4,4,0,0,1,8,0v36h36A4,4,0,0,1,172,128Z"}})])])]),o("Select",{attrs:{required:"",name:"organizacao",id:"organizacao",placeholder:"Selecione uma unidade de negócio",options:e.organizacoes,"option-label":"nome","option-value":"_id","custom-style":e.inputStyle},model:{value:e.form.organizacao,callback:function(a){e.$set(e.form,"organizacao",a)},expression:"form.organizacao"}})],1),e.$store.state.sistema==="nr1"?o("div",[o("Select",{attrs:{name:"turno",id:"turno",label:"Turno",placeholder:"Selecione um turno",options:[{label:"5x2 Diurno (Segunda a Sexta)",value:"5x2 Diurno (Segunda a Sexta)"},{label:"6x1 Diurno (Com folga semanal)",value:"6x1 Diurno (Com folga semanal)"},{label:"12x36 Noturno",value:"12x36 Noturno",alert:"Exige Adicional Noturno e rastreamento de fadiga psicossocial"},{label:"Turno Ininterrupto de Revezamento",value:"Turno Ininterrupto de Revezamento"},{label:"Escala FlexÃvel / Sem Controle de Ponto",value:"Escala FlexÃvel / Sem Controle de Ponto"}],"custom-style":e.inputStyle},model:{value:e.form.turno,callback:function(a){e.$set(e.form,"turno",a)},expression:"form.turno"}})],1):e._e()])]),e.$store.state.user.cliente?e._e():o("section",{staticClass:"rounded-md border p-4 md:p-5",style:e.sectionStyle},[o("h2",{staticClass:"text-base font-semibold mb-4"},[e._v("Situação")]),o("div",{staticClass:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4"},[o("Select",{attrs:{required:"",name:"ativo",id:"ativo",label:"Situação atual",placeholder:"",options:[{label:"Ativo",value:!0},{label:"Desligado (inativo)",value:!1}],"custom-style":e.inputStyle},model:{value:e.form.ativo,callback:function(a){e.$set(e.form,"ativo",a)},expression:"form.ativo"}}),e.form.ativo?e._e():o("div",[o("label",{staticClass:"block mb-1",attrs:{for:"dataDesligamento"}},[e._v("Data de desligamento")]),o("DateInput",{attrs:{name:"dataDesligamento","custom-style":e.inputStyle},model:{value:e.form.dataDesligamento,callback:function(a){e.$set(e.form,"dataDesligamento",a)},expression:"form.dataDesligamento"}})],1)],1)]),o("div",{staticClass:"flex justify-between items-center pt-2"},[o("Button",{attrs:{label:"Voltar",variant:"secondary","icon-left":"arrow-left"},on:{click:function(a){return e.$router.back()}}}),o("Button",{attrs:{label:"Salvar","icon-left":"floppy-disk"},on:{click:e.save}})],1)])]),o("modal",{attrs:{name:"modalNovoItem",adaptive:!0,height:"auto",clickToClose:!0}},[o("div",{staticClass:"p-4",style:e.modalStyle},[e.tipo==="organizacoes"?o("div",{style:{color:e.modalStyle.color}}
1,[e._v(" Cadastrar uma nova unidade de negócio ")]):e._e(),e.tipo==="setores"?o("div",{style:{color:e.modalStyle.color}},[e._v(" Cadastrar um novo Setor / Departamento ")]):e._e(),e.tipo==="funcoes"?o("div",{style:{color:e.modalStyle.color}},[e._v(" Cadastrar um novo Cargo / Função ")]):e._e(),e.tipo==="organizacoes"||e.tipo==="funcoes"||e.tipo==="setores"?o("div",[o("hr"),o("div",{staticClass:"mt-4"},[o("TextInput",{attrs:{name:"formNovoItem_nome",label:"Nome","label-color":e.modalStyle.color,"custom-style":e.inputStyle},model:{value:e.formNovoItem.nome,callback:function(a){e.$set(e.formNovoItem,"nome",a)},expression:"formNovoItem.nome"}})],1)]):e._e(),o("div",[o("Button",{staticClass:"mt-2",attrs:{label:"Cadastrar",size:"sm"},on:{click:e.cadastrarNovoItem}})],1)])])],1)},c=[],m=i(l,n,c,!1,null,null);const u=m.exports;export{u as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.