芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal.sdektun.com/assets/form-FvHhup07.js
import{_ as C,c as r,a as o,l as I,j as u,k as S,x as w,F as p,h as f,b as _,w as M,d as m,r as v,o as a,t as k,p as N,m as B}from"./index-C5D-hTCr.js";const V={name:"formPermissions",data(){return{model:{name:"",permissions:"",active:1,trash:0},system_functions:[],checked:[]}},methods:{save(){this.model.permissions=JSON.stringify(this.checked),this.saveModel()},onModelData(e){this.system_functions=e.system_functions,this.setPermissions(e.permissions)},onPermissionChange(e,s,t){e.target.checked?this.addPermission(s,t):this.removePermission(s,t)},addPermission(e,s){let t=this.checked.findIndex(n=>n.controller==e);t!=-1?this.checked[t].actions.push(s):this.checked.push({controller:e,actions:[s]})},removePermission(e,s){let t=this.checked.findIndex(n=>n.controller==e);if(t!=-1){let n=this.checked[t].actions.findIndex(i=>i==s);this.checked[t].actions.splice(n,1)}},isChecked(e,s){let t=this.checked.findIndex(n=>n.controller==e);return t!=-1&&this.checked[t].actions.findIndex(i=>i==s)!=-1},setPermissions(e){this.checked=JSON.parse(e)},serializePermissions(){let e=[];for(var s in this.checked){let n=this.checked[s].controller,i=this.checked[s].actions;for(var t in i)i[t].active&&(e[s]==null&&(e[s]={}),e[s].controller=n,e[s].hasOwnProperty("actions")||(e[s].actions=[]),e[s].actions.push(t))}return e}},mounted(){this.loadModel(),this.$route.params.id==null&&this.$api.get("/profiles/permissions").then(s=>{this.system_functions=s.data})}},d=e=>(N("data-v-a993b099"),e=e(),B(),e),D={class:"card"},O={class:"card-body"},q=d(()=>o("p",{class:"card-description"}," Datos del perfil ",-1)),F={class:"form-group row"},J=d(()=>o("label",{class:"col-sm-3 col-form-label"},"Nombre del perfil",-1)),T={class:"col-sm-9"},U={class:"form-group row"},j=d(()=>o("label",{class:"col-sm-3 col-form-label"},"Activo",-1)),z={class:"col-sm-9"},A={class:"form-group"},E=d(()=>o("label",{class:"col-form-label"},"Permisos",-1)),L={class:"block-permissions",id:"block-permissions"},G={class:"permission-group"},H=["onChange","checked"],K={class:"form-actions"};function Q(e,s,t,n,i,l){const b=v("router-link"),x=v("SubmitButton");return a(),r("div",D,[o("div",O,[o("form",{class:"form-sample",onSubmit:s[2]||(s[2]=I((...c)=>l.save&&l.save(...c),["prevent"]))},[q,o("div",F,[J,o("div",T,[u(o("input",{type:"text","onUpdate:modelValue":s[0]||(s[0]=c=>i.model.name=c),required:"",class:"form-control"},null,512),[[S,i.model.name]])])]),o("div",U,[j,o("div",z,[u(o("input",{type:"checkbox","onUpdate:modelValue":s[1]||(s[1]=c=>i.model.active=c),value:"1","true-value":"1","false-value":"0",required:""},null,512),[[w,i.model.active]])])]),o("div",A,[E,o("div",L,[(a(!0),r(p,null,f(i.system_functions,(c,g)=>(a(),r("div",{class:"block-group",key:g},[o("label",null,k(c.label),1),o("div",G,[(a(!0),r(p,null,f(c.actions,(y,h)=>(a(),r("label",{key:h},[o("input",{onChange:P=>l.onPermissionChange(P,c.controller,h),checked:l.isChecked(c.controller,h),type:"checkbox"},null,40,H),m(" "+k(y)+" ",1)]))),128))])]))),128))])]),o("div",K,[_(b,{to:e.autolink(),class:"btn btn-danger btn-icon-text"},{default:M(()=>[m("Cancelar")]),_:1},8,["to"]),m(" "),_(x)])],32)])])}const W=C(V,[["render",Q],["__scopeId","data-v-a993b099"]]);export{W as default};