Add vehicle management features in Falukant

- Introduced vehicle types and transport management in the backend, including new models and associations for vehicles and transports.
- Implemented service methods to retrieve vehicle types and handle vehicle purchases, ensuring user validation and transaction management.
- Updated the FalukantController and router to expose new endpoints for fetching vehicle types and buying vehicles.
- Enhanced the frontend with a new transport tab in BranchView, allowing users to buy vehicles, and added localization for vehicle-related terms.
- Included initialization logic for vehicle types in the database setup.
This commit is contained in:
Torsten Schulz (local)
2025-11-24 20:15:45 +01:00
parent 5ed27e5a6a
commit 3f043fc315
14 changed files with 544 additions and 12 deletions

View File

@@ -51,7 +51,21 @@
<div v-else-if="activeTab === 'storage'" class="branch-tab-pane">
<StorageSection :branchId="selectedBranch.id" ref="storageSection" />
</div>
<!-- Transportmittel -->
<div v-else-if="activeTab === 'transport'" class="branch-tab-pane">
<p>{{ $t('falukant.branch.transport.placeholder') }}</p>
<button @click="openBuyVehicleDialog">
{{ $t('falukant.branch.transport.buy') }}
</button>
</div>
</div>
<BuyVehicleDialog
v-if="selectedBranch"
ref="buyVehicleDialog"
:region-id="selectedBranch?.regionId"
@bought="handleVehiclesBought"
/>
</div>
</div>
</template>
@@ -65,6 +79,7 @@ import SaleSection from '@/components/falukant/SaleSection.vue';
import ProductionSection from '@/components/falukant/ProductionSection.vue';
import StorageSection from '@/components/falukant/StorageSection.vue';
import RevenueSection from '@/components/falukant/RevenueSection.vue';
import BuyVehicleDialog from '@/dialogues/falukant/BuyVehicleDialog.vue';
import apiClient from '@/utils/axios.js';
import { mapState } from 'vuex';
@@ -79,8 +94,9 @@ export default {
ProductionSection,
StorageSection,
RevenueSection,
BuyVehicleDialog,
},
data() {
return {
branches: [],
@@ -92,6 +108,7 @@ export default {
{ value: 'inventory', label: 'falukant.branch.tabs.inventory' },
{ value: 'director', label: 'falukant.branch.tabs.director' },
{ value: 'storage', label: 'falukant.branch.tabs.storage' },
{ value: 'transport', label: 'falukant.branch.tabs.transport' },
],
};
},
@@ -155,6 +172,7 @@ export default {
const result = await apiClient.get('/api/falukant/branches');
this.branches = result.data.map(branch => ({
id: branch.id,
regionId: branch.regionId,
cityName: branch.region.name,
type: this.$t(`falukant.branch.types.${branch.branchType.labelTr}`),
isMainBranch: branch.isMainBranch,
@@ -325,6 +343,16 @@ export default {
console.error('Error processing daemon message:', error);
}
},
openBuyVehicleDialog() {
if (!this.selectedBranch) return;
this.$refs.buyVehicleDialog?.open();
},
handleVehiclesBought() {
// Refresh status bar (for updated money) and potentially other data later
this.$refs.statusBar?.fetchStatus();
},
},
};
</script>
@@ -333,4 +361,4 @@ export default {
h2 {
padding-top: 20px;
}
</style>
</style>