feat: search, sort

This commit is contained in:
opbnq-q
2025-03-15 19:21:27 +07:00
parent c68494e07b
commit d2dedd85f9
2 changed files with 25 additions and 5 deletions

View File

@@ -6,6 +6,8 @@ import Service from './{{.LowerName}}.service.ts'
import type { Scheme } from '../types/scheme.type'
import { {{.StructName}} } from '{{.GolangServicesPath}}'
import { ref } from 'vue'
import type { Validate } from "../types/validate.type";
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util.ts";
import type { Validate } from '../types/validate.type'
{{range .Dependencies}}
import {{.ImportName}} from '../{{.LowerName}}/{{.LowerName}}.service.ts'
@@ -20,11 +22,11 @@ const load = async () => {
{{range .Dependencies}}
(scheme as any).{{.FieldName}}.type!.nested!.values = await {{.ServiceName}}.readAll();
{{end}}
items.value = await service.readAll();
items.value = await service.sort(sortOptions.value) ;
return items.value;
};
onMounted(async () => {
onMounted(() => {
load()
})
@@ -37,14 +39,22 @@ const scheme: Scheme<{{.StructName}}> = reactive({
const getDefaults = () => getDefaultValues(scheme)
const validate: Validate<{{.StructName}}> = (entity) => {
const validate: Validate<{{.StructName}}> = entity => {
return {
status: 'success'
}
};
const search = async (input: string) => {
items.value = await service.search(input)
}
const sortOptions = ref(getDefaultSortOptions(scheme))
</script>
<template>
<Table :scheme :service :get-defaults :load :items :validate></Table>
<main class="w-screen h-screen">
<Table :scheme :service :get-defaults :load :items :validate @on-search="search" v-model:sort-options="sortOptions"></Table>
</main>
</template>