-
-
Save wilcorrea/e4c153cefa9a2d1ed926e4b1737f49e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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", | |
| }); | |
| } | |
| } | |
| }, |
This file contains hidden or 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
| function create () { | |
| send('post', 'Dados salvos com Sucesso!') | |
| } | |
| function update () { | |
| send('put', 'Dados alterados com Sucesso!') | |
| } | |
| function send (method, message) { | |
| Http[method](`/${this.buscaBanco}`, this.complementoUrlState) | |
| .then(response => { | |
| swal(message, { | |
| icon: "success", | |
| }); | |
| this.$destroy(); | |
| this.$root.abrirPaginaFilha(`/lista-${this.complementoUrlState}`, `${this.descricaoState}`, true); | |
| } | |
| ).catch(error => { | |
| swal("Erro ao processar os Dados!", { | |
| icon: "error", | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment