text: (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-58ed"],{"4Rne":function(t,e,a){"use strict";a.r(e);var i=a("QbLZ"),s=a.n(i),n=a("P2sY"),o=a.n(n),l=a("L2JU"),r={id:void 0,name:"",surname:"",email:"",image_id:void 0,password:""},c={name:"UserEditor",components:{MediaManager:a("Hvaj").a},data:function(){return{loading:!1,tempRoute:"",isEdit:!1,formData:o()({},r),showMediaGallery:!1,showDeleteDialog:!1,showSettingsDialog:!1}},computed:s()({},Object(l.b)({user:"currentUser"})),created:function(){this.tempRoute=o()({},this.$route),this.$route.params&&this.$route.params.id?this.isEdit=!0:this.isEdit=!1},mounted:function(){this.isEdit&&this.findUser(this.$route.params.id)},methods:{findUser:function(t){var e=this;this.loading=!0,this.$store.dispatch("findUser",t).then(function(){e.loading=!1,e.fillForm()})},fillForm:function(){this.formData=o()({},this.user),this.updateNavigationTab()},handleSave:function(){var t=this;this.loading=!0,this.$store.dispatch("saveUser",this.prepareToSave(this.formData)).then(function(){t.loading=!1,t.$message({message:"Salvo com sucesso!",type:"success",showClose:!0,duration:1e3}),t.fillForm(),t.isEdit||(t.deleteNavigationtab(),t.$router.push({name:"EditUser",params:{id:t.formData.id}})),t.updateNavigationTab()})},handleDestroy:function(){var t=this;this.showDeleteDialog=!1,this.$store.dispatch("destroyUser",this.formData.id).then(function(){t.$message({message:"Usuário Deletado!",type:"warning",showClose:!0,duration:1e3}),t.deleteNavigationtab(),t.$router.go(-1)})},changeImage:function(t){this.formData.image_id=t.id,this.formData.image=t},prepareToSave:function(t){return{id:t.id,name:t.name,surname:t.surname,email:t.email,image_id:t.image_id,password:t.password?t.password:void 0}},updateNavigationTab:function(){var t=o()({},this.tempRoute,{title:""+this.formData.name});this.$store.dispatch("updateVisitedView",t)},deleteNavigationtab:function(){var t=o()({},this.tempRoute,{title:""+this.formData.name});this.$store.dispatch("delVisitedView",t)}}},m=(a("CDg9"),a("KHd+")),u=Object(m.a)(c,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",{staticClass:"app-container"},[a("el-row",{attrs:{gutter:20}},[a("el-form",{ref:"form",model:{value:t.formData,callback:function(e){t.formData=e},expression:"formData"}},[a("el-col",{attrs:{span:17}},[a("el-card",{staticClass:"box-card"},[a("div",{attrs:{slot:"header"},slot:"header"},[a("span",[t._v("Informações do Usuário")]),t._v(" "),t.isEdit?a("el-button",{staticStyle:{float:"right","margin-top":"-5px"},attrs:{type:"primary"},on:{click:function(e){t.showSettingsDialog=!0}}},[a("svg-icon",{attrs:{"icon-class":"reset-pass"}})],1):t._e()],1),t._v(" "),a("el-form-item",{attrs:{label:"Nome"}},[a("el-input",{attrs:{type:"text"},model:{value:t.formData.name,callback:function(e){t.$set(t.formData,"name",e)},expression:"formData.name"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"Sobrenome"}},[a("el-input",{attrs:{type:"text"},model:{value:t.formData.surname,callback:function(e){t.$set(t.formData,"surname",e)},expression:"formData.surname"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"E-mail"}},[a("el-input",{attrs:{type:"text"},model:{value:t.formData.email,callback:function(e){t.$set(t.formData,"email",e)},expression:"formData.email"}})],1),t._v(" "),t.isEdit?t._e():a("el-form-item",{attrs:{label:"Senha"}},[a("el-input",{attrs:{type:"password"},model:{value:t.formData.password,callback:function(e){t.$set(t.formData,"password",e)},expression:"formData.password"}})],1)],1)],1),t._v(" "),a("el-col",{attrs:{span:7}},[a("el-card",{staticClass:"box-card-component"},[a("div",{staticClass:"box-card-header",attrs:{slot:"header"},on:{click:function(e){t.showMediaGallery=!0}},slot:"header"},[a("img",{attrs:{src:t.formData.image?t.formData.image.url:"/static/sem-imagem.png",alt:t.formData.image?t.formData.image.original_name:"Sem Imagem",title:t.formData.image?t.formData.image.original_name:"Clique para escolher uma imagem"}})]),t._v(" "),a("el-row",{staticStyle:{"margin-top":"20px"}},[a("el-button",{directives:[{name:"show",rawName:"v-show",value:t.isEdit,expression:"isEdit"}],attrs:{type:"danger"},on:{click:function(e){e.preventDefault(),t.showDeleteDialog=!0}}},[a("i",{staticClass:"el-icon-delete"})]),t._v(" "),a("el-button",{staticStyle:{float:"right"},attrs:{type:"primary"},on:{click:t.handleSave}},[t._v("Salvar")])],1)],1)],1)],1)],1),t._v(" "),a("media-manager",{attrs:{visibility:t.showMediaGallery,image:t.formData.image},on:{"update:visibility":function(e){t.showMediaGallery=e},selectImage:t.changeImage}}),t._v(" "),a("el-dialog",{attrs:{visible:t.showDeleteDialog,title:"Confirmação",center:""},on:{"update:visible":function(e){t.showDeleteDialog=e}}},[a("span",[t._v("\n      Tem certeza que deseja deletar o Usuário:\n      "),a("b",[t._v(t._s(t.formData.name))])]),t._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{attrs:{type:"danger"},on:{click:function(e){e.preventDefault(),t.showDeleteDialog=!1}}},[t._v("Cancelar")]),t._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(e){return e.preventDefault(),t.handleDestroy(e)}}},[t._v("Confirmar")])],1)]),t._v(" "),a("el-dialog",{attrs:{visible:t.showSettingsDialog,title:"Opções"},on:{"update:visible":function(e){t.showSettingsDialog=e}}},[a("span",[t._v("Deseja resetar a senha deste usuário?")])])],1)},[],!1,null,null,null);u.options.__file="editor.vue";e.default=u.exports},CDg9:function(t,e,a){"use strict";var i=a("N4yj");a.n(i).a},EBDN:function(t,e,a){"use strict";var i=a("zM5g");a.n(i).a},Hvaj:function(t,e,a){"use strict";var i=a("rfXi"),s=a.n(i),n=a("m1cH"),o=a.n(n),l=a("QbLZ"),r=a.n(l),c=a("P2sY"),m=a.n(c),u=a("L2JU"),d=a("7Qib"),p={name:"MediaManager",props:{visibility:{required:!0,default:!1,type:Boolean},image:{type:null|Object,default:null,required:!0}},data:function(){return{opened:!1,activeTab:"gallery",uploadError:null,uploadFieldName:"images",uploadCount:0,isUploading:!1,activeImage:this.image?m()({},this.image):{}}},computed:r()({},Object(u.b)({images:"images"}),{fileList:function(){return[].concat(o()(this.images.data))},hasActiveImage:function(){return this.activeImage&&this.activeImage.id}}),watch:{visibility:function(t){t?(this.opened=!0,this.$emit("update:visibility",!0)):(this.opened=!1,this.$emit("update:visibility",!1))},opened:function(t){t?this.$emit("update:visibility",!0):this.$emit("update:visibility",!1)}},created:function(){this.getImages()},mounted:function(){this.reset()},methods:{getImages:function(){return this.$store.dispatch("getImages")},reset:function(){this.uploadError=null},save:function(t){var e=this;this.isUploading=!0,this.activeTab="gallery",this.$store.dispatch("uploadImages",t).then(function(t){e.uploadCount=0,e.isUploading=!1}).catch(function(t){e.uploadCount=0,e.isUploading=!1,e.uploadError=t.response})},filesChange:function(t,e){var a=new FormData;e.length&&(s()(Array(e.length).keys()).map(function(i){a.append(t,e[i],e[i].name)}),this.uploadCount=e.length,this.save(a))},isActive:function(t){return this.activeImage&&this.activeImage.id===t?"active":""},setActiveImage:function(t){this.activeImage&&this.activeImage.id===t.id?this.activeImage={}:this.activeImage=t},formatSize:function(t){return Object(d.b)(t)},use:function(){this.$store.dispatch("updateImage",this.activeImage),this.opened=!1,this.$emit("selectImage",this.activeImage)},destroyImage:function(){var t=this;this.$store.dispatch("destroyImage",this.activeImage.id).then(function(){t.$message({message:"Deletado com sucesso!",type:"warning",showClose:!0,duration:1e3}),t.activeImage={}})}}},v=(a("PGqW"),a("EBDN"),a("KHd+")),g=Object(v.a)(p,function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("div",[a("el-dialog",{attrs:{visible:t.opened,fullscreen:"",title:"Gerenciador de Mídias"},on:{"update:visible":function(e){t.opened=e}}},[a("el-row",{staticStyle:{"margin-top":"-30px"}},[a("el-col",{attrs:{span:t.hasActiveImage?19:24}},[a("el-tabs",{model:{value:t.activeTab,callback:function(e){t.activeTab=e},expression:"activeTab"}},[a("el-tab-pane",{attrs:{label:"Galeria",name:"gallery"}},[a("el-row",[a("section",{},[a("el-col",[a("div",[a("ul",{staticClass:"gallery-elements"},[t._l(t.uploadCount,function(e){return a("li",{directives:[{name:"show",rawName:"v-show",value:t.isUploading,expression:"isUploading"}],key:"loading_"+e,staticClass:"gallery-element"},[a("div",{staticClass:"element-content"},[a("div",{staticClass:"spinner"},[a("div",{staticClass:"animation"},[a("div",{staticClass:"circle one"})]),t._v(" "),a("div",{staticClass:"animation"},[a("div",{staticClass:"circle two"})]),t._v(" "),a("div",{staticClass:"animation"},[a("div",{staticClass:"circle three"})]),t._v(" "),a("div",{staticClass:"animation"},[a("div",{staticClass:"circle four"})]),t._v(" "),a("div",{staticClass:"animation"},[a("div",{staticClass:"circle five"})])]),t._v(" "),a("span",[t._v("Loading...")])])])}),t._v(" "),t._l(t.fileList,function(e,i){return a("li",{key:i,class:"gallery-element "+t.isActive(e.id),on:{click:function(a){t.setActiveImage(e)}}},[a("div",{staticClass:"element-content thumbnail"},[a("img",{attrs:{src:e.url,alt:e.title}})])])})],2)])])],1)])],1),t._v(" "),a("el-tab-pane",{attrs:{label:"Upload",name:"upload"}},[a("el-row",[a("form",{staticStyle:{"padding-right":"20px"},attrs:{enctype:"multipart/form-data",novalidate:""}},[a("div",{staticClass:"dropbox"},[a("input",{staticClass:"input-file",attrs:{name:t.uploadFieldName,disabled:t.isUploading,type:"file",multiple:"",accept:"image/*"},on:{change:function(e){t.filesChange(e.target.name,e.target.files),t.fileCount=e.target.files.length}}}),t._v(" "),t.isUploading?t._e():a("p",[t._v("Arraste e solte os arquivos aqui\n                    "),a("br"),t._v("Ou Clique para procurar\n                  ")])])])])],1)],1)],1),t._v(" "),t.hasActiveImage?a("el-col",{attrs:{span:5}},[a("el-card",{staticClass:"box-card-component",staticStyle:{"margin-top":"40px"}},[a("div",{staticClass:"box-card-header",attrs:{slot:"header"},slot:"header"},[a("img",{staticClass:"image",staticStyle:{"margin-left":"auto","margin-right":"auto",width:"100%",height:"100%","max-width":"350px"},attrs:{src:t.activeImage.url}})]),t._v(" "),a("span",[t._v(t._s(t.formatSize(t.activeImage.size)))]),t._v(" "),a("el-row",[a("el-form",{attrs:{"label-position":"left"},model:{value:t.activeImage,callback:function(e){t.activeImage=e},expression:"activeImage"}},[a("el-form-item",{attrs:{label:"Título"}},[a("el-input",{model:{value:t.activeImage.original_name,callback:function(e){t.$set(t.activeImage,"original_name",e)},expression:"activeImage.original_name"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"URL"}},[a("el-input",{attrs:{readonly:""},model:{value:t.activeImage.url,callback:function(e){t.$set(t.activeImage,"url",e)},expression:"activeImage.url"}})],1),t._v(" "),a("el-button",{staticStyle:{width:"60%"},attrs:{type:"primary"},on:{click:function(e){return e.preventDefault(),t.use(e)}}},[t._v("Usar esta")]),t._v(" "),a("el-button",{staticStyle:{width:"25%"},attrs:{type:"danger"},on:{click:function(e){return e.preventDefault(),t.destroyImage(e)}}},[a("i",{staticClass:"el-icon-delete"})])],1)],1)],1)],1):t._e()],1)],1)],1)},[],!1,null,"12479201",null);g.options.__file="index.vue";e.a=g.exports},N4yj:function(t,e,a){},PGqW:function(t,e,a){"use strict";var i=a("yVfq");a.n(i).a},yVfq:function(t,e,a){},zM5g:function(t,e,a){}}]);