From 2699040f0e6d9a4350f08f35361ac912bed17401 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Fri, 12 Apr 2024 16:50:41 -0300 Subject: [PATCH] Item request view --- src/composables/getDateQBadgeColor.js | 11 ++++++++ src/pages/Item/ItemRequest.vue | 36 +++++++++++---------------- src/pages/Travel/TravelList.vue | 13 +--------- 3 files changed, 26 insertions(+), 34 deletions(-) create mode 100644 src/composables/getDateQBadgeColor.js diff --git a/src/composables/getDateQBadgeColor.js b/src/composables/getDateQBadgeColor.js new file mode 100644 index 000000000..be9ef41b5 --- /dev/null +++ b/src/composables/getDateQBadgeColor.js @@ -0,0 +1,11 @@ +export function getDateQBadgeColor(date) { + let today = Date.vnNew(); + today.setHours(0, 0, 0, 0); + let timeTicket = new Date(date); + timeTicket.setHours(0, 0, 0, 0); + + let comparation = today - timeTicket; + + if (comparation == 0) return 'warning'; + if (comparation < 0) return 'negative'; +} diff --git a/src/pages/Item/ItemRequest.vue b/src/pages/Item/ItemRequest.vue index 8778d8f6a..dbf1a03c2 100644 --- a/src/pages/Item/ItemRequest.vue +++ b/src/pages/Item/ItemRequest.vue @@ -12,6 +12,7 @@ import ItemRequestDenyForm from './ItemRequestDenyForm.vue'; import { toDateFormat } from 'src/filters/date'; import { toCurrency } from 'filters/index'; import useNotify from 'src/composables/useNotify.js'; +import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js'; import axios from 'axios'; @@ -20,6 +21,7 @@ const { notify } = useNotify(); const denyFormRef = ref(null); const denyRequestId = ref(null); +const denyRequestIndex = ref(null); const itemRequestsOptions = ref([]); const columns = computed(() => [ @@ -108,21 +110,7 @@ const columns = computed(() => [ }, ]); -const getDateQBadgeColor = (date) => { - let today = Date.vnNew(); - today.setHours(0, 0, 0, 0); - let timeTicket = new Date(date); - timeTicket.setHours(0, 0, 0, 0); - - let comparation = today - timeTicket; - - if (comparation == 0) return 'warning'; - if (comparation < 0) return 'negative'; -}; - const changeQuantity = async (request) => { - console.log('change quantity request:: ', request); - try { if (request.saleFk) { const params = { @@ -134,12 +122,11 @@ const changeQuantity = async (request) => { confirmRequest(request); } else confirmRequest(request); } catch (error) { - console.log('Error changing quantity:: ', error); + console.error('Error changing quantity:: ', error); } }; const confirmRequest = async (request) => { - console.log('confirm request:: ', request); try { if (request.itemFk && request.saleQuantity) { const params = { @@ -157,7 +144,7 @@ const confirmRequest = async (request) => { notify(t('globals.dataSaved', 'positive')); } } catch (error) { - console.log('Error confirming request:: ', error); + console.error('Error confirming request:: ', error); } }; @@ -167,13 +154,19 @@ const getState = (isOk) => { else return 'Denied'; }; -const showDenyRequestForm = (requestId) => { +const showDenyRequestForm = (requestId, rowIndex) => { denyRequestId.value = requestId; + denyRequestIndex.value = rowIndex; denyFormRef.value.show(); }; const onDenyAccept = (_, responseData) => { - console.log('response data:: ', responseData); + itemRequestsOptions.value[denyRequestIndex.value].isOk = responseData.isOk; + itemRequestsOptions.value[denyRequestIndex.value].attenderFk = + responseData.attenderFk; + itemRequestsOptions.value[denyRequestIndex.value].response = responseData.response; + denyRequestId.value = null; + denyRequestIndex.value = null; }; onMounted(async () => {}); @@ -186,7 +179,6 @@ onMounted(async () => {}); auto-load @on-fetch="(data) => (itemRequestsOptions = data)" /> - {}); {{ getState(row.isOk) }} -