major claude changes
This commit is contained in:
@@ -157,173 +157,164 @@
|
||||
<Footer />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue'
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import axios from 'axios'
|
||||
import authHeader from '../../../services/auth.header'
|
||||
import { Delivery } from '../../../types/models'
|
||||
import Header from '../../../layouts/headers/headerauth.vue'
|
||||
import PaginationComp from '../../../components/pagination.vue'
|
||||
import SideBar from '../../../layouts/sidebar/sidebar.vue'
|
||||
import Footer from '../../../layouts/footers/footer.vue'
|
||||
import { notify } from "@kyvg/vue3-notification";
|
||||
|
||||
export default defineComponent({
|
||||
name: 'deliveryOutForDelivery',
|
||||
interface TownTotal {
|
||||
town: string;
|
||||
gallons: number;
|
||||
}
|
||||
|
||||
components: {
|
||||
Header,
|
||||
SideBar,
|
||||
Footer,
|
||||
},
|
||||
// Reactive data
|
||||
const token = ref(null)
|
||||
const user = ref(null)
|
||||
const deliveries = ref<Delivery[]>([])
|
||||
const totals = ref<TownTotal[]>([])
|
||||
const grand_total = ref(0)
|
||||
const page = ref(1)
|
||||
const perPage = ref(50)
|
||||
const recordsLength = ref(0)
|
||||
const options = ref({
|
||||
edgeNavigation: false,
|
||||
format: false,
|
||||
template: PaginationComp
|
||||
})
|
||||
|
||||
data() {
|
||||
return {
|
||||
token: null,
|
||||
user: null,
|
||||
deliveries: [] as any[],
|
||||
totals: [] as any[],
|
||||
grand_total: 0,
|
||||
page: 1,
|
||||
perPage: 50,
|
||||
recordsLength: 0,
|
||||
options: {
|
||||
edgeNavigation: false,
|
||||
format: false,
|
||||
template: PaginationComp
|
||||
// Functions
|
||||
const getPage = (pageVal: any) => {
|
||||
deliveries.value = [];
|
||||
get_oil_orders(pageVal)
|
||||
}
|
||||
|
||||
const userStatus = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
user.value = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
user.value = null
|
||||
})
|
||||
}
|
||||
|
||||
const get_oil_orders = (pageVal: any) => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/delivery/tommorrow/' + pageVal;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
deliveries.value = response.data
|
||||
})
|
||||
}
|
||||
|
||||
const get_totals = () => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/deliverystatus/tomorrow-totals';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
totals.value = response.data.totals || []
|
||||
grand_total.value = response.data.grand_total || 0
|
||||
}).catch((error: any) => {
|
||||
console.error('Error fetching totals:', error);
|
||||
totals.value = []
|
||||
grand_total.value = 0
|
||||
})
|
||||
}
|
||||
|
||||
const deleteCall = (delivery_id: any) => {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/delivery/delete/' + delivery_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "deleted delivery",
|
||||
type: "success",
|
||||
});
|
||||
getPage(page.value)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error deleting delivery",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.userStatus()
|
||||
},
|
||||
mounted() {
|
||||
this.getPage(this.page)
|
||||
this.get_totals()
|
||||
},
|
||||
methods: {
|
||||
getPage: function (page: any) {
|
||||
this.deliveries = [];
|
||||
this.get_oil_orders(page)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
userStatus() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/auth/whoami';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
withCredentials: true,
|
||||
headers: authHeader(),
|
||||
})
|
||||
.then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
this.user = response.data.user;
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.user = null
|
||||
})
|
||||
},
|
||||
get_oil_orders(page: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/delivery/tommorrow/' + page;
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.deliveries = response.data
|
||||
})
|
||||
},
|
||||
|
||||
get_totals() {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/deliverystatus/tomorrow-totals';
|
||||
axios({
|
||||
method: 'get',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
this.totals = response.data.totals || []
|
||||
this.grand_total = response.data.grand_total || 0
|
||||
}).catch((error: any) => {
|
||||
console.error('Error fetching totals:', error);
|
||||
this.totals = []
|
||||
this.grand_total = 0
|
||||
})
|
||||
},
|
||||
|
||||
deleteCall(delivery_id: any) {
|
||||
let path = import.meta.env.VITE_BASE_URL + '/delivery/delete/' + delivery_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "deleted delivery",
|
||||
type: "success",
|
||||
});
|
||||
this.getPage(this.page)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error deleting delivery",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
printtTicketAll() {
|
||||
let path = import.meta.env.VITE_PRINT_URL + '/command/printticket/print_tommorrow';
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "Sent to Printer",
|
||||
type: "success",
|
||||
});
|
||||
this.getPage(this.page)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error printing",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
printTicket(delivery_id: number) {
|
||||
let path = import.meta.env.VITE_PRINT_URL + '/command/printticket/' + delivery_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "Sent to Printer",
|
||||
type: "success",
|
||||
});
|
||||
this.getPage(this.page)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error printing",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
const printtTicketAll = () => {
|
||||
let path = import.meta.env.VITE_PRINT_URL + '/command/printticket/print_tommorrow';
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "Sent to Printer",
|
||||
type: "success",
|
||||
});
|
||||
getPage(page.value)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error printing",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const printTicket = (delivery_id: number) => {
|
||||
let path = import.meta.env.VITE_PRINT_URL + '/command/printticket/' + delivery_id;
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: path,
|
||||
headers: authHeader(),
|
||||
}).then((response: any) => {
|
||||
if (response.data.ok) {
|
||||
notify({
|
||||
title: "Success",
|
||||
text: "Sent to Printer",
|
||||
type: "success",
|
||||
});
|
||||
getPage(page.value)
|
||||
} else {
|
||||
notify({
|
||||
title: "Failure",
|
||||
text: "error printing",
|
||||
type: "success",
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Lifecycle
|
||||
onMounted(() => {
|
||||
userStatus()
|
||||
getPage(page.value)
|
||||
get_totals()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user