Updated auto

This commit is contained in:
2024-07-24 17:24:40 -04:00
parent 74fcd282db
commit 47e57f5758
3 changed files with 123 additions and 31 deletions

View File

@@ -25,6 +25,23 @@
<div class="pl-10">1.50 = large oil usage</div>
<div class="pl-10"> 1.00 = medium oil usage</div>
<div class="pl-10">0.50 = small oil usage</div>
<form class="col-span-12 rounded-md px-8 pt-6 pb-8 mb-4 w-full" enctype="multipart/form-data"
@submit.prevent="get_auto_assignment">
<div class="flex-1 mb-4">
<label class="block text-white text-sm font-bold mb-2">Delivery Driver </label>
<select class="select select-bordered select-sm w-full max-w-xs" aria-label="Default select example"
id="customer_state" v-model="CreateOilOrderForm.basicInfo.driver_driver">
<option class="text-white" v-for="(driver, index) in truckDriversList" :key="index"
:value="driver['id']">
{{ driver['employee_first_name'] }} {{ driver['employee_last_name'] }}
</option>
</select>
</div>
<button class="btn btn-accent btn-sm">
Send for delivery
</button>
</form>
</div>
<div class="overflow-x-auto bg-neutral">
@@ -32,8 +49,9 @@
<!-- head -->
<thead>
<tr>
<th>Estimated Gallons Left</th>
<th></th>
<th>Gallons Left</th>
<th>Status</th>
<th>Name</th>
<th>Town</th>
<th>Address</th>
@@ -45,14 +63,22 @@
<!-- row 1 -->
<tr v-for="oil in deliveries" :key="oil['id']">
<td>
<input type="checkbox" :value="oil['id']" v-model="checkedMaterials">
</td>
<td>{{ oil['estimated_gallons_left'] }}</td>
<td>
<div v-if="oil['auto_status'] === 0"></div>
<div v-else-if="oil['auto_status'] === 1">Waiting on Delivery</div>
<div v-else></div>
</td>
<td>{{ oil['customer_full_name'] }}</td>
<td>{{ oil['customer_town'] }}</td>
<td>{{ oil['customer_address'] }}</td>
<td>{{ oil['last_fill'] }} </td>
<td>{{ oil['house_factor'] }}</td>
<td class="flex gap-5">
<router-link :to="{ name: 'customerEdit', params: { id: oil['customer_id'] } }">
<button class="btn btn-accent btn-sm">
Edit
@@ -97,19 +123,27 @@ export default defineComponent({
token: null,
user: null,
deliveries: [],
checkedMaterials: [],
truckDriversList: [],
CreateOilOrderForm: {
basicInfo: {
driver_driver: '',
},
},
}
},
created() {
this.userStatus()
this.getDriversList()
},
mounted() {
this.get_oil_orders()
},
methods: {
userStatus() {
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
axios({
@@ -140,6 +174,50 @@ export default defineComponent({
})
},
getDriversList() {
let path = import.meta.env.VITE_BASE_URL + "/employee/drivers";
axios({
method: "get",
url: path,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
this.truckDriversList = response.data;
})
.catch(() => {
});
},
get_auto_assignment() {
let path = import.meta.env.VITE_AUTO_URL + '/delivery/create/delivery';
const selectedValues : any[] = [];
for (const id in this.checkedMaterials) {
if (this.checkedMaterials[id]) {
selectedValues.push(this.checkedMaterials[id]);
}
}
let payload = {
driver_employee_id: this.CreateOilOrderForm.basicInfo.driver_driver,
values: selectedValues
}
axios({
method: 'post',
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
}).then((response: any) => {
this.get_oil_orders()
})
},
},
})
</script>

View File

@@ -632,8 +632,46 @@ export default defineComponent({
}
})
},
UpdateAuto(payload: {
gallons: string,
delivery_id: string,
}) {
let path = import.meta.env.VITE_AUTO_URL + "/delivery/add/delivery"
axios({
method: "put",
url: path,
data: payload,
withCredentials: true,
headers: authHeader(),
})
.then((response: any) => {
if (response.data.ok) {
notify({
text: 'Update',
type: 'postive',
title: 'top'
})
}
else {
notify({
text: 'Auto Failure',
type: 'negative',
title: 'Update'
})
}
})
},
onSubmit() {
if (this.deliveryOrder.automatic == 1){
let auto_payload = {
gallons: this.CreateOilOrderForm.basicInfo.gallons_delivered,
delivery_id: this.deliveryOrder.id
}
this.UpdateAuto(auto_payload);
}
let payload = {
gallons_delivered: this.CreateOilOrderForm.basicInfo.gallons_delivered,
prime: this.CreateOilOrderForm.basicInfo.prime,

View File

@@ -154,7 +154,6 @@ export default defineComponent({
.then((response: any) => {
this.automatic = response.data;
this.getCustomer(response.data.customer_id);
this.sumdelivery(this.$route.params.id);
})
.catch(() => {
@@ -167,29 +166,6 @@ export default defineComponent({
},
sumdelivery(delivery_id: any) {
let path = import.meta.env.VITE_BASE_URL + "/delivery/total/" + delivery_id;
axios({
method: "get",
url: path,
withCredentials: true,
})
.then((response: any) => {
if (response.data.ok) {
this.priceprime = response.data.priceprime;
this.pricesameday = response.data.pricesameday;
this.total_amount = response.data.total_amount;
}
})
.catch(() => {
notify({
title: "Error",
text: "Could not get oil pricing",
type: "error",
});
});
},
getCustomer(userid: any) {
let path = import.meta.env.VITE_BASE_URL + '/customer/' + userid;
axios({