0
0
Fork 0

Merge branch 'dev' into 5447-travelExtraCommunity

This commit is contained in:
Jon Elias 2024-05-23 07:28:07 +00:00
commit 1183908942
8 changed files with 98 additions and 59 deletions

View File

@ -35,7 +35,7 @@ const $props = defineProps({
downloadModel: { downloadModel: {
type: String, type: String,
required: false, required: false,
default: null, default: undefined,
}, },
defaultDmsCode: { defaultDmsCode: {
type: String, type: String,

View File

@ -1,7 +1,7 @@
export default function dateRange(value) { export default function dateRange(value) {
const minHour = new Date(value); const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0); minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value); const maxHour = new Date();
maxHour.setHours(23, 59, 59, 59); maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour]; return [minHour, maxHour];

View File

@ -14,9 +14,10 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue'; import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
import axios from 'axios';
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t, locale } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const dataRef = ref(null); const dataRef = ref(null);
@ -26,7 +27,7 @@ const selected = ref([]);
const tableColumnComponents = { const tableColumnComponents = {
client: { client: {
component: QBtn, component: QBtn,
props: () => ({ flat: true, color: 'blue', noCaps: true }), props: () => ({ flat: true, class: 'link', noCaps: true }),
event: () => {}, event: () => {},
}, },
isWorker: { isWorker: {
@ -39,7 +40,12 @@ const tableColumnComponents = {
}, },
salesPerson: { salesPerson: {
component: QBtn, component: QBtn,
props: () => ({ flat: true, color: 'blue', noCaps: true }), props: () => ({ flat: true, class: 'link', noCaps: true }),
event: () => {},
},
department: {
component: 'span',
props: () => {},
event: () => {}, event: () => {},
}, },
country: { country: {
@ -59,7 +65,7 @@ const tableColumnComponents = {
}, },
author: { author: {
component: QBtn, component: QBtn,
props: () => ({ flat: true, color: 'blue', noCaps: true }), props: () => ({ flat: true, class: 'link', noCaps: true }),
event: () => {}, event: () => {},
}, },
lastObservation: { lastObservation: {
@ -82,6 +88,16 @@ const tableColumnComponents = {
props: () => {}, props: () => {},
event: () => {}, event: () => {},
}, },
finished: {
component: QCheckbox,
props: (prop) => ({
disable: true,
'model-value': prop.value,
class: 'disabled-checkbox',
}),
event: () => {},
},
}; };
const columns = computed(() => [ const columns = computed(() => [
@ -105,6 +121,13 @@ const columns = computed(() => [
name: 'salesPerson', name: 'salesPerson',
sortable: true, sortable: true,
}, },
{
align: 'left',
field: 'departmentName',
label: t('Department'),
name: 'department',
sortable: true,
},
{ {
align: 'left', align: 'left',
field: 'country', field: 'country',
@ -166,6 +189,12 @@ const columns = computed(() => [
name: 'from', name: 'from',
sortable: true, sortable: true,
}, },
{
align: 'left',
field: 'finished',
label: t('Has recover'),
name: 'finished',
},
]); ]);
const viewAddObservation = (rowsSelected) => { const viewAddObservation = (rowsSelected) => {
@ -178,7 +207,39 @@ const viewAddObservation = (rowsSelected) => {
}); });
}; };
const onFetch = (data) => { const departments = ref(new Map());
const onFetch = async (data) => {
const salesPersonFks = data.map((item) => item.salesPersonFk);
const departmentNames = salesPersonFks.map(async (salesPersonFk) => {
try {
const { data: workerDepartment } = await axios.get(
`WorkerDepartments/${salesPersonFk}`
);
const { data: department } = await axios.get(
`Departments/${workerDepartment.departmentFk}`
);
departments.value.set(salesPersonFk, department.name);
} catch (error) {
console.error('Err: ', error);
}
});
const recoveryData = await axios.get('Recoveries');
const recoveries = recoveryData.data.map(({ clientFk, finished }) => ({
clientFk,
finished,
}));
await Promise.all(departmentNames);
data.forEach((item) => {
item.departmentName = departments.value.get(item.salesPersonFk);
item.isWorker = item.businessTypeFk === 'worker';
const recovery = recoveries.find(({ clientFk }) => clientFk === item.clientFk);
item.finished = recovery?.finished === null;
});
for (const element of data) element.isWorker = element.businessTypeFk === 'worker'; for (const element of data) element.isWorker = element.businessTypeFk === 'worker';
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0); balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
@ -191,6 +252,7 @@ function exprBuilder(param, value) {
case 'creditInsurance': case 'creditInsurance':
case 'amount': case 'amount':
case 'workerFk': case 'workerFk':
case 'departmentFk':
case 'countryFk': case 'countryFk':
case 'payMethod': case 'payMethod':
case 'salesPersonFk': case 'salesPersonFk':
@ -243,7 +305,6 @@ function exprBuilder(param, value) {
</div> </div>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<VnPaginate <VnPaginate
ref="dataRef" ref="dataRef"
@ -302,7 +363,7 @@ function exprBuilder(param, value) {
) )
" "
> >
<template v-if="props.col.name !== 'isWorker'"> <template v-if="typeof props.value !== 'boolean'">
<div <div
v-if=" v-if="
props.col.name === 'lastObservation' props.col.name === 'lastObservation'
@ -354,6 +415,7 @@ es:
Client: Cliente Client: Cliente
Is worker: Es trabajador Is worker: Es trabajador
Salesperson: Comercial Salesperson: Comercial
Department: Departamento
Country: País Country: País
P. Method: F. Pago P. Method: F. Pago
Pay method: Forma de pago Pay method: Forma de pago

View File

@ -45,11 +45,10 @@ const authors = ref();
</div> </div>
</template> </template>
<template #body="{ params }"> <template #body="{ params, searchFn }">
<QItem class="q-mb-sm q-mt-sm"> <QItem class="q-mb-sm">
<QItemSection v-if="clients"> <QItemSection v-if="clients">
<VnSelect <VnSelect
:input-debounce="0"
:label="t('Client')" :label="t('Client')"
:options="clients" :options="clients"
dense dense
@ -62,6 +61,8 @@ const authors = ref();
rounded rounded
use-input use-input
v-model="params.clientFk" v-model="params.clientFk"
@update:model-value="searchFn()"
auto-load
/> />
</QItemSection> </QItemSection>
<QItemSection v-else> <QItemSection v-else>
@ -85,6 +86,7 @@ const authors = ref();
rounded rounded
use-input use-input
v-model="params.salesPersonFk" v-model="params.salesPersonFk"
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
<QItemSection v-else> <QItemSection v-else>
@ -108,6 +110,7 @@ const authors = ref();
rounded rounded
use-input use-input
v-model="params.countryFk" v-model="params.countryFk"
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
<QItemSection v-else> <QItemSection v-else>
@ -153,6 +156,7 @@ const authors = ref();
rounded rounded
use-input use-input
v-model="params.workerFk" v-model="params.workerFk"
@update:model-value="searchFn()"
/> />
</QItemSection> </QItemSection>
<QItemSection v-else> <QItemSection v-else>

View File

@ -28,7 +28,7 @@ const defaultInitialData = {
workerFk: null, workerFk: null,
isOk: false, isOk: false,
}; };
const maxDistance = ref();
const workerList = ref([]); const workerList = ref([]);
const agencyList = ref([]); const agencyList = ref([]);
const vehicleList = ref([]); const vehicleList = ref([]);
@ -81,12 +81,7 @@ const onSave = (data, response) => {
}; };
</script> </script>
<template> <template>
<VnSubToolbar /> <VnSubToolbar v-if="isNew" />
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<RouteSearchbar />
</Teleport>
</template>
<FetchData <FetchData
url="Workers/search" url="Workers/search"
:filter="{ fields: ['id', 'nickname'] }" :filter="{ fields: ['id', 'nickname'] }"
@ -111,6 +106,12 @@ const onSave = (data, response) => {
@on-fetch="(data) => (vehicleList = data)" @on-fetch="(data) => (vehicleList = data)"
auto-load auto-load
/> />
<FetchData
url="RouteConfigs/findOne"
@on-fetch="({ kmMax }) => (maxDistance = kmMax)"
auto-load
sort-by="id ASC"
/>
<FormModel <FormModel
:url="isNew ? null : `Routes/${route.params?.id}`" :url="isNew ? null : `Routes/${route.params?.id}`"
:url-create="isNew ? 'Routes' : null" :url-create="isNew ? 'Routes' : null"
@ -174,7 +175,17 @@ const onSave = (data, response) => {
<template v-if="!isNew"> <template v-if="!isNew">
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<VnInput v-model="data.kmStart" :label="t('Km Start')" clearable /> <VnInput v-model="data.kmStart" :label="t('Km Start')" clearable />
<VnInput v-model="data.kmEnd" :label="t('Km End')" clearable /> <QInput
v-model.number="data.kmEnd"
:label="t('Km End')"
:rules="[
(val) =>
val < maxDistance ||
t('Distance must be lesser than 4000'),
]"
clearable
type="number"
/>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<VnInputTime <VnInputTime
@ -221,4 +232,5 @@ es:
Description: Descripción Description: Descripción
Is served: Se ha servido Is served: Se ha servido
Created: Creado Created: Creado
Distance must be lesser than {maxDistance}: La distancia debe ser inferior a {maxDistance}
</i18n> </i18n>

View File

@ -222,11 +222,6 @@ const openSmsDialog = async () => {
</script> </script>
<template> <template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<RouteSearchbar />
</Teleport>
</template>
<FetchData <FetchData
@on-fetch="(data) => (routeEntity = data)" @on-fetch="(data) => (routeEntity = data)"
auto-load auto-load

View File

@ -170,23 +170,6 @@ watch([year, businessFk], () => refreshData());
ref="WorkerFreelanceRef" ref="WorkerFreelanceRef"
auto-load auto-load
/> />
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#actions-append">
<div class="row q-gutter-x-sm">
<QBtn
flat
@click="stateStore.toggleRightDrawer()"
round
dense
icon="menu"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8"> <QScrollArea class="fit text-grey-8">
<WorkerCalendarFilter <WorkerCalendarFilter

View File

@ -489,23 +489,6 @@ onMounted(async () => {
</QBtnGroup> </QBtnGroup>
</div> </div>
</Teleport> </Teleport>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#actions-append">
<div class="row q-gutter-x-sm">
<QBtn
flat
@click="stateStore.toggleRightDrawer()"
round
dense
icon="menu"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="260" class="q-pa-md"> <QDrawer v-model="stateStore.rightDrawer" side="right" :width="260" class="q-pa-md">
<div class="q-pa-md q-mb-md" style="border: 2px solid #222"> <div class="q-pa-md q-mb-md" style="border: 2px solid #222">
<QCardSection horizontal> <QCardSection horizontal>