(window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-2d216f74"],{c55a:function(t,e,s){"use strict";s.r(e);var i={name:"TablaSuscripciones",props:{selected_filters:{type:Object,default:{},required:!0},show_buscador:{type:Boolean,default:!1},is_venta:{type:Boolean,default:!1}},data:()=>({tabla:{suscripciones:[],count:0,headers:[],filtros:{},options:{itemsPerPage:localStorage.getItem("itemsPerPage")?parseInt(localStorage.getItem("itemsPerPage")):10}}}),methods:{async get_suscripciones(t=null){t&&(this.tabla.filtros.search=t);let e={...this.tabla.filtros,...this.selected_filters};const s=await this.$store.dispatch("suscripcion/get_suscripciones",{params:e});this.tabla.suscripciones=s.results,this.tabla.count=s.count},async change_active(t){try{await this.$store.dispatch("suscripcion/save",{id:t.id,is_active:t.is_active}),this.$snotify.success(this.$t("Acción realizada con éxito"),this.$t("Atención {0}",[this.$store.getters["auth/user"].first_name])),await this.get_suscripciones()}catch(t){this.$snotify.error(this.$t("Ha ocurrido un error"),this.$t("Atención {0}",[this.$store.getters["auth/user"].first_name]))}}},watch:{"tabla.options":{handler(t,e){if(t.itemsPerPage!==e.itemsPerPage)try{localStorage.setItem("itemsPerPage",t.itemsPerPage)}catch(t){}if(this.tabla.filtros.limit=t.itemsPerPage,this.tabla.filtros.offset=(t.page-1)*t.itemsPerPage,t.sortBy.length){let e=!0===t.sortDesc[0]?"-":"";this.tabla.filtros.ordering=`${e}${t.sortBy[0].split(".").join("__")}`}this.get_suscripciones()}}},computed:{is_editable(){return!this.is_venta}},mounted(){this.tabla.headers=[{text:this.$t("Nombre"),value:"nombre",class:"primary white--text"},{text:this.$t("Precio"),value:"precio",class:"primary white--text"},{text:this.$t("Tipo"),value:"tipo",class:"primary white--text"},{text:this.$t("Descripción"),value:"descripcion",class:"primary white--text"},{text:this.$t("Activo"),value:"is_active",class:"primary white--text"},{text:"",value:"actions",class:"primary white--text",sortable:!1,align:"right",width:"10px"}],this.is_editable||(this.tabla.headers.pop(),this.tabla.headers.pop())}},a=s("2877"),r=s("6544"),o=s.n(r),c=s("8336"),n=s("8fea"),l=s("132d"),h=s("b73d"),u=Object(a.a)(i,(function(){var t=this,e=t.$createElement,s=t._self._c||e;return s("div",[t.show_buscador?s("Buscador",{on:{search:function(e){t.tabla.filtros.offset=0,t.tabla.options.page=1,t.get_suscripciones(e)}}}):t._e(),s("v-data-table",{staticClass:"elevation-3",attrs:{headers:t.tabla.headers,items:t.tabla.suscripciones,options:t.tabla.options,"server-items-length":t.tabla.count,"fixed-header":!0,"calculate-widths":"","footer-props":{itemsPerPageOptions:[5,10,20,50],itemsPerPageText:t.$t("Registros por página")},"no-data-text":t.$t("No hay datos"),"no-results-text":t.$t("No hay datos")},on:{"update:options":function(e){return t.$set(t.tabla,"options",e)}},scopedSlots:t._u([{key:"item",fn:function(e){var i=e.item;return[s("tr",{on:{click:function(e){return t.$emit("on_click_selected",i)}}},[s("td",[t._v(t._s(i.nombre))]),s("td",[t._v(t._s(t._f("money")(i.precio)))]),s("td",[t._v(t._s(i.tipo))]),s("td",[t._v(t._s(i.descripcion))]),t.is_editable?s("td",[s("v-switch",{attrs:{dense:""},on:{change:function(e){return t.change_active(i)}},model:{value:i.is_active,callback:function(e){t.$set(i,"is_active",e)},expression:"item.is_active"}})],1):t._e(),t.is_editable?s("td",[s("v-btn",{attrs:{icon:"",color:"primary",title:t.$t("Editar")},on:{click:function(e){return t.$emit("on_click_edit",i)}}},[s("v-icon",[t._v("mdi-pencil ")])],1)],1):t._e()])]}}])})],1)}),[],!1,null,null,null);e.default=u.exports,o()(u,{VBtn:c.a,VDataTable:n.a,VIcon:l.a,VSwitch:h.a})}}]);