fix: creating, updating

This commit is contained in:
opbnq-q
2025-03-07 07:16:20 -08:00
parent 96b814d54a
commit 4ec5fd2d0c
115 changed files with 11543 additions and 153 deletions

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(3684602449, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -34,7 +34,7 @@ export function Delete(id: number): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(3248293926) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -43,7 +43,7 @@ export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void
export function GetById(id: number): Promise<$models.Author | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(1703016211, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -52,7 +52,7 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
export function Update(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(2240704960, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(1443399856, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -39,7 +39,7 @@ export function ExportToExcel(): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(65691059) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -48,7 +48,7 @@ export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void }
export function GetById(id: number): Promise<$models.Post | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(4074736792, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -57,7 +57,7 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
export function Update(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(137798821, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,14 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
<script type="module" crossorigin src="/assets/index-Z-UIusQp.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-hwTd8BmI.css">
</head>
<body>
<div id="app"></div>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
<script type="module" crossorigin src="/assets/index-DsBrcYCq.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BnDWzbnJ.css">
</head>
<body>
<div id="app"></div>
</body>

1852
frontend/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,62 +1,8 @@
<script setup lang="ts">
import { ref } from 'vue';
import type { IEntity } from './types/entity.type';
import type { IService } from './types/service.type';
import type { Scheme } from './types/scheme.type';
import Table from './table/Table.vue';
import { getDefaultValues } from './utils/structs/defaults.util';
import PostScheme from './post/PostScheme.vue';
class Entity implements IEntity {
constructor(public Id: number, public Name: string, public Region: string) { }
}
class Service implements IService<Entity> {
private readonly entities = ref<Entity[]>([])
private maxId = 0
async create(data: Entity): Promise<void | never> {
this.maxId++
this.entities.value.push({ ...data, Id: this.maxId })
}
async delete(id: number): Promise<void | never> {
this.entities.value = this.entities.value.filter(el => el.Id != id)
}
async read(id: number): Promise<Entity | undefined> {
return this.entities.value.find(el => el.Id == id)
}
async readAll(): Promise<Entity[]> {
return this.entities.value
}
async update(data: Entity): Promise<void | never> {
this.entities.value = this.entities.value.map(el => el.Id == data.Id ? data : el)
}
}
const service = new Service
const scheme: Scheme<Entity> = {
Id: {
hidden: true,
russian: 'Id'
},
Name: {
type: {
primitive: 'string'
},
russian: 'Имя'
},
Region: {
type: {
nested: {
field: [],
values: ['kemerovo', 'kuzbass', 'berlin']
}
},
russian: "Место жительства"
},
}
</script>
<template>
<Table :scheme :service :get-defaults="() => getDefaultValues(scheme)"></Table>
<PostScheme />
</template>

View File

@@ -0,0 +1,38 @@
<script setup lang="ts">
import Table from '../table/Table.vue'
import { onMounted, reactive } from 'vue'
import { getDefaultValues } from '../utils/structs/defaults.util'
import S from './author.service.ts'
import type { Scheme } from '../types/scheme.type'
import { Author } from '../../bindings/app/internal/services/models.ts'
const service = new S
onMounted(async () => {
})
const scheme: Scheme<Author> = reactive({
Id:{
type: {
primitive: "number",
},
},
Name:{
type: {
primitive: "string",
},
},
})
const getDefaults = () => getDefaultValues(scheme)
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :getDefaults></Table>
</main>
</template>

View File

@@ -0,0 +1,27 @@
import { GetAll, Create, Delete, GetById, Update, Count } from "../../bindings/app/internal/services/authorservice.ts"
import type { Author } from "../../bindings/app/internal/services/models.ts"
import type { IService } from "../types/service.type.ts"
export default class AuthorService implements IService<Author> {
async read(id: number) {
return await GetById(id)
}
async readAll() {
return await GetAll() as Author[]
}
async create(item: Author) {
await Create(item)
}
async delete(id: number) {
return await Delete(id)
}
async update(item: Author) {
await Update(item)
}
async count() {
return await Count()
}
}

View File

@@ -18,6 +18,7 @@ Id:{
type: {
primitive: "number",
},
hidden: true,
},
Text:{
type: {

View File

@@ -8,7 +8,7 @@ export default class PostService implements IService<Post> {
}
async readAll() {
return await GetAll()
return await GetAll() as Post[]
}
async create(item: Post) {

View File

@@ -62,8 +62,7 @@ const emits = defineEmits<{
</template>
</Select>
<MultiSelect v-else-if="props.scheme[key].type?.many" v-model:model-value="createItem![key]"
:options="props.scheme[key].type?.nested?.values"
class="w-[300px] h-11"
:options="props.scheme[key].type?.nested?.values" class="w-[300px] h-11"
:placeholder="`Выберите ${props.scheme[key].russian}`">
<template #option="{ option }">
{{ manyStructsView(option, props.scheme[key]?.type?.nested?.field) }}
@@ -78,15 +77,16 @@ const emits = defineEmits<{
<template #footer>
<Button severity="success" @click="async () => {
if (props.updateMode) {
props.service.update(createItem as T)
emits('onSaveUpdate', createItem as T)
emits('onSave', createItem as T)
await props.service.update(createItem as T)
await emits('onSaveUpdate', createItem as T)
await emits('onSave', createItem as T)
} else {
props.service.create(createItem as T)
emits('onSaveCreate', createItem as T)
emits('onSave', createItem as T)
if (createItem) createItem.Id = 0;
await props.service.create(createItem as T)
await emits('onSaveCreate', createItem as T)
await emits('onSave', createItem as T)
}
items = await service.readAll() as UnwrapRef<T[]>
items = await props.service.readAll() as UnwrapRef<T[]>
showCreate = false
}">Сохранить</Button>
</template>

View File

@@ -1,5 +1,5 @@
export interface IService<T> {
read(id: number): Promise<T | undefined>
read(id: number): Promise<T | null>
readAll(): Promise<T[]>
create(data: T): Promise<void | never>
update(data: T): Promise<void | never>

View File

@@ -2,13 +2,15 @@
"extends": "@vue/tsconfig/tsconfig.dom.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"allowImportingTsExtensions": true,
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
"noUncheckedSideEffectImports": true,
"lib": ["ES2015", "DOM"]
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
}

View File

@@ -4,4 +4,4 @@
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
}

View File

@@ -21,4 +21,4 @@
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
}