forked from Simnation/Main
2 lines
7.6 KiB
JavaScript
2 lines
7.6 KiB
JavaScript
![]() |
import{_ as q,o as p,X as h,a7 as i,a as o,w as n,a6 as V,ab as v,a5 as d,U as c,a9 as m,Y as $,Z as C,W as w}from"./app-014d9ed9.js";import{Q as f}from"./QForm.8d79ab03.js";import{Q as S}from"./QSelect.d7ce3d4c.js";import{Q as U}from"./QTooltip.9d840032.js";import{Q as k}from"./QMarkupTable.ba6854cc.js";import{B as Q}from"./BasicDialog.9dd9de92.js";import"./externalHosting.js";import"./QItemLabel.b6dd3adb.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";import"./rtl.b51694b1.js";const N={name:"VehicleCreate",data(){return{defaults:["name","brand","model","price","category","categorylabel","hash","shop"],pendingSave:!1,vehicle:{name:"",brand:"",model:"",price:0,category:"",categoryLabel:"",hash:"",shop:[]},customVars:[]}},methods:{isNumeric(e){return typeof e!="string"?!1:!isNaN(e)&&!isNaN(parseFloat(e))},isBoolean(e){return e==="true"||(e==="false"?!1:e)},addCustomVar(){this.customVars.push({name:"",value:""})},removeVar(e){const t=this.customVars.indexOf(e);t>-1&&this.$q.dialog({component:Q,componentProps:{title:this.$i18n.t("components.devVehicle.deleteHeader"),message:this.$i18n.t("components.devVehicle.deleteCustomVarMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.customVars.splice(t,1)})},trySave(){this.$refs.vehDefaults.validate().then(e=>{if(!e){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.devVehicle.msg.error.missingFields")});return}this.$refs.customVarForm.validate().then(t=>{if(!t){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.devVehicle.msg.error.uniqueVars")});return}this.customVars.forEach(r=>{!r.name||(this.vehicle[r.name]=this.isNumeric(r.value)?Number(r.value):this.isBoolean(r.value))}),this.pendingSave=!0,this.$axios.post("/api/dev-vehicles/create",this.vehicle).then(r=>{if(this.pendingSave=!1,!r.data.resCode){const s=r.data.resMsg;this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t(`components.devVehicle.msg.error.${s}`,{name:this.vehicle.model})});return}this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.saved")}),this.$router.push({name:"dev-vehicle-list"})}).catch(()=>{})})})}}},B={class:"row"},_={class:"col-12"},L={class:"q-ma-sm row"},F={class:"text-h6"},M={class:"col-12"},D={class:"q-ma-sm row"},x={class:"row"},z={class:"text-h6"},T={class:"text-caption text-sub"},E={class:"q-ml-auto"},O={style:{width:"30px"},class:"text-right vertical-middle"},j={class:"col-12"},H={class:"q-ma-sm row justify-end"};function I(e,t,r,b,s,u){return p(),h("div",B,[i("div",_,[i("div",L,[o(V,{class:"bg-secondary full-width row"},{default:n(()=>[o(d,{class:"col-12"},{default:n(()=>[i("div",F,c(e.$t("components.devVehicleCreate.new"))+": ",1)]),_:1}),o(d,{class:"col-12 col-md-6"},{default:n(()=>[o(f,{ref:"vehDefaults"},{default:n(()=>[o(m,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:s.vehicle.model,"onUpdate:modelValue":t[0]||(t[0]=l=>s.vehicle.model=l),onChange:t[1]||(t[1]=l=>{s.vehicle.model=l.toLowerCase()}),"lazy-rules":"",rules:[l=>l&&l.length>0||e.$t("rules.required"),l=>l&&!/\s/.test(l)||e.$t("rules.noSpace")],label:e.$t("components.devVehicle.model")},null,8,["input-style","modelValue","rules","label"]),o(m,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",disable:"",class:"q-mt-md",modelValue:s.vehicle.model,"onUpdate:modelValue":t[2]||(t[2]=l=>s.vehicle.model=l),label:e.$t("components.devVehicle.hash")},null,8,["input-style","modelValue","label"]),o(m,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",class:"q-mt-md",modelValue:s.vehicle.name,"onUpdate:modelValue":t[3]||(t[3]=l=>s.vehicle.name=l),label:e.$t("components.devVehicle.name")},null,8,["input-style","modelValue","label"]),o(m,{"label-color":"primary","input-st
|