fix: fix search record

This commit is contained in:
yosaphatprs 2025-12-01 11:22:27 +07:00
parent 5388ef03bc
commit fda1d5d92a
3 changed files with 14 additions and 15 deletions

View File

@ -15,7 +15,7 @@ export class ValidationController {
@Query('skip') skip: number, @Query('skip') skip: number,
@Query('page') page: number, @Query('page') page: number,
@Query('orderBy') orderBy: string, @Query('orderBy') orderBy: string,
@Query('searchIdRecord') searchIdRecord: string, @Query('search') search: string,
@Query('order') order: 'asc' | 'desc', @Query('order') order: 'asc' | 'desc',
@Query('kelompok_data') kelompok_data: string, @Query('kelompok_data') kelompok_data: string,
@Query('aksi') aksi: string, @Query('aksi') aksi: string,
@ -26,7 +26,7 @@ export class ValidationController {
skip, skip,
page, page,
orderBy, orderBy,
searchIdRecord, search,
order, order,
kelompok_data, kelompok_data,
aksi, aksi,

View File

@ -116,7 +116,7 @@ export class ValidationService {
page, page,
orderBy, orderBy,
order, order,
searchIdRecord, search,
kelompok_data, kelompok_data,
aksi, aksi,
status, status,
@ -132,9 +132,9 @@ export class ValidationService {
skip: skipValue, skip: skipValue,
orderBy: orderBy ? { [orderBy]: order || 'asc' } : { created_at: 'desc' }, orderBy: orderBy ? { [orderBy]: order || 'asc' } : { created_at: 'desc' },
where: { where: {
record_id: searchIdRecord record_id: search
? { ? {
contains: searchIdRecord, contains: search,
} }
: undefined, : undefined,
table_name: table_name:
@ -147,9 +147,9 @@ export class ValidationService {
}); });
const totalCount = await this.prisma.validation_queue.count({ const totalCount = await this.prisma.validation_queue.count({
where: { where: {
record_id: searchIdRecord record_id: search
? { ? {
contains: searchIdRecord, contains: search,
} }
: undefined, : undefined,
table_name: table_name:

View File

@ -26,7 +26,6 @@ interface ApiResponse {
} }
const data = ref<ValidationLog[]>([]); const data = ref<ValidationLog[]>([]);
const searchValidation = ref("");
const sortBy = ref("created_at"); const sortBy = ref("created_at");
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@ -52,8 +51,8 @@ const updateQueryParams = () => {
pageSize: pagination.pageSize.value.toString(), pageSize: pagination.pageSize.value.toString(),
}; };
if (searchValidation.value) { if (searchId.value) {
query.search = searchValidation.value; query.search = searchId.value;
} }
if (sortBy.value !== "id") { if (sortBy.value !== "id") {
@ -180,7 +179,7 @@ const fetchData = async () => {
: "", : "",
aksi: filters.value.aksi !== "initial" ? filters.value.aksi : "", aksi: filters.value.aksi !== "initial" ? filters.value.aksi : "",
status: filters.value.status !== "initial" ? filters.value.status : "", status: filters.value.status !== "initial" ? filters.value.status : "",
...(searchValidation.value && { validation: searchValidation.value }), ...(searchId.value && { search: searchId.value }),
}); });
const result = await api.get<ApiResponse>( const result = await api.get<ApiResponse>(
@ -249,7 +248,7 @@ watch(sortOrder, () => {
fetchData(); fetchData();
}); });
watch(searchValidation, (newValue, oldValue) => { watch(searchId, (newValue, oldValue) => {
if (oldValue && !newValue) { if (oldValue && !newValue) {
pagination.reset(); pagination.reset();
fetchData(); fetchData();
@ -282,7 +281,7 @@ watch(
onMounted(async () => { onMounted(async () => {
if (route.query.search) { if (route.query.search) {
searchValidation.value = route.query.search as string; searchId.value = route.query.search as string;
} }
if (route.query.sortBy) { if (route.query.sortBy) {
sortBy.value = route.query.sortBy as string; sortBy.value = route.query.sortBy as string;
@ -391,8 +390,8 @@ onMounted(async () => {
> >
<div class="flex flex-col w-full gap-2 md:flex-row md:items-center"> <div class="flex flex-col w-full gap-2 md:flex-row md:items-center">
<SearchInput <SearchInput
v-model="searchValidation" v-model="searchId"
placeholder="Cari berdasarkan Validation" placeholder="Cari berdasarkan ID Record"
@search="handleSearch" @search="handleSearch"
/> />
<div class="flex items-center gap-2 md:ml-4"> <div class="flex items-center gap-2 md:ml-4">