forked from verdnatura/salix-front
fix: refs #7353 salesClientTable
This commit is contained in:
parent
4b2f4ffac1
commit
a13ea900ce
|
@ -1,44 +1,33 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, reactive, watch } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
|
||||||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||||
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
|
||||||
|
|
||||||
import { toDateFormat } from 'src/filters/date.js';
|
import { toDateFormat } from 'src/filters/date.js';
|
||||||
import VnTable from 'src/components/VnTable/VnTable.vue';
|
import VnTable from 'src/components/VnTable/VnTable.vue';
|
||||||
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
|
import VnRow from 'src/components/ui/VnRow.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const paginateRef = ref(null);
|
|
||||||
const workersActiveOptions = ref([]);
|
|
||||||
const clientsOptions = ref([]);
|
|
||||||
|
|
||||||
const from = ref(Date.vnNew());
|
const from = ref(Date.vnNew());
|
||||||
const to = ref(Date.vnNew());
|
const to = ref(Date.vnNew());
|
||||||
|
|
||||||
const dateRange = computed(() => {
|
const filter = computed(() => {
|
||||||
const minHour = new Date(from.value);
|
const obj = {};
|
||||||
minHour.setHours(0, 0, 0, 0);
|
const formatFrom = setHours(from.value, 'from');
|
||||||
const maxHour = new Date(to.value);
|
const formatTo = setHours(to.value, 'to');
|
||||||
maxHour.setHours(23, 59, 59, 59);
|
|
||||||
return [minHour, maxHour];
|
|
||||||
});
|
|
||||||
|
|
||||||
const filter = reactive({
|
if (!formatFrom && formatTo)
|
||||||
where: {
|
Object.assign(obj, { where: { 'v.stamp': { lte: formatTo } } });
|
||||||
'v.stamp': {
|
else if (formatFrom && !formatTo)
|
||||||
between: dateRange.value,
|
Object.assign(obj, { where: { 'v.stamp': { gte: formatFrom } } });
|
||||||
},
|
else if (formatFrom && formatTo)
|
||||||
},
|
Object.assign(obj, {
|
||||||
});
|
where: { 'v.stamp': { between: [formatFrom, formatTo] } },
|
||||||
|
});
|
||||||
|
|
||||||
const refetch = async () => await paginateRef.value.fetch();
|
return obj;
|
||||||
|
|
||||||
watch(dateRange, (val) => {
|
|
||||||
filter.where['v.stamp'].between = val;
|
|
||||||
refetch();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
function exprBuilder(param, value) {
|
||||||
|
@ -50,7 +39,14 @@ function exprBuilder(param, value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const params = reactive({});
|
function setHours(date, type) {
|
||||||
|
if (!date) return null;
|
||||||
|
|
||||||
|
const d = new Date(date);
|
||||||
|
if (type == 'from') d.setHours(0, 0, 0, 0);
|
||||||
|
else d.setHours(23, 59, 59, 59);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
@ -58,8 +54,7 @@ const columns = computed(() => [
|
||||||
name: 'dated',
|
name: 'dated',
|
||||||
field: 'dated',
|
field: 'dated',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
columnFilter: null,
|
columnFilter: false,
|
||||||
sortable: true,
|
|
||||||
format: (row) => toDateFormat(row.dated),
|
format: (row) => toDateFormat(row.dated),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -67,81 +62,88 @@ const columns = computed(() => [
|
||||||
name: 'hour',
|
name: 'hour',
|
||||||
field: 'hour',
|
field: 'hour',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
columnFilter: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('salesClientsTable.salesPerson'),
|
label: t('salesClientsTable.salesPerson'),
|
||||||
name: 'salesPerson',
|
name: 'salesPersonFk',
|
||||||
field: 'salesPerson',
|
field: 'salesPerson',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
|
||||||
columnField: {
|
columnField: {
|
||||||
component: null,
|
component: null,
|
||||||
},
|
},
|
||||||
|
optionFilter: 'firstName',
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Workers/activeWithInheritedRole',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
sortBy: 'nickname ASC',
|
||||||
|
where: { role: 'salesPerson' },
|
||||||
|
useLike: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('salesClientsTable.client'),
|
label: t('salesClientsTable.client'),
|
||||||
field: 'clientName',
|
field: 'clientName',
|
||||||
name: 'client',
|
name: 'clientFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
sortable: true,
|
|
||||||
columnField: {
|
columnField: {
|
||||||
component: null,
|
component: null,
|
||||||
},
|
},
|
||||||
|
orderBy: 'c.name',
|
||||||
|
columnFilter: {
|
||||||
|
component: 'select',
|
||||||
|
attrs: {
|
||||||
|
url: 'Clients',
|
||||||
|
fields: ['id', 'name'],
|
||||||
|
sortBy: 'name ASC',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
|
||||||
url="Workers/activeWithInheritedRole"
|
|
||||||
:filter="{
|
|
||||||
fields: ['id', 'nickname'],
|
|
||||||
order: 'nickname ASC',
|
|
||||||
where: { role: 'salesPerson' },
|
|
||||||
}"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (workersActiveOptions = data)"
|
|
||||||
/>
|
|
||||||
<FetchData
|
|
||||||
url="Clients"
|
|
||||||
:filter="{
|
|
||||||
fields: ['id', 'name'],
|
|
||||||
order: 'name ASC',
|
|
||||||
}"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (clientsOptions = data)"
|
|
||||||
/>
|
|
||||||
<QCard style="max-height: 380px; overflow-y: scroll">
|
<QCard style="max-height: 380px; overflow-y: scroll">
|
||||||
<VnTable
|
<QCardSection>
|
||||||
ref="paginateRef"
|
<VnRow>
|
||||||
data-key="SalesMonitorClients"
|
<VnInputDate v-model="from" label="From" dense style="flex: 0.25" />
|
||||||
url="SalesMonitors/clientsFilter"
|
<VnInputDate v-model="to" label="To" dense style="flex: 0.25" />
|
||||||
:order="['dated DESC', 'hour DESC']"
|
</VnRow>
|
||||||
:limit="6"
|
</QCardSection>
|
||||||
:expr-builder="exprBuilder"
|
<QCardSection>
|
||||||
:user-params="params"
|
<VnTable
|
||||||
:filter="filter"
|
ref="table"
|
||||||
:offset="50"
|
data-key="SalesMonitorClients"
|
||||||
auto-load
|
url="SalesMonitors/clientsFilter"
|
||||||
:columns="columns"
|
search-url="SalesMonitorClients"
|
||||||
:right-search="false"
|
:order="['dated DESC', 'hour DESC']"
|
||||||
default-mode="table"
|
:limit="6"
|
||||||
dense
|
:expr-builder="exprBuilder"
|
||||||
:without-header="true"
|
:filter="filter"
|
||||||
>
|
:offset="50"
|
||||||
<template #column-salesPerson="{ row }">
|
auto-load
|
||||||
<QTd>
|
:columns="columns"
|
||||||
<span class="link">{{ row.salesPerson }}</span>
|
:right-search="false"
|
||||||
<WorkerDescriptorProxy :id="row.salesPersonFk" dense />
|
default-mode="table"
|
||||||
</QTd>
|
dense
|
||||||
</template>
|
:without-header="true"
|
||||||
<template #column-client="{ row }">
|
>
|
||||||
<QTd>
|
<template #column-salesPersonFk="{ row }">
|
||||||
<span class="link">{{ row.clientName }}</span>
|
<QTd>
|
||||||
<CustomerDescriptorProxy :id="row.clientFk" />
|
<span class="link">{{ row.salesPerson }}</span>
|
||||||
</QTd>
|
<WorkerDescriptorProxy :id="row.salesPersonFk" dense />
|
||||||
</template>
|
</QTd>
|
||||||
</VnTable>
|
</template>
|
||||||
|
<template #column-clientFk="{ row }">
|
||||||
|
<QTd>
|
||||||
|
<span class="link">{{ row.clientName }}</span>
|
||||||
|
<CustomerDescriptorProxy :id="row.clientFk" />
|
||||||
|
</QTd>
|
||||||
|
</template>
|
||||||
|
</VnTable>
|
||||||
|
</QCardSection>
|
||||||
</QCard>
|
</QCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -129,6 +129,7 @@ const redirectToOrderSummary = (orderId) => {
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="SalesMonitorOrders"
|
data-key="SalesMonitorOrders"
|
||||||
url="SalesMonitors/ordersFilter"
|
url="SalesMonitors/ordersFilter"
|
||||||
|
search-url="SalesMonitorOrders"
|
||||||
order="date_make DESC"
|
order="date_make DESC"
|
||||||
:limit="6"
|
:limit="6"
|
||||||
:right-search="false"
|
:right-search="false"
|
||||||
|
|
|
@ -430,6 +430,7 @@ const redirectToSales = (id) => {
|
||||||
ref="paginateRef"
|
ref="paginateRef"
|
||||||
data-key="SalesMonitorTickets"
|
data-key="SalesMonitorTickets"
|
||||||
url="SalesMonitors/salesFilter"
|
url="SalesMonitors/salesFilter"
|
||||||
|
search-url="SalesMonitorTickets"
|
||||||
:filter="filter"
|
:filter="filter"
|
||||||
:limit="20"
|
:limit="20"
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
|
|
Loading…
Reference in New Issue