Compare commits
3 Commits
fix/CI-CD
...
316a20c43a
| Author | SHA1 | Date | |
|---|---|---|---|
| 316a20c43a | |||
| d16a81630c | |||
| d8c0a8b8e3 |
@@ -3,6 +3,8 @@ api_platform:
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
defaults:
|
defaults:
|
||||||
stateless: true
|
stateless: true
|
||||||
|
pagination_client_items_per_page: true
|
||||||
|
pagination_maximum_items_per_page: 100
|
||||||
cache_headers:
|
cache_headers:
|
||||||
vary: ['Content-Type', 'Authorization', 'Origin']
|
vary: ['Content-Type', 'Authorization', 'Origin']
|
||||||
formats:
|
formats:
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// This file is auto-generated and is for apps only. Bundles SHOULD NOT rely on its content.
|
// This file is auto-generated and is for apps only. Bundles SHOULD NOT rely on its content.
|
||||||
|
|
||||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||||
@@ -1472,7 +1470,7 @@ use Symfony\Component\Config\Loader\ParamConfigurator as Param;
|
|||||||
* mercure?: bool|array{
|
* mercure?: bool|array{
|
||||||
* enabled?: bool|Param, // Default: false
|
* enabled?: bool|Param, // Default: false
|
||||||
* hub_url?: scalar|Param|null, // The URL sent in the Link HTTP header. If not set, will default to the URL for MercureBundle's default hub. // Default: null
|
* hub_url?: scalar|Param|null, // The URL sent in the Link HTTP header. If not set, will default to the URL for MercureBundle's default hub. // Default: null
|
||||||
* include_type?: bool|Param, // Always include @var in updates (including delete ones). // Default: false
|
* include_type?: bool|Param, // Always include @type in updates (including delete ones). // Default: false
|
||||||
* },
|
* },
|
||||||
* messenger?: bool|array{
|
* messenger?: bool|array{
|
||||||
* enabled?: bool|Param, // Default: false
|
* enabled?: bool|Param, // Default: false
|
||||||
|
|||||||
268
frontend/components/ui/UiDataTable.vue
Normal file
268
frontend/components/ui/UiDataTable.vue
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
<template>
|
||||||
|
<div class="mt-6">
|
||||||
|
<table class="min-w-full border-collapse border border-slate-300">
|
||||||
|
<thead class="gap-4 bg-slate-100 px-4 py-3 uppercase tracking-wide">
|
||||||
|
<tr>
|
||||||
|
<th
|
||||||
|
v-for="column in normalizedColumns"
|
||||||
|
:key="column.key"
|
||||||
|
class="border border-slate-300 px-3 py-2 text-left"
|
||||||
|
>
|
||||||
|
<span>{{ column.label }}</span>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-if="loading">
|
||||||
|
<td
|
||||||
|
class="border border-slate-300 px-3 py-2 text-center text-slate-500"
|
||||||
|
:colspan="normalizedColumns.length || 1"
|
||||||
|
>
|
||||||
|
Chargement...
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-else-if="rows.length === 0">
|
||||||
|
<td
|
||||||
|
class="border border-slate-300 px-3 py-2 text-center text-slate-500"
|
||||||
|
:colspan="normalizedColumns.length || 1"
|
||||||
|
>
|
||||||
|
Aucune donnée
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<template v-else>
|
||||||
|
<tr
|
||||||
|
v-for="(row, rowIndex) in rows"
|
||||||
|
:key="rowIndex"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="onRowClick(row)"
|
||||||
|
>
|
||||||
|
<td
|
||||||
|
v-for="column in normalizedColumns"
|
||||||
|
:key="column.key"
|
||||||
|
class="border border-slate-300 px-2 py-2 whitespace-pre-line"
|
||||||
|
>
|
||||||
|
{{ formatColumnValue(row, column) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<p class="text-sm text-slate-600">
|
||||||
|
{{ pageLabel }}
|
||||||
|
</p>
|
||||||
|
<div class="flex items-center gap-2 mt-4">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="rounded border border-slate-300 px-3 py-1 disabled:cursor-not-allowed disabled:opacity-50"
|
||||||
|
:disabled="currentPage <= 1 || loading"
|
||||||
|
@click="currentPage = currentPage - 1"
|
||||||
|
>
|
||||||
|
Précédent
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
v-for="(item, index) in paginationItems"
|
||||||
|
:key="`${item}-${index}`"
|
||||||
|
type="button"
|
||||||
|
class="min-w-9 rounded border px-3 py-1 disabled:cursor-default"
|
||||||
|
:class="typeof item === 'number' && item === currentPage
|
||||||
|
? 'border-primary-500 bg-primary-500 text-white'
|
||||||
|
: 'border-slate-300'"
|
||||||
|
:disabled="loading || item === '...'"
|
||||||
|
@click="typeof item === 'number' ? (currentPage = item) : null"
|
||||||
|
>
|
||||||
|
{{ item }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="rounded border border-slate-300 px-3 py-1 disabled:cursor-not-allowed disabled:opacity-50"
|
||||||
|
:disabled="currentPage >= totalPages || loading"
|
||||||
|
@click="currentPage = currentPage + 1"
|
||||||
|
>
|
||||||
|
Suivant
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
type Row = Record<string, unknown>
|
||||||
|
|
||||||
|
type ColumnConfig = {
|
||||||
|
key: string
|
||||||
|
label?: string
|
||||||
|
format?: (value: unknown, row: Row) => string
|
||||||
|
}
|
||||||
|
type HydraCollection<T> = {
|
||||||
|
'hydra:member': T[]
|
||||||
|
'hydra:totalItems': number
|
||||||
|
}
|
||||||
|
type AnyCollection<T> = HydraCollection<T> & {
|
||||||
|
member?: T[]
|
||||||
|
items?: T[]
|
||||||
|
totalItems?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
url: string
|
||||||
|
columns?: ColumnConfig[]
|
||||||
|
query?: Record<string, unknown>
|
||||||
|
itemsPerPage?: number
|
||||||
|
}>(), {
|
||||||
|
columns: () => [],
|
||||||
|
query: () => ({}),
|
||||||
|
itemsPerPage: 10
|
||||||
|
})
|
||||||
|
|
||||||
|
const api = useApi()
|
||||||
|
const emit = defineEmits<{
|
||||||
|
rowClick: [row: Row]
|
||||||
|
}>()
|
||||||
|
const loading = ref(false)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const rows = ref<Row[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
|
||||||
|
const normalizedColumns = computed(() => {
|
||||||
|
if (props.columns.length > 0) {
|
||||||
|
return props.columns.map((column) => ({
|
||||||
|
key: column.key,
|
||||||
|
label: column.label ?? column.key,
|
||||||
|
format: column.format
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rows.value.length === 0) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return Object.keys(rows.value[0])
|
||||||
|
.filter((key) => !key.startsWith('@'))
|
||||||
|
.map((key) => ({
|
||||||
|
key,
|
||||||
|
label: key
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
|
||||||
|
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / props.itemsPerPage)))
|
||||||
|
const paginationItems = computed<Array<number | '...'>>(() => {
|
||||||
|
const totalPagesValue = totalPages.value
|
||||||
|
const page = currentPage.value
|
||||||
|
|
||||||
|
if (totalPagesValue <= 7) {
|
||||||
|
return Array.from({ length: totalPagesValue }, (_, index) => index + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
const pages = new Set<number>([1, totalPagesValue, page - 1, page, page + 1])
|
||||||
|
const sortedPages = Array.from(pages)
|
||||||
|
.filter((value) => value >= 1 && value <= totalPagesValue)
|
||||||
|
.sort((a, b) => a - b)
|
||||||
|
|
||||||
|
const items: Array<number | '...'> = []
|
||||||
|
for (let i = 0; i < sortedPages.length; i++) {
|
||||||
|
const value = sortedPages[i]
|
||||||
|
const previousValue = sortedPages[i - 1]
|
||||||
|
if (previousValue != null && value - previousValue > 1) {
|
||||||
|
items.push('...')
|
||||||
|
}
|
||||||
|
items.push(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return items
|
||||||
|
})
|
||||||
|
const pageLabel = computed(() => {
|
||||||
|
if (total.value === 0) {
|
||||||
|
return '0 resultat'
|
||||||
|
}
|
||||||
|
const start = (currentPage.value - 1) * props.itemsPerPage + 1
|
||||||
|
const end = Math.min(currentPage.value * props.itemsPerPage, total.value)
|
||||||
|
return `${start}-${end} sur ${total.value}`
|
||||||
|
})
|
||||||
|
|
||||||
|
// Surveille pagination et filtres pour recharger la liste ; si les filtres changent, revient d'abord à la page 1.
|
||||||
|
watch(
|
||||||
|
() => ({
|
||||||
|
page: currentPage.value,
|
||||||
|
query: props.query,
|
||||||
|
url: props.url,
|
||||||
|
itemsPerPage: props.itemsPerPage
|
||||||
|
}),
|
||||||
|
async (state, previousState) => {
|
||||||
|
const queryChanged = JSON.stringify(state.query ?? {}) !== JSON.stringify(previousState?.query ?? {})
|
||||||
|
|
||||||
|
if (queryChanged && state.page !== 1) {
|
||||||
|
currentPage.value = 1
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await loadPage()
|
||||||
|
},
|
||||||
|
{immediate: true, deep: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Construit la requête, charge les données et normalise la réponse, puis met à jour rows et total
|
||||||
|
async function loadPage(): Promise<void> {
|
||||||
|
loading.value = true
|
||||||
|
|
||||||
|
try {
|
||||||
|
const requestQuery: Record<string, unknown> = {
|
||||||
|
...props.query,
|
||||||
|
page: currentPage.value,
|
||||||
|
itemsPerPage: props.itemsPerPage
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await api.get<AnyCollection<Row> | Row[]>(props.url, requestQuery, {
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/ld+json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (Array.isArray(response)) {
|
||||||
|
rows.value = response
|
||||||
|
total.value = response.length
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const mappedRows = response['hydra:member'] ?? response.member ?? response.items ?? []
|
||||||
|
rows.value = Array.isArray(mappedRows) ? mappedRows : []
|
||||||
|
total.value = Number(response['hydra:totalItems'] ?? response.totalItems ?? rows.value.length)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onRowClick(row: Row): void {
|
||||||
|
emit('rowClick', row)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lit une valeur imbriquée dans une ligne à partir d'un chemin de type "objet.sousObjet.cle".
|
||||||
|
function readPath(source: Row, path: string): unknown {
|
||||||
|
return path.split('.').reduce<unknown>((acc, key) => (acc as Row | undefined)?.[key], source)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formate une valeur brute pour l'affichage dans une cellule (vide, tableau, objet ou valeur simple).
|
||||||
|
function formatCell(value: unknown): string {
|
||||||
|
if (value == null || value === '') return '-'
|
||||||
|
if (Array.isArray(value)) return value.length ? value.map(formatCell).join(', ') : '-'
|
||||||
|
if (typeof value === 'object') {
|
||||||
|
const objectValue = value as Row
|
||||||
|
return String(objectValue.label ?? objectValue.name ?? objectValue.code ?? objectValue.id ?? '[object]')
|
||||||
|
}
|
||||||
|
return String(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Résout la valeur de colonne pour une ligne et applique un formateur personnalisé s'il existe.
|
||||||
|
function formatColumnValue(
|
||||||
|
row: Row,
|
||||||
|
column: { key: string; format?: (value: unknown, row: Row) => string }
|
||||||
|
): string {
|
||||||
|
const value = readPath(row, column.key)
|
||||||
|
if (column.format) {
|
||||||
|
return column.format(value, row)
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatCell(value)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
19
frontend/pages/datatable.vue
Normal file
19
frontend/pages/datatable.vue
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<UiDataTable
|
||||||
|
:columns="columns"
|
||||||
|
url="receptions"
|
||||||
|
:items-per-page="2"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const columns = [
|
||||||
|
{key: 'identificationNumber', label: 'Numero'},
|
||||||
|
{key: 'receptionDate', label: 'Date de livraison'},
|
||||||
|
{key: 'supplier', label: 'Fournisseur'},
|
||||||
|
{key: 'address.fullAddress', label: 'Adresse'},
|
||||||
|
{key: 'receptionType', label: 'Type'},
|
||||||
|
{key: 'weights', label: 'Poids', format: formatWeights}
|
||||||
|
]
|
||||||
|
</script>
|
||||||
|
|
||||||
@@ -1,58 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex items-center justify-start gap-10 mt-16">
|
<div class="flex items-center justify-start gap-10 mt-16">
|
||||||
<Icon @click="router.push('/')" name="gg:arrow-left-o" style="color: black" size="44" class="cursor-pointer"/>
|
<Icon @click="router.push('/')" name="gg:arrow-left-o" style="color: black" size="44" class="cursor-pointer"/>
|
||||||
<h1 class="text-3xl font-bold uppercase">listes des réceptions finie</h1>
|
<h1 class="text-3xl font-bold uppercase">listes des réceptions finie</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="px-[86px]">
|
<UiDataTable
|
||||||
<div class="mt-6 border border-slate-200 mb-16 ">
|
:columns="columns"
|
||||||
<div class="grid grid-cols-6 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
url="receptions"
|
||||||
<div>Numéro</div>
|
:query="{ isValid: true }"
|
||||||
<div>Date</div>
|
@row-click="goToReception"
|
||||||
<div>Fournisseur</div>
|
/>
|
||||||
<div>Adresse</div>
|
|
||||||
<div>Type réception</div>
|
|
||||||
<div>Poids</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="reception in receptionList"
|
|
||||||
:key="reception.id"
|
|
||||||
class="grid grid-cols-6 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
@click="goToReception(reception.id)"
|
|
||||||
>
|
|
||||||
<div>{{ reception.identificationNumber}}</div>
|
|
||||||
<div>{{ reception.receptionDate}}</div>
|
|
||||||
<div>{{ reception.supplier?.name }}</div>
|
|
||||||
<div>{{ reception.address?.fullAddress }}</div>
|
|
||||||
<div>{{ reception.receptionType?.label }}</div>
|
|
||||||
<div>Plein : {{ formatWeighing(reception, 'gross') }} <br> Vide : {{ formatWeighing(reception, 'tare') }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {ReceptionData} from "~/services/dto/reception-data";
|
|
||||||
import {getReceptionList} from "~/services/reception";
|
|
||||||
|
|
||||||
const receptionList = ref<ReceptionData[]>()
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const columns = [
|
||||||
const formatWeighing = (reception: ReceptionData, type: 'gross' | 'tare') => {
|
{key: 'identificationNumber', label: 'Numero'},
|
||||||
const entry = reception.weights?.find((weight) => weight.type === type)
|
{key: 'receptionDate', label: 'Date de livraison'},
|
||||||
if (!entry || entry.weight == null || entry.dsd == null) {
|
{key: 'supplier', label: 'Fournisseur'},
|
||||||
return '—'
|
{key: 'address.fullAddress', label: 'Adresse'},
|
||||||
}
|
{key: 'receptionType', label: 'Type'},
|
||||||
return `${entry.weight} kg`
|
{key: 'weights', label: 'Poids', format: formatWeights}
|
||||||
|
]
|
||||||
|
type ReceptionRow = {
|
||||||
|
id?: number | string
|
||||||
}
|
}
|
||||||
|
const goToReception = (row: ReceptionRow) => {
|
||||||
const goToReception = (id: number) => {
|
const id = Number(row?.id)
|
||||||
|
if (!Number.isFinite(id)) return
|
||||||
router.push(`/reception/update/${id}`)
|
router.push(`/reception/update/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
receptionList.value = await getReceptionList(true)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,44 +4,12 @@
|
|||||||
<h1 class="text-3xl font-bold uppercase">listes des expéditions finie</h1>
|
<h1 class="text-3xl font-bold uppercase">listes des expéditions finie</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="px-[86px]">
|
<UiDataTable
|
||||||
<div class="mt-6 border border-slate-200 mb-16 ">
|
:columns="columns"
|
||||||
<div class="grid grid-cols-6 gap-4 bg-slate-100 px-4 py-3 text-sm font-semibold uppercase tracking-wide">
|
url="shipments"
|
||||||
<div>Numéro</div>
|
:query="{ isValid: true }"
|
||||||
<div>Date</div>
|
@row-click="goToShipment"
|
||||||
<div>Client</div>
|
/>
|
||||||
<div>Adresse</div>
|
|
||||||
<div>Type d'expéditon</div>
|
|
||||||
<div>Poids</div>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
v-for="shipment in shipmentList"
|
|
||||||
:key="shipment
|
|
||||||
.id"
|
|
||||||
class="grid grid-cols-6 gap-4 px-4 py-3 text-sm hover:bg-slate-50 cursor-pointer border-t border-slate-200"
|
|
||||||
role="button"
|
|
||||||
tabindex="0"
|
|
||||||
@click="goShipment(shipment.id)"
|
|
||||||
>
|
|
||||||
<div>{{ shipment.identificationNumber }}</div>
|
|
||||||
<div>{{ shipment.shipmentDate }}</div>
|
|
||||||
<div>{{ shipment.customer?.name }}</div>
|
|
||||||
<div>{{ shipment.address?.fullAddress }}</div>
|
|
||||||
<div>
|
|
||||||
<template v-if="formatBovinShipmentLines(shipment).length">
|
|
||||||
<div
|
|
||||||
v-for="(line, index) in formatBovinShipmentLines(shipment)"
|
|
||||||
:key="index"
|
|
||||||
class="leading-5"
|
|
||||||
>
|
|
||||||
{{ line }}
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
<div>Vide : {{ formatWeighing(shipment, 'tare') }} <br> Plein :{{ formatWeighing(shipment, 'gross') }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@@ -50,32 +18,20 @@ import {getShipmentList} from "~/services/shipment";
|
|||||||
|
|
||||||
const shipmentList = ref<ShipmentData[]>()
|
const shipmentList = ref<ShipmentData[]>()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const columns = [
|
||||||
const formatWeighing = (shipment: ShipmentData, type: 'gross' | 'tare') => {
|
{key: 'identificationNumber', label: 'Numero'},
|
||||||
const entry = shipment.weights?.find((weight) => weight.type === type)
|
{key: 'shipmentDate', label: 'Date de livraison'},
|
||||||
if (!entry || entry.weight == null || entry.dsd == null) {
|
{key: 'customer', label: 'Client'},
|
||||||
return '—'
|
{key: 'address.fullAddress', label: 'Adresse'},
|
||||||
}
|
{key: 'bovinShipments', label: 'Type', format:formatBovinShipments},
|
||||||
return `${entry.weight} kg`
|
{key: 'weights', label: 'Poids', format: formatWeights}
|
||||||
|
]
|
||||||
|
type ReceptionRow = {
|
||||||
|
id?: number | string
|
||||||
}
|
}
|
||||||
|
const goToShipment = (row: ReceptionRow) => {
|
||||||
const formatBovinShipmentLines = (shipment: ShipmentData) => {
|
const id = Number(row?.id)
|
||||||
if (!shipment.bovinShipments?.length) {
|
if (!Number.isFinite(id)) return
|
||||||
return []
|
|
||||||
}
|
|
||||||
return shipment.bovinShipments.map((entry) => {
|
|
||||||
const label = typeof entry.shipmentType === 'string'
|
|
||||||
? entry.shipmentType
|
|
||||||
: entry.shipmentType?.label
|
|
||||||
return `${label ?? '—'} : ${entry.nbBovinSend ?? '—'}`
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const goShipment = (id: number) => {
|
|
||||||
router.push(`/shipment/update/${id}`)
|
router.push(`/shipment/update/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
shipmentList.value = await getShipmentList(true)
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
41
frontend/utils/datatable-formatters.ts
Normal file
41
frontend/utils/datatable-formatters.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
export const formatBovinShipments = (value: unknown): string => {
|
||||||
|
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||||
|
return value.map((item: any) => {
|
||||||
|
const label = item?.shipmentType?.label ?? item?.shipmentType?.code ??
|
||||||
|
'Type inconnu'
|
||||||
|
const qty = item?.nbBovinSend ?? '-'
|
||||||
|
return `${label} (${qty})`
|
||||||
|
}).join(', ')
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatWeights = (value: unknown): string => {
|
||||||
|
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||||
|
|
||||||
|
return value
|
||||||
|
.map((item: any) => {
|
||||||
|
const type = item?.type === 'tare'
|
||||||
|
? 'Poids à vide'
|
||||||
|
: item?.type === 'gross'
|
||||||
|
? 'Poids à plein'
|
||||||
|
: (item?.type ?? 'Poids')
|
||||||
|
|
||||||
|
const weight = item?.weight ?? '-'
|
||||||
|
return `${type}: ${weight}`
|
||||||
|
})
|
||||||
|
.join(', ')
|
||||||
|
}
|
||||||
|
|
||||||
|
export const formatPelletBuildings = (value: unknown): string => {
|
||||||
|
if (!Array.isArray(value) || value.length === 0) return '-'
|
||||||
|
|
||||||
|
return value
|
||||||
|
.map((item: any) => {
|
||||||
|
const pelletLabel =
|
||||||
|
item?.pelletType?.label ?? item?.pelletType?.code ?? 'Granule inconnu'
|
||||||
|
const buildingLabel =
|
||||||
|
item?.building?.label ?? item?.building?.code ?? 'Bâtiment inconnu'
|
||||||
|
|
||||||
|
return `${pelletLabel} : ${buildingLabel}`
|
||||||
|
})
|
||||||
|
.join('\n')
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user