mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-07 00:30:34 +07:00
feat: search, sort
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user