add: search vehicles view & fixes: bugs state
This commit is contained in:
@@ -83,17 +83,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.attachment p {
|
.attachment p {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
font-weight: 900;
|
font-weight: 900;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attachment img {
|
.attachment img {
|
||||||
width: 50%;
|
width: 33%;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
align-content: center;
|
align-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 568px) {
|
||||||
|
.attachment img {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -19,13 +19,17 @@
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
required: false,
|
required: false,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
tracking: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
defineEmits(['set-load'])
|
defineEmits(['set-load'])
|
||||||
|
|
||||||
|
|
||||||
const openAttachmentsModal = () => {
|
const openAttachmentsModal = () => {
|
||||||
loadsStore.currentLoad = props.load;
|
loadsStore.currentLoad = props.load;
|
||||||
loadsStore.openAttachmentsModal = true;
|
loadsStore.openAttachmentsModal = true;
|
||||||
@@ -94,32 +98,32 @@
|
|||||||
<div class="col-lg-6 col-sm-12">
|
<div class="col-lg-6 col-sm-12">
|
||||||
<p>
|
<p>
|
||||||
<span>{{t('loads.origin')}}: </span>
|
<span>{{t('loads.origin')}}: </span>
|
||||||
<template v-if="load.origin.company_name"> {{ load.origin.company_name }}, </template>
|
<template v-if="load.origin?.company_name"> {{ load.origin?.company_name }}, </template>
|
||||||
<template v-if="load.origin.street_address1">{{ load.origin.street_address1 }}, </template>
|
<template v-if="load.origin?.street_address1">{{ load.origin?.street_address1 }}, </template>
|
||||||
<template v-if="load.origin.city">{{ load.origin.city }}, </template>
|
<template v-if="load.origin?.city">{{ load.origin?.city }}, </template>
|
||||||
<template v-if="load.origin.state">{{ load.origin.state }}, </template>
|
<template v-if="load.origin?.state">{{ load.origin?.state }}, </template>
|
||||||
<template v-if="load.origin.country">{{ load.origin.country }}, </template>
|
<template v-if="load.origin?.country">{{ load.origin?.country }}, </template>
|
||||||
<template v-if="load.origin.zipcode">{{ load.origin.zipcode }} </template>
|
<template v-if="load.origin?.zipcode">{{ load.origin?.zipcode }} </template>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<span>{{t('loads.destination')}}: </span>
|
<span>{{t('loads.destination')}}: </span>
|
||||||
<template v-if="load.destination.company_name"> {{ load.destination.company_name }}, </template>
|
<template v-if="load.destination?.company_name"> {{ load.destination?.company_name }}, </template>
|
||||||
<template v-if="load.destination.street_address1">{{ load.destination.street_address1 }}, </template>
|
<template v-if="load.destination?.street_address1">{{ load.destination?.street_address1 }}, </template>
|
||||||
<template v-if="load.destination.city">{{ load.destination.city }}, </template>
|
<template v-if="load.destination?.city">{{ load.destination?.city }}, </template>
|
||||||
<template v-if="load.destination.state">{{ load.destination.state }}, </template>
|
<template v-if="load.destination?.state">{{ load.destination?.state }}, </template>
|
||||||
<template v-if="load.destination.country">{{ load.destination.country }}, </template>
|
<template v-if="load.destination?.country">{{ load.destination?.country }}, </template>
|
||||||
<template v-if="load.destination.zipcode">{{ load.destination.zipcode }} </template>
|
<template v-if="load.destination?.zipcode">{{ load.destination?.zipcode }} </template>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-sm-12" v-if="readOnly">
|
<div class="col-lg-6 col-sm-12">
|
||||||
<p>
|
<p v-if="readOnly">
|
||||||
<span>{{t('loads.company')}}: </span>
|
<span>{{t('loads.company')}}: </span>
|
||||||
{{ load.company.company_name }}
|
{{ load.company?.company_name }}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
<div v-if="!readOnly">
|
||||||
<div class="col-lg-6 col-sm-12" v-if="authStore.user?.permissions === 'role_shipper'">
|
<p><span>{{t('loads.postStatus')}}:</span> <span class="simple">{{ getStatusPublished(load) }}</span></p>
|
||||||
<p><span>{{t('loads.postStatus')}}:</span> <span class="simple">{{ getStatusPublished(load) }}</span></p>
|
<p :style="{color: getStatusLoad(load).color}"><span>{{t('loads.loadStatus')}}:</span> <span class="simple">{{ getStatusLoad(load).status }}</span></p>
|
||||||
<p :style="{color: getStatusLoad(load).color}"><span>{{t('loads.loadStatus')}}:</span> <span class="simple">{{ getStatusLoad(load).status }}</span></p>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
<p><span>{{t('global.segment')}}: </span> {{ load.categories?.map((e) => e.name).join(', ') }}</p>
|
<p><span>{{t('global.segment')}}: </span> {{ load.categories?.map((e) => e.name).join(', ') }}</p>
|
||||||
<p><span>{{t('loads.loadCode')}}: </span> {{ load.shipment_code?.toUpperCase() }}
|
<p><span>{{t('loads.loadCode')}}: </span> {{ load.shipment_code?.toUpperCase() }}
|
||||||
<span
|
<span
|
||||||
v-if="load.load_status !== 'Draft' && !readOnly"
|
v-if="load.status !== 'Draft' && tracking"
|
||||||
class="tracking-icon"
|
class="tracking-icon"
|
||||||
@click="handleTracking"
|
@click="handleTracking"
|
||||||
data-target="_blank"
|
data-target="_blank"
|
||||||
@@ -156,7 +160,7 @@
|
|||||||
<div v-if="load.notes" class="box-note">
|
<div v-if="load.notes" class="box-note">
|
||||||
{{ load.notes }}
|
{{ load.notes }}
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-row" v-if="!readOnly && authStore.user?.permissions === 'role_shipper'">
|
<div class="btn-row" v-if="load?.company?._id === authStore?.user?.company._id">
|
||||||
<button
|
<button
|
||||||
v-if="(authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager') || authStore.user._id === props.load.posted_by"
|
v-if="(authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager') || authStore.user._id === props.load.posted_by"
|
||||||
class="btn-primary-sm bg-danger"
|
class="btn-primary-sm bg-danger"
|
||||||
@@ -185,7 +189,7 @@
|
|||||||
data-target="#proposalsModal"
|
data-target="#proposalsModal"
|
||||||
>#{{ load.no_of_proposals }} {{t('loads.offers')}}</button>
|
>#{{ load.no_of_proposals }} {{t('loads.offers')}}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-row" v-if="!readOnly && authStore.user?.permissions === 'role_carrier'">
|
<div class="btn-row" v-if="readOnly && authStore.user?.permissions === 'role_carrier'">
|
||||||
<button
|
<button
|
||||||
class="btn-primary-sm bg-dark"
|
class="btn-primary-sm bg-dark"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { getDateMonthDay } from '../helpers/date_formats';
|
import { getDateOnly } from '../helpers/date_formats';
|
||||||
import { getStatusLoad } from '../helpers/status';
|
import { getStatusLoad } from '../helpers/status';
|
||||||
import { useCompanyStore } from '../stores/company';
|
import { useCompanyStore } from '../stores/company';
|
||||||
import { useAuthStore } from '../stores/auth';
|
import { useAuthStore } from '../stores/auth';
|
||||||
@@ -87,10 +87,10 @@
|
|||||||
<p v-if="proposal.vehicle"><span>{{ t('labels.codeId') }}:</span> {{proposal.vehicle.vehicle_code?.toUpperCase()}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('labels.codeId') }}:</span> {{proposal.vehicle.vehicle_code?.toUpperCase()}}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('global.segment') }}:</span> {{proposal.load.categories?.map((e) => e.name).join(', ')}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('global.segment') }}:</span> {{proposal.load.categories?.map((e) => e.name).join(', ')}}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('directory.typeTruck') }}:</span> {{proposal.vehicle.truck_type}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('directory.typeTruck') }}:</span> {{proposal.vehicle.truck_type}}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('labels.datePublished') }}:</span> {{ getDateMonthDay(proposal.vehicle.published_date) }}</p>
|
<p v-if="proposal.vehicle?.published_date"><span>{{ t('labels.datePublished') }}:</span> {{ getDateOnly(proposal.vehicle.published_date) }}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('labels.dateAvailable') }}:</span> {{ getDateMonthDay(proposal.vehicle.available_date) }}</p>
|
<p v-if="proposal.vehicle?.is_available"><span>{{ t('labels.dateAvailable') }}:</span> {{ getDateOnly(proposal.vehicle.available_date) }}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('vehicles.availableIn') }}:</span> {{proposal.vehicle.city}}<template v-if="proposal.vehicle.state">, {{proposal.vehicle.state}}</template></p>
|
<p v-if="proposal.vehicle?.is_available"><span>{{ t('vehicles.availableIn') }}:</span> {{proposal.vehicle.city}}<template v-if="proposal.vehicle.state">, {{proposal.vehicle.state}}</template></p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('loads.destination') }}:</span> {{proposal.vehicle.destino}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('loads.destination') }}:</span> {{proposal.vehicle?.destino.replace(';', ', ')}}</p>
|
||||||
<p><span>{{ t('vehicles.truckPlates') }}:</span> {{ proposal.vehicle.circulation_serial_number }}</p>
|
<p><span>{{ t('vehicles.truckPlates') }}:</span> {{ proposal.vehicle.circulation_serial_number }}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('vehicles.trailerPlates') }} 1:</span> {{proposal.vehicle.trailer_plate_1}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('vehicles.trailerPlates') }} 1:</span> {{proposal.vehicle.trailer_plate_1}}</p>
|
||||||
<p v-if="proposal.vehicle"><span>{{ t('vehicles.trailerPlates') }} 2:</span> {{proposal.vehicle.trailer_plate_2}}</p>
|
<p v-if="proposal.vehicle"><span>{{ t('vehicles.trailerPlates') }} 2:</span> {{proposal.vehicle.trailer_plate_2}}</p>
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
@click="$emit('set-proposal', {proposal: proposal, modal: 'detail'})"
|
@click="$emit('set-proposal', {proposal: proposal, modal: 'detail'})"
|
||||||
data-toggle="modal" data-target="#loadDetailModal"
|
data-toggle="modal" data-target="#loadDetailModal"
|
||||||
>{{proposal.load.shipment_code.toUpperCase()}}</span></p>
|
>{{proposal.load.shipment_code.toUpperCase()}}</span></p>
|
||||||
<p v-if="proposal.vehicle" :style="{color: getStatusLoad(proposal.load, locale).color}"><span>{{ t('loads.loadStatus') }}:</span> {{ getStatusLoad(proposal.load, locale).status}}</p>
|
<p v-if="proposal.vehicle" :style="{color: getStatusLoad(proposal.load, locale).color, fontWeight: 'bold'}"><span>{{ t('loads.loadStatus') }}:</span> {{ getStatusLoad(proposal.load, locale).status}}</p>
|
||||||
<p v-if="proposal._driver">{{ t('labels.operator') }}: {{proposal._driver}}</p>
|
<p v-if="proposal._driver">{{ t('labels.operator') }}: {{proposal._driver}}</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -222,4 +222,5 @@
|
|||||||
gap: 0.2rem;
|
gap: 0.2rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
import { getDateMonthDayEs } from '../helpers/date_formats';
|
import { getDateOnly } from '../helpers/date_formats';
|
||||||
import { useVehiclesStore } from '../stores/vehicles';
|
import { useVehiclesStore } from '../stores/vehicles';
|
||||||
import { useAuthStore } from '../stores/auth';
|
import { useAuthStore } from '../stores/auth';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
@@ -10,6 +10,11 @@
|
|||||||
vehicle: {
|
vehicle: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
readOnly: {
|
||||||
|
type: Boolean,
|
||||||
|
required: false,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
defineEmits(['set-vehicle']);
|
defineEmits(['set-vehicle']);
|
||||||
@@ -70,15 +75,17 @@
|
|||||||
<div class="card-fixed card-vehicle">
|
<div class="card-fixed card-vehicle">
|
||||||
<div class="row my-2">
|
<div class="row my-2">
|
||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
|
<p v-if="vehicle.company !== authStore?.user?.company._id">{{ t('global.company') }}: <span>{{ vehicle?.company_name }}</span></p>
|
||||||
<p>{{ t('labels.codeId') }}: <span>{{ vehicle?.vehicle_code.toUpperCase() }}</span></p>
|
<p>{{ t('labels.codeId') }}: <span>{{ vehicle?.vehicle_code.toUpperCase() }}</span></p>
|
||||||
<p>{{ t('directory.typeTruck') }}: <span>{{ vehicle.truck_type }}</span></p>
|
<p>{{ t('directory.typeTruck') }}: <span>{{ vehicle.truck_type }}</span></p>
|
||||||
<p>{{ t('vehicles.serialNumber') }}: <span>{{ vehicle.vehicle_number }}</span></p>
|
<p v-if="!readOnly">{{ t('vehicles.serialNumber') }}: <span>{{ vehicle.vehicle_number }}</span></p>
|
||||||
<p>{{ t('global.segment') }}: <span>{{vehicle.categories?.map((e) => e.name).join(', ')}}</span></p>
|
<p>{{ t('global.segment') }}: <span>{{vehicle.categories?.map((e) => e.name).join(', ')}}</span></p>
|
||||||
<p>{{ t('labels.driver') }}:
|
<p>{{ t('labels.driver') }}:
|
||||||
<span>
|
<span>
|
||||||
<span v-if="vehicle?.driver">{{ vehicle?.driver?.first_name }} {{ vehicle?.driver?.last_name }} </span>
|
<span v-if="vehicle?.driver">{{ vehicle?.driver?.first_name }} {{ vehicle?.driver?.last_name }} </span>
|
||||||
<span v-else>{{ t('vehicles.noDriver') }} </span>
|
<span v-else>{{ t('vehicles.noDriver') }} </span>
|
||||||
<i
|
<i
|
||||||
|
v-if="!readOnly"
|
||||||
class="fa-solid fa-pen-to-square icon-btn"
|
class="fa-solid fa-pen-to-square icon-btn"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#editDriverVehicle"
|
data-target="#editDriverVehicle"
|
||||||
@@ -92,11 +99,12 @@
|
|||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<p>{{ t('vehicles.trailerPlates') }} 2: <span>{{ vehicle.trailer_plate_2 }}</span></p>
|
<p>{{ t('vehicles.trailerPlates') }} 2: <span>{{ vehicle.trailer_plate_2 }}</span></p>
|
||||||
<p>{{ t('vehicles.chargingBase') }}: <span>{{ vehicle.city }}, {{ vehicle.state }}</span></p>
|
<p>{{ t('vehicles.chargingBase') }}: <span>{{ vehicle.city }}, {{ vehicle.state }}</span></p>
|
||||||
<p v-if="vehicle.destino">{{ t('loads.destination') }}: <span>{{ vehicle.destino.replace(';', ', ') }}</span></p>
|
|
||||||
<p v-if="vehicle.available_in">{{ t('vehicles.availableIn') }}: <span>{{ vehicle.available_in.replace(';', ', ') }}</span></p>
|
<p v-if="vehicle.available_in">{{ t('vehicles.availableIn') }}: <span>{{ vehicle.available_in.replace(';', ', ') }}</span></p>
|
||||||
|
<p v-if="vehicle.destino">{{ t('loads.destination') }}: <span>{{ vehicle.destino.replace(';', ', ') }}</span></p>
|
||||||
<p>Status:
|
<p>Status:
|
||||||
<span>{{ vehicle.is_available ? t('vehicles.available') : t('vehicles.reserved')}}
|
<span>{{ vehicle.is_available ? t('vehicles.available') : t('vehicles.reserved')}}
|
||||||
<i
|
<i
|
||||||
|
v-if="!readOnly"
|
||||||
class="fa-solid fa-pen-to-square icon-btn"
|
class="fa-solid fa-pen-to-square icon-btn"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-target="#editStatusVehicle"
|
data-target="#editStatusVehicle"
|
||||||
@@ -104,23 +112,26 @@
|
|||||||
</i>
|
</i>
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<p v-if="vehicle.is_available">{{ t('vehicles.availableDate') }}: <span>{{ getDateMonthDayEs(vehicle.available_date, false) }}</span></p>
|
<p v-if="vehicle.is_available">{{ t('vehicles.availableDate') }}: <span>{{ getDateOnly(vehicle.available_date) }}</span></p>
|
||||||
<p v-if="vehicle.active_load">
|
<p v-if="vehicle.active_load && !readOnly">
|
||||||
{{ t('loads.loadCode') }}:
|
{{ t('loads.loadCode') }}:
|
||||||
<span
|
<span
|
||||||
class="code-enruta"
|
class="code-enruta font-bold"
|
||||||
@click="handleTracking"
|
@click="handleTracking"
|
||||||
data-target="_blank"
|
data-target="_blank"
|
||||||
>{{ vehicle.active_load.shipment_code?.toUpperCase() }}</span>
|
>{{ vehicle.active_load.shipment_code?.toUpperCase() }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p v-if="vehicle.active_load">{{ t('loads.loadStatus') }}: <span>{{ getStatusLoad(vehicle.active_load, locale).status}}</span></p>
|
<p v-if="vehicle.active_load && !readOnly">
|
||||||
|
{{ t('loads.loadStatus') }}:
|
||||||
|
<span :style="{color: getStatusLoad(vehicle.active_load).color, fontWeight: 'bold'}">{{ getStatusLoad(vehicle.active_load, locale).status}}</span>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p v-if="vehicle.notes">{{ t('vehicles.additionalInfoVehicle') }}:</p>
|
<p v-if="vehicle.notes">{{ t('vehicles.additionalInfoVehicle') }}:</p>
|
||||||
<div v-if="vehicle.notes" class="box-note mb-4">
|
<div v-if="vehicle.notes" class="box-note mb-4">
|
||||||
{{ vehicle.notes }}
|
{{ vehicle.notes }}
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer" v-if="vehicle.company === authStore?.user?.company._id">
|
||||||
<button
|
<button
|
||||||
v-if="(authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager') || authStore.user._id === props.vehicle.posted_by"
|
v-if="(authStore.user?.job_role === 'owner' || authStore.user?.job_role === 'manager') || authStore.user._id === props.vehicle.posted_by"
|
||||||
class="btn btn-dark radius-sm"
|
class="btn btn-dark radius-sm"
|
||||||
@@ -182,4 +193,7 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: rgb(107, 107, 227);
|
color: rgb(107, 107, 227);
|
||||||
}
|
}
|
||||||
|
.font-bold {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -53,9 +53,8 @@
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
||||||
const [destinoCityName = '', destinoStateName = ''] = props.vehicle.destino?.split(';') || [];
|
|
||||||
|
|
||||||
if(props.vehicle) {
|
if(props.vehicle) {
|
||||||
|
const [destinoCityName = '', destinoStateName = ''] = props.vehicle.destino?.split(';') || [];
|
||||||
vehicleForm.truck_type = {
|
vehicleForm.truck_type = {
|
||||||
meta_value: props.vehicle.truck_type
|
meta_value: props.vehicle.truck_type
|
||||||
};
|
};
|
||||||
@@ -162,15 +161,15 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body form-content">
|
<div class="modal-body form-content">
|
||||||
<form @submit.prevent="handleSaveVehicle" autocomplete="off" class="vehicle-form">
|
<form @submit.prevent="handleSaveVehicle" autocomplete="off" class="vehicle-form">
|
||||||
<div class="row mt-4">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-12">
|
<div class="col-lg-6 col-12 mt-4">
|
||||||
<label class="custom-label">{{ t('directory.typeTruck') }}*</label>
|
<label class="custom-label">{{ t('directory.typeTruck') }}*</label>
|
||||||
<TruckTypes
|
<TruckTypes
|
||||||
v-model="vehicleForm.truck_type"
|
v-model="vehicleForm.truck_type"
|
||||||
/>
|
/>
|
||||||
<span class="error-msg" v-if="errors.truck_type">{{ errors.truck_type }}</span>
|
<span class="error-msg" v-if="errors.truck_type">{{ errors.truck_type }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-6 col-12">
|
<div class="col-lg-6 col-12 mt-4">
|
||||||
<label class="custom-label">{{ t('vehicles.segments') }}*</label>
|
<label class="custom-label">{{ t('vehicles.segments') }}*</label>
|
||||||
<Segments
|
<Segments
|
||||||
v-model="vehicleForm.categories"
|
v-model="vehicleForm.categories"
|
||||||
|
|||||||
@@ -86,11 +86,8 @@
|
|||||||
formLoad.owner = auth.user?.first_name + ' ' + auth.user?.last_name;
|
formLoad.owner = auth.user?.first_name + ' ' + auth.user?.last_name;
|
||||||
//origin_formatted_address
|
//origin_formatted_address
|
||||||
if(loadStore.currentLoad){
|
if(loadStore.currentLoad){
|
||||||
// console.log(loadStore.currentLoad)
|
|
||||||
const dateStart = getDateTime(loadStore.currentLoad.est_loading_date, 0);
|
const dateStart = getDateTime(loadStore.currentLoad.est_loading_date, 0);
|
||||||
const dateEnd = getDateTime(loadStore.currentLoad.est_unloading_date, 0);
|
const dateEnd = getDateTime(loadStore.currentLoad.est_unloading_date, 0);
|
||||||
console.log(dateStart)
|
|
||||||
console.log(dateEnd)
|
|
||||||
formLoad.price = loadStore.currentLoad.actual_cost;
|
formLoad.price = loadStore.currentLoad.actual_cost;
|
||||||
formLoad.segment = loadStore.currentLoad.categories?.length <= 0 ? [] : loadStore.currentLoad.categories.map(m =>{
|
formLoad.segment = loadStore.currentLoad.categories?.length <= 0 ? [] : loadStore.currentLoad.categories.map(m =>{
|
||||||
return m;
|
return m;
|
||||||
@@ -275,13 +272,18 @@
|
|||||||
if(loadStore.currentLoad){
|
if(loadStore.currentLoad){
|
||||||
const resp = await loadStore.updateLoad(loadStore.currentLoad._id, loadData);
|
const resp = await loadStore.updateLoad(loadStore.currentLoad._id, loadData);
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
const dataLocal = {
|
||||||
|
company: auth.user.company,
|
||||||
|
categories: formLoad.segment || null,
|
||||||
|
product: formLoad.terms?.length <= 0 ? null : formLoad.terms
|
||||||
|
};
|
||||||
if(resp) {
|
if(resp) {
|
||||||
const index = loadStore.loads.findIndex((load) => load._id === resp._id);
|
const index = loadStore.loads.findIndex((load) => load._id === resp._id);
|
||||||
loadStore.loads[index] = {
|
loadStore.loads[index] = {
|
||||||
...loadStore.loads[index],
|
...loadStore.loads[index],
|
||||||
...resp
|
...resp,
|
||||||
|
...dataLocal,
|
||||||
};
|
};
|
||||||
|
|
||||||
return 'success';
|
return 'success';
|
||||||
} else {
|
} else {
|
||||||
return 'error';
|
return 'error';
|
||||||
@@ -295,6 +297,7 @@
|
|||||||
...loadData,
|
...loadData,
|
||||||
categories: [loadData.categories]
|
categories: [loadData.categories]
|
||||||
}
|
}
|
||||||
|
|
||||||
loadStore.loads.unshift(load);
|
loadStore.loads.unshift(load);
|
||||||
return 'success';
|
return 'success';
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
<i class="fas fa-align-left"></i>
|
<i class="fas fa-align-left"></i>
|
||||||
</button>
|
</button>
|
||||||
<div class="nav-options">
|
<div class="nav-options">
|
||||||
|
<RouterLink
|
||||||
|
v-if="auth.user?.permissions === 'role_shipper'"
|
||||||
|
active-class="router-link-active"
|
||||||
|
class="nav-link" :to="{name: 'search-vehicles'}"> <i class="fa-solid fa-truck-ramp-box me-1"></i> <span class="clear-xsm">{{ t('global.vehicles') }}</span></RouterLink>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-if="auth.user?.permissions === 'role_shipper'"
|
v-if="auth.user?.permissions === 'role_shipper'"
|
||||||
active-class="router-link-active"
|
active-class="router-link-active"
|
||||||
|
|||||||
@@ -44,10 +44,16 @@
|
|||||||
isLoadingActions.value = true;
|
isLoadingActions.value = true;
|
||||||
let load = await loadsStore.updateLoad(load_id, loadData);
|
let load = await loadsStore.updateLoad(load_id, loadData);
|
||||||
if(load != null) {
|
if(load != null) {
|
||||||
|
const dataLocal = {
|
||||||
|
company: authStore.user.company,
|
||||||
|
categories: loadsStore?.currentLoad?.categories,
|
||||||
|
product: loadsStore?.currentLoad?.product
|
||||||
|
};
|
||||||
const index = loadsStore.loads.findIndex((load) => load._id === load_id);
|
const index = loadsStore.loads.findIndex((load) => load._id === load_id);
|
||||||
loadsStore.loads[index] = {
|
loadsStore.loads[index] = {
|
||||||
...loadsStore.loads[index],
|
...loadsStore.loads[index],
|
||||||
...load
|
...load,
|
||||||
|
...dataLocal
|
||||||
};
|
};
|
||||||
const proposal_id = proposal._id;
|
const proposal_id = proposal._id;
|
||||||
|
|
||||||
@@ -109,10 +115,16 @@
|
|||||||
isLoadingActions.value = true;
|
isLoadingActions.value = true;
|
||||||
let load = await loadsStore.updateLoad(load_id, loadData);
|
let load = await loadsStore.updateLoad(load_id, loadData);
|
||||||
if(load) {
|
if(load) {
|
||||||
|
const dataLocal = {
|
||||||
|
company: authStore.user.company,
|
||||||
|
categories: loadsStore?.currentLoad?.categories,
|
||||||
|
product: loadsStore?.currentLoad?.product
|
||||||
|
};
|
||||||
const index = loadsStore.loads.findIndex((load) => load._id === load_id);
|
const index = loadsStore.loads.findIndex((load) => load._id === load_id);
|
||||||
loadsStore.loads[index] = {
|
loadsStore.loads[index] = {
|
||||||
...loadsStore.loads[index],
|
...loadsStore.loads[index],
|
||||||
...load
|
...load,
|
||||||
|
...dataLocal
|
||||||
};
|
};
|
||||||
let formData = {
|
let formData = {
|
||||||
accepted_by : null,
|
accepted_by : null,
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
import States from './ui/States.vue';
|
import States from './ui/States.vue';
|
||||||
import Cities from './ui/Cities.vue';
|
import Cities from './ui/Cities.vue';
|
||||||
import Swal from 'sweetalert2';
|
import Swal from 'sweetalert2';
|
||||||
|
import { getDateTime } from '../helpers/date_formats';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
vehicle: {
|
vehicle: {
|
||||||
type: Object
|
type: Object
|
||||||
@@ -24,12 +26,12 @@
|
|||||||
|
|
||||||
const [destinoCityName = '', destinoStateName = ''] = props.vehicle.destino?.split(';') || [];
|
const [destinoCityName = '', destinoStateName = ''] = props.vehicle.destino?.split(';') || [];
|
||||||
const [availableCityName = '', availableStateName = ''] = props.vehicle.available_in?.split(';') || [];
|
const [availableCityName = '', availableStateName = ''] = props.vehicle.available_in?.split(';') || [];
|
||||||
|
const date = getDateTime( props.vehicle?.available_date || new Date(), 0);
|
||||||
formAvailiable.destinoCity = destinoCityName ? { city_name: destinoCityName } : '';
|
formAvailiable.destinoCity = destinoCityName ? { city_name: destinoCityName } : '';
|
||||||
formAvailiable.destinoState = destinoStateName ? { state_name: destinoStateName } : '';
|
formAvailiable.destinoState = destinoStateName ? { state_name: destinoStateName } : '';
|
||||||
formAvailiable.availableCity = availableCityName ? { city_name: availableCityName } : '';
|
formAvailiable.availableCity = availableCityName ? { city_name: availableCityName } : '';
|
||||||
formAvailiable.availableState = availableStateName ? { state_name: availableStateName } : '';
|
formAvailiable.availableState = availableStateName ? { state_name: availableStateName } : '';
|
||||||
formAvailiable.available_date = props.vehicle.available_date?.substring(0, 10);
|
formAvailiable.available_date = date.substring(0, 10);
|
||||||
});
|
});
|
||||||
|
|
||||||
defineEmits(['reset-vehicle']);
|
defineEmits(['reset-vehicle']);
|
||||||
@@ -53,18 +55,19 @@
|
|||||||
|
|
||||||
const handleSetStatusVehicle = async() => {
|
const handleSetStatusVehicle = async() => {
|
||||||
let vehicleData;
|
let vehicleData;
|
||||||
// console.log(statusSelected.value);
|
const currentDate = new Date();
|
||||||
|
const hours = currentDate.getHours().toString().padStart(2, '0');
|
||||||
|
const minutes = currentDate.getMinutes().toString().padStart(2, '0');
|
||||||
|
const seconds = currentDate.getSeconds().toString().padStart(2, '0');
|
||||||
if(statusSelected.value === 'Availiable') {
|
if(statusSelected.value === 'Availiable') {
|
||||||
// console.log('check validations');
|
|
||||||
validations();
|
validations();
|
||||||
if(errors.value.availableCity || errors.value.availableState || errors.value.destinoCity || errors.value.destinoState ) return;
|
if(errors.value.availableCity || errors.value.availableState || errors.value.destinoCity || errors.value.destinoState ) return;
|
||||||
vehicleData = {
|
vehicleData = {
|
||||||
available_date : formAvailiable.available_date,
|
available_date : new Date(`${formAvailiable.available_date}T${hours}:${minutes}:${seconds}`).toISOString(),
|
||||||
destino: formAvailiable.destinoCity.city_name + ';' + formAvailiable.destinoState.state_name,
|
destino: formAvailiable.destinoCity.city_name + ';' + formAvailiable.destinoState.state_name,
|
||||||
available_in: formAvailiable.availableCity.city_name + ';' + formAvailiable.availableState.state_name,
|
available_in: formAvailiable.availableCity.city_name + ';' + formAvailiable.availableState.state_name,
|
||||||
is_available : true
|
is_available : true
|
||||||
}
|
}
|
||||||
console.log(vehicleData);
|
|
||||||
} else {
|
} else {
|
||||||
vehicleData = {
|
vehicleData = {
|
||||||
available_date : null,
|
available_date : null,
|
||||||
@@ -73,7 +76,8 @@
|
|||||||
}
|
}
|
||||||
let localData = {
|
let localData = {
|
||||||
driver: props.vehicle.driver,
|
driver: props.vehicle.driver,
|
||||||
categories: props.vehicle.categories
|
categories: props.vehicle.categories,
|
||||||
|
active_load: props.vehicle.active_load,
|
||||||
}
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const result = await vehicleStore.updateVehicleCompany(props.vehicle._id, vehicleData, localData);
|
const result = await vehicleStore.updateVehicleCompany(props.vehicle._id, vehicleData, localData);
|
||||||
|
|||||||
37
src/composables/useSearchVehicles.js
Normal file
37
src/composables/useSearchVehicles.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { ref } from "vue";
|
||||||
|
import api from "../lib/axios";
|
||||||
|
|
||||||
|
export default function useSearchVehicles() {
|
||||||
|
const vehicles = ref([]);
|
||||||
|
const loading = ref(false);
|
||||||
|
const total = ref(0);
|
||||||
|
const currentPage = ref(0);
|
||||||
|
|
||||||
|
const getVehiclesPublished = async(filterQuery) => {
|
||||||
|
loading.value = true;
|
||||||
|
let filterArr = Object.values(filterQuery);
|
||||||
|
let cleanfilterArr = filterArr.filter(n=>n);
|
||||||
|
var filterStr = "";
|
||||||
|
if(cleanfilterArr.length >0){
|
||||||
|
filterStr = "?"+cleanfilterArr.join("&");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const endpoint = `/v1/vehicles/global/find${filterStr}&$sort[createdAt]=-1`;
|
||||||
|
const {data} = await api.get(endpoint);
|
||||||
|
total.value = data.total;
|
||||||
|
vehicles.value = data.data;
|
||||||
|
} catch (error) {
|
||||||
|
vehicles.value = [];
|
||||||
|
total.value = 0;
|
||||||
|
}
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getVehiclesPublished,
|
||||||
|
loading,
|
||||||
|
vehicles,
|
||||||
|
total,
|
||||||
|
currentPage,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ export default function useSearchLoads() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const endpoint = `/v1/loads/find${filterStr}&$sort[createdAt]=-1`;
|
const endpoint = `/v1/loads/find${filterStr}&$sort[createdAt]=-1`;
|
||||||
console.log(endpoint);
|
// console.log(endpoint);
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
total.value = data.total;
|
total.value = data.total;
|
||||||
loads.value = data.data;
|
loads.value = data.data;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ export const getDateTime = (value, hour) => {
|
|||||||
export const getDateOnly = (value) => {
|
export const getDateOnly = (value) => {
|
||||||
|
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
date.setHours(date.getHours());
|
date.setHours(date.getHours(), 0);
|
||||||
|
|
||||||
// Obtener los componentes de la fecha
|
// Obtener los componentes de la fecha
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ const en = {
|
|||||||
loadingRetired: 'Withdrawing offer',
|
loadingRetired: 'Withdrawing offer',
|
||||||
msgTitleRetire: 'Offer withdrawn!',
|
msgTitleRetire: 'Offer withdrawn!',
|
||||||
|
|
||||||
title: 'My offers accepted',
|
title: 'Offers',
|
||||||
retired: 'Retired',
|
retired: 'Retired',
|
||||||
withdraw: 'Withdraw',
|
withdraw: 'Withdraw',
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ const es = {
|
|||||||
shippers: 'Embarcadores',
|
shippers: 'Embarcadores',
|
||||||
vehicles: 'Vehiculos',
|
vehicles: 'Vehiculos',
|
||||||
loads: 'Cargas',
|
loads: 'Cargas',
|
||||||
acceptedOffers: 'Ofertas aceptadas',
|
acceptedOffers: 'Ofertas',
|
||||||
calculator: 'Calculadora',
|
calculator: 'Calculadora',
|
||||||
cities: 'Ciudades',
|
cities: 'Ciudades',
|
||||||
states: 'Estados',
|
states: 'Estados',
|
||||||
|
|||||||
@@ -148,6 +148,11 @@ const router = createRouter({
|
|||||||
name: 'search-loads',
|
name: 'search-loads',
|
||||||
component: () => import('../views/SearchLoadsView.vue'),
|
component: () => import('../views/SearchLoadsView.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'buscar-vehiclulos',
|
||||||
|
name: 'search-vehicles',
|
||||||
|
component: () => import('../views/SearchVehiclesView.vue'),
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export const deleteBudget = async(id) => {
|
|||||||
|
|
||||||
export const getLocations = async(filter) => {
|
export const getLocations = async(filter) => {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/v1/branches/find${filter}&$sort%5BcreatedAt%5D=-1`;
|
const endpoint = `/v1/branches/find${filter}&$sort[createdAt]=1`;
|
||||||
console.log(endpoint);
|
console.log(endpoint);
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@@ -318,14 +318,14 @@ export const useCompanyStore = defineStore('company', () => {
|
|||||||
|
|
||||||
const createLocationCompany = async(formData, localData) => {
|
const createLocationCompany = async(formData, localData) => {
|
||||||
const data = await createLocation(formData);
|
const data = await createLocation(formData);
|
||||||
if(data) {
|
if(data?.data) {
|
||||||
locations.value.unshift({
|
locations.value.unshift({
|
||||||
...data,
|
...data?.data,
|
||||||
...localData
|
...localData
|
||||||
});
|
});
|
||||||
locationsTotal.value++;
|
locationsTotal.value++;
|
||||||
locationsLoads.value.unshift({
|
locationsLoads.value.unshift({
|
||||||
...data,
|
...data?.data,
|
||||||
...localData
|
...localData
|
||||||
})
|
})
|
||||||
return 'success';
|
return 'success';
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export const useLoadsStore = defineStore('load', () => {
|
|||||||
if(loads.value.length <= 0 || reload) {
|
if(loads.value.length <= 0 || reload) {
|
||||||
try {
|
try {
|
||||||
const endpoint = `/v1/loads/find?company=${companyid}&${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
const endpoint = `/v1/loads/find?company=${companyid}&${filterStr}&$sort%5BcreatedAt%5D=-1`;
|
||||||
|
console.log(endpoint);
|
||||||
const {data} = await api.get(endpoint);
|
const {data} = await api.get(endpoint);
|
||||||
loads.value = data.data;
|
loads.value = data.data;
|
||||||
loadsTotal.value = data.total;
|
loadsTotal.value = data.total;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const useVehiclesStore = defineStore('vehicles', () => {
|
|||||||
}
|
}
|
||||||
if(vehicles.value.length <= 0 || reload === true) {
|
if(vehicles.value.length <= 0 || reload === true) {
|
||||||
const resp = await getVehicles(filterStr + '&$sort%5BcreatedAt%5D=-1');
|
const resp = await getVehicles(filterStr + '&$sort%5BcreatedAt%5D=-1');
|
||||||
console.log(resp);
|
// console.log(resp);
|
||||||
if(resp !== null) {
|
if(resp !== null) {
|
||||||
vehiclesTotal.value = resp.total;
|
vehiclesTotal.value = resp.total;
|
||||||
vehicles.value = resp.data;
|
vehicles.value = resp.data;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
const company = reactive({
|
const company = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
rfc: 'USAL950402D96',
|
rfc: '',
|
||||||
segments: [],
|
segments: [],
|
||||||
states: [],
|
states: [],
|
||||||
cities: [],
|
cities: [],
|
||||||
|
|||||||
@@ -133,7 +133,7 @@
|
|||||||
:key="load._id"
|
:key="load._id"
|
||||||
:load="load"
|
:load="load"
|
||||||
/>
|
/>
|
||||||
<CardEmpty v-else :text="t('loads.empty')"/>
|
<CardEmpty v-else :text="t('loads.empty')" class="mt-5"/>
|
||||||
<Pagination
|
<Pagination
|
||||||
:limit="limit"
|
:limit="limit"
|
||||||
:total="loadStore.loadsTotal"
|
:total="loadStore.loadsTotal"
|
||||||
|
|||||||
@@ -204,7 +204,7 @@
|
|||||||
v-if="loads.length > 0"
|
v-if="loads.length > 0"
|
||||||
v-for="load in loads"
|
v-for="load in loads"
|
||||||
:load="load"
|
:load="load"
|
||||||
:read-only="false"
|
:read-only="true"
|
||||||
@set-load="handleSetCurrentLoad(load)"
|
@set-load="handleSetCurrentLoad(load)"
|
||||||
/>
|
/>
|
||||||
<CardEmpty
|
<CardEmpty
|
||||||
|
|||||||
226
src/views/SearchVehiclesView.vue
Normal file
226
src/views/SearchVehiclesView.vue
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
<script setup>
|
||||||
|
import { onMounted, ref, watch } from 'vue';
|
||||||
|
import useSearchVehicles from '../composables/useSearchVehicles';
|
||||||
|
import Spiner from '../components/ui/Spiner.vue';
|
||||||
|
import CardVehicle from '../components/CardVehicle.vue';
|
||||||
|
import CardEmpty from '../components/CardEmpty.vue'
|
||||||
|
import TruckTypes from '../components/ui/TruckTypes.vue';
|
||||||
|
import Segments from '../components/ui/Segments.vue';
|
||||||
|
import States from '../components/ui/States.vue';
|
||||||
|
import Cities from '../components/ui/Cities.vue';
|
||||||
|
import Pagination from '../components/Pagination.vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
const filterQuery = ref([]);
|
||||||
|
const query = ref('');
|
||||||
|
const selectedTruckType = ref([]);
|
||||||
|
const selectedCategory = ref([]);
|
||||||
|
const selectedState = ref([]);
|
||||||
|
const selectedCities = ref([]);
|
||||||
|
const limit = 10;
|
||||||
|
const isSearch = ref(false);
|
||||||
|
const { getVehiclesPublished, vehicles, loading, currentPage, total } = useSearchVehicles();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getInitData();
|
||||||
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
watch(query, () => {
|
||||||
|
isSearch.value = true;
|
||||||
|
setFilterUnlimited();
|
||||||
|
if(query.value.length === 0){
|
||||||
|
if(selectedCategory.value?.length === 0 && selectedTruckType.value?.length === 0 && selectedCities.value?.length === 0 && selectedState.value?.length === 0 ) {
|
||||||
|
clearRequest();
|
||||||
|
isSearch.value = false;
|
||||||
|
}
|
||||||
|
filterQuery.value.search = "";
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedState, () => {
|
||||||
|
if(selectedState.value != null){
|
||||||
|
setFilterUnlimited()
|
||||||
|
filterQuery.value.state = "state[$in][]="+ selectedState.value.state_name;
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedCities, () => {
|
||||||
|
if(selectedCities.value != null){
|
||||||
|
setFilterUnlimited()
|
||||||
|
filterQuery.value.city = "city[$regex]="+ selectedCities.value.city_name;
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedCategory, () => {
|
||||||
|
if(selectedCategory.value != null){
|
||||||
|
setFilterUnlimited()
|
||||||
|
filterQuery.value.category = "categories[$in][]=" + selectedCategory.value._id;
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedTruckType, () => {
|
||||||
|
if(selectedTruckType.value != null){
|
||||||
|
setFilterUnlimited()
|
||||||
|
filterQuery.value.truck_type = "truck_type[$in][]="+ selectedTruckType.value.meta_value;
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const search = () => {
|
||||||
|
if(query.value.length >= 2){
|
||||||
|
// filterQuery.value.search = "company_name[$regex]=" + query.value + "&company_name[$options]=i";
|
||||||
|
filterQuery.value.search = `company_name[$regex]=${query.value}&company_name[$options]=i`;
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearFilter = () => {
|
||||||
|
clearRequest();
|
||||||
|
isSearch.value = false;
|
||||||
|
selectedCities.value = null;
|
||||||
|
selectedCategory.value = null;
|
||||||
|
selectedState.value = null;
|
||||||
|
selectedTruckType.value = null;
|
||||||
|
|
||||||
|
filterQuery.value.truck_type = "";
|
||||||
|
filterQuery.value.category = "";
|
||||||
|
filterQuery.value.city = "";
|
||||||
|
filterQuery.value.state = "";
|
||||||
|
|
||||||
|
filterQuery.value.status = "is_available=true";
|
||||||
|
|
||||||
|
if(query.value == ''){
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
} else {
|
||||||
|
query.value = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearState = () => {
|
||||||
|
filterQuery.value.state = "";
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearCity = () => {
|
||||||
|
filterQuery.value.city = "";
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearTruckType = () => {
|
||||||
|
filterQuery.value.truck_type = "";
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearCategory = () => {
|
||||||
|
filterQuery.value.category = "";
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getInitData = async() => {
|
||||||
|
filterQuery.value.limit = 'elements=' + limit;
|
||||||
|
filterQuery.value.page = "page=0";
|
||||||
|
filterQuery.value.company = "";
|
||||||
|
|
||||||
|
filterQuery.value.status = "is_available=true";
|
||||||
|
await getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getLoadsByPage = (data) => {
|
||||||
|
filterQuery.value.page = "page="+ data.page;
|
||||||
|
currentPage.value = data.page
|
||||||
|
getVehiclesPublished(filterQuery.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
const clearRequest = () => {
|
||||||
|
filterQuery.value.page = "page="+ 0;
|
||||||
|
filterQuery.value.limit = "elements="+ limit;
|
||||||
|
currentPage.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const setFilterUnlimited = () => {
|
||||||
|
filterQuery.value.page = "page="+ 0;
|
||||||
|
filterQuery.value.limit = "elements="+ 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<h2 class="title mb-5">{{ t('vehicles.search') }}</h2>
|
||||||
|
|
||||||
|
<div class="card-filters">
|
||||||
|
<div class="d-flex mb-2">
|
||||||
|
<input class="form-control me-2" type="search" name="" :placeholder="t('carriers.searchByCarrier')" id="" @:input="search()" v-model="query" aria-label="Search">
|
||||||
|
<button class="btn btn-outline-dark me-2" type="button" @click="search">{{ t('buttons.search') }}</button>
|
||||||
|
<button
|
||||||
|
class="btn btn-danger" type="button" @click="clearFilter">
|
||||||
|
<i class="fa-solid fa-arrow-rotate-right"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-sm-6 px-2 py-2">
|
||||||
|
<TruckTypes v-model="selectedTruckType" @clear-option="clearTruckType"/>
|
||||||
|
</div>
|
||||||
|
<div class=" col-xs-12 col-sm-6 px-2 py-2">
|
||||||
|
<Segments v-model="selectedCategory" @clear-option="clearCategory"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xs-12 col-sm-6 px-2 py-2">
|
||||||
|
<States v-model="selectedState" @clear-option="clearState"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-xs-12 col-sm-6 px-2 py-2">
|
||||||
|
<Cities v-model="selectedCities" @clear-option="clearCity"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Spiner class="mt-4" v-if="loading"/>
|
||||||
|
<div v-else>
|
||||||
|
<CardVehicle
|
||||||
|
v-if="vehicles.length > 0"
|
||||||
|
v-for="vehicle in vehicles"
|
||||||
|
:vehicle="vehicle"
|
||||||
|
:key="vehicle._id"
|
||||||
|
:read-only="true"
|
||||||
|
/>
|
||||||
|
<CardEmpty
|
||||||
|
v-else
|
||||||
|
text="No hay vehiculos publicadas"
|
||||||
|
/>
|
||||||
|
<Pagination
|
||||||
|
v-if="!isSearch"
|
||||||
|
:limit="limit"
|
||||||
|
:total="total"
|
||||||
|
:current-page="currentPage"
|
||||||
|
@get-elements="getLoadsByPage"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.card-filters {
|
||||||
|
display: flex;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #FFF;
|
||||||
|
border-radius: 13px;
|
||||||
|
/* background-color: red; */
|
||||||
|
flex-direction: column;
|
||||||
|
/* align-items: center; */
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
padding: 20px 10%;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.card-filters {
|
||||||
|
padding: 20px 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
<Spiner v-if="loading"/>
|
<Spiner v-if="loading"/>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div v-if="load">
|
<div v-if="load">
|
||||||
<CardLoad :load="load" :read-only="true"/>
|
<CardLoad :load="load" :read-only="true" :tracking="false"/>
|
||||||
<br/>
|
<br/>
|
||||||
<GoogleMap
|
<GoogleMap
|
||||||
:api-key="mapKey"
|
:api-key="mapKey"
|
||||||
|
|||||||
Reference in New Issue
Block a user