(window.webpackJsonp=window.webpackJsonp||[]).push([[1063],{2812:function(e,t,o){"use strict";o.r(t);o(7),o(4),o(137);var r={name:"Empresa",data:function(){return{errorMsg:null,infoMsg:null,empresas:[],empresa:{},fieldsEmpresa:[{key:"actions",label:"Ações"},{key:"razaoSocial",label:"Razão Social"},{key:"nomeFantasia",label:"Nome Fantasia"},{key:"sigla",label:"Sigla"}],dismissSecs:5,dismissCountDown:0,showDismissibleAlert:!1}},mounted:function(){this.findEmpresas()},methods:{addEmpresa:function(){this.empresa={},this.$bvModal.show("modalEmpresa")},editEmpresa:function(e){var t=this.empresas.filter((function(data){return data.id===e}));null!=t&&(this.empresa=t[0],console.log("Empresa=>",this.empresa),this.$bvModal.show("modalEmpresa"))},findEmpresas:function(){var e=this;this.$empresaService.find().then((function(t){e.empresas=t.data})).catch((function(t){e.empresas=[],e.errorMsg=t.masseger,e.showAlert()}))},deleteEmpresa:function(e){var t=this;this.$bvModal.msgBoxConfirm("Deseja excluir a empresa ?").then((function(o){o&&t.$empresaService.delete(e).then((function(){t.findEmpresas(),t.infoMsg="Empresa deletada com sucesso!",t.showAlert()}))})).catch((function(e){t.empresas=[],t.errorMsg=e.masseger,t.showAlert()}))},hideModal:function(){this.$bvModal.hide("modalEmpresa")},saveEmpresa:function(){var e=this;this.$empresaService.save(this.empresa).then((function(){e.findEmpresas(),e.$bvModal.hide("modalEmpresa"),e.infoMsg="Empresa salva com sucesso!",e.showAlert()})).catch((function(t){e.errorMsg=t.masseger,e.showAlert()}))},countDownChanged:function(e){this.dismissCountDown=e},showAlert:function(){this.dismissCountDown=this.dismissSecs}}},n=o(42),component=Object(n.a)(r,(function(){var e=this,t=e.$createElement,o=e._self._c||t;return o("div",{staticClass:"animated fadeIn"},[o("b-row",[o("b-col",{attrs:{sm:"12"}},[o("b-card",[o("div",{attrs:{slot:"header"},slot:"header"},[o("b-row",[o("b-col",{attrs:{cols:"10"}},[o("h4",{staticClass:"primary mt-4"},[e._v("Empresa")])]),e._v(" "),o("b-col",{attrs:{cols:"2"}},[o("b-button",{staticClass:"mt-4 ml-5",attrs:{small:"",variant:"info"},on:{click:e.addEmpresa}},[o("fa-icon",{attrs:{icon:"file"}}),e._v(" "),o("span",{staticClass:"ml-1"},[e._v("Inserir")])],1)],1)],1)],1),e._v(" "),o("b-table",{attrs:{striped:"",hover:"",fields:e.fieldsEmpresa,items:e.empresas,"show-empty":!0,"empty-text":"Não há empresa disponíveis."},scopedSlots:e._u([{key:":cell(actions)",fn:function(t){return[o("b-button",{staticClass:"mr-1",attrs:{small:"",variant:"info"},on:{click:function(o){return e.editEmpresa(t.item.id)}}},[o("fa-icon",{attrs:{icon:"edit"}})],1),e._v(" "),o("b-button",{attrs:{small:"",variant:"danger"},on:{click:function(o){return e.deleteEmpresa(t.item.id)}}},[o("fa-icon",{attrs:{icon:"trash-alt"}})],1)]}}])})],1)],1)],1),e._v(" "),o("b-modal",{attrs:{id:"modalEmpresa","hide-footer":""},scopedSlots:e._u([{key:":modal-title",fn:function(){return[e._v(e._s(null==e.empresa.id?"Adicionar empresa":"Editar empresa"))]},proxy:!0}])},[e._v(" "),o("b-row",[o("b-col",{attrs:{cols:"12"}},[o("b-form-group",{attrs:{label:"Razão Social: "}},[o("b-form-input",{attrs:{maxlength:60},model:{value:e.empresa.razaoSocial,callback:function(t){e.$set(e.empresa,"razaoSocial",t)},expression:"empresa.razaoSocial"}})],1)],1),e._v(" "),o("b-col",{attrs:{cols:"12"}},[o("b-form-group",{attrs:{label:"Nome Fantasia: "}},[o("b-form-input",{attrs:{maxlength:60},model:{value:e.empresa.nomeFantasia,callback:function(t){e.$set(e.empresa,"nomeFantasia",t)},expression:"empresa.nomeFantasia"}})],1)],1),e._v(" "),o("b-col",{attrs:{cols:"12"}},[o("b-form-group",{attrs:{label:"Sigla: "}},[o("b-form-input",{attrs:{maxlength:20},model:{value:e.empresa.sigla,callback:function(t){e.$set(e.empresa,"sigla",t)},expression:"empresa.sigla"}})],1)],1)],1),e._v(" "),o("b-row",[o("b-col",{attrs:{cols:"6"}}),e._v(" "),o("b-col",[o("b-button",{staticClass:"px-3 ml-3",attrs:{variant:"primary",block:""},on:{click:function(t){return e.saveEmpresa()}}},[o("fa-icon",{attrs:{icon:"save"}}),e._v(" "),o("span",{staticClass:"ml-1"},[e._v("Salvar")])],1)],1),e._v(" "),o("b-col",[o("b-button",{staticClass:"px-3",attrs:{variant:"secondary",block:""},on:{click:function(t){return e.hideModal()}}},[e._v("Cancelar")])],1)],1)],1),e._v(" "),o("b-alert",{staticClass:"position-fixed fixed-top m-0 rounded-0",staticStyle:{"z-index":"2000"},attrs:{show:e.dismissCountDown,variant:"success",dismissible:"",fade:""},on:{"dismiss-count-down":e.countDownChanged}},[e._v(e._s(e.infoMsg))]),e._v(" "),o("b-alert",{staticClass:"position-fixed fixed-bottom m-0 rounded-0",staticStyle:{"z-index":"2000"},attrs:{show:e.dismissCountDown,variant:"danger",dismissible:"",fade:""},on:{"dismiss-count-down":e.countDownChanged}},[e._v(e._s(e.errorMsg))])],1)}),[],!1,null,null,null);t.default=component.exports}}]);
//# sourceMappingURL=3c78477-1.2.11.js.map