mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 20:00:33 +07:00
60 lines
1.6 KiB
Cheetah
60 lines
1.6 KiB
Cheetah
<script setup lang="ts">
|
|
import Table from '../table/Table.vue'
|
|
import { onMounted, reactive } from 'vue'
|
|
import { getDefaultValues } from '../utils/structs/defaults.util'
|
|
import Service from './{{.LowerName}}.service'
|
|
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";
|
|
{{range .Dependencies}}
|
|
import {{.ImportName}} from '../{{.LowerName}}/{{.LowerName}}.service'
|
|
const {{.ServiceName}} = new {{.ImportName}}
|
|
{{end}}
|
|
|
|
const service = new Service
|
|
|
|
const items = ref<{{ .StructName }}[]>([])
|
|
|
|
const load = async () => {
|
|
{{range .Dependencies}}
|
|
(scheme as any).{{.FieldName}}.type!.nested!.values = await {{.ServiceName}}.readAll();
|
|
{{end}}
|
|
items.value = await service.sort(sortOptions.value) ;
|
|
return items.value;
|
|
};
|
|
|
|
onMounted(() => {
|
|
load()
|
|
})
|
|
|
|
const scheme: Scheme<{{.StructName}}> = reactive({
|
|
entityId: "{{.StructName}}Id",
|
|
{{range .Fields}}
|
|
{{.Name}}: {{.GenerateFieldCode}},
|
|
{{end}}
|
|
})
|
|
|
|
const getDefaults = () => getDefaultValues(scheme)
|
|
|
|
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>
|
|
<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>
|