Main/resources/[tools]/unlimited-spectre/html/assets/Vehicle.2c374c7e.js

2 lines
18 KiB
JavaScript
Raw Normal View History

2025-06-07 08:51:21 +02:00
import{_ as k,P as V,R as A,o as r,X as c,a7 as t,a as i,w as m,a6 as f,ab as d,a5 as v,c as g,V as y,U as o,Y as p,a9 as u}from"./app-014d9ed9.js";import{Q as E}from"./QMarkupTable.ba6854cc.js";import{Q as M}from"./QForm.8d79ab03.js";import{d as O}from"./utils.9ce591f3.js";import{B as C}from"./BasicDialog.9dd9de92.js";import{B as q}from"./BasicInput.94e22095.js";import"./externalHosting.js";const x={name:"Vehicle",data(){return{ACTION:V,RESOURCE:A,vehicle:{},oldPlate:null}},methods:{can:O,async loadVehicle(){await this.$axios.get(`/api/vehicles/${this.$route.params.vehicleId}`).then(l=>{const s=l.data.vehicle;if(!l.data.resCode){this.$q.notify({message:"Error",position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.vehicle.msg.error.noMatch")}),this.$router.push({name:"game-vehicle-list"});return}this.vehicle=s,this.oldPlate=s.plate})},updatePlate(){this.$refs.plate.validate().then(l=>{if(!l){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.gang.msg.error.allowedCharsNumbers")});return}this.$axios.post("/api/vehicles/changePlate",{id:this.vehicle.id,plate:this.oldPlate,newPlate:this.vehicle.plate}).then(s=>{if(!s.data.resCode){const b=s.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.${b}`)});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.loadVehicle()}).catch(s=>{})})},updateField(l){this.$axios.post("/api/vehicles/updateField",{id:this.vehicle.id,value:this.vehicle[l],field:l,plate:this.vehicle.plate}).then(s=>{if(!s.data.resCode){const b=s.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.${b}`)});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.loadVehicle()}).catch(s=>{})},changeOwner(){this.$q.dialog({component:q,componentProps:{title:this.$i18n.t("components.vehicle.changeOwnerHeader"),message:this.$i18n.t("components.vehicle.changeOwnerInput")},cancel:!0,persistent:!0}).onOk(l=>{const s=l.input;if(!s){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.missingData")});return}this.$axios.post("/api/vehicles/changeOwner",{id:this.vehicle.id,citizenid:s}).then(h=>{if(!h.data.resCode){const e=h.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.${e}`)});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.loadVehicle()}).catch(h=>{})})},repairVehicle(){this.$axios.post("/api/vehicles/repair",{id:this.vehicle.id,plate:this.vehicle.plate}).then(l=>{if(!l.data.resCode){const h=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.${h}`)});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.loadVehicle()}).catch(l=>{})},despawnehicle(){this.$q.dialog({component:C,componentProps:{title:this.$i18n.t("components.vehicle.despawnHeader"),message:this.$i18n.t("components.vehicle.despawnMsg")},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.post("/api/vehicles/despawn",{id:this.vehicle.id,plate:this.vehicle.plate}).then(l=>{if(!l.data.resCode){const h=l.data.resMsg;this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fa