Initial commit with contrats and domaines modules
This commit is contained in:
37
resources/js/Pages/Articles/Create.vue
Normal file
37
resources/js/Pages/Articles/Create.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
|
||||
const props = defineProps({ categories: Array, fournisseurs: Array })
|
||||
const form = useForm({ reference: '', designation: '', description: '', categorie_id: '', fournisseur_id: '', prix_unitaire_ht: '', unite: 'unité' })
|
||||
function submit() { form.post(route('articles.store')) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Nouvel article" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link :href="route('articles.index')" class="text-gray-400 hover:text-gray-600"><svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg></Link>
|
||||
<h1 class="text-xl font-semibold text-gray-900">Nouvel article</h1>
|
||||
</div>
|
||||
</template>
|
||||
<form @submit.prevent="submit" class="max-w-2xl space-y-6">
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Désignation *</label><input v-model="form.designation" type="text" required class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Référence</label><input v-model="form.reference" type="text" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Catégorie</label><select v-model="form.categorie_id" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"><option value="">—</option><option v-for="c in categories" :key="c.id" :value="c.id">{{ c.nom }}</option></select></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Fournisseur</label><select v-model="form.fournisseur_id" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"><option value="">—</option><option v-for="f in fournisseurs" :key="f.id" :value="f.id">{{ f.nom }}</option></select></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Prix HT</label><input v-model="form.prix_unitaire_ht" type="number" min="0" step="0.01" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Unité</label><input v-model="form.unite" type="text" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Description</label><textarea v-model="form.description" rows="2" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3">
|
||||
<Link :href="route('articles.index')" class="rounded-lg border border-gray-300 px-5 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors">Annuler</Link>
|
||||
<button type="submit" :disabled="form.processing" class="rounded-lg bg-blue-600 px-5 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50 transition-colors">{{ form.processing ? '...' : 'Créer' }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
43
resources/js/Pages/Articles/Edit.vue
Normal file
43
resources/js/Pages/Articles/Edit.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import { Head, Link, useForm } from '@inertiajs/vue3'
|
||||
|
||||
const props = defineProps({ article: Object, categories: Array, fournisseurs: Array })
|
||||
const form = useForm({
|
||||
reference: props.article.reference ?? '', designation: props.article.designation,
|
||||
description: props.article.description ?? '', categorie_id: props.article.categorie_id ?? '',
|
||||
fournisseur_id: props.article.fournisseur_id ?? '', prix_unitaire_ht: props.article.prix_unitaire_ht ?? '',
|
||||
unite: props.article.unite, active: props.article.active,
|
||||
})
|
||||
function submit() { form.put(route('articles.update', props.article.id)) }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="`Modifier — ${article.designation}`" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center gap-3">
|
||||
<Link :href="route('articles.index')" class="text-gray-400 hover:text-gray-600"><svg class="h-5 w-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" /></svg></Link>
|
||||
<h1 class="text-xl font-semibold text-gray-900">Modifier {{ article.designation }}</h1>
|
||||
</div>
|
||||
</template>
|
||||
<form @submit.prevent="submit" class="max-w-2xl space-y-6">
|
||||
<div class="rounded-xl bg-white p-6 shadow-sm border border-gray-100">
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Désignation *</label><input v-model="form.designation" type="text" required class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Référence</label><input v-model="form.reference" type="text" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Catégorie</label><select v-model="form.categorie_id" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"><option value="">—</option><option v-for="c in categories" :key="c.id" :value="c.id">{{ c.nom }}</option></select></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Fournisseur</label><select v-model="form.fournisseur_id" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none"><option value="">—</option><option v-for="f in fournisseurs" :key="f.id" :value="f.id">{{ f.nom }}</option></select></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Prix HT</label><input v-model="form.prix_unitaire_ht" type="number" min="0" step="0.01" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div><label class="block text-sm font-medium text-gray-700">Unité</label><input v-model="form.unite" type="text" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div class="sm:col-span-2"><label class="block text-sm font-medium text-gray-700">Description</label><textarea v-model="form.description" rows="2" class="mt-1 block w-full rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" /></div>
|
||||
<div class="flex items-center gap-2"><input v-model="form.active" type="checkbox" id="active" class="rounded border-gray-300 text-blue-600 focus:ring-blue-500" /><label for="active" class="text-sm font-medium text-gray-700">Article actif</label></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-3">
|
||||
<Link :href="route('articles.index')" class="rounded-lg border border-gray-300 px-5 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 transition-colors">Annuler</Link>
|
||||
<button type="submit" :disabled="form.processing" class="rounded-lg bg-blue-600 px-5 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50 transition-colors">{{ form.processing ? '...' : 'Enregistrer' }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
73
resources/js/Pages/Articles/Index.vue
Normal file
73
resources/js/Pages/Articles/Index.vue
Normal file
@@ -0,0 +1,73 @@
|
||||
<script setup>
|
||||
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
||||
import Pagination from '@/Components/Pagination.vue'
|
||||
import { Head, Link, router } from '@inertiajs/vue3'
|
||||
import { reactive } from 'vue'
|
||||
|
||||
const props = defineProps({ articles: Object, categories: Array, filters: Object })
|
||||
const filters = reactive({ ...props.filters })
|
||||
|
||||
function applyFilters() {
|
||||
router.get(route('articles.index'), filters, { preserveState: true, replace: true })
|
||||
}
|
||||
|
||||
function formatCurrency(v) {
|
||||
if (v == null) return '—'
|
||||
return new Intl.NumberFormat('fr-FR', { style: 'currency', currency: 'EUR' }).format(v)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Articles" />
|
||||
<AuthenticatedLayout>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h1 class="text-xl font-semibold text-gray-900">Articles</h1>
|
||||
<Link :href="route('articles.create')" class="rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 transition-colors">+ Ajouter</Link>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="space-y-4">
|
||||
<div class="rounded-xl bg-white p-4 shadow-sm border border-gray-100 flex gap-3">
|
||||
<input v-model="filters.search" @input="applyFilters" type="text" placeholder="Recherche désignation, référence..." class="flex-1 rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none" />
|
||||
<select v-model="filters.categorie_id" @change="applyFilters" class="rounded-lg border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none">
|
||||
<option value="">Toutes catégories</option>
|
||||
<option v-for="c in categories" :key="c.id" :value="c.id">{{ c.nom }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="rounded-xl bg-white shadow-sm border border-gray-100 overflow-hidden">
|
||||
<table class="min-w-full divide-y divide-gray-100 text-sm">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Désignation</th>
|
||||
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Référence</th>
|
||||
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Catégorie</th>
|
||||
<th class="px-5 py-3 text-left text-xs font-medium text-gray-500 uppercase">Fournisseur</th>
|
||||
<th class="px-5 py-3 text-right text-xs font-medium text-gray-500 uppercase">Prix HT</th>
|
||||
<th class="px-5 py-3 text-center text-xs font-medium text-gray-500 uppercase">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-50">
|
||||
<tr v-for="art in articles.data" :key="art.id" :class="['hover:bg-gray-50', !art.active ? 'opacity-60' : '']">
|
||||
<td class="px-5 py-3 font-medium text-gray-900">{{ art.designation }}</td>
|
||||
<td class="px-5 py-3 text-gray-500">{{ art.reference || '—' }}</td>
|
||||
<td class="px-5 py-3 text-gray-500">{{ art.categorie?.nom || '—' }}</td>
|
||||
<td class="px-5 py-3 text-gray-500">{{ art.fournisseur?.nom || '—' }}</td>
|
||||
<td class="px-5 py-3 text-right text-gray-900">{{ formatCurrency(art.prix_unitaire_ht) }}</td>
|
||||
<td class="px-5 py-3 text-center">
|
||||
<Link :href="route('articles.edit', art.id)" class="text-gray-400 hover:text-indigo-600 transition-colors">
|
||||
<svg class="h-4 w-4 inline" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div v-if="!articles.data.length" class="py-10 text-center text-gray-400">Aucun article.</div>
|
||||
<div class="border-t border-gray-100 px-5 py-3">
|
||||
<Pagination :links="articles.links" :meta="articles.meta" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
</template>
|
||||
Reference in New Issue
Block a user