add base front

This commit is contained in:
Kseninia Mikhaylova 2024-06-25 13:58:38 +03:00
parent b4ffe1c551
commit 6a9264ff50
4 changed files with 69 additions and 25 deletions

View File

@ -6,6 +6,11 @@ const links = [
label: 'Организации',
icon: 'i-heroicons-archive-box',
to: '/organization'
},
{
label: 'TMC',
icon: 'i-heroicons-archive-box',
to: '/tmc'
}
]
</script>

View File

@ -1,30 +1,6 @@
const config = useRuntimeConfig()
export const apiBase = config.public.apiBase
export type ApiTypeList = {
count: number;
next?: any;
previous?: any;
results: ApiTypeBase[]
}
export type ApiTypeBase =
ApiPartner | ApiInventory | ApiElement;
export type ApiPartner = { id: number, external_id: number, name: string, total_inventory: number }
export type ApiInventory = { id: number, partner: number, name: string }
export type ApiElement = { id: number, external_id: string, element_id: number, photo: string, additional_text: string, inventory: number }
export type ApiElementSave = {
partner: ApiPartner,
inventory: ApiInventory,
element: ApiElement
}
export type ApiTypeExternal = {
'НаименованиеПолное': string;
Description: string;
Ref_Key: string;
}
export const makeColumns = (cols: string[]) => {
return cols.map(el => {
return {

View File

@ -1,3 +1,22 @@
<script setup lang="ts">
import { apiBase } from '~/helpers';
const headers = new Headers();
headers.append("Content-Type", "application/json");
const items = ref()
onMounted(async () => {
const items_data = await $fetch<ApiTypeTmc>(`${apiBase}/tmc/items/`, { headers })
items.value = items_data.results
})
</script>
<template>
123
<template v-for="item in items">
<h2>{{ item.name }}</h2>
<ul>
<li v-for="child in item.fields">
{{ child.name }}
</li>
</ul>
</template>
</template>

44
front/types/index.d.ts vendored Normal file
View File

@ -0,0 +1,44 @@
declare global {
type ApiTypeList = {
count: number;
next?: any;
previous?: any;
results: ApiTypeBase[]
}
type ApiTypeBase =
ApiPartner | ApiInventory | ApiElement;
type ApiPartner = { id: number, external_id: number, name: string, total_inventory: number }
type ApiInventory = { id: number, partner: number, name: string }
type ApiElement = { id: number, external_id: string, element_id: number, photo: string, additional_text: string, inventory: number }
type ApiElementSave = {
partner: ApiPartner,
inventory: ApiInventory,
element: ApiElement
}
type ApiTypeExternal = {
'НаименованиеПолное': string;
Description: string;
Ref_Key: string;
}
interface TmcField {
id: number
name: string
}
interface TmcItem {
id: number
name: string
fields: TmcField[]
}
type ApiTypeTmc = {
count: number;
next?: any;
previous?: any;
results: TmcItem[]
}
}
export { }