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()" >