芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/nectar.sdektun.com/assets/VForm-C3kZ1XFr.js
import{_ as c,o as d,a as h,f as e,i as u,r as l,b as r,d as p,w as m,e as f,t as b}from"./index-Bl6SGUXe.js";const g={data(){return{loading:!1}},props:{id:{default:!1},action:{type:Object},model:{type:Object}},methods:{save(){this.id?this.update():this.create()},create(){const t=this.$push.promise("Guardando");this.$restapi.post(this.action.create,this.model).then(s=>{t.success("Datos guardados"),this.$router.push(this.route)}).catch(s=>{t.reject("Hubo un error guardando")})},update(){const t=this.$push.promise("Guardando");this.$restapi.patch(this.action.update,this.model).then(s=>{t.success("Datos guardados"),this.$router.push(this.route)}).catch(s=>{t.reject("Hubo un error guardando")})},fill(t){for(var s in t)this.model.hasOwnProperty(s)&&(this.model[s]=t[s])}},mounted(){if(this.id){this.model[this.action.primarykey]=parseInt(this.id);const t=this;this.create=!1,this.loading=!0,this.$restapi.get(this.action.get+"?"+this.action.primarykey+"="+this.id).then(s=>{}).catch(s=>{}).finally(s=>{setTimeout(function(){t.fill(t.mockupdata),t.loading=!1},1e3)})}}},_={class:"form-buttons"},$={class:"btn btn-gradient-primary"};function y(t,s,a,k,v,o){const i=l("router-link");return d(),h("form",{onSubmit:s[0]||(s[0]=u((...n)=>o.save&&o.save(...n),["prevent"]))},[e(t.$slots,"inputs"),e(t.$slots,"buttons",{},()=>[r("div",_,[e(t.$slots,"cancel",{},()=>[p(i,{to:a.action.path,class:"btn btn-light"},{default:m(()=>[f("Cancelar")]),_:1},8,["to"])]),e(t.$slots,"submit",{},()=>[r("button",$,b(a.id?"Actualizar":"Crear"),1)])])])],32)}const j=c(g,[["render",y]]);export{j as V};