forked from Simnation/Main
2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
![]() |
import{_ as D,R as I,P as N,o as p,X as f,a7 as s,a as l,w as d,a6 as y,ab as b,c as V,V as $,r as E,a5 as u,W as j,U as m,a9 as g,aT as _,Y as C,Z as k,S as O,bG as U,bH as B}from"./app-014d9ed9.js";import{Q as q}from"./QTooltip.9d840032.js";import{Q as x}from"./QMarkupTable.ba6854cc.js";import{Q}from"./QForm.8d79ab03.js";import{d as M}from"./utils.9ce591f3.js";import{B as v}from"./BasicDialog.9dd9de92.js";import{S as J,m as T}from"./move.a5bc0ce3.js";import"./externalHosting.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";const P={name:"Job",data(){return{RESOURCE:I,ACTION:N,defaults:["name","grades","label","defaultduty","offdutypay"],customVars:[],sortable:null,pendingSave:!1,pendingDelete:!1,job:{},jobGrades:[]}},methods:{can:M,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,o){e>-1&&this.$q.dialog({component:v,componentProps:{title:this.$i18n.t("components.job.deleteHeader"),message:this.$i18n.t("components.job.deleteCustomVarMsg",{name:o.name})},cancel:!0,persistent:!0}).onOk(()=>{delete this.job[o.oldName],this.customVars.splice(e,1)})},removeNode(e){e.parentElement!==null&&e.parentElement.removeChild(e)},insertNodeAt(e,o,i){const r=i===0?e.children[0]:e.children[i-1].nextSibling;e.insertBefore(o,r)},buildJobGrade(e){let o=[];for(const[i,r]of Object.entries(e))o.push({name:r.name,payment:r.payment,isboss:r.isboss?r.isboss:!1});return o},updateBoss(){},addGrade(){this.jobGrades.push({name:"",payment:0,isboss:!1})},removeGrade(e){const o=this.jobGrades.indexOf(e);o>-1&&this.$q.dialog({component:v,componentProps:{title:this.$i18n.t("components.job.deleteHeader"),message:this.$i18n.t("components.job.deleteGradeMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.jobGrades.splice(o,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.job.msg.error.uniqueVars")});return}this.customVars.forEach(i=>{!i.name||(i.oldName=i.name,this.job[i.name]=this.isNumeric(i.value)?Number(i.value):this.isBoolean(i.value))});let o={};for(const[i,r]of Object.entries(this.jobGrades)){if(!r.isboss&&!r.name&&!r.payment)continue;const t=Object.keys(o).length;r.isboss?o[t]={name:r.name,payment:r.payment,isboss:!0}:o[t]={name:r.name,payment:r.payment}}if(Object.keys(o).length===0){this.$q.notify({message:this.$i18n.t("general.error"),position:"top",color:"red",icon:"fas fa-exclamation-triangle",caption:this.$i18n.t("components.job.msg.error.gradeNeeded")});return}this.pendingSave=!0,this.job.grades=o,this.$axios.patch(`/api/jobs/save/${this.$route.params.jobId}`,this.job).then(i=>{if(this.pendingSave=!1,!i.data.resCode){const t=i.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.job.msg.error.${t}`,{name:this.job.name})});return}Object.keys(o).length!==this.jobGrades.length&&(this.jobGrades=this.buildJobGrade(this.job.grades)),this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n.t("general.saved")})}).catch(i=>{})})},tryDelete(){this.pendingDelete=!0,this.$q.dialog({component:v,componentProps:{title:this.$i18n.t("components.job.deleteHeader"),message:this.$i18n.t("components.job.deleteMsg",{name:this.$route.params.jobId})},cancel:!0,persistent:!0}).onOk(()=>{this.$axios.delete(`/api/jobs/delete/${this.$route.params.jobId}`).then(e=>{if(this.pendingDelete=!1,!e.data.resCode){const i=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.job.msg.error.${i}`,{name:this.$route.params.jobId})});return}this.$q.notify({message:this.$i18n.t("general.success"),position:"top",color:"green",icon:"fas fa-check",caption:this.$i18n
|