diff --git a/src/modules/04_registry/components/Salary.vue b/src/modules/04_registry/components/Salary.vue index cb2652e24..4d81a9fe8 100644 --- a/src/modules/04_registry/components/Salary.vue +++ b/src/modules/04_registry/components/Salary.vue @@ -281,7 +281,9 @@ map-options option-label="name" :options="opLevel" + @input-value="inputPositionLevel" @new-value="createValue" + @blur.stop="inputPositionLevelBlur" option-value="name" hide-bottom-space use-input @@ -1268,6 +1270,27 @@ const formDataSalary = reactive({ doc: "", }); +const tempPositionLevelInput = ref(""); + +function inputPositionLevel(v: string) { + if (!!v) tempPositionLevelInput.value = v; +} + +function inputPositionLevelBlur() { + if (tempPositionLevelInput.value === formDataSalary.levelPosition) return; + + if ( + !optionStore.optipnLevel.some( + (v) => v.name === tempPositionLevelInput.value + ) + ) { + createValue(tempPositionLevelInput.value); + } + + formDataSalary.levelPosition = tempPositionLevelInput.value; + tempPositionLevelInput.value = ""; +} + const opPos = ref([]); const opType = ref([]); const opLevel = ref([]); @@ -2115,7 +2138,7 @@ function coppyForm() { formDataSalary.doc = formDataSalary.doc; } -function createValue(val: any, done: any) { +function createValue(val: any, done?: any) { if (val.length > 0) { const maxId = optionStore.optipnLevel.reduce((max: any, item: any) => { const itemId = typeof item.id === "number" ? item.id : parseInt(item.id); @@ -2130,7 +2153,7 @@ function createValue(val: any, done: any) { optionStore.optipnLevel.push(newObj); } - done(newObj, "toggle"); + done?.(newObj, "toggle"); } }