add base front
This commit is contained in:
parent
b4ffe1c551
commit
6a9264ff50
|
@ -6,6 +6,11 @@ const links = [
|
||||||
label: 'Организации',
|
label: 'Организации',
|
||||||
icon: 'i-heroicons-archive-box',
|
icon: 'i-heroicons-archive-box',
|
||||||
to: '/organization'
|
to: '/organization'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'TMC',
|
||||||
|
icon: 'i-heroicons-archive-box',
|
||||||
|
to: '/tmc'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,30 +1,6 @@
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
export const apiBase = config.public.apiBase
|
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[]) => {
|
export const makeColumns = (cols: string[]) => {
|
||||||
return cols.map(el => {
|
return cols.map(el => {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -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>
|
<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>
|
</template>
|
|
@ -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 { }
|
Loading…
Reference in New Issue