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

View File

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

View File

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