improved some bugs
This commit is contained in:
@@ -169,53 +169,27 @@ export default {
|
||||
return hoursEntries.value.map(e => e.userId).filter(id => id !== null);
|
||||
});
|
||||
|
||||
// Initialize
|
||||
onMounted(async () => {
|
||||
await Promise.all([
|
||||
loadUserCar(),
|
||||
loadAllCars(),
|
||||
loadHourTypes()
|
||||
]);
|
||||
await loadInitializationData();
|
||||
detectGPS();
|
||||
});
|
||||
|
||||
// Load user's assigned car
|
||||
const loadUserCar = async () => {
|
||||
const loadInitializationData = async () => {
|
||||
try {
|
||||
const data = await shippingNoteApi.get(`getUserCar?userId=${props.user?.id}`);
|
||||
if (data.success && data.car) {
|
||||
userCar.value = data.car;
|
||||
if (hoursEntries.value[0]) {
|
||||
hoursEntries.value[0].carId = data.car.id;
|
||||
hoursEntries.value[0].carName = data.car.name;
|
||||
const data = await shippingNoteApi.get('initialize');
|
||||
if (data.success) {
|
||||
if (data.userCar) {
|
||||
userCar.value = data.userCar;
|
||||
if (hoursEntries.value[0]) {
|
||||
hoursEntries.value[0].carId = data.userCar.id;
|
||||
hoursEntries.value[0].carName = data.userCar.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load user car:', e);
|
||||
}
|
||||
};
|
||||
|
||||
// Load all available cars
|
||||
const loadAllCars = async () => {
|
||||
try {
|
||||
const data = await shippingNoteApi.get('getAllCars');
|
||||
if (data.success) {
|
||||
allCars.value = data.cars || [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load cars:', e);
|
||||
}
|
||||
};
|
||||
|
||||
// Load hour types
|
||||
const loadHourTypes = async () => {
|
||||
try {
|
||||
const data = await shippingNoteApi.get('getHourTypes');
|
||||
if (data.success) {
|
||||
allCars.value = data.allCars || [];
|
||||
hourTypes.value = data.hourTypes || [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Failed to load hour types:', e);
|
||||
console.error('Failed to load initialization data:', e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user