Last active
May 18, 2018 17:41
-
-
Save hamiltongabriel/51571d713b6fe490ea939a34e18b8b82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data:()=> ({ | |
tituloStatus:null, | |
somenteLeitura:false, | |
listaSistema: [], | |
nomeListaPesquisa:'listaSistema', | |
complementoUrlState:'perfil', | |
descricaoState: 'Perfil', | |
getterTempVuex: 'GET_PERFIL_TEMP', | |
buscaBanco: 'perfis', | |
perfil: { | |
nome: '', | |
ativo: true, | |
} | |
}), | |
salvar() { | |
if (!this.somenteLeitura) { | |
this.complementoUrlState = this.$store.getters.getterTempVuex; | |
if (this.complementoUrlState == null || !this.complementoUrlState.hasOwnProperty("nome") || !this.complementoUrlState.hasOwnProperty("ativo")) { | |
this.complementoUrlState = { | |
nome: '', | |
ativo: '', | |
} | |
} | |
this.complementoUrlState.nome = this.this.complementoUrlState.nome; | |
this.complementoUrlState.ativo = this.this.complementoUrlState.ativo; | |
swal({ | |
title: "Confirmação", | |
text: "Deseja Salvar os Dados", | |
icon: "info", | |
closeOnClickOutside: false, | |
buttons: { | |
cancel: { | |
text: "Cancelar", | |
value: null, | |
visible: true, | |
className: "danger", | |
closeModal: true, | |
}, | |
confirm: { | |
text: "OK", | |
value: true, | |
visible: true, | |
className: "", | |
closeModal: true | |
} | |
}, | |
}) | |
.then((willDelete) => { | |
if (willDelete) { | |
if (this.complementoUrlState.id === null || this.complementoUrlState.id === '' || !this.complementoUrlState.hasOwnProperty("id")) { | |
Http.post(`/${this.buscaBanco}`, this.complementoUrlState) | |
.then(response => { | |
swal("Dados salvos com Sucesso!", { | |
icon: "success", | |
}); | |
this.$destroy(); | |
this.$root.abrirPaginaFilha(`/lista-${this.complementoUrlState}`, `${this.descricaoState}`, true); | |
} | |
).catch(error => { | |
}); | |
} else { | |
Http.put(`/${this.buscaBanco}`, this.complementoUrlState) | |
.then(response => { | |
swal("Dados alterados com Sucesso!", { | |
icon: "success", | |
}); | |
this.$destroy(); | |
this.$root.abrirPaginaFilha(`/lista-${this.complementoUrlState}`, `${this.descricao}`, true); | |
} | |
).catch(error => { | |
swal("Erro ao Atualizar Dados!", { | |
icon: "error", | |
}); | |
}); | |
} | |
} | |
}); | |
} else { | |
swal({ | |
title: "Atenção !", | |
text: "Campo de Pessoa é Obrigatório !", | |
icon: "warning", | |
}); | |
} | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment