From 16f0cb273f0bcfe125e3c2851d8b8eba43ba88f9 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Fri, 1 Mar 2024 15:42:51 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=E0=B8=81=E0=B9=84=E0=B8=A1?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=E0=B8=B5=20=E0=B8=95=E0=B8=B1=E0=B8=A7?= =?UTF-8?q?=E0=B9=80=E0=B8=A5=E0=B8=B7=E0=B8=AD=E0=B8=81=E0=B9=83=E0=B8=AB?= =?UTF-8?q?=E0=B9=89=E0=B8=81=E0=B8=A3=E0=B8=AD=E0=B8=81=E0=B9=80=E0=B8=AD?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/04_registry/components/Salary.vue | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/modules/04_registry/components/Salary.vue b/src/modules/04_registry/components/Salary.vue index ffe8f8359..cb2652e24 100644 --- a/src/modules/04_registry/components/Salary.vue +++ b/src/modules/04_registry/components/Salary.vue @@ -274,13 +274,14 @@ :readonly="!edit" :borderless="!edit" v-model="formDataSalary.levelPosition" - :rules="[(val: string) => !!val || `${'กรุณาเลือกระดับ'}`]" + :rules="[(val: string) => !!val || `${'กรุณาเลือกระดับ หรือหากกรอกเอง กรุณากด enter'}`]" :label="`${'ระดับ'}`" @update:modelValue="clickEditRow" emit-value map-options option-label="name" :options="opLevel" + @new-value="createValue" option-value="name" hide-bottom-space use-input @@ -2113,6 +2114,25 @@ function coppyForm() { formDataSalary.templateDoc = formDataSalary.templateDoc; formDataSalary.doc = formDataSalary.doc; } + +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); + return itemId > max ? itemId : max; + }, 0); + const newId = isNaN(maxId) ? 1 : maxId + 1; + const newObj = { + id: typeof val === "number" ? val : newId, + name: val, + }; + if (!optionStore.optipnLevel.some((item: any) => item.id === newObj.id)) { + optionStore.optipnLevel.push(newObj); + } + + done(newObj, "toggle"); + } +}