芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/xmintal.sdektun.com/assets/create-B-Snee0s.js
import{W as y}from"./vuejs3-datepicker-C6wjEZix.js";import{C as v}from"./form-XBo-5UOF.js";import{_ as V,c as b,a as t,l as C,b as i,w as u,f as D,g as w,d,r as c,o as h,p as k,m as x}from"./index-C5D-hTCr.js";const S={components:{DatePicker:y,CustomerForm:v},name:"customerForm",data(){return{payment:{validity_start_date:new Date},payment_methods:[{id:"cash",name:"Efectivo"},{id:"transfer",name:"Depósito/Transferencia"}],customerlicense:{},customer:{active:1,trash:0},searching:!1,hascustomer:!1,suggestions:[],licenses:[]}},props:{modelValue:{type:Object,default:{}},autosearch:{type:Boolean,default:!1},errors:{type:Object,default:{}}},methods:{onSearchResult(s){this.customer=s,this.customer.password=""},createCustomer(){let s=this.$push.promise("Guardando usuario");this.$api.post("/customerlicenses/createlicense",{customer:this.customer,customerlicense:this.customerlicense,payment:this.payment}).then(e=>{s.resolve(e.data.message),this.$router.push("/customerlicenses")}).catch(e=>{s.reject({message:e.response.data.message,duration:3e4})})},fill(s){this.hascustomer=!0,this.$emit("autosearch",this.suggestions[s]),this.suggestions=[]},updateValidityEndDate(){let s=this.licenses.find(e=>e.id==this.customerlicense.license_id);if(s){const e=this.payment.validity_start_date,r=new Date;r.setFullYear(e.getFullYear()),r.setDate(e.getDate()),r.setHours(e.getHours()),r.setMinutes(e.getMinutes()),r.setSeconds(e.getSeconds()),r.setMonth(e.getMonth()+parseInt(s.month_duration)),this.payment.validity_end_date=r}},onLicenseChange(s){let e=this.licenses.find(r=>r.id==s);this.payment.amount=e.price,this.customerlicense.price=e.price,this.updateValidityEndDate()},onNameInput(s){!this.searching&&s.length>=3&&this.autosearch&&(this.searching=!0,this.$api.get("/customers?filter[name][like]="+s).then(e=>{this.suggestions=e.data}).catch(e=>{}).finally(()=>{this.searching=!1}))},removecustomer(){this.hascustomer=!1,this.$emit("autosearch",{})}},mounted(){this.$route.params.id==null&&this.$allow("licenses.index")&&this.$api.get("/licenses").then(s=>{this.licenses=s.data})},watch:{"payment.validity_start_date":{handler:function(){this.updateValidityEndDate()},deep:!0}}},n=s=>(k("data-v-a299d2c7"),s=s(),x(),s),F={class:"card"},U={class:"card-body"},B=n(()=>t("h4",{class:"card-title page-title"},[t("span",{class:"page-title-icon bg-gradient-primary text-white me-2"},[t("i",{class:"mdi mdi-account-key"})]),d(" Registrar una licencia")],-1)),I=n(()=>t("p",{class:"card-description"}," Datos del cliente ",-1)),M=n(()=>t("p",{class:"card-description"},"Datos de la licencia",-1)),E={class:"row"},N={class:"col-md-6"},q={class:"form-group row"},P=n(()=>t("label",{class:"col-form-label"},"Elige una licencia",-1)),R={class:"col-md-6"},j={class:"form-group"},A=n(()=>t("label",{class:"col-form-label"},"Dirección MAC",-1)),T={class:"row"},H={class:"col-md-3"},L={class:"form-group"},O=n(()=>t("label",{class:"col-form-label"},"Precio",-1)),W={class:"col-md-3"},Y={class:"form-group"},G=n(()=>t("label",{class:"col-form-label"},"Medio de pago",-1)),z={class:"col-md-3"},J={class:"form-group"},K=n(()=>t("label",{class:"col-form-label"},"Inicia vigencia",-1)),Q={class:"col-md-3"},X={class:"form-group"},Z=n(()=>t("label",{class:"col-form-label"},"Termina vigencia",-1)),$={class:"form-actions"};function ee(s,e,r,te,o,m){const _=c("CustomerForm"),l=c("FormControl"),p=c("DatePicker"),f=c("router-link"),g=c("SubmitButton");return h(),b("div",F,[t("div",U,[B,t("form",{class:"form-sample",onSubmit:e[8]||(e[8]=C((...a)=>m.createCustomer&&m.createCustomer(...a),["prevent"]))},[I,i(_,{modelValue:o.customer,"onUpdate:modelValue":e[0]||(e[0]=a=>o.customer=a),autosearch:!0,onAutosearch:m.onSearchResult},{options:u(()=>[d(" ")]),active:u(()=>[d(" ")]),_:1},8,["modelValue","onAutosearch"]),M,t("div",E,[t("div",N,[t("div",q,[P,i(l,{type:"select",modelValue:o.customerlicense.license_id,"onUpdate:modelValue":e[1]||(e[1]=a=>o.customerlicense.license_id=a),onChange:m.onLicenseChange,error:r.errors.license_id,options:o.licenses,required:!0},null,8,["modelValue","onChange","error","options"])])]),t("div",R,[t("div",j,[A,i(l,{type:"text",modelValue:o.customerlicense.mac_address,"onUpdate:modelValue":e[2]||(e[2]=a=>o.customerlicense.mac_address=a),error:r.errors.mac_address,required:!0},null,8,["modelValue","error"])])])]),t("div",T,[t("div",H,[t("div",L,[O,i(l,{type:"text",modelValue:o.customerlicense.price,"onUpdate:modelValue":e[3]||(e[3]=a=>o.customerlicense.price=a),error:r.errors.price,disabled:!0,required:!0},null,8,["modelValue","error"])])]),t("div",W,[t("div",Y,[G,i(l,{type:"select",modelValue:o.payment.payment_method,"onUpdate:modelValue":e[4]||(e[4]=a=>o.payment.payment_method=a),error:r.errors.payment_method,options:o.payment_methods,required:!0},null,8,["modelValue","error","options"]),o.payment.payment_method=="transfer"?(h(),D(l,{key:0,type:"text",placeholder:"Referencia",modelValue:o.payment.payment_reference,"onUpdate:modelValue":e[5]||(e[5]=a=>o.payment.payment_reference=a)},null,8,["modelValue"])):w("",!0)])]),t("div",z,[t("div",J,[K,i(p,{modelValue:o.payment.validity_start_date,"onUpdate:modelValue":e[6]||(e[6]=a=>o.payment.validity_start_date=a),"calendar-class":"calendar-top-right",language:"es"},null,8,["modelValue"])])]),t("div",Q,[t("div",X,[Z,i(p,{modelValue:o.payment.validity_end_date,"onUpdate:modelValue":e[7]||(e[7]=a=>o.payment.validity_end_date=a),disabled:!0,"calendar-class":"calendar-top-right",language:"es"},null,8,["modelValue"])])])]),t("div",$,[i(f,{to:s.autolink(),class:"btn btn-danger btn-icon-text"},{default:u(()=>[d("Cancelar")]),_:1},8,["to"]),d(" "),i(g)])],32)])])}const re=V(S,[["render",ee],["__scopeId","data-v-a299d2c7"]]);export{re as default};