芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal.sdektun.com/assets/form-XBo-5UOF.js
import{W as b}from"./vuejs3-datepicker-C6wjEZix.js";import{_ as y,o as d,c as n,a as e,l as w,i as m,g as _,b as r,F as C,h as k,d as h,t as v,w as D,r as V,p as U,m as S,e as I}from"./index-C5D-hTCr.js";const F={components:{DatePicker:b},name:"customerForm",data(){return{payment:{validity_start_date:new Date},payment_methods:[{id:"cash",name:"Efectivo"},{id:"transfer",name:"Depósito/Transferencia"}],customerlicense:{},searching:!1,hascustomer:!1,suggestions:[]}},props:{licenses:{type:Array,default:[]},modelValue:{type:Object,default:{}},autosearch:{type:Boolean,default:!1},errors:{type:Object,default:{}}},methods:{createCustomer(){let o=this.$push.promise("Guardando usuario");this.$api.post("/customers/createcustomer",{customer:this.modelValue,customerlicense:this.customerlicense,payment:this.payment}).then(s=>{o.resolve(s.data.message),this.$router.push("/customers")}).catch(s=>{o.reject(s.response.data.message)})},fill(o){this.hascustomer=!0,this.$emit("autosearch",this.suggestions[o]),this.suggestions=[]},updateValidityEndDate(){let o=this.licenses.find(s=>s.id==this.customerlicense.license_id);if(o){const s=this.payment.validity_start_date,t=new Date;t.setFullYear(s.getFullYear()),t.setDate(s.getDate()),t.setHours(s.getHours()),t.setMinutes(s.getMinutes()),t.setSeconds(s.getSeconds()),t.setMonth(s.getMonth()+parseInt(o.month_duration)),this.payment.validity_end_date=t}},onLicenseChange(o){let s=this.licenses.find(t=>t.id==o);this.payment.amount=s.price,this.customerlicense.price=s.price,this.updateValidityEndDate()},onNameInput(o){!this.searching&&o.length>=3&&this.autosearch&&(this.searching=!0,this.$api.get("/customers?filter[name][like]="+o).then(s=>{this.suggestions=s.data}).catch(s=>{}).finally(()=>{this.searching=!1}))},removecustomer(){this.hascustomer=!1,this.$emit("autosearch",{})}},mounted(){this.modelValue.password=""},watch:{"payment.validity_start_date":{handler:function(){this.updateValidityEndDate()},deep:!0}}},a=o=>(U("data-v-00f50542"),o=o(),S(),o),N={class:"card"},M={class:"card-body"},B=a(()=>e("p",{class:"card-description"}," Datos del cliente ",-1)),E={class:"row"},x={class:"col-md-6"},j={class:"form-group row"},L=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Nombre",-1)),W={class:"col-sm-9 col-relative"},A={key:0,class:"spinner"},H=a(()=>e("i",{class:"mdi mdi-close-circle-outline"},null,-1)),O=[H],T={key:2,class:"user-suggestions"},Y=["onClick"],q=a(()=>e("img",{width:"25px",src:I},null,-1)),z=a(()=>e("br",null,null,-1)),G={class:"form-group row"},P=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Correo",-1)),J={class:"col-sm-9"},K={class:"form-group row"},Q=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Whatsapp",-1)),R={class:"col-sm-9"},X={class:"col-md-6"},Z={class:"form-group row"},$=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Dirección",-1)),ee={class:"col-sm-9"},se={class:"form-group"},te={class:"form-group"},oe=a(()=>e("div",{class:"row"},[e("div",{class:"col-md-7"}),e("div",{class:"col-md-5"})],-1)),le={class:"row"},ae={class:"col-sm-5"},re={class:"col-sm-7"},ie=a(()=>e("br",null,null,-1)),de=a(()=>e("br",null,null,-1)),ne=a(()=>e("p",{class:"card-description"},"Crea una cuenta",-1)),me={class:"row"},ce={class:"col-md-6"},ue={class:"form-group row"},he=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Usuario",-1)),_e={class:"col-sm-9"},Ve={class:"col-md-6"},ve={class:"form-group row"},fe=a(()=>e("label",{class:"col-sm-3 col-form-label"},"Contraseña",-1)),ge={class:"col-sm-9"},pe={class:"form-group"},be={class:"form-actions"};function ye(o,s,t,we,c,u){const i=V("FormControl"),f=V("router-link"),g=V("SubmitButton");return d(),n("div",N,[e("div",M,[e("form",{class:"form-sample",onSubmit:s[11]||(s[11]=w((...l)=>o.saveModel&&o.saveModel(...l),["prevent"]))},[m(o.$slots,"title",{},()=>[B],!0),e("div",E,[e("div",x,[e("div",j,[L,e("div",W,[this.searching?(d(),n("i",A)):_("",!0),c.hascustomer?(d(),n("a",{key:1,class:"customer-remover",onClick:s[0]||(s[0]=(...l)=>u.removecustomer&&u.removecustomer(...l))},O)):_("",!0),r(i,{type:"text",modelValue:t.modelValue.name,"onUpdate:modelValue":s[1]||(s[1]=l=>t.modelValue.name=l),error:t.errors.name,onInput:u.onNameInput,disabled:c.hascustomer,required:!0},null,8,["modelValue","error","onInput","disabled"]),c.suggestions.length>0?(d(),n("div",T,[(d(!0),n(C,null,k(c.suggestions,(l,p)=>(d(),n("div",{class:"user-suggestion",onClick:Ce=>u.fill(p)},[q,h(" "+v(l.name)+" ",1),z,e("small",null,v(l.address),1)],8,Y))),256))])):_("",!0)])]),e("div",G,[P,e("div",J,[r(i,{type:"email",modelValue:t.modelValue.email,"onUpdate:modelValue":s[2]||(s[2]=l=>t.modelValue.email=l),error:t.errors.email},null,8,["modelValue","error"])])]),e("div",K,[Q,e("div",R,[r(i,{type:"tel",modelValue:t.modelValue.mobile,"onUpdate:modelValue":s[3]||(s[3]=l=>t.modelValue.mobile=l),error:t.errors.mobile,placeholder:"-"},null,8,["modelValue","error"])])])]),e("div",X,[e("div",Z,[$,e("div",ee,[e("div",se,[r(i,{type:"text",error:t.errors.location,placeholder:"Localidad",modelValue:t.modelValue.location,"onUpdate:modelValue":s[4]||(s[4]=l=>t.modelValue.location=l)},null,8,["error","modelValue"])]),e("div",te,[r(i,{type:"text",error:t.errors.street,placeholder:"Calle",modelValue:t.modelValue.street,"onUpdate:modelValue":s[5]||(s[5]=l=>t.modelValue.street=l)},null,8,["error","modelValue"])]),oe,e("div",le,[e("div",ae,[r(i,{type:"text",placeholder:"Número",error:t.errors.number,modelValue:t.modelValue.number,"onUpdate:modelValue":s[6]||(s[6]=l=>t.modelValue.number=l)},null,8,["error","modelValue"])]),e("div",re,[r(i,{type:"text",placeholder:"Cruzamiento(s)",error:t.errors.intersection,modelValue:t.modelValue.intersection,"onUpdate:modelValue":s[7]||(s[7]=l=>t.modelValue.intersection=l)},null,8,["error","modelValue"])])])])])])]),m(o.$slots,"account",{model:t.modelValue},()=>[ie,de,ne,e("div",me,[e("div",ce,[e("div",ue,[he,e("div",_e,[r(i,{type:"text",modelValue:t.modelValue.username,"onUpdate:modelValue":s[8]||(s[8]=l=>t.modelValue.username=l),error:t.errors.username},null,8,["modelValue","error"])])])]),e("div",Ve,[e("div",ve,[fe,e("div",ge,[r(i,{type:"password",modelValue:t.modelValue.password,"onUpdate:modelValue":s[9]||(s[9]=l=>t.modelValue.password=l),error:t.errors.password},null,8,["modelValue","error"])])])])])],!0),m(o.$slots,"active",{},()=>[e("div",pe,[e("label",null,[h("Activo "),r(i,{type:"switch",modelValue:t.modelValue.active,"onUpdate:modelValue":s[10]||(s[10]=l=>t.modelValue.active=l)},null,8,["modelValue"])])])],!0),m(o.$slots,"options",{},()=>[e("div",be,[m(o.$slots,"cancel",{},()=>[r(f,{to:o.autolink(),class:"btn btn-danger btn-icon-text"},{default:D(()=>[h("Cancelar")]),_:1},8,["to"])],!0),h(" "),m(o.$slots,"submit",{},()=>[r(g)],!0)])],!0)],32)])])}const Ue=y(F,[["render",ye],["__scopeId","data-v-00f50542"]]);export{Ue as C};