forked from Simnation/Main
2 lines
9.1 KiB
JavaScript
2 lines
9.1 KiB
JavaScript
![]() |
import{_ as E,R as D,P as N,o as m,X as f,a7 as a,a as t,w as n,a6 as b,ab as u,c as y,V as q,a5 as p,W as C,U as h,a9 as r,Y as S,Z as w}from"./app-014d9ed9.js";import{Q as V}from"./QForm.8d79ab03.js";import{Q as U}from"./QSelect.d7ce3d4c.js";import{Q}from"./QTooltip.9d840032.js";import{Q as I}from"./QMarkupTable.ba6854cc.js";import{d as O}from"./utils.9ce591f3.js";import{B as $}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 B={name:"Vehicle",data(){return{RESOURCE:D,ACTION:N,defaults:["name","brand","model","price","category","categorylabel","hash","shop"],vehicle:{},customVars:[],pendingSave:!1,pendingDelete:!1}},methods:{can:O,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,l){e>-1&&this.$q.dialog({component:$,componentProps:{title:this.$i18n.t("components.devVehicle.deleteHeader"),message:this.$i18n.t("components.devVehicle.deleteCustomVarMsg",{name:l.name})},cancel:!0,persistent:!0}).onOk(()=>{delete this.vehicle[l.oldName],this.customVars.splice(e,1)})},trySave(){this.$refs.customVarForm.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.uniqueVars")});return}this.customVars.forEach(l=>{!l.name||(l.oldName=l.name,this.vehicle[l.name]=this.isNumeric(l.value)?Number(l.value):this.isBoolean(l.value))}),this.pendingSave=!0,this.$axios.patch(`/api/dev-vehicles/save/${this.$route.params.vehicleId}`,this.vehicle).then(l=>{if(this.pendingSave=!1,!l.data.resCode){const v=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.devVehicle.msg.error.${v}`,{name:this.job.name})});return}this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.saved")})}).catch(l=>{console.error(l)})})},tryDelete(){this.pendingDelete=!0,this.$q.dialog({component:$,componentProps:{title:this.$i18n.t("components.devVehicle.deleteHeader"),message:this.$i18n.t("components.devVehicle.deleteMsg",{model:this.vehicle.model})},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.delete(`/api/dev-vehicles/delete/${this.$route.params.vehicleId}`).then(e=>{if(this.pendingDelete=!1,!e.data.resCode){const c=e.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.${c}`)});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:"dev-vehicle-list"})}).catch(e=>{})}).onCancel(()=>{this.pendingDelete=!1})}},mounted(){this.$axios.get(`/api/dev-vehicles/${this.$route.params.vehicleId}`).then(e=>{const l=e.data.vehicle;if(!l){this.$q.notify({message:e.data.msg,position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:"Error"});return}this.vehicle=l,this.vehicle.shop=Array.isArray(l.shop)?l.shop:[l.shop];for(const[c,v]of Object.entries(l))this.defaults.includes(c.toLowerCase())||this.customVars.push({name:c,value:v,oldName:c})}).catch(e=>{console.error(e)})}},L={class:"row"},M={class:"col-12"},_={class:"q-ma-sm row"},R={class:"text-h6"},T={class:"text-primary"},F={class:"col-12"},A={class:"q-ma-sm row"},x={class:"row"},H={class:"text-h6"},j={class:"text-caption text-sub"},P={class:"q-ml-auto"},z={style:{width:"30px"},class:"text-right vertical-middle"},Y={class:"col-12"},W={class:"q-ma-sm row justify-end"};function X(e,l,c,v,o,d){return m(),f("div",L,[a("div",M,[a("div",_,[t(b,{class:"bg-secondary full-width row"},{default:n(()=>[t(p,{class:"col-12"},{default:n(()=>[a("div",R,[C(h(e.$t("components
|