From b30cc6d6573e8be25bc30848f7289ca927639f45 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Mon, 11 Nov 2024 16:53:12 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B9=89=E0=B8=99=E0=B9=81=E0=B8=9A?= =?UTF-8?q?=E0=B8=9A=20=E0=B8=AA=E0=B8=B3=E0=B8=AB=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=E0=B8=A5=E0=B8=87=E0=B9=83=E0=B8=99=E0=B8=95=E0=B8=B3?= =?UTF-8?q?=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87/=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=20fix=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2?= =?UTF-8?q?=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/05_command/api.command.ts | 7 ++-- src/modules/05_command/views/salaryLists.vue | 42 +++++++++++--------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/api/05_command/api.command.ts b/src/api/05_command/api.command.ts index b332aefb..d9c4e897 100644 --- a/src/api/05_command/api.command.ts +++ b/src/api/05_command/api.command.ts @@ -10,8 +10,9 @@ export default { page: number, pageSize: number, isActive: boolean, - commandSysId: string + commandSysId: string, + search: string ) => - `${commandSalary}/admin?page=${page}&pageSize=${pageSize}&isActive=${isActive}&commandSysId=${commandSysId}`, - commandSalaryById:(id:string)=>`${commandSalary}/${id}` + `${commandSalary}/admin?page=${page}&pageSize=${pageSize}&isActive=${isActive}&commandSysId=${commandSysId}&search=${search}`, + commandSalaryById: (id: string) => `${commandSalary}/${id}`, }; diff --git a/src/modules/05_command/views/salaryLists.vue b/src/modules/05_command/views/salaryLists.vue index d3fdbb1e..1f23ed54 100644 --- a/src/modules/05_command/views/salaryLists.vue +++ b/src/modules/05_command/views/salaryLists.vue @@ -116,21 +116,21 @@ function onDialogEdit(data: ListTemplateSalary) { * ลบ คำสั่ง * @param id id คำสั่ง */ -function onDelete(id: string) { - dialogRemove($q, () => { +async function onDelete(id: string) { + dialogRemove($q, async () => { showLoader(); - http + await http .delete(config.API.commandSalaryById(id)) - .then(async (res) => { - success($q, "ลบข้อมูลเสร็จสิ้น"); + .then(async () => { await fetchSalaryList(); - hideLoader(); + success($q, "ลบข้อมูลเสร็จสิ้น"); }) .catch((e) => { messageError($q, e); - hideLoader(); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }); } @@ -146,33 +146,34 @@ function closeDialog() { /** บันทึกข้อมูล dialog */ function onSubmit() { - dialogConfirm($q, () => { + dialogConfirm($q, async () => { const url = isEdit.value ? config.API.commandSalaryById(dataForm.id) : config.API.commandSalary; showLoader(); - http[isEdit.value ? "put" : "post"](url, { + await http[isEdit.value ? "put" : "post"](url, { name: dataForm.name, commandSysId: activeOrderId.value, isActive: dataForm.isActive, }) - .then(async (res) => { - closeDialog(); - success($q, "บันทึกข้อมูลสำเร็จ"); + .then(async () => { await fetchSalaryList(); - hideLoader(); + success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); }) .catch((e) => { messageError($q, e); - hideLoader(); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }); } /** เก็บ id list คำสั่งที่เลือก เพื่อใช้ class */ function selectInbox(data: CommandSysType) { activeOrderId.value = data.id; + pagination.value.page = 1; fetchSalaryList(); } @@ -181,13 +182,15 @@ function selectInbox(data: CommandSysType) { */ async function fetchSalaryList() { showLoader(); + rows.value = []; await http .get( config.API.commandSalaryDetail( pagination.value.page, pagination.value.rowsPerPage, isActive.value, - activeOrderId.value + activeOrderId.value, + filter.value ) ) .then(async (res) => { @@ -239,6 +242,7 @@ watch( watch( () => isActive.value, async () => { + pagination.value.page = 1; await fetchSalaryList(); } ); @@ -321,6 +325,7 @@ onMounted(() => { outlined v-model="filter" placeholder="ค้นหา" + @keydown.enter="(pagination.page = 1), fetchSalaryList()" >