forked from verdnatura/salix-front
Merge branch 'dev' into 5447-travelExtraCommunity
This commit is contained in:
commit
1183908942
|
@ -35,7 +35,7 @@ const $props = defineProps({
|
|||
downloadModel: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null,
|
||||
default: undefined,
|
||||
},
|
||||
defaultDmsCode: {
|
||||
type: String,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export default function dateRange(value) {
|
||||
const minHour = new Date(value);
|
||||
minHour.setHours(0, 0, 0, 0);
|
||||
const maxHour = new Date(value);
|
||||
const maxHour = new Date();
|
||||
maxHour.setHours(23, 59, 59, 59);
|
||||
|
||||
return [minHour, maxHour];
|
||||
|
|
|
@ -14,9 +14,10 @@ import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.v
|
|||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import CustomerDefaulterAddObservation from './CustomerDefaulterAddObservation.vue';
|
||||
import axios from 'axios';
|
||||
const stateStore = useStateStore();
|
||||
|
||||
const { t, locale } = useI18n();
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const dataRef = ref(null);
|
||||
|
||||
|
@ -26,7 +27,7 @@ const selected = ref([]);
|
|||
const tableColumnComponents = {
|
||||
client: {
|
||||
component: QBtn,
|
||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
||||
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||
event: () => {},
|
||||
},
|
||||
isWorker: {
|
||||
|
@ -39,7 +40,12 @@ const tableColumnComponents = {
|
|||
},
|
||||
salesPerson: {
|
||||
component: QBtn,
|
||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
||||
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||
event: () => {},
|
||||
},
|
||||
department: {
|
||||
component: 'span',
|
||||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
country: {
|
||||
|
@ -59,7 +65,7 @@ const tableColumnComponents = {
|
|||
},
|
||||
author: {
|
||||
component: QBtn,
|
||||
props: () => ({ flat: true, color: 'blue', noCaps: true }),
|
||||
props: () => ({ flat: true, class: 'link', noCaps: true }),
|
||||
event: () => {},
|
||||
},
|
||||
lastObservation: {
|
||||
|
@ -82,6 +88,16 @@ const tableColumnComponents = {
|
|||
props: () => {},
|
||||
event: () => {},
|
||||
},
|
||||
finished: {
|
||||
component: QCheckbox,
|
||||
|
||||
props: (prop) => ({
|
||||
disable: true,
|
||||
'model-value': prop.value,
|
||||
class: 'disabled-checkbox',
|
||||
}),
|
||||
event: () => {},
|
||||
},
|
||||
};
|
||||
|
||||
const columns = computed(() => [
|
||||
|
@ -105,6 +121,13 @@ const columns = computed(() => [
|
|||
name: 'salesPerson',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'departmentName',
|
||||
label: t('Department'),
|
||||
name: 'department',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'country',
|
||||
|
@ -166,6 +189,12 @@ const columns = computed(() => [
|
|||
name: 'from',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
align: 'left',
|
||||
field: 'finished',
|
||||
label: t('Has recover'),
|
||||
name: 'finished',
|
||||
},
|
||||
]);
|
||||
|
||||
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';
|
||||
|
||||
balanceDueTotal.value = data.reduce((acc, { amount = 0 }) => acc + amount, 0);
|
||||
|
@ -191,6 +252,7 @@ function exprBuilder(param, value) {
|
|||
case 'creditInsurance':
|
||||
case 'amount':
|
||||
case 'workerFk':
|
||||
case 'departmentFk':
|
||||
case 'countryFk':
|
||||
case 'payMethod':
|
||||
case 'salesPersonFk':
|
||||
|
@ -243,7 +305,6 @@ function exprBuilder(param, value) {
|
|||
</div>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnPaginate
|
||||
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
|
||||
v-if="
|
||||
props.col.name === 'lastObservation'
|
||||
|
@ -354,6 +415,7 @@ es:
|
|||
Client: Cliente
|
||||
Is worker: Es trabajador
|
||||
Salesperson: Comercial
|
||||
Department: Departamento
|
||||
Country: País
|
||||
P. Method: F. Pago
|
||||
Pay method: Forma de pago
|
||||
|
|
|
@ -45,11 +45,10 @@ const authors = ref();
|
|||
</div>
|
||||
</template>
|
||||
|
||||
<template #body="{ params }">
|
||||
<QItem class="q-mb-sm q-mt-sm">
|
||||
<template #body="{ params, searchFn }">
|
||||
<QItem class="q-mb-sm">
|
||||
<QItemSection v-if="clients">
|
||||
<VnSelect
|
||||
:input-debounce="0"
|
||||
:label="t('Client')"
|
||||
:options="clients"
|
||||
dense
|
||||
|
@ -62,6 +61,8 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.clientFk"
|
||||
@update:model-value="searchFn()"
|
||||
auto-load
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -85,6 +86,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.salesPersonFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -108,6 +110,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.countryFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
@ -153,6 +156,7 @@ const authors = ref();
|
|||
rounded
|
||||
use-input
|
||||
v-model="params.workerFk"
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection v-else>
|
||||
|
|
|
@ -28,7 +28,7 @@ const defaultInitialData = {
|
|||
workerFk: null,
|
||||
isOk: false,
|
||||
};
|
||||
|
||||
const maxDistance = ref();
|
||||
const workerList = ref([]);
|
||||
const agencyList = ref([]);
|
||||
const vehicleList = ref([]);
|
||||
|
@ -81,12 +81,7 @@ const onSave = (data, response) => {
|
|||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnSubToolbar />
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<RouteSearchbar />
|
||||
</Teleport>
|
||||
</template>
|
||||
<VnSubToolbar v-if="isNew" />
|
||||
<FetchData
|
||||
url="Workers/search"
|
||||
:filter="{ fields: ['id', 'nickname'] }"
|
||||
|
@ -111,6 +106,12 @@ const onSave = (data, response) => {
|
|||
@on-fetch="(data) => (vehicleList = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="RouteConfigs/findOne"
|
||||
@on-fetch="({ kmMax }) => (maxDistance = kmMax)"
|
||||
auto-load
|
||||
sort-by="id ASC"
|
||||
/>
|
||||
<FormModel
|
||||
:url="isNew ? null : `Routes/${route.params?.id}`"
|
||||
:url-create="isNew ? 'Routes' : null"
|
||||
|
@ -174,7 +175,17 @@ const onSave = (data, response) => {
|
|||
<template v-if="!isNew">
|
||||
<VnRow class="row q-gutter-md q-mb-md">
|
||||
<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 class="row q-gutter-md q-mb-md">
|
||||
<VnInputTime
|
||||
|
@ -221,4 +232,5 @@ es:
|
|||
Description: Descripción
|
||||
Is served: Se ha servido
|
||||
Created: Creado
|
||||
Distance must be lesser than {maxDistance}: La distancia debe ser inferior a {maxDistance}
|
||||
</i18n>
|
||||
|
|
|
@ -222,11 +222,6 @@ const openSmsDialog = async () => {
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#searchbar">
|
||||
<RouteSearchbar />
|
||||
</Teleport>
|
||||
</template>
|
||||
<FetchData
|
||||
@on-fetch="(data) => (routeEntity = data)"
|
||||
auto-load
|
||||
|
|
|
@ -170,23 +170,6 @@ watch([year, businessFk], () => refreshData());
|
|||
ref="WorkerFreelanceRef"
|
||||
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>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<WorkerCalendarFilter
|
||||
|
|
|
@ -489,23 +489,6 @@ onMounted(async () => {
|
|||
</QBtnGroup>
|
||||
</div>
|
||||
</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">
|
||||
<div class="q-pa-md q-mb-md" style="border: 2px solid #222">
|
||||
<QCardSection horizontal>
|
||||
|
|
Loading…
Reference in New Issue