Initial commit: Shop Database Flask Application

Flask backend with Vue 3 frontend for shop floor machine management.
Includes database schema export for MySQL shopdb_flask database.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-01-13 16:07:34 -05:00
commit 1196de6e88
188 changed files with 19921 additions and 0 deletions

View File

@@ -0,0 +1,322 @@
<template>
<div>
<div class="page-header">
<h2>Vendors</h2>
<button class="btn btn-primary" @click="openModal()">+ Add Vendor</button>
</div>
<!-- Filters -->
<div class="filters">
<input
v-model="search"
type="text"
class="form-control"
placeholder="Search vendors..."
@input="debouncedSearch"
/>
</div>
<div class="card">
<div v-if="loading" class="loading">Loading...</div>
<template v-else>
<div class="table-container">
<table>
<thead>
<tr>
<th>Vendor Name</th>
<th>Contact</th>
<th>Phone</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="vendor in vendors" :key="vendor.vendorid">
<td>{{ vendor.vendor }}</td>
<td>{{ vendor.contact || '-' }}</td>
<td>{{ vendor.phone || '-' }}</td>
<td>{{ vendor.email || '-' }}</td>
<td class="actions">
<button
class="btn btn-secondary btn-sm"
@click="openModal(vendor)"
>
Edit
</button>
<button
class="btn btn-danger btn-sm"
@click="confirmDelete(vendor)"
>
Delete
</button>
</td>
</tr>
<tr v-if="vendors.length === 0">
<td colspan="5" style="text-align: center; color: var(--text-light);">
No vendors found
</td>
</tr>
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="pagination" v-if="totalPages > 1">
<button
v-for="p in totalPages"
:key="p"
:class="{ active: p === page }"
@click="goToPage(p)"
>
{{ p }}
</button>
</div>
</template>
</div>
<!-- Add/Edit Modal -->
<div v-if="showModal" class="modal-overlay" @click.self="closeModal">
<div class="modal">
<div class="modal-header">
<h3>{{ editingVendor ? 'Edit Vendor' : 'Add Vendor' }}</h3>
</div>
<form @submit.prevent="saveVendor">
<div class="modal-body">
<div class="form-group">
<label for="vendor">Vendor Name *</label>
<input
id="vendor"
v-model="form.vendor"
type="text"
class="form-control"
required
/>
</div>
<div class="form-group">
<label for="contact">Contact Person</label>
<input
id="contact"
v-model="form.contact"
type="text"
class="form-control"
/>
</div>
<div class="form-group">
<label for="phone">Phone</label>
<input
id="phone"
v-model="form.phone"
type="text"
class="form-control"
/>
</div>
<div class="form-group">
<label for="email">Email</label>
<input
id="email"
v-model="form.email"
type="email"
class="form-control"
/>
</div>
<div class="form-group">
<label for="address">Address</label>
<textarea
id="address"
v-model="form.address"
class="form-control"
rows="2"
></textarea>
</div>
<div class="form-group">
<label for="website">Website</label>
<input
id="website"
v-model="form.website"
type="url"
class="form-control"
/>
</div>
<div class="form-group">
<label for="notes">Notes</label>
<textarea
id="notes"
v-model="form.notes"
class="form-control"
rows="2"
></textarea>
</div>
<div v-if="error" class="error-message">{{ error }}</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" @click="closeModal">Cancel</button>
<button type="submit" class="btn btn-primary" :disabled="saving">
{{ saving ? 'Saving...' : 'Save' }}
</button>
</div>
</form>
</div>
</div>
<!-- Delete Confirmation Modal -->
<div v-if="showDeleteModal" class="modal-overlay" @click.self="showDeleteModal = false">
<div class="modal">
<div class="modal-header">
<h3>Delete Vendor</h3>
</div>
<div class="modal-body">
<p>Are you sure you want to delete <strong>{{ vendorToDelete?.vendor }}</strong>?</p>
<p style="color: var(--text-light); font-size: 0.875rem;">This action cannot be undone.</p>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" @click="showDeleteModal = false">Cancel</button>
<button class="btn btn-danger" @click="deleteVendor">Delete</button>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { vendorsApi } from '../../api'
const vendors = ref([])
const loading = ref(true)
const search = ref('')
const page = ref(1)
const totalPages = ref(1)
const showModal = ref(false)
const editingVendor = ref(null)
const saving = ref(false)
const error = ref('')
const showDeleteModal = ref(false)
const vendorToDelete = ref(null)
const form = ref({
vendor: '',
contact: '',
phone: '',
email: '',
address: '',
website: '',
notes: ''
})
let searchTimeout = null
onMounted(() => {
loadVendors()
})
async function loadVendors() {
loading.value = true
try {
const params = {
page: page.value,
perpage: 20
}
if (search.value) params.search = search.value
const response = await vendorsApi.list(params)
vendors.value = response.data.data || []
totalPages.value = response.data.meta?.pages || 1
} catch (err) {
console.error('Error loading vendors:', err)
} finally {
loading.value = false
}
}
function debouncedSearch() {
clearTimeout(searchTimeout)
searchTimeout = setTimeout(() => {
page.value = 1
loadVendors()
}, 300)
}
function goToPage(p) {
page.value = p
loadVendors()
}
function openModal(vendor = null) {
editingVendor.value = vendor
if (vendor) {
form.value = {
vendor: vendor.vendor || '',
contact: vendor.contact || '',
phone: vendor.phone || '',
email: vendor.email || '',
address: vendor.address || '',
website: vendor.website || '',
notes: vendor.notes || ''
}
} else {
form.value = {
vendor: '',
contact: '',
phone: '',
email: '',
address: '',
website: '',
notes: ''
}
}
error.value = ''
showModal.value = true
}
function closeModal() {
showModal.value = false
editingVendor.value = null
}
async function saveVendor() {
error.value = ''
saving.value = true
try {
if (editingVendor.value) {
await vendorsApi.update(editingVendor.value.vendorid, form.value)
} else {
await vendorsApi.create(form.value)
}
closeModal()
loadVendors()
} catch (err) {
console.error('Error saving vendor:', err)
error.value = err.response?.data?.message || 'Failed to save vendor'
} finally {
saving.value = false
}
}
function confirmDelete(vendor) {
vendorToDelete.value = vendor
showDeleteModal.value = true
}
async function deleteVendor() {
try {
await vendorsApi.delete(vendorToDelete.value.vendorid)
showDeleteModal.value = false
vendorToDelete.value = null
loadVendors()
} catch (err) {
console.error('Error deleting vendor:', err)
alert('Failed to delete vendor')
}
}
</script>