forked from Simnation/Main
1 line
3.2 KiB
JavaScript
1 line
3.2 KiB
JavaScript
import{_ as u,o as p,X as h,a7 as a,a as i,w as o,a6 as v,ab as f,a5 as r,U as g,a9 as n}from"./app-014d9ed9.js";import{Q as y}from"./QForm.8d79ab03.js";import"./externalHosting.js";const b={name:"VehicleCreate",data(){return{pendingSave:!1,citizenid:null,vehicle:{}}},methods:{tryCreateVehicle(){this.$refs.vehicleCreate.validate().then(t=>{!t||(this.pendingSave=!0,this.$axios.post("/api/vehicles/create",{citizenid:this.citizenid,vehicle:this.vehicle}).then(l=>{if(this.pendingSave=!1,!l.data.resCode){const c=l.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.vehicle.msg.error.${c}`)});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:"game-vehicle-list"})}).catch(l=>{}))})}},mounted(){this.citizenid=this.$route.query.citizenid||""}},V={class:"row"},C={class:"col-12"},q={class:"q-ma-sm row"},$={class:"text-h6"},z={class:"col-12"},w={class:"q-ma-sm row justify-end"};function _(t,l,d,c,s,m){return p(),h("div",V,[a("div",C,[a("div",q,[i(v,{class:"bg-secondary full-width row"},{default:o(()=>[i(r,{class:"col-12"},{default:o(()=>[a("div",$,g(t.$t("components.vehicleCreate.new"))+":",1)]),_:1}),i(r,{class:"col-12 col-md-6"},{default:o(()=>[i(y,{ref:"vehicleCreate"},{default:o(()=>[i(n,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:s.citizenid,"onUpdate:modelValue":l[0]||(l[0]=e=>s.citizenid=e),label:t.$t("components.vehicle.labels.citizenid")},null,8,["input-style","modelValue","label"]),i(n,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",class:"q-mt-md",modelValue:s.vehicle.model,"onUpdate:modelValue":l[1]||(l[1]=e=>s.vehicle.model=e),label:t.$t("components.vehicle.labels.model"),"lazy-rules":"",rules:[e=>e&&e.length>0||t.$t("rules.required")]},null,8,["input-style","modelValue","label","rules"]),i(n,{class:"q-mt-md",dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",maxlength:"8",modelValue:s.vehicle.plate,"onUpdate:modelValue":l[2]||(l[2]=e=>s.vehicle.plate=e),label:t.$t("components.vehicle.labels.plate"),"lazy-rules":"",rules:[e=>e&&/^[a-zA-Z0-9 ]+$/.test(e)||t.$t("rules.onlyCharsNumbers")]},null,8,["input-style","modelValue","label","rules"])]),_:1},512)]),_:1}),i(r,{class:"col-12 col-md-6"},{default:o(()=>[i(n,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:s.vehicle.garage,"onUpdate:modelValue":l[3]||(l[3]=e=>s.vehicle.garage=e),label:t.$t("components.vehicle.labels.garage")},null,8,["input-style","modelValue","label"]),i(n,{"label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",class:"q-mt-md",type:"number",modelValue:s.vehicle.state,"onUpdate:modelValue":l[4]||(l[4]=e=>s.vehicle.state=e),modelModifiers:{number:!0},label:t.$t("components.vehicle.labels.state")},null,8,["input-style","modelValue","label"])]),_:1})]),_:1})])]),a("div",z,[a("div",w,[i(f,{"text-color":"main",loading:s.pendingSave,color:"primary",onClick:m.tryCreateVehicle,label:t.$t("general.create"),class:"q-mr-sm"},null,8,["loading","onClick","label"])])])])}const k=u(b,[["render",_]]);export{k as default};
|