Main/resources/[tools]/unlimited-spectre/html/assets/JobCreate.06aadcb6.js

2 lines
10 KiB
JavaScript
Raw Normal View History

2025-06-07 08:51:21 +02:00
import{_ as S,o as f,X as h,a7 as t,a as s,w as d,a6 as g,ab as y,r as U,a5 as c,U as u,a9 as p,aT as j,Y as _,Z as v,W as V,S as N,bG as I,bH as B}from"./app-014d9ed9.js";import{Q as $}from"./QForm.8d79ab03.js";import{Q as C}from"./QTooltip.9d840032.js";import{Q as q}from"./QMarkupTable.ba6854cc.js";import{B as w}from"./BasicDialog.9dd9de92.js";import{S as Q,m as D}from"./move.a5bc0ce3.js";import"./externalHosting.js";import"./position-engine.65ebcb34.js";import"./selection.2a17b691.js";const O={name:"JobCreate",data(){return{defaults:["name","grades","label","defaultduty","offdutypay"],customVars:[],sortable:null,pendingSave:!1,job:{name:"",label:"",defaultDuty:!1,offDutyPay:!1,grades:{}},jobGrades:[]}},methods:{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){const l=this.customVars.indexOf(e);l>-1&&this.$q.dialog({component:w,componentProps:{title:this.$i18n.t("components.job.deleteHeader"),message:this.$i18n.t("components.job.deleteCustomVarMsg",{name:e.name})},cancel:!0,persistent:!0}).onOk(()=>{this.customVars.splice(l,1)})},removeNode(e){e.parentElement!==null&&e.parentElement.removeChild(e)},insertNodeAt(e,l,r){const i=r===0?e.children[0]:e.children[r-1].nextSibling;e.insertBefore(l,i)},buildJobGrade(e){let l=[];for(const[r,i]of Object.entries(e))l.push({name:i.name,payment:i.payment,isboss:i.isboss?i.isboss:!1});return l},updateBoss(){},addGrade(){this.jobGrades.push({name:"",payment:0,isboss:!1})},removeGrade(e){const l=this.jobGrades.indexOf(e);l>-1&&this.$q.dialog({component:w,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(l,1)})},trySave(){this.$refs.jobForm.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.missingFields")});return}this.$refs.customVarForm.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.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 r={};for(const[i,a]of Object.entries(this.jobGrades)){if(!a.isboss&&!a.name&&!a.payment)continue;const m=Object.keys(r).length;a.isboss?r[m]={name:a.name,payment:a.payment,isboss:!0}:r[m]={name:a.name,payment:a.payment}}if(Object.keys(r).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=r,this.$axios.post("/api/jobs/create",this.job).then(i=>{if(this.pendingSave=!1,!i.data.resCode){const m=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.${m}`,{name:this.job.name})});return}Object.keys(r).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")}),this.$router.push({name:"dev-job-list"})}).catch(i=>{})})})}},mounted(){const e=this.$el.querySelector(".q-table > draggable"),l=this;this.sortable=Q.create(e,{handle:".drag-handle",animation:150,onEnd(r){r.oldIndex!==r.newIndex&&(l.removeNode(r.item),l.insertNodeAt(r.from,r.item,r.oldIndex),D(l.jobGrades,r.oldIndex,r.newIndex))}})},beforeUnmount(){this.sortable.destroy()}},x=e=>(I("data-v-036fe121"),e=e(),B(),e),F={class:"row"},M={class:"col-12"},P={class:"q-ma-sm row"},E={class:"text-h6"},J={class:"col-12"},T={class:"q-ma-sm row"},z={class:"row"},A={class:"text-