芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal.sdektun.com/assets/InteracTable-QPmpzMbW.js
import{_ as y,S as w,o as a,c as r,a as s,i as u,g as c,b,F as p,h as _,s as d,f as C,w as v,t as I,u as N,r as g}from"./index-C5D-hTCr.js";const S={name:"InteracTable",components:{Skeleton:w},props:{route:{type:String,required:!0},rows:{type:Array,default:[]},itemsperpage:{type:Number,default:10}},methods:{onModelDelete(e){this.$emit("deleted",e)},loadItems(e){let i=e||1;this.isloading=!0,this.$api.get(this.makeRoute(i)).then(t=>{this.totalpages=parseInt(t.headers.get("x-pagination-page-count")),this.isloading=!1,this.items=t.data}).catch(t=>{this.$push.error(t.response.data.error)})},generatePermissionName(){let e=this.$route.matched[0].path;return this.$route.matched[0].aliasOf&&(e=this.$route.matched[0].aliasOf.path),e=e.replace("/",""),e=e.split("?"),e=e[0],e},allow(e){const i=this.generatePermissionName();let t=[];const h=e.split(",");for(var l in h)t.push(i+"."+h[l]);return t=t.join(","),this.$allow(t)},allowUpdate(){const e=this.generatePermissionName();return this.$allow(e+".update")},paginate(e){this.currentpage=e,this.loadItems(e)},isActive(e){return e==this.currentpage?"active":""},makeRoute(e){let i=this.route&&this.route.indexOf("?")!=-1?"&":"?";return this.route+i+"per-page="+this.itemsperpage+"&page="+e}},data(){return{isloading:!0,items:[],totalpages:1,currentpage:1}},mounted(){this.loadItems()},watch:{rows:{handler:function(e){this.items=e}}}},$={class:"table"},A=s("th",null,[s("input",{type:"checkbox"})],-1),B={key:0},P={key:0},O={colspan:"10"},V=s("input",{type:"checkbox"},null,-1),q={key:0},D=s("i",{class:"mdi mdi-square-edit-outline"},null,-1),F=["onClick"],M=s("i",{class:"mdi mdi-delete-outline"},null,-1),R=[M],T={key:0,class:"pagination"},j=["onClick"];function z(e,i,t,h,l,n){const k=g("skeleton"),f=g("router-link");return a(),r(p,null,[s("table",$,[s("thead",null,[s("tr",null,[A,u(e.$slots,"headers"),n.allow("update,delete")?(a(),r("th",B,"Acciones")):c("",!0)])]),s("tbody",null,[l.isloading?(a(),r("tr",P,[s("td",O,[b(k,{rows:t.itemsperpage,cols:3},null,8,["rows"])])])):(a(!0),r(p,{key:1},_(l.items,(o,m)=>(a(),r("tr",{key:m},[s("td",null,[u(e.$slots,"checkbox",d({ref_for:!0},{item:o,items:l.items}),()=>[V])]),u(e.$slots,"row",d({ref_for:!0},o)),n.allow("update,delete")?(a(),r("td",q,[u(e.$slots,"update",d({ref_for:!0},o),()=>[n.allow("update")?(a(),C(f,{key:0,class:"action-link",to:e.autolink("/update/"+o.id)},{default:v(()=>[D]),_:2},1032,["to"])):c("",!0)]),u(e.$slots,"delete",d({ref_for:!0},{item:o,items:l.items}),()=>[n.allow("delete")?(a(),r("a",{key:0,class:"action-link",onClick:E=>e.deleteModel(o.id,t.route)},R,8,F)):c("",!0)])])):c("",!0)]))),128))])]),l.totalpages>1?(a(),r("ul",T,[(a(!0),r(p,null,_(l.totalpages,o=>(a(),r("li",{key:o,class:"page-item"},[s("a",{class:N(n.isActive(o)),onClick:m=>n.paginate(o)},I(o),11,j)]))),128))])):c("",!0)],64)}const U=y(S,[["render",z]]);export{U as I};