forked from Simnation/Main
1 line
18 KiB
JavaScript
1 line
18 KiB
JavaScript
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:"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.deleted")})}).catch(l=>{})})},deleteVehicle(){this.$q.dialog({component:C,componentProps:{title:this.$i18n.t("components.vehicle.deleteHeader"),message:this.$i18n.t("components.vehicle.deleteMsg")},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.post("/api/vehicles/delete",{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.deleted")}),this.$router.push({name:"game-vehicle-list"})}).catch(l=>{})})}},mounted(){this.loadVehicle()}},I={class:"row"},R={class:"col-12 q-pa-sm"},w={class:"row"},G={class:"row"},U={class:"col-12 col-md-6 q-pa-sm"},_={class:"text-h6"},S={class:"text-main"},$={key:0},F={class:"text-left"},N={class:"text-left"},T={class:"text-left"},D={key:1,class:"text-left"},H={class:"text-left"},L={class:"text-left"},Y={class:"text-h6"},P={class:"text-main"},B={class:"text-left"},z={style:{"min-width":"250px"}},Q={key:1},j={class:"text-left"},W={style:{"min-width":"250px"}},X={key:1},Z={class:"text-left"},J={style:{"min-width":"250px"}},K={key:1},ee={class:"text-left"},le={style:{"min-width":"250px"}},te={key:1},se={class:"text-left"},ne={style:{"min-width":"250px"}},ie={key:1},oe={class:"col-12 col-md-6 q-pa-sm"},ae={class:"text-h6"},re={class:"text-main"},ce={class:"text-left"},de={class:"text-left"},me={class:"text-left"},he={style:{"min-width":"250px"}},pe={key:1},ue={class:"text-left"},ve={class:"text-left"},ye={class:"text-left"},ge={style:{"min-width":"250px"}},be={key:1},fe={class:"text-left"},Ee={style:{"min-width":"250px"}},Ce={key:1},ke={class:"text-left"},Ve={style:{"min-width":"250px"}},Ae={key:1},Me={class:"text-left"},Oe={style:{"min-width":"250px"}},qe={key:1},xe={class:"text-left"},Ie={style:{"min-width":"250px"}},Re={key:1},we={class:"text-left"},Ge={style:{"min-width":"250px"}},Ue={key:1},_e={class:"col-12"},Se={class:"q-ma-sm row justify-end"};function $e(l,s,h,b,e,a){return r(),c("div",I,[t("div",R,[t("div",w,[i(f,{class:"bg-secondary row",style:{width:"100%"}},{default:m(()=>[i(v,{class:"q-pa-none"},{default:m(()=>[t("div",G,[a.can(e.ACTION.GAME.STASHES.READ,e.RESOURCE.GAME)?(r(),g(d,{key:0,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.openTrunk"),onClick:s[0]||(s[0]=n=>l.$router.push({name:"game-stashes-detail",params:{stashId:e.vehicle.plate},query:{type:"Trunk"}}))},null,8,["label"])):y("",!0),a.can(e.ACTION.GAME.STASHES.READ,e.RESOURCE.GAME)?(r(),g(d,{key:1,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.openGlovebox"),onClick:s[1]||(s[1]=n=>l.$router.push({name:"game-stashes-detail",params:{stashId:e.vehicle.plate},query:{type:"Glovebox"}}))},null,8,["label"])):y("",!0),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),g(d,{key:2,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.changeOwner"),onClick:a.changeOwner},null,8,["label","onClick"])):y("",!0),a.can(e.ACTION.GAME.VEHICLE.DESPAWN,e.RESOURCE.GAME)?(r(),g(d,{key:3,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.despawnVehicle"),onClick:a.despawnehicle},null,8,["label","onClick"])):y("",!0),a.can(e.ACTION.GAME.VEHICLE.REPAIR,e.RESOURCE.GAME)?(r(),g(d,{key:4,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.repairVehicle"),onClick:a.repairVehicle},null,8,["label","onClick"])):y("",!0),a.can(e.ACTION.GAME.VEHICLE.DELETE,e.RESOURCE.GAME)?(r(),g(d,{key:5,"text-color":"main",class:"q-ma-md",color:"primary",label:l.$t("components.vehicle.buttons.deleteVehicle"),onClick:a.deleteVehicle},null,8,["label","onClick"])):y("",!0)])]),_:1})]),_:1})])]),t("div",U,[i(f,{class:"bg-secondary col-12 col-md-6",style:{height:"100%"}},{default:m(()=>[i(v,{class:"col-12"},{default:m(()=>[t("div",_,[t("span",S,o(l.$t("components.vehicle.header.owner")),1)])]),_:1}),i(v,{class:"col-12"},{default:m(()=>[i(E,{class:"bg-secondary text-main",flat:"",square:"",separator:"none"},{default:m(()=>[e.vehicle.ownerName?(r(),c("tr",$,[t("td",F,o(l.$t("components.vehicle.labels.owner")),1),t("td",N,o(e.vehicle.ownerName),1)])):y("",!0),t("tr",null,[t("td",T,o(l.$t("components.vehicle.labels.citizenid")),1),a.can(e.ACTION.GAME.PLAYER.READ,e.RESOURCE.GAME)?(r(),c("td",{key:0,class:"text-left cursor-pointer text-primary",style:{"text-decoration":"underline"},onClick:s[2]||(s[2]=n=>l.$router.push({name:"game-player-detail",params:{citizenid:e.vehicle.citizenid}}))},o(e.vehicle.citizenid),1)):(r(),c("td",D,o(e.vehicle.citizenid),1))]),t("tr",null,[t("td",H,o(l.$t("components.vehicle.labels.license")),1),t("td",L,o(e.vehicle.license),1)])]),_:1})]),_:1}),i(v,{class:"col-12"},{default:m(()=>[t("div",Y,[t("span",P,o(l.$t("components.vehicle.header.payment")),1)])]),_:1}),i(v,{class:"col-12"},{default:m(()=>[i(E,{class:"bg-secondary text-main",flat:"",square:"",separator:"none"},{default:m(()=>[t("tr",null,[t("td",B,o(l.$t("components.vehicle.labels.depotprice")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",z,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.depotprice,"onUpdate:modelValue":s[3]||(s[3]=n=>e.vehicle.depotprice=n),label:l.$t("components.vehicle.labels.depotprice")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},filled:"",onClick:s[4]||(s[4]=n=>a.updateField("depotprice")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",Q,o(e.vehicle.depotprice),1))]),t("tr",null,[t("td",j,o(l.$t("components.vehicle.labels.balance")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",W,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.balance,"onUpdate:modelValue":s[5]||(s[5]=n=>e.vehicle.balance=n),label:l.$t("components.vehicle.labels.balance")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},filled:"",onClick:s[6]||(s[6]=n=>a.updateField("balance")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",X,o(e.vehicle.balance),1))]),t("tr",null,[t("td",Z,o(l.$t("components.vehicle.labels.paymentamount")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",J,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.paymentamount,"onUpdate:modelValue":s[7]||(s[7]=n=>e.vehicle.paymentamount=n),label:l.$t("components.vehicle.labels.paymentamount")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[8]||(s[8]=n=>a.updateField("paymentamount")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",K,o(e.vehicle.paymentamount),1))]),t("tr",null,[t("td",ee,o(l.$t("components.vehicle.labels.paymentsleft")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",le,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.paymentsleft,"onUpdate:modelValue":s[9]||(s[9]=n=>e.vehicle.paymentsleft=n),label:l.$t("components.vehicle.labels.paymentsleft")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[10]||(s[10]=n=>a.updateField("paymentsleft")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",te,o(e.vehicle.paymentsleft),1))]),t("tr",null,[t("td",se,o(l.$t("components.vehicle.labels.financetime")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",ne,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.financetime,"onUpdate:modelValue":s[11]||(s[11]=n=>e.vehicle.financetime=n),label:l.$t("components.vehicle.labels.financetime")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[12]||(s[12]=n=>a.updateField("financetime")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",ie,o(e.vehicle.financetime),1))])]),_:1})]),_:1})]),_:1})]),t("div",oe,[i(f,{class:"bg-secondary col-12 col-md-6",style:{height:"100%"}},{default:m(()=>[i(v,{class:"col-12"},{default:m(()=>[t("div",ae,[t("span",re,o(l.$t("components.vehicle.header.car")),1)])]),_:1}),i(v,{class:"col-12"},{default:m(()=>[i(E,{class:"bg-secondary text-main",flat:"",square:"",separator:"none"},{default:m(()=>[t("tr",null,[t("td",ce,o(l.$t("components.vehicle.labels.model")),1),t("td",de,o(e.vehicle.vehicle),1)]),t("tr",null,[t("td",me,o(l.$t("components.vehicle.labels.plate")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",he,[i(M,{ref:"plate"},{default:m(()=>[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",maxlength:"8",modelValue:e.vehicle.plate,"onUpdate:modelValue":s[13]||(s[13]=n=>e.vehicle.plate=n),label:l.$t("components.vehicle.labels.plate"),"lazy-rules":"",rules:[n=>n&&/^[a-zA-Z0-9 ]+$/.test(n)||l.$t("rules.onlyCharsNumbers")]},null,8,["input-style","modelValue","label","rules"])]),_:1},512)]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[14]||(s[14]=n=>a.updatePlate()),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",pe,o(e.vehicle.plate),1))]),t("tr",null,[t("td",ue,o(l.$t("components.vehicle.labels.fakeplate")),1),t("td",ve,o(e.vehicle.fakeplate),1)]),t("tr",null,[t("td",ye,o(l.$t("components.vehicle.labels.drivingdistance")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",ge,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.drivingdistance,"onUpdate:modelValue":s[15]||(s[15]=n=>e.vehicle.drivingdistance=n),label:l.$t("components.vehicle.labels.drivingdistance")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[16]||(s[16]=n=>a.updateField("drivingdistance")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",be,o(e.vehicle.drivingdistance),1))]),t("tr",null,[t("td",fe,o(l.$t("components.vehicle.labels.garage")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",Ee,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",modelValue:e.vehicle.garage,"onUpdate:modelValue":s[17]||(s[17]=n=>e.vehicle.garage=n),label:l.$t("components.vehicle.labels.garage")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[18]||(s[18]=n=>a.updateField("garage")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",Ce,o(e.vehicle.garage),1))]),t("tr",null,[t("td",ke,o(l.$t("components.vehicle.labels.state")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",Ve,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.state,"onUpdate:modelValue":s[19]||(s[19]=n=>e.vehicle.state=n),label:l.$t("components.vehicle.labels.state")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[20]||(s[20]=n=>a.updateField("state")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",Ae,o(e.vehicle.state),1))]),t("tr",null,[t("td",Me,o(l.$t("components.vehicle.labels.fuel")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",Oe,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.fuel,"onUpdate:modelValue":s[21]||(s[21]=n=>e.vehicle.fuel=n),label:l.$t("components.vehicle.labels.fuel")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[22]||(s[22]=n=>a.updateField("fuel")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",qe,o(e.vehicle.fuel),1))]),t("tr",null,[t("td",xe,o(l.$t("components.vehicle.labels.engine")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",Ie,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.engine,"onUpdate:modelValue":s[23]||(s[23]=n=>e.vehicle.engine=n),label:l.$t("components.vehicle.labels.engine")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[24]||(s[24]=n=>a.updateField("engine")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",Re,o(e.vehicle.engine),1))]),t("tr",null,[t("td",we,o(l.$t("components.vehicle.labels.body")),1),a.can(e.ACTION.GAME.VEHICLE.MODIFY,e.RESOURCE.GAME)?(r(),c(p,{key:0},[t("td",Ge,[i(u,{dense:"","label-color":"primary","input-style":{color:"var(--q-main)"},filled:"",type:"number",modelValue:e.vehicle.body,"onUpdate:modelValue":s[25]||(s[25]=n=>e.vehicle.body=n),label:l.$t("components.vehicle.labels.body")},null,8,["input-style","modelValue","label"])]),t("td",null,[i(d,{"text-color":"main",class:"q-ml-md",color:"primary",style:{"max-height":"24px"},onClick:s[26]||(s[26]=n=>a.updateField("body")),label:l.$t("general.save")},null,8,["label"])])],64)):(r(),c("td",Ue,o(e.vehicle.body),1))])]),_:1})]),_:1})]),_:1})]),t("div",_e,[t("div",Se,[i(d,{"text-color":"main",color:"primary",onClick:s[27]||(s[27]=n=>l.$router.push({name:"game-vehicle-list"})),label:l.$t("general.back"),class:"q-mr-auto"},null,8,["label"])])])])}const Pe=k(x,[["render",$e]]);export{Pe as default};
|